Linux Archive

Linux Archive (http://www.linux-archive.org/)
-   EXT3 Users (http://www.linux-archive.org/ext3-users/)
-   -   something odd with the order of files in a directory (http://www.linux-archive.org/ext3-users/228784-something-odd-order-files-directory.html)

Folkert van Heusden 01-16-2009 11:01 AM

something odd with the order of files in a directory
 
Hi,

I noticed something odd with the order of files in a directory.
When I put files in a directory in a certain order on an
ext3-filesystem, the order is not kept. On fat-filesystem it does.
E.g.:
rm -rf t ; mkdir t
touch a.a a.b a.c
mv a.b t/ ; mv a.c t/ ; mv a.a t/
ls -Ula t/

I then would expect:
a.b
a.c
a.a

but instead I get
drwxr-xr-x 3 root root 4096 2009-01-16 12:59 ..
-rw-r--r-- 1 root root 0 2009-01-16 12:59 a.c
-rw-r--r-- 1 root root 0 2009-01-16 12:59 a.b
-rw-r--r-- 1 root root 0 2009-01-16 12:59 a.a
drwxr-xr-x 2 root root 4096 2009-01-16 12:59 .

I tried adding sync between each mv but that didn't help.


Folkert van Heusden

--
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com

_______________________________________________
Ext3-users mailing list
Ext3-users@redhat.com
https://www.redhat.com/mailman/listinfo/ext3-users

Folkert van Heusden 01-16-2009 11:01 AM

something odd with the order of files in a directory
 
Hi,

I noticed something odd with the order of files in a directory.
When I put files in a directory in a certain order on an
ext3-filesystem, the order is not kept. On fat-filesystem it does.
E.g.:
rm -rf t ; mkdir t
touch a.a a.b a.c
mv a.b t/ ; mv a.c t/ ; mv a.a t/
ls -Ula t/

I then would expect:
a.b
a.c
a.a

but instead I get
drwxr-xr-x 3 root root 4096 2009-01-16 12:59 ..
-rw-r--r-- 1 root root 0 2009-01-16 12:59 a.c
-rw-r--r-- 1 root root 0 2009-01-16 12:59 a.b
-rw-r--r-- 1 root root 0 2009-01-16 12:59 a.a
drwxr-xr-x 2 root root 4096 2009-01-16 12:59 .

I tried adding sync between each mv but that didn't help.


Folkert van Heusden

--
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com

_______________________________________________
Ext3-users mailing list
Ext3-users@redhat.com
https://www.redhat.com/mailman/listinfo/ext3-users

Eric Sandeen 01-16-2009 02:35 PM

something odd with the order of files in a directory
 
Folkert van Heusden wrote:
> Hi,
>
> I noticed something odd with the order of files in a directory.
> When I put files in a directory in a certain order on an
> ext3-filesystem, the order is not kept. On fat-filesystem it does.
> E.g.:
> rm -rf t ; mkdir t
> touch a.a a.b a.c
> mv a.b t/ ; mv a.c t/ ; mv a.a t/
> ls -Ula t/
>
> I then would expect:
> a.b
> a.c
> a.a
>
> but instead I get
> drwxr-xr-x 3 root root 4096 2009-01-16 12:59 ..
> -rw-r--r-- 1 root root 0 2009-01-16 12:59 a.c
> -rw-r--r-- 1 root root 0 2009-01-16 12:59 a.b
> -rw-r--r-- 1 root root 0 2009-01-16 12:59 a.a
> drwxr-xr-x 2 root root 4096 2009-01-16 12:59 .
>
> I tried adding sync between each mv but that didn't help.

This is due to the dir_index feature; you're getting them back in hash
(read: random) order. If you turn it off:

[root@inode mnt]# tune2fs -O ^dir_index /dev/sdb4

you'll get what you expect:

[root@inode test]# rm -rf t ; mkdir t
[root@inode test]# touch a.a a.b a.c
[root@inode test]# mv a.b t/ ; mv a.c t/ ; mv a.a t/
[root@inode test]# ls -Ula t/
total 8
drwxr-xr-x 2 root root 4096 2009-01-16 15:30 .
drwxr-xr-x 4 root root 4096 2009-01-16 15:30 ..
-rw-r--r-- 1 root root 0 2009-01-16 15:30 a.b
-rw-r--r-- 1 root root 0 2009-01-16 15:30 a.c
-rw-r--r-- 1 root root 0 2009-01-16 15:30 a.a

but you'll lose the other efficiencies of the dir_index feature.

-Eric

_______________________________________________
Ext3-users mailing list
Ext3-users@redhat.com
https://www.redhat.com/mailman/listinfo/ext3-users

Folkert van Heusden 01-16-2009 02:44 PM

something odd with the order of files in a directory
 
> > When I put files in a directory in a certain order on an
> > ext3-filesystem, the order is not kept. On fat-filesystem it does.
>
> This is due to the dir_index feature; you're getting them back in hash
> (read: random) order. If you turn it off:

Ah ok, thanks!


Folkert van Heusden

--
MultiTail er et flexible tool for å kontrolere Logfiles og commandoer.
Med filtrer, farger, sammenføringer, forskeliger ansikter etc.
http://www.vanheusden.com/multitail/
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com

_______________________________________________
Ext3-users mailing list
Ext3-users@redhat.com
https://www.redhat.com/mailman/listinfo/ext3-users


All times are GMT. The time now is 03:12 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.