Hi Ben, Ben Hutchings wrote:
laptop_mode implements the READAHEAD setting by running blockdev with the --setra option for each block-device underlying a mounted file-system. This in turn appears to use the BLKRASET ioctl. In Linux 2.6 this ioctl this has the desired effect. 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. Unhelpfully, laptop_mode redirects its error message to /dev/null so this is not reported anywhere.
Ahhhh. I'll see if I can change the stdout/stderr redirection to just a stdout redirection.
laptop_mode should instead use the BLKFRASET ioctl, which is the same as BLKRASET on 2.6 and also works properly on 2.4 for IDE devices (but unfortunately no others). If there is no command that exposes this ioctl, laptop_mode could instead write this setting through the /proc filesystem:
Thanks for the code. I'd prefer to have a tool that does the job correctly, of course, so for now I've submitted bug #355536 to the util-linux package (of which blockdev is a part) with the request that a flag for this be added, plus a patch to achieve it. If you want to have this problem fixed for yourself, apply the attached patch to disk-utils/blockdev.c in the util-linux package, and then modify /usr/sbin/laptop_mode to use --setfra instead of --setra. I'll update laptop-mode-tools to use it in the next version. I'll let you know what happens with the blockdev patch.
--Bart
--- blockdev.c.orig 2006-03-06 10:28:07.000000000 +0100 +++ blockdev.c 2006-03-06 10:42:05.000000000 +0100 @@ -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 @@ #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