From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DB589C4CEC9 for ; Sat, 14 Sep 2019 16:49:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AF9B920640 for ; Sat, 14 Sep 2019 16:49:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568479783; bh=NIfhSfTpVOIBe6Z6X8zndE/V+7Vd3jd2dm1Ybvm8Pmk=; h=References:In-Reply-To:From:Date:Subject:To:Cc:List-ID:From; b=JRMcT+cui92bVkcaeSvAjAAROvRTqTxONn8aVBOGPoXO2xnIu7dSyZq28I2CHPukD nuSl9I+NO5CCrPqi0znNWYO1S8IYj46qhG7VP83mRIi5+PDMGaLZVyyJ9BwrRaQZHK +HJdONQ9oRb/6x5E7s830YaM7pYLF0ph9a5Os4GQ= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727684AbfINQtn (ORCPT ); Sat, 14 Sep 2019 12:49:43 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:36489 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727407AbfINQtn (ORCPT ); Sat, 14 Sep 2019 12:49:43 -0400 Received: by mail-lj1-f195.google.com with SMTP id v24so2311180ljj.3 for ; Sat, 14 Sep 2019 09:49:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux-foundation.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=WyQciLB9X1pp0U/5BdJbJHwfqT/eBV/wnFJqHb8MbG4=; b=QzwIxM7S8v3x+6uUvJU7G0idzMnl7fTJhiG+3SW9fhVzPiiUu0KZ5Fwa6WNiIZVBot XzTsVJX9jf967PsgxhUA9C5WKzQjPmMT4z5+D/ovDgIwveD6cpdeKoBI8T4cE22jGYLD IYaCF6ND+tezHqbB+aXJPs9D3IW8OodzqizXU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=WyQciLB9X1pp0U/5BdJbJHwfqT/eBV/wnFJqHb8MbG4=; b=ZRw+3il4HCfAlBJVds2smNDrEubX0Jl2X0KaO1gpFfVsHT/jkhxnjuyDid5paPaoth PiLko9HH/X55Vu/DfAzw75gxnRWF8N7V3P8r0V0kmEYiUaRypqYgQDb/XdM68xOaeDLO fSp9vIkB9hrCJziFLIzabk3nWsvXsaIh1OWRED8csS7NN2wTf3VL7CIrPFTIFENdJ5D8 LYQ/ffVpv7nnkAsYvxlwm5262NJLnhwNFTlt2spDZ8uZJyQHMkJUIXoU8MVh7CmxPqD8 vSQvZ+OP+zNgoknVbc855bjkMKXBPHXITOdZmkadDl9IRE5/XRlZfrC25XjEsk1dMWBe KnXQ== X-Gm-Message-State: APjAAAXF+bn6WEWnp81lkmAQwUatqOgKAp8sPGfZau1u5Ia5+7v/MsPW P4Yb5cYf/fnTBuwnQf2CMx7V0uyCjHA= X-Google-Smtp-Source: APXvYqwHCILCSdskOUEq0t8I2DM1mgKi1g0brhFzlYd+o/kxRRTOjjik7tycvhPrBNOpmQee6zhWAQ== X-Received: by 2002:a2e:8789:: with SMTP id n9mr395032lji.52.1568479778914; Sat, 14 Sep 2019 09:49:38 -0700 (PDT) Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com. [209.85.167.42]) by smtp.gmail.com with ESMTPSA id m9sm7116959lji.66.2019.09.14.09.49.37 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 14 Sep 2019 09:49:37 -0700 (PDT) Received: by mail-lf1-f42.google.com with SMTP id u3so9228363lfl.10 for ; Sat, 14 Sep 2019 09:49:37 -0700 (PDT) X-Received: by 2002:ac2:5c11:: with SMTP id r17mr34749484lfp.61.1568479777071; Sat, 14 Sep 2019 09:49:37 -0700 (PDT) MIME-Version: 1.0 References: <20190903154007.GJ1131@ZenIV.linux.org.uk> <20190903154114.GK1131@ZenIV.linux.org.uk> <20190909145910.GG1131@ZenIV.linux.org.uk> <14888449-3300-756c-2029-8e494b59348b@huawei.com> <7e32cda5-dc89-719d-9651-cf2bd06ae728@huawei.com> <20190910215357.GH1131@ZenIV.linux.org.uk> <20190914161622.GS1131@ZenIV.linux.org.uk> In-Reply-To: <20190914161622.GS1131@ZenIV.linux.org.uk> From: Linus Torvalds Date: Sat, 14 Sep 2019 09:49:21 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] Re: Possible FS race condition between iterate_dir and d_alloc_parallel To: Al Viro Cc: "zhengbin (A)" , Jan Kara , Andrew Morton , linux-fsdevel , "zhangyi (F)" , renxudong1@huawei.com, Hou Tao Content-Type: text/plain; charset="UTF-8" Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Sat, Sep 14, 2019 at 9:16 AM Al Viro wrote: > > OK, folks, could you try the following? It survives the local beating > so far. This looks like the right solution to me. Keep the locking simple, take the dentry refcount as long as we keep a ref to it in "*res". However, the one thing that strikes me is that it looks to me like this means that the "cursor" and the dentry in "*res" are basically synonymous. Could we drop the cursor entirely, and just keep the ref to the last dentry we showd _as_ the cursor? Yes, this would mean that we'd keep a ref to the dentry across readdir() calls, and maybe that's a horrible idea. But is that all that different from keeping the ref to the dentry that is the directory itself? Linus