From: Karel Zak Date: Fri, 29 Jun 2007 09:38:54 +0000 (+0200) Subject: blockdev: add BLKFRAGET/BLKFRASET ioctls X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2a1e7880895bbd0ecdd50984ebbf9e68b745e8e;p=util-linux blockdev: add BLKFRAGET/BLKFRASET ioctls In Linux 2.6 the BLKRASET ioctl has the desired effect for mounted file-systems. In Linux 2.4 it appears to set the number of blocks to read-ahead on the *device* as opposed to within a *file*, and the maximum value of this number is 255. As a result the invocation of blockdev will fail on Linux 2.4 for any usefully large value of READAHEAD, and will not in any case have the desired affect for fragmented files. (Based on the blockdev-getfra-setfra.patch Debian patch.) Signed-off-by: Karel Zak --- diff --git a/disk-utils/blockdev.8 b/disk-utils/blockdev.8 index bde64265..86c29dd2 100644 --- a/disk-utils/blockdev.8 +++ b/disk-utils/blockdev.8 @@ -48,6 +48,12 @@ Set readahead to .B \--getra Print readahead (in 512-byte sectors). .TP +.BI \--setfra " N" +Set filesystem readahead (same like --setra on 2.6 kernels). +.TP +.B \--getfra +Get filesystem readahead. +.TP .B \--flushbufs Flush buffers. .TP diff --git a/disk-utils/blockdev.c b/disk-utils/blockdev.c index c07fb30a..6cd038f1 100644 --- a/disk-utils/blockdev.c +++ b/disk-utils/blockdev.c @@ -23,6 +23,8 @@ #define BLKFLSBUF _IO(0x12,97) #define BLKRASET _IO(0x12,98) #define BLKRAGET _IO(0x12,99) +#define BLKFRASET _IO(0x12,100) +#define BLKFRAGET _IO(0x12,101) #define BLKSSZGET _IO(0x12,104) #define BLKBSZGET _IOR(0x12,112,size_t) #define BLKBSZSET _IOW(0x12,113,size_t) @@ -86,6 +88,12 @@ struct bdc { #ifdef BLKRAGET { "--getra", "BLKRAGET", BLKRAGET, ARGLINTG, -1, NULL, N_("get readahead") }, #endif +#ifdef BLKFRASET + { "--setfra", "BLKFRASET", BLKFRASET, ARGINTA, 0, "FSREADAHEAD", N_("set filesystem readahead") }, +#endif +#ifdef BLKFRAGET + { "--getfra", "BLKFRAGET", BLKFRAGET, ARGLINTG, -1, NULL, N_("get filesystem readahead") }, +#endif #ifdef BLKFLSBUF { "--flushbufs", "BLKFLSBUF", BLKFLSBUF, ARGNONE, 0, NULL, N_("flush buffers") }, #endif