From: Jeff Layton <jlayton@kernel.org>
To: NeilBrown <neil@brown.name>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
Christian Brauner <brauner@kernel.org>,
Amir Goldstein <amir73il@gmail.com>, Jan Kara <jack@suse.cz>,
linux-fsdevel@vger.kernel.org, linux-nfs@vger.kernel.org
Subject: Re: [PATCH v2 7/7] Use simple_start_creating() in various places.
Date: Wed, 10 Sep 2025 07:54:25 -0400 [thread overview]
Message-ID: <889f488eb1b27c91f445d4fa22dd4ff425b49454.camel@kernel.org> (raw)
In-Reply-To: <175750382935.2850467.264144428541875879@noble.neil.brown.name>
On Wed, 2025-09-10 at 21:30 +1000, NeilBrown wrote:
> On Wed, 10 Sep 2025, Jeff Layton wrote:
> > On Wed, 2025-09-10 at 08:37 +0100, Al Viro wrote:
> > > > ... and see viro/vfs.git#work.persistency for the part of the queue that
> > > > had order already settled down (I'm reshuffling the tail at the moment;
> > > > hypfs commit is still in the leftovers pile - the whole thing used to
> > > > have a really messy topology, with most of the prep work that used to
> > > > be the cause of that topology already in mainline - e.g. rpc_pipefs
> > > > series, securityfs one, etc.)
> > >
> > > Speaking of which, nfsctl series contains the following and I'd like to
> > > make sure that behaviour being fixed there *is* just an accident...
> > > Could nfsd folks comment?
> > >
> > > [PATCH] nfsctl: don't bump st_nlink of directory when creating a symlink in it
> > >
> > >
> > > apparently blindly copied from mkdir...
> > >
> > >
> > > Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
> > > ---
> > > diff --git a/fs/nfsd/nfsctl.c b/fs/nfsd/nfsctl.c
> > > index bc6b776fc657..282b961d8788 100644
> > > --- a/fs/nfsd/nfsctl.c
> > > +++ b/fs/nfsd/nfsctl.c
> > > @@ -1181,7 +1181,6 @@ static int __nfsd_symlink(struct inode *dir, struct dentry *dentry,
> > > inode->i_size = strlen(content);
> > >
> > >
> > > d_add(dentry, inode);
> > > - inc_nlink(dir);
> > > fsnotify_create(dir, dentry);
> > > return 0;
> > > }
> >
> > That is increasing the link count on the parent because it's adding a
> > dentry to "dir". The link count on a dir doesn't have much meaning, but
> > why do we need to remove it here, but keep the one in __nfsd_mkdir?
>
> The link count in an inode is the number of links *to* the inode.
> A symlink (or file etc) in a directory doesn't imply a link to that
> directory (they are links "from" the directory, but those aren't counted).
> A directory in a directory, on the other hand, does imply a link to the
> (parent) directory due to the ".." entry.
>
> In fact the link count on a directory should always be 2 plus the number
> of subdirectories (one for the name in the parent, one for "." in the
> directory itself, and one for ".." in each subdirectory). Some "find"
> style programs depend on that to a degree, though mostly as an
> optimisation.
>
I'm having a hard time finding where that is defined in the POSIX
specs. The link count for normal files is fairly well-defined. The link
count for directories has always been more nebulous.
I think we would be well-served by a clearly-defined meaning for the
link count on a directory for Linux, because different filesystems do
this differently today.
Yours and Al's semantics seem fine (I don't have a real preference,
tbh), but we should codify this in Documentation/ since it is unclear.
--
Jeff Layton <jlayton@kernel.org>
next prev parent reply other threads:[~2025-09-10 11:54 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-09 4:43 [PATCH v2 0/8] VFS: more prep for change to directory locking NeilBrown
2025-09-09 4:43 ` [PATCH v2 1/7] VFS/ovl: add lookup_one_positive_killable() NeilBrown
2025-09-11 20:05 ` Al Viro
2025-09-11 23:02 ` NeilBrown
2025-09-09 4:43 ` [PATCH v2 2/7] VFS: discard err2 in filename_create() NeilBrown
2025-09-09 11:24 ` Jeff Layton
2025-09-09 4:43 ` [PATCH v2 3/7] VFS: unify old_mnt_idmap and new_mnt_idmap in renamedata NeilBrown
2025-09-09 4:43 ` [PATCH v2 4/7] VFS/audit: introduce kern_path_parent() for audit NeilBrown
2025-09-09 4:43 ` [PATCH v2 5/7] VFS: rename kern_path_locked() and related functions NeilBrown
2025-09-09 14:07 ` Amir Goldstein
2025-09-10 2:49 ` NeilBrown
2025-09-09 4:43 ` [PATCH v2 6/7] VFS: introduce simple_end_creating() and simple_failed_creating() NeilBrown
2025-09-09 8:20 ` Al Viro
2025-09-09 4:43 ` [PATCH v2 7/7] Use simple_start_creating() in various places NeilBrown
2025-09-09 8:19 ` Al Viro
2025-09-10 3:01 ` NeilBrown
2025-09-10 4:12 ` Al Viro
2025-09-10 4:16 ` Al Viro
2025-09-10 7:37 ` Al Viro
2025-09-10 11:04 ` Jeff Layton
2025-09-10 11:30 ` NeilBrown
2025-09-10 11:54 ` Jeff Layton [this message]
2025-09-10 18:28 ` Al Viro
2025-09-10 12:34 ` Jeff Layton
2025-09-10 23:13 ` NeilBrown
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=889f488eb1b27c91f445d4fa22dd4ff425b49454.camel@kernel.org \
--to=jlayton@kernel.org \
--cc=amir73il@gmail.com \
--cc=brauner@kernel.org \
--cc=jack@suse.cz \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=neil@brown.name \
--cc=viro@zeniv.linux.org.uk \
/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).