[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20250207194538.GE1977892@ZenIV>
Date: Fri, 7 Feb 2025 19:45:38 +0000
From: Al Viro <viro@...iv.linux.org.uk>
To: NeilBrown <neilb@...e.de>
Cc: Christian Brauner <brauner@...nel.org>, Jan Kara <jack@...e.cz>,
Linus Torvalds <torvalds@...ux-foundation.org>,
Jeff Layton <jlayton@...nel.org>,
Dave Chinner <david@...morbit.com>, linux-fsdevel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH 01/19] VFS: introduce vfs_mkdir_return()
On Thu, Feb 06, 2025 at 04:42:38PM +1100, NeilBrown wrote:
> vfs_mkdir() does not guarantee to make the child dentry positive on
> success. It may leave it negative and then the caller needs to perform a
> lookup to find the target dentry.
>
> This patch introduced vfs_mkdir_return() which performs the lookup if
> needed so that this code is centralised.
>
> This prepares for a new inode operation which will perform mkdir and
> returns the correct dentry.
* Calling conventions stink; make it _consume_ dentry reference and
return dentry reference or ERR_PTR(). Callers will be happier that way
(check it).
* Calling conventions should be documented in commit message *and* in
D/f/porting
* devpts, nfs4recover and xfs might as well convert (not going to hit
the "need a lookup" case anyway)
* that
+ /* Need a "const" pointer. We know d_name is const
+ * because we hold an exclusive lock on i_rwsem
+ * in d_parent.
+ */
+ const struct qstr *d_name = (void*)&dentry->d_name;
+ d = lookup_dcache(d_name, dentry->d_parent, 0);
+ if (!d)
+ d = __lookup_slow(d_name, dentry->d_parent, 0);
doesn't need a cast. C is perfectly fine with
T *x = foo();
const T *y = x;
You are not allowed to _strip_ qualifiers; adding them is fine.
Same reason why you are allowed to pass char * to strlen() without
any casts whatsoever.
Comment re stability is fine; the cast is pure WTF material.
Powered by blists - more mailing lists