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=-2.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 F312FC49ED7 for ; Sat, 21 Sep 2019 14:07:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id CFE7E20644 for ; Sat, 21 Sep 2019 14:07:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393452AbfIUOHi (ORCPT ); Sat, 21 Sep 2019 10:07:38 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:54996 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393406AbfIUOHh (ORCPT ); Sat, 21 Sep 2019 10:07:37 -0400 Received: from viro by ZenIV.linux.org.uk with local (Exim 4.92.2 #3 (Red Hat Linux)) id 1iBg2t-0007XS-Oi; Sat, 21 Sep 2019 14:07:31 +0000 Date: Sat, 21 Sep 2019 15:07:31 +0100 From: Al Viro To: Linus Torvalds Cc: "zhengbin (A)" , Jan Kara , Andrew Morton , linux-fsdevel , "zhangyi (F)" , renxudong1@huawei.com, Hou Tao Subject: Re: [PATCH] Re: Possible FS race condition between iterate_dir and d_alloc_parallel Message-ID: <20190921140731.GQ1131@ZenIV.linux.org.uk> References: <20190914161622.GS1131@ZenIV.linux.org.uk> <20190914170146.GT1131@ZenIV.linux.org.uk> <20190914200412.GU1131@ZenIV.linux.org.uk> <20190915005046.GV1131@ZenIV.linux.org.uk> <20190915160236.GW1131@ZenIV.linux.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.12.0 (2019-05-25) Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Sun, Sep 15, 2019 at 10:58:50AM -0700, Linus Torvalds wrote: > On Sun, Sep 15, 2019 at 9:02 AM Al Viro wrote: > > > > Could be done, AFAICS. I'm not even sure we need a flag per se - we > > have two cases when the damn thing is not in the list and "before > > everything" case doesn't really need to be distinguished from post-EOF > > one. > > Agreed, it looks like we could just look at f_pos and use that > (together with whether we have a cursor or not) as the flag: > > - no cursor: f_pos < 2 means beginning, otherwise EOF > > - otherwise: cursor points to position FWIW, #next.dcache has the straight conversion to hlist. It definitely wants at least nfsd, er... misconception dealt with, though: list_head or hlist, this static void nfsdfs_remove_files(struct dentry *root) { struct dentry *dentry; struct hlist_node *n; hlist_for_each_entry_safe(dentry, n, &root->d_children, d_sibling) { if (!simple_positive(dentry)) { WARN_ON_ONCE(1); /* I think this can't happen? */ continue; } nfsdfs_remove_file(d_inode(root), dentry); } } is wrong, for obvious reasons (have the victim directory opened before that gets called and watch the fireworks)... No "take cursors out of the list" parts yet.