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

Re: reading an empty directory after reboot is very slow



On Wed, Apr 15, 2015, at 16:57, Bob Proulx wrote:
> Henrique de Moraes Holschuh wrote:
> > 2. unmount filesystem and run e2fsck -D on it every so often.
> 
> Every so often?  That phrase roused my interest.  Wouldn't exactly
> once be enough?

Yes, as long as nobody ever creates a massive number of entries in a directory that is not going to be rmdir'd again after you did the e2fsck -D...

So, "every so often"...

> I think there are two issues under discussion.  One is if dir_index
> has been applied.  For that once would be enough.

Yes.  But dir_index is about locating files fast for open() or stat() in massive directories, not shrinking a very sparse one.

And BTW, a directory has very little information about a file. In fact, in simplified terms it usually has only the file name and the inode number, everything else is related to how the filesystem implements the directory itself (such as h-tree topology information).

Everything else about the file is in the inode (including size, access times, attributes, ACLs, xattrs, hardlink count).  And inode tables are not stored together with the directory: they're in reserved areas of the filesystem for inode tables, while the directories are inside the data area, at least in ext4 and XFS.

Do note that it can happen that a directory with very few entries could be stored entirely inside the inode for ("."), should it be small enough. Depends on the filesystem. This means you effectively loaded that directory when you caused its parent to be loaded.

>   # fsck -D /dev/v1/test
>   fsck from util-linux 2.25.2
>   e2fsck 1.42.12 (29-Aug-2014)
>   /dev/mapper/v1-test: clean, 13/25688 files, 9121/102400 blocks
> 
> This produced no change in that directory size.  It does not appear to
> me that e2fsck -D compacts existing empty directories.

Hmm, you could try "e2fsck -D", not "fsck -D".

If e2fsck also refuses to do anything, try "e2fsck -D -f" to force it to check a clean filesystem.

> I am not immediately sure how to create a new ext file system without
> dir_index.  Otherwise I would do a quick test to verify that it does
> actually add dir_index to existing directories.

"tune2fs -O ^dir_index", then e2fsck -D (maybe with -f) should remove dir_index, AFAIK.

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique de Moraes Holschuh <hmh@debian.org>


Reply to: