<div>HI</div><div>Agree, but I think we can merge this patch firstly. And I will send a patchset for this api  tomorrow because other case like ioctl09 ioctl_loop01 also can use this api.  What do you think about this?</div><div>Best Regards</div><div>Yang Xu</div><div><br></div><div><!--emptysign--></div><div><div style="font-size:12px;padding:2px 0;">---Original---</div><div style="font-size:12px;background:#f0f0f0;color:#212121;padding:8px!important;border-radius:4px;line-height:1.5;"><div><b>From:</b> "Cyril Hrubis"<chrubis@suse.cz></div><div><b>Date:</b> Wed, Jul 22, 2020 20:59 PM</div><div><b>To:</b> "Yang Xu"<xuyang2018.jy@cn.fujitsu.com>;</div><div><b>Cc:</b> "ltp"<ltp@lists.linux.it>;</div><div><b>Subject:</b> Re: [LTP] [PATCH v2 1/2] syscalls/ioctl_loop06: Using LOOP_CONFIGURE to test invalid block size</div></div><br>Hi!<br>> > Do we really need to close and open the dev_fd repeatedly and also we<br>> > don't have to attach the device in the test setup?<br>> YES, we don't need to attach the device in the setup because <br>> LOOP_SET_BLOCK_SIZE checks works well(return ENXIO if supports, return <br>> EINVAL if not supports) when not attaching device.<br>> <br>> But for close and open the dev_fd repeatedly, I think it is necessary <br>> because when we detach device firstly without closing dev fd, it will <br>> report the warnging as below:<br>> <br>> tst_device.c:89: INFO: Found free device 0 '/dev/loop0'<br>> ioctl_loop06.c:69: INFO: Using LOOP_SET_BLOCK_SIZE with arg < 512<br>> ioctl_loop06.c:60: PASS: Set block size failed as expected: EINVAL (22)<br>> ioctl_loop06.c:69: INFO: Using LOOP_SET_BLOCK_SIZE with arg > PAGE_SIZE<br>> ioctl_loop06.c:60: PASS: Set block size failed as expected: EINVAL (22)<br>> ioctl_loop06.c:69: INFO: Using LOOP_SET_BLOCK_SIZE with arg != power_of_2<br>> ioctl_loop06.c:60: PASS: Set block size failed as expected: EINVAL (22)<br>> ioctl_loop06.c:69: INFO: Using LOOP_CONFIGURE with block_size < 512<br>> tst_device.c:223: WARN: ioctl(/dev/loop0, LOOP_CLR_FD, 0) no ENXIO for <br>> too long<br>> ioctl_loop06.c:62: FAIL: Set block size failed expected EINVAL got: <br>> EBUSY (16)<br>> <br>> That is why I close dev_fd firstly and then detach device in cleanup <br>> function.<br><br>Ah, right, the tst_detach_device() opens the dev_path so the function<br>fails to destroy it because the device is opened twice at that point.<br><br>I guess that proper solution would be to add a tst_detach_device_by_fd()<br>and change the library so that tst_detach_device() opens the dev_path<br>and calls tst_detach_device_by_fd() internally.<br><br>-- <br>Cyril Hrubis<br>chrubis@suse.cz<br><br>-- <br>Mailing list info: https://lists.linux.it/listinfo/ltp<br></div>