[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: reading an empty directory after reboot is very slow



Quoting Vincent Lefevre (vincent@vinc17.net):
> On 2015-04-15 14:13:43 -0500, David Wright wrote:
> > Quoting Kushal Kumaran (kushal@locationd.net):
> > > Moving entries around breaks ongoing readdir operations.  If a readdir
> > > has gone past the file being removed, and you moved the last entry
> > > there, the entry being moved would be missed, despite *it* not being the
> > > entry added or removed.
> > 
> > I don't think this matters. There's no guarantee that another process
> > isn't writing to that directory while you are working your way along
> > the entries.
> 
> But with the current solution (no automatic moving of an entry), you
> can't miss an entry that hasn't been removed.

$ mkdir /tmp/testdir
~ $ mkdir /tmp/testdir/file1
~ $ mkdir /tmp/testdir/file2
~ $ mkdir /tmp/testdir/file3
~ $ mkdir /tmp/testdir/file4
~ $ mkdir /tmp/testdir/file5
~ $ ls -lU /tmp/testdir/
total 20
drwxr-x--- 2 david david 4096 Apr 20 12:53 file1
drwxr-x--- 2 david david 4096 Apr 20 12:54 file4
drwxr-x--- 2 david david 4096 Apr 20 12:54 file5
drwxr-x--- 2 david david 4096 Apr 20 12:54 file2
drwxr-x--- 2 david david 4096 Apr 20 12:54 file3
~ $ mv -i /tmp/testdir/file4 /tmp/testdir/file4file4file4file4file4file4file4file4file4file4file4file4file4file4file4file4file4file4file4file4file4file4
~ $ ls -lU /tmp/testdir/
total 20
drwxr-x--- 2 david david 4096 Apr 20 12:53 file1
drwxr-x--- 2 david david 4096 Apr 20 12:54 file5
drwxr-x--- 2 david david 4096 Apr 20 12:54 file4file4file4file4file4file4file4file4file4file4file4file4file4file4file4file4file4file4file4file4file4file4
drwxr-x--- 2 david david 4096 Apr 20 12:54 file2
drwxr-x--- 2 david david 4096 Apr 20 12:54 file3
~ $ 

...so if you happen to be reading the entry for file5 at the
time I typed mv, you'll get the entry for file4 twice, under
two different names. (Or the opposite.)

Cheers,
David.


Reply to: