Skip to content

Commit 625bba6

Browse files
committed
Merge tag 'locks-v3.15-2' of git://git.samba.org/jlayton/linux
Pull file locking fixes from Jeff Layton: "File locking related bugfixes for v3.15 (pile #2) - fix for a long-standing bug in __break_lease that can cause soft lockups - renaming of file-private locks to "open file description" locks, and the command macros to more visually distinct names The fix for __break_lease is also in the pile of patches for which Bruce sent a pull request, but I assume that your merge procedure will handle that correctly. For the other patches, I don't like the fact that we need to rename this stuff at this late stage, but it should be settled now (hopefully)" * tag 'locks-v3.15-2' of git://git.samba.org/jlayton/linux: locks: rename FL_FILE_PVT and IS_FILE_PVT to use "*_OFDLCK" instead locks: rename file-private locks to "open file description locks" locks: allow __break_lease to sleep even when break_time is 0
2 parents b8e6dec + cff2fce commit 625bba6

File tree

7 files changed

+54
-54
lines changed

7 files changed

+54
-54
lines changed

arch/arm/kernel/sys_oabi-compat.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,9 @@ asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd,
203203
int ret;
204204

205205
switch (cmd) {
206-
case F_GETLKP:
207-
case F_SETLKP:
208-
case F_SETLKPW:
206+
case F_OFD_GETLK:
207+
case F_OFD_SETLK:
208+
case F_OFD_SETLKW:
209209
case F_GETLK64:
210210
case F_SETLK64:
211211
case F_SETLKW64:

fs/compat.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -457,9 +457,9 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
457457
case F_GETLK64:
458458
case F_SETLK64:
459459
case F_SETLKW64:
460-
case F_GETLKP:
461-
case F_SETLKP:
462-
case F_SETLKPW:
460+
case F_OFD_GETLK:
461+
case F_OFD_SETLK:
462+
case F_OFD_SETLKW:
463463
ret = get_compat_flock64(&f, compat_ptr(arg));
464464
if (ret != 0)
465465
break;
@@ -468,7 +468,7 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
468468
conv_cmd = convert_fcntl_cmd(cmd);
469469
ret = sys_fcntl(fd, conv_cmd, (unsigned long)&f);
470470
set_fs(old_fs);
471-
if ((conv_cmd == F_GETLK || conv_cmd == F_GETLKP) && ret == 0) {
471+
if ((conv_cmd == F_GETLK || conv_cmd == F_OFD_GETLK) && ret == 0) {
472472
/* need to return lock information - see above for commentary */
473473
if (f.l_start > COMPAT_LOFF_T_MAX)
474474
ret = -EOVERFLOW;
@@ -493,9 +493,9 @@ COMPAT_SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd,
493493
case F_GETLK64:
494494
case F_SETLK64:
495495
case F_SETLKW64:
496-
case F_GETLKP:
497-
case F_SETLKP:
498-
case F_SETLKPW:
496+
case F_OFD_GETLK:
497+
case F_OFD_SETLK:
498+
case F_OFD_SETLKW:
499499
return -EINVAL;
500500
}
501501
return compat_sys_fcntl64(fd, cmd, arg);

fs/fcntl.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -274,15 +274,15 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
274274
break;
275275
#if BITS_PER_LONG != 32
276276
/* 32-bit arches must use fcntl64() */
277-
case F_GETLKP:
277+
case F_OFD_GETLK:
278278
#endif
279279
case F_GETLK:
280280
err = fcntl_getlk(filp, cmd, (struct flock __user *) arg);
281281
break;
282282
#if BITS_PER_LONG != 32
283283
/* 32-bit arches must use fcntl64() */
284-
case F_SETLKP:
285-
case F_SETLKPW:
284+
case F_OFD_SETLK:
285+
case F_OFD_SETLKW:
286286
#endif
287287
/* Fallthrough */
288288
case F_SETLK:
@@ -399,13 +399,13 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
399399

400400
switch (cmd) {
401401
case F_GETLK64:
402-
case F_GETLKP:
402+
case F_OFD_GETLK:
403403
err = fcntl_getlk64(f.file, cmd, (struct flock64 __user *) arg);
404404
break;
405405
case F_SETLK64:
406406
case F_SETLKW64:
407-
case F_SETLKP:
408-
case F_SETLKPW:
407+
case F_OFD_SETLK:
408+
case F_OFD_SETLKW:
409409
err = fcntl_setlk64(fd, f.file, cmd,
410410
(struct flock64 __user *) arg);
411411
break;

fs/locks.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@
135135
#define IS_POSIX(fl) (fl->fl_flags & FL_POSIX)
136136
#define IS_FLOCK(fl) (fl->fl_flags & FL_FLOCK)
137137
#define IS_LEASE(fl) (fl->fl_flags & (FL_LEASE|FL_DELEG))
138-
#define IS_FILE_PVT(fl) (fl->fl_flags & FL_FILE_PVT)
138+
#define IS_OFDLCK(fl) (fl->fl_flags & FL_OFDLCK)
139139

140140
static bool lease_breaking(struct file_lock *fl)
141141
{
@@ -564,7 +564,7 @@ static void __locks_insert_block(struct file_lock *blocker,
564564
BUG_ON(!list_empty(&waiter->fl_block));
565565
waiter->fl_next = blocker;
566566
list_add_tail(&waiter->fl_block, &blocker->fl_block);
567-
if (IS_POSIX(blocker) && !IS_FILE_PVT(blocker))
567+
if (IS_POSIX(blocker) && !IS_OFDLCK(blocker))
568568
locks_insert_global_blocked(waiter);
569569
}
570570

@@ -759,12 +759,12 @@ EXPORT_SYMBOL(posix_test_lock);
759759
* of tasks (such as posix threads) sharing the same open file table.
760760
* To handle those cases, we just bail out after a few iterations.
761761
*
762-
* For FL_FILE_PVT locks, the owner is the filp, not the files_struct.
762+
* For FL_OFDLCK locks, the owner is the filp, not the files_struct.
763763
* Because the owner is not even nominally tied to a thread of
764764
* execution, the deadlock detection below can't reasonably work well. Just
765765
* skip it for those.
766766
*
767-
* In principle, we could do a more limited deadlock detection on FL_FILE_PVT
767+
* In principle, we could do a more limited deadlock detection on FL_OFDLCK
768768
* locks that just checks for the case where two tasks are attempting to
769769
* upgrade from read to write locks on the same inode.
770770
*/
@@ -791,9 +791,9 @@ static int posix_locks_deadlock(struct file_lock *caller_fl,
791791

792792
/*
793793
* This deadlock detector can't reasonably detect deadlocks with
794-
* FL_FILE_PVT locks, since they aren't owned by a process, per-se.
794+
* FL_OFDLCK locks, since they aren't owned by a process, per-se.
795795
*/
796-
if (IS_FILE_PVT(caller_fl))
796+
if (IS_OFDLCK(caller_fl))
797797
return 0;
798798

799799
while ((block_fl = what_owner_is_waiting_for(block_fl))) {
@@ -1890,7 +1890,7 @@ EXPORT_SYMBOL_GPL(vfs_test_lock);
18901890

18911891
static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl)
18921892
{
1893-
flock->l_pid = IS_FILE_PVT(fl) ? -1 : fl->fl_pid;
1893+
flock->l_pid = IS_OFDLCK(fl) ? -1 : fl->fl_pid;
18941894
#if BITS_PER_LONG == 32
18951895
/*
18961896
* Make sure we can represent the posix lock via
@@ -1912,7 +1912,7 @@ static int posix_lock_to_flock(struct flock *flock, struct file_lock *fl)
19121912
#if BITS_PER_LONG == 32
19131913
static void posix_lock_to_flock64(struct flock64 *flock, struct file_lock *fl)
19141914
{
1915-
flock->l_pid = IS_FILE_PVT(fl) ? -1 : fl->fl_pid;
1915+
flock->l_pid = IS_OFDLCK(fl) ? -1 : fl->fl_pid;
19161916
flock->l_start = fl->fl_start;
19171917
flock->l_len = fl->fl_end == OFFSET_MAX ? 0 :
19181918
fl->fl_end - fl->fl_start + 1;
@@ -1941,13 +1941,13 @@ int fcntl_getlk(struct file *filp, unsigned int cmd, struct flock __user *l)
19411941
if (error)
19421942
goto out;
19431943

1944-
if (cmd == F_GETLKP) {
1944+
if (cmd == F_OFD_GETLK) {
19451945
error = -EINVAL;
19461946
if (flock.l_pid != 0)
19471947
goto out;
19481948

19491949
cmd = F_GETLK;
1950-
file_lock.fl_flags |= FL_FILE_PVT;
1950+
file_lock.fl_flags |= FL_OFDLCK;
19511951
file_lock.fl_owner = (fl_owner_t)filp;
19521952
}
19531953

@@ -2073,25 +2073,25 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
20732073

20742074
/*
20752075
* If the cmd is requesting file-private locks, then set the
2076-
* FL_FILE_PVT flag and override the owner.
2076+
* FL_OFDLCK flag and override the owner.
20772077
*/
20782078
switch (cmd) {
2079-
case F_SETLKP:
2079+
case F_OFD_SETLK:
20802080
error = -EINVAL;
20812081
if (flock.l_pid != 0)
20822082
goto out;
20832083

20842084
cmd = F_SETLK;
2085-
file_lock->fl_flags |= FL_FILE_PVT;
2085+
file_lock->fl_flags |= FL_OFDLCK;
20862086
file_lock->fl_owner = (fl_owner_t)filp;
20872087
break;
2088-
case F_SETLKPW:
2088+
case F_OFD_SETLKW:
20892089
error = -EINVAL;
20902090
if (flock.l_pid != 0)
20912091
goto out;
20922092

20932093
cmd = F_SETLKW;
2094-
file_lock->fl_flags |= FL_FILE_PVT;
2094+
file_lock->fl_flags |= FL_OFDLCK;
20952095
file_lock->fl_owner = (fl_owner_t)filp;
20962096
/* Fallthrough */
20972097
case F_SETLKW:
@@ -2143,13 +2143,13 @@ int fcntl_getlk64(struct file *filp, unsigned int cmd, struct flock64 __user *l)
21432143
if (error)
21442144
goto out;
21452145

2146-
if (cmd == F_GETLKP) {
2146+
if (cmd == F_OFD_GETLK) {
21472147
error = -EINVAL;
21482148
if (flock.l_pid != 0)
21492149
goto out;
21502150

21512151
cmd = F_GETLK64;
2152-
file_lock.fl_flags |= FL_FILE_PVT;
2152+
file_lock.fl_flags |= FL_OFDLCK;
21532153
file_lock.fl_owner = (fl_owner_t)filp;
21542154
}
21552155

@@ -2208,25 +2208,25 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
22082208

22092209
/*
22102210
* If the cmd is requesting file-private locks, then set the
2211-
* FL_FILE_PVT flag and override the owner.
2211+
* FL_OFDLCK flag and override the owner.
22122212
*/
22132213
switch (cmd) {
2214-
case F_SETLKP:
2214+
case F_OFD_SETLK:
22152215
error = -EINVAL;
22162216
if (flock.l_pid != 0)
22172217
goto out;
22182218

22192219
cmd = F_SETLK64;
2220-
file_lock->fl_flags |= FL_FILE_PVT;
2220+
file_lock->fl_flags |= FL_OFDLCK;
22212221
file_lock->fl_owner = (fl_owner_t)filp;
22222222
break;
2223-
case F_SETLKPW:
2223+
case F_OFD_SETLKW:
22242224
error = -EINVAL;
22252225
if (flock.l_pid != 0)
22262226
goto out;
22272227

22282228
cmd = F_SETLKW64;
2229-
file_lock->fl_flags |= FL_FILE_PVT;
2229+
file_lock->fl_flags |= FL_OFDLCK;
22302230
file_lock->fl_owner = (fl_owner_t)filp;
22312231
/* Fallthrough */
22322232
case F_SETLKW64:
@@ -2412,8 +2412,8 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
24122412
if (IS_POSIX(fl)) {
24132413
if (fl->fl_flags & FL_ACCESS)
24142414
seq_printf(f, "ACCESS");
2415-
else if (IS_FILE_PVT(fl))
2416-
seq_printf(f, "FLPVT ");
2415+
else if (IS_OFDLCK(fl))
2416+
seq_printf(f, "OFDLCK");
24172417
else
24182418
seq_printf(f, "POSIX ");
24192419

include/linux/fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -815,7 +815,7 @@ static inline struct file *get_file(struct file *f)
815815
#define FL_SLEEP 128 /* A blocking lock */
816816
#define FL_DOWNGRADE_PENDING 256 /* Lease is being downgraded */
817817
#define FL_UNLOCK_PENDING 512 /* Lease is being broken */
818-
#define FL_FILE_PVT 1024 /* lock is private to the file */
818+
#define FL_OFDLCK 1024 /* lock is "owned" by struct file */
819819

820820
/*
821821
* Special return value from posix_lock_file() and vfs_lock_file() for

include/uapi/asm-generic/fcntl.h

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -133,20 +133,20 @@
133133
#endif
134134

135135
/*
136-
* fd "private" POSIX locks.
136+
* Open File Description Locks
137137
*
138-
* Usually POSIX locks held by a process are released on *any* close and are
138+
* Usually record locks held by a process are released on *any* close and are
139139
* not inherited across a fork().
140140
*
141-
* These cmd values will set locks that conflict with normal POSIX locks, but
142-
* are "owned" by the opened file, not the process. This means that they are
143-
* inherited across fork() like BSD (flock) locks, and they are only released
144-
* automatically when the last reference to the the open file against which
145-
* they were acquired is put.
141+
* These cmd values will set locks that conflict with process-associated
142+
* record locks, but are "owned" by the open file description, not the
143+
* process. This means that they are inherited across fork() like BSD (flock)
144+
* locks, and they are only released automatically when the last reference to
145+
* the the open file against which they were acquired is put.
146146
*/
147-
#define F_GETLKP 36
148-
#define F_SETLKP 37
149-
#define F_SETLKPW 38
147+
#define F_OFD_GETLK 36
148+
#define F_OFD_SETLK 37
149+
#define F_OFD_SETLKW 38
150150

151151
#define F_OWNER_TID 0
152152
#define F_OWNER_PID 1

security/selinux/hooks.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3317,9 +3317,9 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd,
33173317
case F_GETLK:
33183318
case F_SETLK:
33193319
case F_SETLKW:
3320-
case F_GETLKP:
3321-
case F_SETLKP:
3322-
case F_SETLKPW:
3320+
case F_OFD_GETLK:
3321+
case F_OFD_SETLK:
3322+
case F_OFD_SETLKW:
33233323
#if BITS_PER_LONG == 32
33243324
case F_GETLK64:
33253325
case F_SETLK64:

0 commit comments

Comments
 (0)