From: Al Viro <viro@zeniv.linux.org.uk>
To: Greg KH <gregkh@linuxfoundation.org>
Cc: yu kuai <yukuai3@huawei.com>,
rafael@kernel.org, rostedt@goodmis.org, oleg@redhat.com,
mchehab+samsung@kernel.org, corbet@lwn.net, tytso@mit.edu,
jmorris@namei.org, linux-kernel@vger.kernel.org,
linux-fsdevel@vger.kernel.org, zhengbin13@huawei.com,
yi.zhang@huawei.com, chenxiang66@hisilicon.com,
xiexiuqi@huawei.com
Subject: Re: [PATCH 1/3] dcache: add a new enum type for 'dentry_d_lock_class'
Date: Fri, 15 Nov 2019 13:16:25 +0000 [thread overview]
Message-ID: <20191115131625.GO26530@ZenIV.linux.org.uk> (raw)
In-Reply-To: <20191115072011.GA1203354@kroah.com>
On Fri, Nov 15, 2019 at 03:20:11PM +0800, Greg KH wrote:
> > FWIW, I'm not sure it's a good solution. What are the rules for callers
> > of that thing, anyway? If it can be called when somebody is creating
> > more files in that subtree, we almost certainly will have massive
> > problems with the lifetimes of underlying objects...
> >
> > Could somebody familiar with debugfs explain how is that thing actually
> > used and what is required from/promised to its callers? I can try and
> > grep through the tree and guess what the rules are, but I've way too
> > much on my platter right now and I don't want to get sidetracked into yet
> > another tree-wide search and analysis session ;-/
>
> Yu wants to use simple_empty() in debugfs_remove_recursive() instead of
> manually checking:
> if (!list_empty(&child->d_subdirs)) {
>
> See patch 3 of this series for that change and why they feel it is
> needed:
> https://lore.kernel.org/lkml/1573788472-87426-4-git-send-email-yukuai3@huawei.com/
>
> As to if patch 3 really is needed, I'll leave that up to Yu given that I
> thought we had resolved these types of issues already a year or so ago.
What I'm asking is what concurrency warranties does the whole thing
(debugfs_remove_recursive()) have to deal with. IMO the overall
structure of the walk-and-remove the tree algorithm in there
is Not Nice(tm) and I'd like to understand if it needs to be kept
that way. And the locking is confused in there - it either locks
too much, or not enough.
So... can debugfs_remove_recursive() rely upon the lack of attempts to create
new entries inside the subtree it's trying to kill? If it can, the things
can be made simpler; if it can't, it's not locking enough; e.g. results of
simple_empty() on child won't be guaranteed to remain unchanged just as it
returns to caller.
What's more, the uses of simple_unlink()/simple_rmdir() there are not
imitiating the normal locking environment for ->unlink() and ->rmdir() resp. -
the victim's inode is not locked, so just for starters the call of simple_empty()
from simple_rmdir() itself is not guaranteed to give valid result.
I want to understand the overall situation. No argument, list_empty()
in there is BS, for many reasons. But I wonder if trying to keep the
current structure of the iterator _and_ the use of simple_rmdir()/simple_unlink()
is the right approach.
next prev parent reply other threads:[~2019-11-15 13:16 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-11-15 3:27 [PATCH 0/3] fix potential infinite loop in debugfs_remove_recursive yu kuai
2019-11-15 3:27 ` [PATCH 1/3] dcache: add a new enum type for 'dentry_d_lock_class' yu kuai
2019-11-15 3:27 ` Greg KH
2019-11-15 4:12 ` Al Viro
2019-11-15 7:20 ` Greg KH
2019-11-15 10:08 ` yukuai (C)
2019-11-15 13:16 ` Al Viro [this message]
2019-11-15 13:38 ` Steven Rostedt
2019-11-15 13:39 ` Steven Rostedt
2019-11-15 13:48 ` Al Viro
2019-11-15 13:58 ` Steven Rostedt
2019-11-15 14:17 ` Al Viro
2019-11-15 17:54 ` Al Viro
2019-11-15 18:42 ` [RFC] simple_recursive_removal() Al Viro
2019-11-15 19:41 ` Al Viro
2019-11-15 21:18 ` Al Viro
2019-11-15 21:26 ` Steven Rostedt
2019-11-15 22:10 ` Al Viro
2019-11-16 12:04 ` Greg KH
2019-11-17 22:24 ` Al Viro
2019-11-18 6:37 ` Greg KH
2019-11-15 10:02 ` [PATCH 1/3] dcache: add a new enum type for 'dentry_d_lock_class' yukuai (C)
2019-11-15 3:27 ` [PATCH 2/3] fs/libfs.c: use 'spin_lock_nested' when taking 'd_lock' for dentry in simple_empty yu kuai
2019-11-15 3:27 ` [PATCH 3/3] debugfs: fix potential infinite loop in debugfs_remove_recursive yu kuai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191115131625.GO26530@ZenIV.linux.org.uk \
--to=viro@zeniv.linux.org.uk \
--cc=chenxiang66@hisilicon.com \
--cc=corbet@lwn.net \
--cc=gregkh@linuxfoundation.org \
--cc=jmorris@namei.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mchehab+samsung@kernel.org \
--cc=oleg@redhat.com \
--cc=rafael@kernel.org \
--cc=rostedt@goodmis.org \
--cc=tytso@mit.edu \
--cc=xiexiuqi@huawei.com \
--cc=yi.zhang@huawei.com \
--cc=yukuai3@huawei.com \
--cc=zhengbin13@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).