]> www.infradead.org Git - users/hch/blktests.git/commitdiff
loop/004: Need to wait for drop caches if block_size is changed
authorzhengbin <zhengbin13@huawei.com>
Wed, 20 Feb 2019 09:38:06 +0000 (17:38 +0800)
committerOmar Sandoval <osandov@fb.com>
Wed, 20 Feb 2019 19:35:43 +0000 (11:35 -0800)
When i test blktests, loop/004 will be fail. The Key test steps
are as follows:
1. losetup -f --show  /dev/sda
2. src/loblksize /dev/loop0 4096

step 1 will create /dev/loop0. after that, daemon systemd-udevd
will visit and close /dev/loop0 who will add and delete
i_mapping->nrpages.
PS: the operation of systemd-udevd is in the background.

step 2 will set /dev/loop0 block size, linux kernel function
loop_set_block_size has been changed since commit 5db470e229e2
("loop: drop caches if offset or block_size are changed")
+ if (lo->lo_queue->limits.logical_block_size != arg &&
+     lo->lo_device->bd_inode->i_mapping->nrpages) {
+               err = -EAGAIN;
+               pr_warn("%s: loop%d (%s) has still dirty pages\n",
+                       __func__, lo->lo_number, lo->lo_file_name,
+                       lo->lo_device->bd_inode->i_mapping->nrpages);
+               goto out_unfreeze;
+       }
--->maybe systemd-udevd just visited /dev/loop0, this leads to failure

Add a step between 1 and 2.

Signed-off-by: zhengbin <zhengbin13@huawei.com>
tests/loop/004

index 363fb5e2d5a3129f10484f9029031fbb3ecb1427..fab34e806da24b48c521ae79656d53615cca1443 100755 (executable)
@@ -28,6 +28,7 @@ test() {
                return 1
        fi
 
+       udevadm settle
        src/loblksize "$loop_dev" 4096
        losetup --direct-io=on "$loop_dev"
        cat "/sys/block/${loop_dev#/dev/}/loop/dio"