linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Youling Tang <youling.tang@linux.dev>
To: Chris Mason <clm@fb.com>, Josef Bacik <josef@toxicpanda.com>,
	David Sterba <dsterba@suse.com>
Cc: linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org,
	youling.tang@linux.dev, Youling Tang <tangyouling@kylinos.cn>
Subject: [PATCH] btrfs: Add the nlink annotation in btrfs_inode_item
Date: Fri, 26 Sep 2025 15:45:43 +0800	[thread overview]
Message-ID: <20250926074543.585249-1-youling.tang@linux.dev> (raw)

From: Youling Tang <tangyouling@kylinos.cn>

When I created a directory, I found that its hard link count was
1 (unlike other file system phenomena, including the "." directory,
which defaults to an initial count of 2).

By analyzing the code, it is found that the nlink of the directory
in btrfs has always been kept at 1, which is a deliberate design.

Adding its comments can prevent it from being mistakenly regarded
as a BUG.

Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
---
 include/uapi/linux/btrfs_tree.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/include/uapi/linux/btrfs_tree.h b/include/uapi/linux/btrfs_tree.h
index fc29d273845d..b4f7da90fd0e 100644
--- a/include/uapi/linux/btrfs_tree.h
+++ b/include/uapi/linux/btrfs_tree.h
@@ -876,6 +876,7 @@ struct btrfs_inode_item {
 	__le64 size;
 	__le64 nbytes;
 	__le64 block_group;
+	/* nlink in directories is fixed at 1 */
 	__le32 nlink;
 	__le32 uid;
 	__le32 gid;
-- 
2.43.0


             reply	other threads:[~2025-09-26  7:46 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-26  7:45 Youling Tang [this message]
2025-09-26  8:34 ` [PATCH] btrfs: Add the nlink annotation in btrfs_inode_item Qu Wenruo
2025-09-28  2:14   ` Youling Tang
2025-09-28  5:16     ` Qu Wenruo
2025-09-28  7:09       ` Youling Tang
2025-09-28  7:37         ` Qu Wenruo
2025-09-28  8:35           ` Youling Tang

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=20250926074543.585249-1-youling.tang@linux.dev \
    --to=youling.tang@linux.dev \
    --cc=clm@fb.com \
    --cc=dsterba@suse.com \
    --cc=josef@toxicpanda.com \
    --cc=linux-btrfs@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;
as well as URLs for NNTP newsgroup(s).