• Filipe Manana's avatar
    btrfs: add and use helper to verify the calling task has locked the inode · 1b6e068a
    Filipe Manana authored
    We have a few places that check if we have the inode locked by doing:
    
        ASSERT(inode_is_locked(vfs_inode));
    
    This actually proved to be useful several times as if assertions are
    enabled (and by default they are in many distros) it immediately triggers
    a crash which is impossible for users to miss.
    
    However that doesn't check if the lock is held by the calling task, so
    the check passes if some other task locked the inode.
    
    Using one of the lockdep functions to check the lock is held, like
    lockdep_assert_held() for example, does check that the calling task
    holds the lock, and if that's not the case it produces a warning and
    stack trace in dmesg. However, despite the misleading "assert" in the
    name of the lockdep helpers, it does not trigger a crash/BUG_ON(), just
    a warning and splat in dmesg, which is easy to get unnoticed by users
    who may have lockdep enabled.
    
    So add a helper that does the ASSERT() and calls lockdep_assert_held()
    immediately after and use it every where we check the inode is locked.
    Like this if the lock is held by some other task we get the warning
    in dmesg which is caught by fstests, very helpful during development,
    and may also be occassionaly noticed by users with lockdep enabled.
    Reviewed-by: default avatarJosef Bacik <josef@toxicpanda.com>
    Signed-off-by: default avatarFilipe Manana <fdmanana@suse.com>
    Signed-off-by: default avatarDavid Sterba <dsterba@suse.com>
    1b6e068a
xattr.c 14.5 KB