Skip to content

Commit 50f2112

Browse files
bcodding-rhtrondmypd
authored andcommitted
locks: Set FL_CLOSE when removing flock locks on close()
Set FL_CLOSE in fl_flags as in locks_remove_posix() when clearing locks. NFS will check for this flag to ensure an unlock is sent in a following patch. Fuse handles flock and posix locks differently for FL_CLOSE, and so requires a fixup to retain the existing behavior for flock. Signed-off-by: Benjamin Coddington <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Acked-by: Miklos Szeredi <[email protected]> Signed-off-by: Trond Myklebust <[email protected]>
1 parent e129372 commit 50f2112

File tree

3 files changed

+4
-2
lines changed

3 files changed

+4
-2
lines changed

fs/fuse/file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2168,7 +2168,7 @@ static int fuse_setlk(struct file *file, struct file_lock *fl, int flock)
21682168
}
21692169

21702170
/* Unlock on close is handled by the flush method */
2171-
if (fl->fl_flags & FL_CLOSE)
2171+
if ((fl->fl_flags & FL_CLOSE_POSIX) == FL_CLOSE_POSIX)
21722172
return 0;
21732173

21742174
fuse_lk_fill(&args, file, fl, opcode, pid, flock, &inarg);

fs/locks.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2504,7 +2504,7 @@ locks_remove_flock(struct file *filp, struct file_lock_context *flctx)
25042504
.fl_owner = filp,
25052505
.fl_pid = current->tgid,
25062506
.fl_file = filp,
2507-
.fl_flags = FL_FLOCK,
2507+
.fl_flags = FL_FLOCK | FL_CLOSE,
25082508
.fl_type = F_UNLCK,
25092509
.fl_end = OFFSET_MAX,
25102510
};

include/linux/fs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -909,6 +909,8 @@ static inline struct file *get_file(struct file *f)
909909
#define FL_OFDLCK 1024 /* lock is "owned" by struct file */
910910
#define FL_LAYOUT 2048 /* outstanding pNFS layout */
911911

912+
#define FL_CLOSE_POSIX (FL_POSIX | FL_CLOSE)
913+
912914
/*
913915
* Special return value from posix_lock_file() and vfs_lock_file() for
914916
* asynchronous locking.

0 commit comments

Comments
 (0)