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>