[LTP] [PATCH] readahead02: fix read_ahead_kb file not found

Naresh Kamboju naresh.kamboju@linaro.org
Wed Aug 31 11:14:22 CEST 2016


On 30 August 2016 at 17:51, Cyril Hrubis <chrubis@suse.cz> wrote:
> Hi!
>> @@ -193,7 +193,7 @@ static long get_device_readahead(const char *fname)
>>       if (stat(fname, &st) == -1)
>>               tst_brkm(TBROK | TERRNO, cleanup, "stat");
>>       snprintf(buf, sizeof(buf), "/sys/dev/block/%d:%d/queue/read_ahead_kb",
>> -              major(st.st_dev), minor(st.st_dev));
>> +              major(st.st_dev), minor(st.st_dev) & ~31);
>
> So we clear lower five bits of the minor number here. Why exactly that amount?
>
> Shouldn't we just pass zero as a minor number there anyway?

For block device like sda the read_ahead_kb is present in 8:0. if it
sdb it is present at 8:16. like wise
 8:0   sda
 8:16 sdb
 8:32 sdc
 8:48 sdd

I changed my patch to clear lower four bits of the minor number

  minor(st.st_dev) & ~15);

- Naresh

>
>>       SAFE_FILE_SCANF(cleanup, buf, "%ld", &ra_kb);
>>
>>       return ra_kb * 1024;
>> --
>> 1.9.1
>>
>
> --
> Cyril Hrubis
> chrubis@suse.cz


More information about the ltp mailing list