From: Youling Tang <youling.tang@linux.dev>
To: Kent Overstreet <kent.overstreet@linux.dev>
Cc: linux-bcachefs@vger.kernel.org, linux-kernel@vger.kernel.org,
Youling Tang <tangyouling@kylinos.cn>
Subject: Re: [PATCH 3/3] bcachefs: Move the link counting check to the VFS layer
Date: Fri, 26 Sep 2025 12:22:37 +0800 [thread overview]
Message-ID: <b41b9b8e-6623-4e07-a132-515a6e88f1cc@linux.dev> (raw)
In-Reply-To: <frs3oa3te2yznm2yttqfm2pjqdwlecwkad6y6o5dymyvk2jh4p@7zncp5imxdjp>
Hi, Kent
On 9/26/25 11:42, Kent Overstreet wrote:
> On Fri, Sep 26, 2025 at 10:21:50AM +0800, Youling Tang wrote:
>> From: Youling Tang <tangyouling@kylinos.cn>
>>
>> Currently bcachefs only performs link count checks during link operations,
>> during rename and mkdir operations, the link count should also be checked.
>>
>> This patch moves the checks to the vfs_{link,rename,mkdir} functions when
>> sb->s_max_links is set, eliminating the need for filesystem-specific checks.
>>
>> Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
> I applied the other two patches, but not this one. We can't rely on the
> VFS for checks like this, there's lots of routes to modifying the
> filesystem that don't go through the VFS.
```
vfs_link
bch2_link
__bch2_link
bch2_link_trans
bch2_inode_nlink_inc
bch2_symlink
__bch2_link
```
I have traversed the bcachefs code and found that bch2_inode_nlink_inc is
called only once by bch2_link_trans, which in turn is called only once
by __bch2_link.
Although __bch2_link is also called by bch2_symlink, symlink operations
don't involve i_nlink values. Therefore, all effective calls to
bch2_inode_nlink_incoriginate from vfs_link. Please let me know if
there are any calls from other sources.
Even without moving to the VFS layer, do we still need to add link count
validation in bch2_{mkdir, rename}?
Thanks,
Youling.
prev parent reply other threads:[~2025-09-26 4:23 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-26 2:21 [PATCH 0/3] bcachefs: Fix some hard link count issues Youling Tang
2025-09-26 2:21 ` [PATCH 1/3] bcachefs: return -EMLINK instead of -EINVAL when hard link count exceeds limit Youling Tang
2025-09-26 2:21 ` [PATCH 2/3] bcachefs: Fix maximum link count check when creating hard links Youling Tang
2025-09-26 2:21 ` [PATCH 3/3] bcachefs: Move the link counting check to the VFS layer Youling Tang
2025-09-26 3:42 ` Kent Overstreet
2025-09-26 4:22 ` Youling Tang [this message]
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=b41b9b8e-6623-4e07-a132-515a6e88f1cc@linux.dev \
--to=youling.tang@linux.dev \
--cc=kent.overstreet@linux.dev \
--cc=linux-bcachefs@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=tangyouling@kylinos.cn \
/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