Skip to content

Commit

Permalink
Merge tag 'locks-v3.16-2' of git://git.samba.org/jlayton/linux
Browse files Browse the repository at this point in the history
Pull file locking fixes from Jeff Layton:
 "File locking related bugfixes

  Nothing too earth-shattering here.  A fix for a potential regression
  due to a patch in pile grate-driver#1, and the addition of a memory barrier to
  prevent a race condition between break_deleg and generic_add_lease"

* tag 'locks-v3.16-2' of git://git.samba.org/jlayton/linux:
  locks: set fl_owner for leases back to current->files
  locks: add missing memory barrier in break_deleg
  • Loading branch information
torvalds committed Jun 22, 2014
2 parents 532f513 + 0c27362 commit 2dfded8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion fs/locks.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ static int lease_init(struct file *filp, long type, struct file_lock *fl)
if (assign_type(fl, type) != 0)
return -EINVAL;

fl->fl_owner = (fl_owner_t)filp;
fl->fl_owner = (fl_owner_t)current->files;
fl->fl_pid = current->tgid;

fl->fl_file = filp;
Expand Down
6 changes: 6 additions & 0 deletions include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1921,6 +1921,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 2dfded8

Please sign in to comment.