linux 下,ubi获取write mutex的问题

在linux中有,对于互斥的操作,大多用到了read/write mutex,今天发现一个问题,同一个进程内可以多次获取到。有点像vxworks中的量子锁一样。

但是会有crash打出:

=============================================
[ INFO: possible recursive locking detected ]
3.14.0-xilinx-00012-gfba9419-dirty #101 Not tainted
---------------------------------------------
ubimkvol/503 is trying to acquire lock:
 (&le->mutex){+.+...}, at: [<c02edbd0>] leb_write_lock+0x18/0x20   我在这调用一次

but task is already holding lock:
 (&le->mutex){+.+...}, at: [<c02edbd0>] leb_write_lock+0x18/0x20

other info that might help us debug this:
 Possible unsafe locking scenario:

       CPU0
       ----
  lock(&le->mutex);
  lock(&le->mutex);

 *** DEADLOCK ***

 May be due to missing lock nesting notation

2 locks held by ubimkvol/503:
 #0:  (&ubi->device_mutex){+.+.+.}, at: [<c02ebc9c>] ubi_cdev_ioctl+0x1f4/0x8dc
 #1:  (&le->mutex){+.+...}, at: [<c02edbd0>] leb_write_lock+0x18/0x20
Volume ID 0, size 19 LEBs (19767296 bytes, 18.9 MiB), LEB size 1
stack backtrace:
CPU: 0 PID: 503 Comm: ubimkvol Not tainted 3.14.0-xilinx-00012-gfba9419-dirty #101
[<c001e2a4>] (unwind_backtrace) from [<c0019d38>] (show_stack+0x10/0x14)
[<c0019d38>] (show_stack) from [<c041b280>] (dump_stack+0x84/0xd4)

[<c041b280>] (dump_stack) from [<c0061d6c>] (__lock_acquire+0x1cc0/0x1d58)
[<c0061d6c>] (__lock_acquire) from [<c00622b8>] (lock_acquire+0x60/0x74)
[<c00622b8>] (lock_acquire) from [<c041fdd8>] (down_write+0x40/0x54)
[<c041fdd8>] (down_write) from [<c02edbd0>] (leb_write_lock+0x18/0x20)
# [<c02edbd0>] (leb_write_lock) from [<c02f7184>] (ubi_backup_data_to_backup_volume+0xf4/0x47c)
[<c02f7184>] (ubi_backup_data_to_backup_volume) from [<c02f116c>] (ubi_io_write+0x340/0x6c4)
[<c02f116c>] (ubi_io_write) from [<c02ee654>] (ubi_eba_write_leb+0x540/0x6b0)
[<c02ee654>] (ubi_eba_write_leb) from [<c02e7560>] (ubi_change_vtbl_record+0xc8/0x12c)日 在这个函数中已经调用了一次。
[<c02e7560>] (ubi_change_vtbl_record) from [<c02e8bb0>] (ubi_create_volume+0x438/0x570)
[<c02e8bb0>] (ubi_create_volume) from [<c02ebca8>] (ubi_cdev_ioctl+0x200/0x8dc)
[<c02ebca8>] (ubi_cdev_ioctl) from [<c00de480>] (vfs_ioctl+0x18/0x34)
[<c00de480>] (vfs_ioctl) from [<c00df0b8>] (do_vfs_ioctl+0x5b8/0x600)
[<c00df0b8>] (do_vfs_ioctl) from [<c00df138>] (SyS_ioctl+0x38/0x54)
[<c00df138>] (SyS_ioctl) from [<c00163c0>] (ret_fast_syscall+0x0/0x48)
UBI DBG io (pid 503): read 4096 bytes from PEB 22:0

是上一个函数中已经获取到这个锁,在下面的子函数中,又一次的去获取这个锁,尽然成功了。但是有上面的信息打出。

冒似这样没有什么多大问题,因为是同一个进程,所以多次成功获取不会有问题。因为是同一个进程内,不会有死锁的情况。


你可能感兴趣的:(linux 下,ubi获取write mutex的问题)