* btrfs and default directory link count
@ 2013-11-08 11:07 Andreas Schneider
2013-11-08 12:24 ` cwillu
0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schneider @ 2013-11-08 11:07 UTC (permalink / raw)
To: linux-btrfs; +Cc: samba-technical
Hello,
I did run the Samba testsuite and have a failing test
(samba.vfstest.stream_depot). It revealed that it only fails on btrfs. The
reason is that a simple check fails:
if (smb_fname_base->st.st_ex_nlink == 2)
If you create a directory on btrfs and check stat:
$ mkdir x
$ stat x
File: ‘x’
Size: 0 Blocks: 0 IO Block: 4096 directory
Device: 2bh/43d Inode: 3834720 Links: 1
Access: (0755/drwxr-xr-x) Uid: ( 1000/ asn) Gid: ( 100/ users)
Access: 2013-11-08 11:54:32.431040963 +0100
Modify: 2013-11-08 11:54:32.430040956 +0100
Change: 2013-11-08 11:54:32.430040956 +0100
Birth: -
then you see Links: 1. On ext4 or other filesystems:
mkdir x
stat x
File: ‘x’
Size: 4096 Blocks: 8 IO Block: 4096 directory
Device: fd00h/64768d Inode: 8126886 Links: 2
Access: (0755/drwxr-xr-x) Uid: ( 1000/ asn) Gid: ( 100/ users)
Access: 2013-11-08 11:54:55.428212340 +0100
Modify: 2013-11-08 11:54:55.427212319 +0100
Change: 2013-11-08 11:54:55.427212319 +0100
Birth: -
the link count for a directory differs: Links: 2.
Why is btrfs different here? Could someone explain this?
Thanks,
-- andreas
--
Andreas Schneider GPG-ID: CC014E3D
www.cryptomilk.org asn@cryptomilk.org
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: btrfs and default directory link count
2013-11-08 11:07 btrfs and default directory link count Andreas Schneider
@ 2013-11-08 12:24 ` cwillu
2013-11-08 14:11 ` Andreas Schneider
0 siblings, 1 reply; 3+ messages in thread
From: cwillu @ 2013-11-08 12:24 UTC (permalink / raw)
To: Andreas Schneider; +Cc: linux-btrfs, samba-technical
On Fri, Nov 8, 2013 at 5:07 AM, Andreas Schneider <asn@cryptomilk.org> wrote:
> Hello,
>
> I did run the Samba testsuite and have a failing test
> (samba.vfstest.stream_depot). It revealed that it only fails on btrfs. The
> reason is that a simple check fails:
>
> if (smb_fname_base->st.st_ex_nlink == 2)
>
> If you create a directory on btrfs and check stat:
>
> $ mkdir x
> $ stat x
> File: ‘x’
> Size: 0 Blocks: 0 IO Block: 4096 directory
> Device: 2bh/43d Inode: 3834720 Links: 1
> Access: (0755/drwxr-xr-x) Uid: ( 1000/ asn) Gid: ( 100/ users)
> Access: 2013-11-08 11:54:32.431040963 +0100
> Modify: 2013-11-08 11:54:32.430040956 +0100
> Change: 2013-11-08 11:54:32.430040956 +0100
> Birth: -
>
> then you see Links: 1. On ext4 or other filesystems:
>
> mkdir x
> stat x
> File: ‘x’
> Size: 4096 Blocks: 8 IO Block: 4096 directory
> Device: fd00h/64768d Inode: 8126886 Links: 2
> Access: (0755/drwxr-xr-x) Uid: ( 1000/ asn) Gid: ( 100/ users)
> Access: 2013-11-08 11:54:55.428212340 +0100
> Modify: 2013-11-08 11:54:55.427212319 +0100
> Change: 2013-11-08 11:54:55.427212319 +0100
> Birth: -
>
> the link count for a directory differs: Links: 2.
>
> Why is btrfs different here? Could someone explain this?
As I understand it, inferring the number of directory entries from
st_nlink is an optimization that isn't universally valid. If that
count is 1, it must be considered invalid, and programs that don't
handle this correctly are broken. Coreutils handle this, at least...
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: btrfs and default directory link count
2013-11-08 12:24 ` cwillu
@ 2013-11-08 14:11 ` Andreas Schneider
0 siblings, 0 replies; 3+ messages in thread
From: Andreas Schneider @ 2013-11-08 14:11 UTC (permalink / raw)
To: cwillu; +Cc: linux-btrfs, samba-technical
On Friday 08 November 2013 06:24:01 cwillu wrote:
> On Fri, Nov 8, 2013 at 5:07 AM, Andreas Schneider <asn@cryptomilk.org>
wrote:
> > Hello,
> >
> > I did run the Samba testsuite and have a failing test
> > (samba.vfstest.stream_depot). It revealed that it only fails on btrfs. The
> > reason is that a simple check fails:
> >
> > if (smb_fname_base->st.st_ex_nlink == 2)
> >
> > If you create a directory on btrfs and check stat:
> >
> > $ mkdir x
> > $ stat x
> >
> > File: ‘x’
> > Size: 0 Blocks: 0 IO Block: 4096 directory
> >
> > Device: 2bh/43d Inode: 3834720 Links: 1
> > Access: (0755/drwxr-xr-x) Uid: ( 1000/ asn) Gid: ( 100/ users)
> > Access: 2013-11-08 11:54:32.431040963 +0100
> > Modify: 2013-11-08 11:54:32.430040956 +0100
> > Change: 2013-11-08 11:54:32.430040956 +0100
> >
> > Birth: -
> >
> > then you see Links: 1. On ext4 or other filesystems:
> >
> > mkdir x
> > stat x
> >
> > File: ‘x’
> > Size: 4096 Blocks: 8 IO Block: 4096 directory
> >
> > Device: fd00h/64768d Inode: 8126886 Links: 2
> > Access: (0755/drwxr-xr-x) Uid: ( 1000/ asn) Gid: ( 100/ users)
> > Access: 2013-11-08 11:54:55.428212340 +0100
> > Modify: 2013-11-08 11:54:55.427212319 +0100
> > Change: 2013-11-08 11:54:55.427212319 +0100
> >
> > Birth: -
> >
> > the link count for a directory differs: Links: 2.
> >
> > Why is btrfs different here? Could someone explain this?
>
> As I understand it, inferring the number of directory entries from
> st_nlink is an optimization that isn't universally valid. If that
> count is 1, it must be considered invalid, and programs that don't
> handle this correctly are broken. Coreutils handle this, at least...
Thanks for the explanation, I will fix our code.
-- andreas
--
Andreas Schneider GPG-ID: CC014E3D
www.cryptomilk.org asn@cryptomilk.org
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2013-11-08 14:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-11-08 11:07 btrfs and default directory link count Andreas Schneider
2013-11-08 12:24 ` cwillu
2013-11-08 14:11 ` Andreas Schneider
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.