From: Linus Torvalds Date: Mon, 18 Jan 2010 23:09:21 +0000 (+0100) Subject: libblkid: disable read-ahead when probing device files X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=07684fc3b1802e092ea60786418c9b75d99cb435;p=util-linux libblkid: disable read-ahead when probing device files Read-ahead doesn't work very well on device probing, and can hurt a lot when we do essentially random accesses on very slow devices. So disable it if possible. [kzak@redhat.com: - add posix_fadvise() configure test] Signed-off-by: Linus Torvalds Signed-off-by: Karel Zak --- diff --git a/configure.ac b/configure.ac index 5ddeaa5d..1fef9444 100644 --- a/configure.ac +++ b/configure.ac @@ -163,6 +163,7 @@ AC_CHECK_FUNCS( setresuid \ inotify_init \ prctl \ + posix_fadvise \ getmntinfo \ __secure_getenv \ rpmatch]) diff --git a/shlibs/blkid/src/probe.c b/shlibs/blkid/src/probe.c index 2d3cafec..b2c96a6b 100644 --- a/shlibs/blkid/src/probe.c +++ b/shlibs/blkid/src/probe.c @@ -640,6 +640,10 @@ int blkid_probe_set_device(blkid_probe pr, int fd, pr->mode = 0; pr->blkssz = 0; +#if defined(POSIX_FADV_RANDOM) && defined(HAVE_POSIX_FADVISE) + /* Disable read-ahead */ + posix_fadvise(fd, 0, 0, POSIX_FADV_RANDOM); +#endif if (size) pr->size = size; else {