Skip to contentSkip to conversation

LVM2 test script failed, is it a read_ahead bug?

PATCH Dongmao Zhang 2 participants 2 messages Aug 27, 2013

lore
Share & tools
lore
#0 lore raw

Dear mail-list,
I met this in running the test case for lvm:
sh shell/read-ahead.sh FAILED:

#COMM "read ahead is properly inherited from underlying PV" blockdev --setra 768 "$dev1"
#read-ahead.sh:34+ blockdev --setra 768 @TESTDIR@/dev/mapper/@PREFIX at pv1 vgscan
#read-ahead.sh:35+ vgscan
Reading all physical volumes. This may take a while...
Found volume group "@PREFIX at vg" using metadata type lvm2
WARNING: This metadata update is NOT backed up
lvcreate -n $lv -L4m $vg "$dev1"
#read-ahead.sh:36+ lvcreate -n LV -L4m @PREFIX at vg @TESTDIR@/dev/mapper/@PREFIX at pv1
WARNING: This metadata update is NOT backed up
WARNING: This metadata update is NOT backed up
Logical volume "LV" created
test $(blockdev --getra $DM_DEV_DIR/$vg/$lv) -eq 768
blockdev --getra $DM_DEV_DIR/$vg/$lv
##read-ahead.sh:37+ blockdev --getra @TESTDIR@/dev/@PREFIX at vg/LV #read-ahead.sh:37+ test 1024 -eq 768

The read_ahead of underlying device was set to 768. After creating the logical volume device, lvm found the auto read ahead was 1024 which is bigger than 768. So lvm selected the bigger number(1024) to the read_ahead of logical volume.

However I think we should use the minimal read_ahead in underlying device and auto-detected kernel parameter. if so, this behavior could be consistent with the test script.

I suggest use:

libdm/libdm-common.c +0 -0
index 9043352..b9000f9 100644
@@ -1225,7 +1225,7 @@ static int _set_dev_node_read_ahead(const char

*dev_name,
if (!get_dev_node_read_ahead(dev_name, major, minor,
&current_read_ahead))

                        return_0;

- if (current_read_ahead >= read_ahead) {
+ if (current_read_ahead <= read_ahead) {
log_debug_activation("%s: retaining kernel read
ahead of %" PRIu32

                                  " (requested %" PRIu32 ")",
                                  dev_name, current_read_ahead, read_ahead);

If I am wrong, please correct me:)

thank you

#1 lore raw

Dne 27.8.2013 12:00, Dongmao Zhang napsal(a):

Quoted 10 lines

Dear mail-list,
I met this in running the test case for lvm:
sh shell/read-ahead.sh FAILED:

(quoted diff) +1 -1
-               if (current_read_ahead >= read_ahead) {
+               if (current_read_ahead <= read_ahead) {
                         log_debug_activation("%s: retaining kernel read

ahead of %" PRIu32

Quoted 5 lines
                                   " (requested %" PRIu32 ")",
                                   dev_name, current_read_ahead, read_ahead);

If I am wrong, please correct me:)

Basic rules for 'auto'mated read_ahead setting is simple: never set smaller value then the one which has been already set by kernel when device has been initialized.

If you need any specific more 'clever' value - simply use direct value for lvcreate/lvchange --readahead.

There is no thing like 'minimal' RA estimation in lvm2.

It's quite tricky to estimate the ideal RA for devices and it mostly depends on the type of use.

Zdenek