]> err.no Git - util-linux/commitdiff
libblkid: disable read-ahead when probing device files
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 18 Jan 2010 23:09:21 +0000 (00:09 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 16 Feb 2010 08:58:56 +0000 (09:58 +0100)
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 <torvalds@linux-foundation.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
configure.ac
shlibs/blkid/src/probe.c

index 5ddeaa5d9d086586f85fe8267863aada29aaa9d1..1fef94445deae5ffc8236e899ef7ca6d9ceed1ad 100644 (file)
@@ -163,6 +163,7 @@ AC_CHECK_FUNCS(
        setresuid \
        inotify_init \
        prctl \
+       posix_fadvise \
        getmntinfo \
        __secure_getenv \
        rpmatch])
index 2d3cafec4aa74682fea6dad659e2a6229fcd9aa3..b2c96a6b2477432c3aaf0c7d4d93ef72dff5323c 100644 (file)
@@ -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 {