Skip to contentSkip to conversation

lib/tst_device.c: Add exception handling of function tst_find_free_loopdev

PATCH New zhaogongyi 2 participants 2 messages Mar 12, 2021

lore
Share & tools
lore

zhaogongyi

author
#0 lore raw

PATCH 1/1 lib/tst_device.c: Add exception handling of function tst_find_free_loopdev

Hi!

Quoted 5 lines

In addition, when "loopdevno = ioctl(fd, LOOP_CTL_GET_FREE)" get free loop device i, and the loop device file /dev/loop%i has been removed? set_dev_path will return 1 and set " /dev/block/loop%i " in path. It might happened in many Embedded Systems because the test process's id is root always. So we could also Add exception handling?

Or maybe we can try to create it when node doesn't exist?

	mknod("/dev/loop%i", S_IFBLK|0644, makedev(7, i))

-----------------------------------------------------------

Quoted 33 lines

Hi Petr, Li,

At first, it seems ok that using ST_RETRY_FUNC macro to try more times for race condition.

In addition, when "loopdevno = ioctl(fd, LOOP_CTL_GET_FREE)" get free loop device i, and the loop device file /dev/loop%i has been removed? set_dev_path will return 1 and set " /dev/block/loop%i " in path. It might happened in many Embedded Systems because the test process's id is root always. So we could also Add exception handling?

Thanks!

Best Regards,
Gongyi

Quoted 16 lines

Hi,

Quoted 8 lines
Quoted 3 lines

Because of race condition or abnormal env, set_dev_path may be return 1. And when set_dev_path return 1 in tst_find_free_loopdev, we should return Immediately.

If there exists a race condition, I firstly think of the TST_RETRY_FUNC macro to try more times for the set_dev_path. That might help to get the function success in the follow-up tries.

+1

Kind regards,
Petr

#1 lore raw

PATCH 1/1 lib/tst_device.c: Add exception handling of function tst_find_free_loopdev

Hi!

Quoted 8 lines
Quoted 5 lines

In addition, when "loopdevno = ioctl(fd, LOOP_CTL_GET_FREE)" get free loop device i, and the loop device file /dev/loop%i has been removed?? set_dev_path will return 1 and set " /dev/block/loop%i "
in path. It might happened in many Embedded Systems because the test process's id is root always. So we could also Add exception handling?

Or maybe we can try to create it when node doesn't exist?

	mknod("/dev/loop%i", S_IFBLK|0644, makedev(7, i))

I do not really get what happens on your system. It looks like dev fs is not properly populated, which would be bug in your system rather than in the test library.

What is the state of /dev/loop* and /dev/block/loop* before you attempt to run the test?

Signature · 2 lines
Cyril Hrubis
[email protected]