Jeff Liu
2011-Nov-28 07:47 UTC
[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. Signed-off-by: Jie Liu <jeff.liu@oracle.com> --- fs/btrfs/inode.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index 116ab67..92b3cb9 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -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) -- 1.7.4.1 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
David Sterba
2011-Nov-29 00:08 UTC
Re: [PATCH 2/2] Btrfs: set the i_nlink to 2 for an initial dir inode
On Mon, Nov 28, 2011 at 03:47:20PM +0800, Jeff Liu wrote:> 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 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Liu
2011-Nov-29 06:04 UTC
Re: [PATCH 2/2] Btrfs: set the i_nlink to 2 for an initial dir inode
Please ignore this patch for now, it can cause the file system corrupted and failed to mount again, sorry for the noise! -Jeff On 11/28/2011 03:47 PM, Jeff Liu wrote:> For an initial dir inode, stat(1) show it links as 1, IMHO it should be > 2 by default. > > Signed-off-by: Jie Liu <jeff.liu@oracle.com> > > --- > fs/btrfs/inode.c | 1 + > 1 files changed, 1 insertions(+), 0 deletions(-) > > diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c > index 116ab67..92b3cb9 100644 > --- a/fs/btrfs/inode.c > +++ b/fs/btrfs/inode.c > @@ -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)-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Chris Mason
2011-Nov-29 15:48 UTC
Re: [PATCH 2/2] Btrfs: set the i_nlink to 2 for an initial dir inode
On Tue, Nov 29, 2011 at 02:04:37PM +0800, Jeff Liu wrote:> 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 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jan Schmidt
2011-Nov-29 16:10 UTC
Re: [PATCH 2/2] Btrfs: set the i_nlink to 2 for an initial dir inode
On 29.11.2011 16:48, Chris Mason wrote:> On Tue, Nov 29, 2011 at 02:04:37PM +0800, Jeff Liu wrote: >> 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 -- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Jeff Liu
2011-Nov-30 02:12 UTC
Re: [PATCH 2/2] Btrfs: set the i_nlink to 2 for an initial dir inode
On 11/29/2011 11:48 PM, Chris Mason wrote:> On Tue, Nov 29, 2011 at 02:04:37PM +0800, Jeff Liu wrote: >> 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> > -chris > -- > To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html-- To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html