btrfs clone ordering of mutex

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Pavel pointed out (as we were discussing clone) that this mutex
locking sequence in btrfs_ioctl_clone in btrfs/ioctl.c will unlock the
mutexes in the wrong order much of the time.  Shouldn't the unlock of
two mutexes be done in the reverse order from the lock of the mutexes
to avoid other users of these mutexes potentially deadlocking?  See
this small section of btrfs_ioctl_clone

    if (!same_inode) {
        if (inode < src) {
            mutex_lock_nested(&inode->i_mutex, I_MUTEX_PARENT);
            mutex_lock_nested(&src->i_mutex, I_MUTEX_CHILD);
        } else {
            mutex_lock_nested(&src->i_mutex, I_MUTEX_PARENT);
            mutex_lock_nested(&inode->i_mutex, I_MUTEX_CHILD);
        }
    } else {
        mutex_lock(&src->i_mutex);
    }

followed by:

    mutex_unlock(&src->i_mutex);
    if (!same_inode)
        mutex_unlock(&inode->i_mutex);

-- 
Thanks,

Steve
--
To unsubscribe from this list: send the line "unsubscribe linux-cifs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux