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=-7.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham 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 04430C04AAF for ; Thu, 16 May 2019 18:47:54 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C4835206A3 for ; Thu, 16 May 2019 18:47:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aphVSKbA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726733AbfEPSrx (ORCPT ); Thu, 16 May 2019 14:47:53 -0400 Received: from mail-yw1-f65.google.com ([209.85.161.65]:44050 "EHLO mail-yw1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726336AbfEPSrx (ORCPT ); Thu, 16 May 2019 14:47:53 -0400 Received: by mail-yw1-f65.google.com with SMTP id e74so1739298ywe.11 for ; Thu, 16 May 2019 11:47:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=E3tJ1afrXapwwYV1ieQt+NpYeDQ3GQFIeuKwtSQpZiQ=; b=aphVSKbAwt/pTsXVqmq/xgpHA8JljyPhp2e9vJsZqqwJPSeF/S83CbB2Y8BIwFvA/U MJJV7GhsSxBi9nCi/kOM4omu67zurFXAO7V8pDJ6cTcwS+4zFHQel+JKrT3n2CFtGbm0 JIp0CmXWQ6a8XbhR/xERDgP/KVwY+fREqmNClXo4iGaB3fC13Z6/H0KUb0grk5u85TuA hnbXsRpwOCv7p2S0fZaYPr9T1Jf00RlD34HCA1sKh6pCQnZo/ntOqpdH4ycPusbwoAJM QViVqWfDJS1NW0hsSyAcu85Mrdrg4LNInBeFnzlH93nRPl19/B80EqCpEDb3sOrY+VYF OWlA== 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=E3tJ1afrXapwwYV1ieQt+NpYeDQ3GQFIeuKwtSQpZiQ=; b=VVWpXMruIQ46H7T4WjEU8vg6WnKm9lBQ9yA32KPw0DQGtdtg30vMp94xsDJLfCqM/p ju6zqLz8OFLFF84ZGGa/AWD8IfYjJMnsrPY4X7LxXi475ZojeM70f55eyvDRBeLGseR4 SlVa7ns6ZNT7zssWdPPD0lLijUrPSQJy8239grts63uB/Dwqt4OE8F1j4FSJJR57KfZY GO4qnfunqJlH027WOJfIRFEnx9IvuA/BQ6JMxWA0Inmkgfm4BknaazUdPMBkSsceZsH9 HEmg6Fj2iTqfxG3CsBAJ6QOyq29TNsh1HlavPMUSceLPEIK2AU+d42ssClsQ93pV2k0v TjuQ== X-Gm-Message-State: APjAAAUmFIHWqxr0aOzT0PdYlRrhnaunonhyUuJW7WD83EMpQolzBt3Z OPHPkb42Y2iKGrUZqfqxy2BXq5vpUfShAy8MEaI= X-Google-Smtp-Source: APXvYqwnS7D7CFOoprjyxkEKWdbp5gqghjXvjCWTjQ5wWGHtjiypjYIXEM0Cd6Q2pTYfMYPy/pmg0rlIWivHCQ2cMTk= X-Received: by 2002:a81:7554:: with SMTP id q81mr24678102ywc.404.1558032472028; Thu, 16 May 2019 11:47:52 -0700 (PDT) MIME-Version: 1.0 References: <20190516102641.6574-1-amir73il@gmail.com> <20190516102641.6574-7-amir73il@gmail.com> <20190516103547.GA2125@kroah.com> <20190516120227.GE13274@quack2.suse.cz> <20190516152847.GA612@kroah.com> <20190516165236.GA27726@kroah.com> In-Reply-To: <20190516165236.GA27726@kroah.com> From: Amir Goldstein Date: Thu, 16 May 2019 21:47:40 +0300 Message-ID: Subject: Re: [PATCH v2 06/14] fs: convert debugfs to use simple_remove() helper To: Greg Kroah-Hartman Cc: Jan Kara , Matthew Bobrowski , linux-fsdevel 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 Thu, May 16, 2019 at 7:52 PM Greg Kroah-Hartman wrote: > > On Thu, May 16, 2019 at 06:38:50PM +0300, Amir Goldstein wrote: > > On Thu, May 16, 2019 at 6:28 PM Greg Kroah-Hartman > > wrote: > > > > > > On Thu, May 16, 2019 at 03:09:20PM +0300, Amir Goldstein wrote: > > > > On Thu, May 16, 2019 at 3:02 PM Jan Kara wrote: > > > > > > > > > > On Thu 16-05-19 13:44:51, Amir Goldstein wrote: > > > > > > On Thu, May 16, 2019 at 1:35 PM Greg Kroah-Hartman > > > > > > wrote: > > > > > > > > > > > > > > On Thu, May 16, 2019 at 01:26:33PM +0300, Amir Goldstein wrote: > > > > > > > > This will allow generating fsnotify delete events after the > > > > > > > > fsnotify_nameremove() hook is removed from d_delete(). > > > > > > > > > > > > > > > > Cc: Greg Kroah-Hartman > > > > > > > > Signed-off-by: Amir Goldstein > > > > > > > > --- > > > > > > > > fs/debugfs/inode.c | 20 ++++---------------- > > > > > > > > 1 file changed, 4 insertions(+), 16 deletions(-) > > > > > > > > > > > > > > > > diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c > > > > > > > > index acef14ad53db..bc96198df1d4 100644 > > > > > > > > --- a/fs/debugfs/inode.c > > > > > > > > +++ b/fs/debugfs/inode.c > > > > > > > > @@ -617,13 +617,10 @@ struct dentry *debugfs_create_symlink(const char *name, struct dentry *parent, > > > > > > > > } > > > > > > > > EXPORT_SYMBOL_GPL(debugfs_create_symlink); > > > > > > > > > > > > > > > > -static void __debugfs_remove_file(struct dentry *dentry, struct dentry *parent) > > > > > > > > +static void __debugfs_file_removed(struct dentry *dentry) > > > > > > > > { > > > > > > > > struct debugfs_fsdata *fsd; > > > > > > > > > > > > > > > > - simple_unlink(d_inode(parent), dentry); > > > > > > > > - d_delete(dentry); > > > > > > > > > > > > > > What happened to this call? Why no unlinking anymore? > > > > > > > > > > > > > > > - > > > > > > > > /* > > > > > > > > * Paired with the closing smp_mb() implied by a successful > > > > > > > > * cmpxchg() in debugfs_file_get(): either > > > > > > > > @@ -643,18 +640,9 @@ static int __debugfs_remove(struct dentry *dentry, struct dentry *parent) > > > > > > > > int ret = 0; > > > > > > > > > > > > > > > > if (simple_positive(dentry)) { > > > > > > > > - dget(dentry); > > > > > > > > - if (!d_is_reg(dentry)) { > > > > > > > > - if (d_is_dir(dentry)) > > > > > > > > - ret = simple_rmdir(d_inode(parent), dentry); > > > > > > > > - else > > > > > > > > - simple_unlink(d_inode(parent), dentry); > > > > > > > > - if (!ret) > > > > > > > > - d_delete(dentry); > > > > > > > > - } else { > > > > > > > > - __debugfs_remove_file(dentry, parent); > > > > > > > > - } > > > > > > > > - dput(dentry); > > > > > > > > + ret = simple_remove(d_inode(parent), dentry); > > > > > > > > + if (d_is_reg(dentry)) > > > > > > > > > > > > > > Can't dentry be gone here? This doesn't seem to match the same pattern > > > > > > > as before. > > > > > > > > > > > > > > What am I missing? > > > > > > > > > > > > > > > > > > > The grammatical change __debugfs_remove_file() => __debugfs_file_removed() > > > > > > After change, the helper only does the post delete stuff. > > > > > > simple_unlink() is now done inside simple_remove(). > > > > > > This debugfs patch depends on a patch that adds the simple_remove() helper. > > > > > > sorry for not mentioning this explicitly. > > > > > > > > > > Right. But Greg is right that simple_remove() may have dropped last dentry > > > > > reference and thus you now pass freed dentry to d_is_reg() and > > > > > __debugfs_file_removed()? > > > > > > > > > > > > > It seem so. Good spotting! > > > > > > Yes, that's what I was trying to say. I don't think this conversion is > > > correct, so you might either have to rework your simple_rmdir(), or this > > > patch, to make it work properly. > > > > > > > To fix the correctness issue we will keep dget(dentry)/dput(dentry) > > in place both in __debugfs_remove() and in simple_remove(), i.e: > > > > dget(dentry); > > ret = simple_remove(d_inode(parent), dentry); > > if (d_is_reg(dentry)) > > __debugfs_file_removed(dentry); > > dput(dentry); > > > > Will this have addressed your concern? > > Shouldn't you check for !d_is_reg before calling simple_remove()? Current code does simple_unlink() or simple_rmdir() for !d_is_reg and simple_unlink() + stuff for d_is_reg. New helper does simple_unlink() or simple_rmdir() as appropriate for all cases, so all we are left is with + stuff only for d_is_reg. But anyway, Al is calling this patch set off. So will continue this discussion on another thread some other time. Thanks, Amir.