Btrfs: set the i_nlink to 2 for an initial dir inode
PATCH 2/2 Btrfs: set the i_nlink to 2 for an initial dir inode
For an initial dir inode, stat(1) show it links as 1, IMHO it should be 2 by default.
--- fs/btrfs/inode.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
fs/btrfs/inode.c +0 -0
@@ -4734,6 +4734,7 @@ static int btrfs_mkdir(struct inode *dir, struct
dentry *dentry, int mode)
inode->i_op = &btrfs_dir_inode_operations; inode->i_fop = &btrfs_dir_file_operations;
+ set_nlink(inode, 2);
btrfs_i_size_write(inode, 0);
err = btrfs_update_inode(trans, root, inode); if (err)
Signature · 1 line
1.7.4.1
Quoted 2 lines · Jeff Liu
For an initial dir inode, stat(1) show it links as 1, IMHO it should be 2 by default.
Yes, this is correct for directories. And newly created subvolumes should have nlink == 2 as well, can you please add it to your patch? (I have tested your patch + the proposed change.)
Thanks,
david
Please ignore this patch for now, it can cause the file system corrupted and failed to mount again, sorry for the noise!
-Jeff
Quoted 22 lines · Jeff Liu
For an initial dir inode, stat(1) show it links as 1, IMHO it should be 2 by default.
Signed-off-by Jie Liu <[email protected]>--- fs/btrfs/inode.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)fs/btrfs/inode.c +1
-0@@ -4734,6 +4734,7 @@ static int btrfs_mkdir(struct inode *dir, struct dentry *dentry, int mode) inode->i_op = &btrfs_dir_inode_operations; inode->i_fop = &btrfs_dir_file_operations; +set_nlink (inode,2 );btrfs_i_size_write (inode,0 ); err =btrfs_update_inode (trans, root, inode);if (err)
Quoted 2 lines · Jeff Liu
Please ignore this patch for now, it can cause the file system corrupted and failed to mount again, sorry for the noise!
Directories always have a link count of 1 in btrfs. This tells find not to use the link count as the count of subdirectories in the directory.
-chris
Quoted 6 lines · Chris Mason
Quoted 2 lines · Jeff Liu
Please ignore this patch for now, it can cause the file system corrupted and failed to mount again, sorry for the noise!
Directories always have a link count of 1 in btrfs. This tells find not to use the link count as the count of subdirectories in the directory.
I'm surprised.
Now I see why my thread "Creation of pseudo items leads to (seemingly) duplicate inodes (BUG inside)" suffered from little attention :-)
-Jan
Quoted 6 lines · Chris Mason
Quoted 2 lines · Jeff Liu
Please ignore this patch for now, it can cause the file system corrupted and failed to mount again, sorry for the noise!
Directories always have a link count of 1 in btrfs. This tells find not to use the link count as the count of subdirectories in the directory.
Thank you for your clarification!
-Jeff
Quoted 6 lines
-chris
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html