• Jeff Layton's avatar
    locks: use cmpxchg to assign i_flctx pointer · 0429c2b5
    Jeff Layton authored
    During the v3.20/v4.0 cycle, I had originally had the code manage the
    inode->i_flctx pointer using a compare-and-swap operation instead of the
    Sasha Levin though hit a problem while testing with trinity that made me
    believe that that wasn't safe. At the time, changing the code to protect
    the i_flctx pointer seemed to fix the issue, but I now think that was
    just coincidence.
    The issue was likely the same race that Kirill Shutemov hit while
    testing the pre-rc1 v4.0 kernel and that Linus spotted. Due to the way
    that the spinlock was dropped in the middle of flock_lock_file, you
    could end up with multiple flock locks for the same struct file on the
    Reinstate the use of a CAS operation to assign this pointer since it's
    likely to be more efficient and gets the i_lock completely out of the
    file locking business.
    Signed-off-by: default avatarJeff Layton <jeff.layton@primarydata.com>
locks.c 68.7 KB