* [PATCH 2/2] Btrfs: set the i_nlink to 2 for an initial dir inode
@ 2011-11-28 7:47 Jeff Liu
2011-11-29 0:08 ` David Sterba
2011-11-29 6:04 ` Jeff Liu
0 siblings, 2 replies; 6+ messages in thread
From: Jeff Liu @ 2011-11-28 7:47 UTC (permalink / raw)
To: linux-btrfs@vger.kernel.org
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
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] Btrfs: set the i_nlink to 2 for an initial dir inode
2011-11-28 7:47 [PATCH 2/2] Btrfs: set the i_nlink to 2 for an initial dir inode Jeff Liu
@ 2011-11-29 0:08 ` David Sterba
2011-11-29 6:04 ` Jeff Liu
1 sibling, 0 replies; 6+ messages in thread
From: David Sterba @ 2011-11-29 0:08 UTC (permalink / raw)
To: Jeff Liu; +Cc: linux-btrfs@vger.kernel.org
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] Btrfs: set the i_nlink to 2 for an initial dir inode
2011-11-28 7:47 [PATCH 2/2] Btrfs: set the i_nlink to 2 for an initial dir inode Jeff Liu
2011-11-29 0:08 ` David Sterba
@ 2011-11-29 6:04 ` Jeff Liu
2011-11-29 15:48 ` Chris Mason
1 sibling, 1 reply; 6+ messages in thread
From: Jeff Liu @ 2011-11-29 6:04 UTC (permalink / raw)
To: linux-btrfs@vger.kernel.org
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)
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] Btrfs: set the i_nlink to 2 for an initial dir inode
2011-11-29 6:04 ` Jeff Liu
@ 2011-11-29 15:48 ` Chris Mason
2011-11-29 16:10 ` Jan Schmidt
2011-11-30 2:12 ` Jeff Liu
0 siblings, 2 replies; 6+ messages in thread
From: Chris Mason @ 2011-11-29 15:48 UTC (permalink / raw)
To: Jeff Liu; +Cc: linux-btrfs@vger.kernel.org
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] Btrfs: set the i_nlink to 2 for an initial dir inode
2011-11-29 15:48 ` Chris Mason
@ 2011-11-29 16:10 ` Jan Schmidt
2011-11-30 2:12 ` Jeff Liu
1 sibling, 0 replies; 6+ messages in thread
From: Jan Schmidt @ 2011-11-29 16:10 UTC (permalink / raw)
To: Chris Mason, Jeff Liu, linux-btrfs@vger.kernel.org
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
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH 2/2] Btrfs: set the i_nlink to 2 for an initial dir inode
2011-11-29 15:48 ` Chris Mason
2011-11-29 16:10 ` Jan Schmidt
@ 2011-11-30 2:12 ` Jeff Liu
1 sibling, 0 replies; 6+ messages in thread
From: Jeff Liu @ 2011-11-30 2:12 UTC (permalink / raw)
To: Chris Mason, linux-btrfs@vger.kernel.org
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
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2011-11-30 2:12 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-28 7:47 [PATCH 2/2] Btrfs: set the i_nlink to 2 for an initial dir inode Jeff Liu
2011-11-29 0:08 ` David Sterba
2011-11-29 6:04 ` Jeff Liu
2011-11-29 15:48 ` Chris Mason
2011-11-29 16:10 ` Jan Schmidt
2011-11-30 2:12 ` Jeff Liu
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).