Bug 9866

Summary: chattr sticky behaviour and Orlov block allocator
Product: File System Reporter: Jörg Höhle (Joerg-Cyril.Hoehle)
Component: ext3Assignee: Andrew Morton (akpm)
Status: CLOSED CODE_FIX    
Severity: normal CC: duaneg
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.22 Subsystem:
Regression: --- Bisected commit-id:
Attachments: dont-inherit-topdir-flag.patch

Description Jörg Höhle 2008-02-01 07:25:08 UTC
Latest working kernel version: 2.6.22
Earliest failing kernel version: 2.6.18 (oldest tested)
Distribution: Ubuntu Gutsy
Hardware Environment: Fujitsu Siemens C1110 laptop
Software Environment: chattr 1.40.2 (12-Jul-2007), mke2fs 1.40.2 (12-Jul-2007)
Problem Description:
Some file attributes have sticky behaviour in ext2/3 whereas I believe
it should not. Namely, a directory marked with chattr +T serves "to be
the top of directory hierarchies for the purposes of the Orlov block
allocator", as the manpage says.

It seems wrong that subdirectories stickily inherit the +T flag: they
are obviously not top-level! Even files get the T attribute this way,
even though the chattr manpages only documents it for directories.

References:
http://lwn.net/Articles/14633/
http://lwn.net/Articles/14447/ Theodore Ts'o ext3 patch
http://en.wikipedia.org/wiki/Orlov_block_allocator


Steps to reproduce:
The following shows the sticky behaviour:
$ mkdir tests
chattr -V +T tests
chattr 1.40.2 (12-Jul-2007)
Flags von tests wie folgt gesetzt: ----------------T-
$ mkdir tests/src
$ cp -dp /etc/fstab tests/src
$ lsattr . tests tests/src
----------------T- ./tests
----------------T- tests/src
----------------T- tests/src/fstab

I verified (using cp -dpr and ls -lifR) that indeed, the inherited T
attribute causes all subdirectories to be created in inodes far apart
(like with mount -o remount,oldalloc), whereas the Orlov allocator
normally would put the directories next to each other.  My expectation
is that only e.g. /home/user{1,2,3,4,5,6} should be created spread
out, whereas each user home's contents would be next each other
(/home/user1/{foo,bar,etc}).

The effect of this bug makes chattr +T unusable, because Orlov
optimization is de facto eliminated.

Regards,
 Jörg Höhle
Comment 1 Anonymous Emailer 2008-02-01 10:27:48 UTC
Reply-To: akpm@linux-foundation.org

On Fri,  1 Feb 2008 07:25:09 -0800 (PST) bugme-daemon@bugzilla.kernel.org wrote:

> http://bugzilla.kernel.org/show_bug.cgi?id=9866
> 
>            Summary: chattr sticky behaviour and Orlov block allocator
>            Product: File System
>            Version: 2.5
>      KernelVersion: 2.6.22
>           Platform: All
>         OS/Version: Linux
>               Tree: Mainline
>             Status: NEW
>           Severity: normal
>           Priority: P1
>          Component: ext3
>         AssignedTo: akpm@osdl.org
>         ReportedBy: Joerg-Cyril.Hoehle@T-Systems.com
> 
> 
> Latest working kernel version: 2.6.22
> Earliest failing kernel version: 2.6.18 (oldest tested)
> Distribution: Ubuntu Gutsy
> Hardware Environment: Fujitsu Siemens C1110 laptop
> Software Environment: chattr 1.40.2 (12-Jul-2007), mke2fs 1.40.2
> (12-Jul-2007)
> Problem Description:
> Some file attributes have sticky behaviour in ext2/3 whereas I believe
> it should not. Namely, a directory marked with chattr +T serves "to be
> the top of directory hierarchies for the purposes of the Orlov block
> allocator", as the manpage says.
> 
> It seems wrong that subdirectories stickily inherit the +T flag: they
> are obviously not top-level! Even files get the T attribute this way,
> even though the chattr manpages only documents it for directories.
> 
> References:
> http://lwn.net/Articles/14633/
> http://lwn.net/Articles/14447/ Theodore Ts'o ext3 patch
> http://en.wikipedia.org/wiki/Orlov_block_allocator
> 
> 
> Steps to reproduce:
> The following shows the sticky behaviour:
> $ mkdir tests
> chattr -V +T tests
> chattr 1.40.2 (12-Jul-2007)
> Flags von tests wie folgt gesetzt: ----------------T-
> $ mkdir tests/src
> $ cp -dp /etc/fstab tests/src
> $ lsattr . tests tests/src
> ----------------T- ./tests
> ----------------T- tests/src
> ----------------T- tests/src/fstab
> 
> I verified (using cp -dpr and ls -lifR) that indeed, the inherited T
> attribute causes all subdirectories to be created in inodes far apart
> (like with mount -o remount,oldalloc), whereas the Orlov allocator
> normally would put the directories next to each other.  My expectation
> is that only e.g. /home/user{1,2,3,4,5,6} should be created spread
> out, whereas each user home's contents would be next each other
> (/home/user1/{foo,bar,etc}).
> 
> The effect of this bug makes chattr +T unusable, because Orlov
> optimization is de facto eliminated.
> 
> Regards,
>  J
Comment 2 Duane Griffin 2008-05-31 14:54:59 UTC
Created attachment 16352 [details]
dont-inherit-topdir-flag.patch

Preventing the flag from being sticky seems simple enough -- see attached patch. Could you confirm that this fixes things for you on ext3?
Comment 3 Andrew Morton 2008-06-03 13:25:54 UTC
Seems that I was unable to ge the linux-ext4 people interested in this one.

Please send a full signed-off and changelogged patch to myself,
linux-kernel and linux-ext4 and let's see if that gets us some action.

Thanks.