Skip to content

Commit

Permalink
locks: add missing memory barrier in break_deleg
Browse files Browse the repository at this point in the history
break_deleg is subject to the same potential race as break_lease. Add
a memory barrier to prevent it.

Signed-off-by: Jeff Layton <jlayton@primarydata.com>
  • Loading branch information
Jeff Layton committed Jun 10, 2014
1 parent 64b2d1f commit 962bd40
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1914,6 +1914,12 @@ static inline int break_lease(struct inode *inode, unsigned int mode)

static inline int break_deleg(struct inode *inode, unsigned int mode)
{
/*
* Since this check is lockless, we must ensure that any refcounts
* taken are done before checking inode->i_flock. Otherwise, we could
* end up racing with tasks trying to set a new lease on this file.
*/
smp_mb();
if (inode->i_flock)
return __break_lease(inode, mode, FL_DELEG);
return 0;
Expand Down

0 comments on commit 962bd40

Please sign in to comment.