All of lore.kernel.org
 help / color / mirror / Atom feed
* efficient access to "rotational";  new fcntl?
@ 2009-09-18 19:31 Jim Meyering
  2009-09-18 22:16 ` Theodore Tso
  2009-09-19 11:25 ` Willy Tarreau
  0 siblings, 2 replies; 10+ messages in thread
From: Jim Meyering @ 2009-09-18 19:31 UTC (permalink / raw)
  To: Linux Kernel Mailing List

About a year ago, I fixed GNU rm to avoid quadratic readdir/stat seek
penalties on ext3 and ext4 that became overwhelming on directories with
many entries (1M entries started to look like infloop or DoS).

  From coreutils-7.0 NEWS:

    chgrp, chmod, chown, chcon, du, rm: now all display linear performance,
    even when operating on million-entry directories on ext3 and ext4 file
    systems.  Before, they would exhibit O(N^2) performance, due to linear
    per-entry seek time cost when operating on entries in readdir order.
    Rm was improved directly, while the others inherit the improvement
    from the newer version of fts in gnulib.

To do that efficiently, I changed the core readdir loop (mainly via
gnulib's fts.c) to preprocess entries, when needed, by sorting them
on inode, and *then* processing them.  This optimization is enabled
only when the affected file system is of a type likely to benefit,
and when the number of directory entries is large enough to matter.

However, with e.g., an ext4 partition on non-rotational hardware like
an SSD, that preprocessing is unnecessary and in fact wasted effort.
I'd like to avoid the waste by querying the equivalent of
/sys/.../rotational, via a syscall like fcntl or statvfs,
given a file descriptor.

Is there an efficient way to get that single bit?

IMHO, locating and opening-then-reading a file like
/sys/devices/pci0000:00/0000:00:1f.2/host4/target4:0:0/4:0:0:0/block/sdc/queue/rotational
is not appropriate in the context of a low-level library function like fts.

Jim

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2009-09-19 11:40 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-18 19:31 efficient access to "rotational"; new fcntl? Jim Meyering
2009-09-18 22:16 ` Theodore Tso
2009-09-19  8:01   ` Jim Meyering
2009-09-19  8:31     ` Arjan van de Ven
2009-09-19  9:07       ` Jim Meyering
2009-09-19  9:19         ` Arjan van de Ven
2009-09-19 11:11           ` Avi Kivity
2009-09-19 11:30             ` Arjan van de Ven
2009-09-19 11:40               ` Avi Kivity
2009-09-19 11:25 ` Willy Tarreau

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.