Commit 0d3f7a2d authored by Jeff Layton's avatar Jeff Layton

locks: rename file-private locks to "open file description locks"

File-private locks have been merged into Linux for v3.15, and *now*
people are commenting that the name and macro definitions for the new
file-private locks suck.

...and I can't even disagree. The names and command macros do suck.

We're going to have to live with these for a long time, so it's
important that we be happy with the names before we're stuck with them.
The consensus on the lists so far is that they should be rechristened as
"open file description locks".

The name isn't a big deal for the kernel, but the command macros are not
visually distinct enough from the traditional POSIX lock macros. The
glibc and documentation folks are recommending that we change them to
look like F_OFD_{GETLK|SETLK|SETLKW}. That lessens the chance that a
programmer will typo one of the commands wrong, and also makes it easier
to spot this difference when reading code.

This patch makes the following changes that I think are necessary before
v3.15 ships:

1) rename the command macros to their new names. These end up in the uapi
   headers and so are part of the external-facing API. It turns out that
   glibc doesn't actually use the fcntl.h uapi header, but it's hard to
   be sure that something else won't. Changing it now is safest.

2) make the the /proc/locks output display these as type "OFDLCK"

Cc: Michael Kerrisk <mtk.manpages@gmail.com>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: Carlos O'Donell <carlos@redhat.com>
Cc: Stefan Metzmacher <metze@samba.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Frank Filz <ffilzlnx@mindspring.com>
Cc: Theodore Ts'o <tytso@mit.edu>
Signed-off-by: default avatarJeff Layton <jlayton@redhat.com>
parent f1c6bb2c
...@@ -203,9 +203,9 @@ asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd, ...@@ -203,9 +203,9 @@ asmlinkage long sys_oabi_fcntl64(unsigned int fd, unsigned int cmd,
int ret; int ret;
switch (cmd) { switch (cmd) {
case F_GETLKP: case F_OFD_GETLK:
case F_SETLKP: case F_OFD_SETLK:
case F_SETLKPW: case F_OFD_SETLKW:
case F_GETLK64: case F_GETLK64:
case F_SETLK64: case F_SETLK64:
case F_SETLKW64: case F_SETLKW64:
......
...@@ -457,9 +457,9 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, ...@@ -457,9 +457,9 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
case F_GETLK64: case F_GETLK64:
case F_SETLK64: case F_SETLK64:
case F_SETLKW64: case F_SETLKW64:
case F_GETLKP: case F_OFD_GETLK:
case F_SETLKP: case F_OFD_SETLK:
case F_SETLKPW: case F_OFD_SETLKW:
ret = get_compat_flock64(&f, compat_ptr(arg)); ret = get_compat_flock64(&f, compat_ptr(arg));
if (ret != 0) if (ret != 0)
break; break;
...@@ -468,7 +468,7 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, ...@@ -468,7 +468,7 @@ COMPAT_SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
conv_cmd = convert_fcntl_cmd(cmd); conv_cmd = convert_fcntl_cmd(cmd);
ret = sys_fcntl(fd, conv_cmd, (unsigned long)&f); ret = sys_fcntl(fd, conv_cmd, (unsigned long)&f);
set_fs(old_fs); set_fs(old_fs);
if ((conv_cmd == F_GETLK || conv_cmd == F_GETLKP) && ret == 0) { if ((conv_cmd == F_GETLK || conv_cmd == F_OFD_GETLK) && ret == 0) {
/* need to return lock information - see above for commentary */ /* need to return lock information - see above for commentary */
if (f.l_start > COMPAT_LOFF_T_MAX) if (f.l_start > COMPAT_LOFF_T_MAX)
ret = -EOVERFLOW; ret = -EOVERFLOW;
...@@ -493,9 +493,9 @@ COMPAT_SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd, ...@@ -493,9 +493,9 @@ COMPAT_SYSCALL_DEFINE3(fcntl, unsigned int, fd, unsigned int, cmd,
case F_GETLK64: case F_GETLK64:
case F_SETLK64: case F_SETLK64:
case F_SETLKW64: case F_SETLKW64:
case F_GETLKP: case F_OFD_GETLK:
case F_SETLKP: case F_OFD_SETLK:
case F_SETLKPW: case F_OFD_SETLKW:
return -EINVAL; return -EINVAL;
} }
return compat_sys_fcntl64(fd, cmd, arg); return compat_sys_fcntl64(fd, cmd, arg);
......
...@@ -274,15 +274,15 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg, ...@@ -274,15 +274,15 @@ static long do_fcntl(int fd, unsigned int cmd, unsigned long arg,
break; break;
#if BITS_PER_LONG != 32 #if BITS_PER_LONG != 32
/* 32-bit arches must use fcntl64() */ /* 32-bit arches must use fcntl64() */
case F_GETLKP: case F_OFD_GETLK:
#endif #endif
case F_GETLK: case F_GETLK:
err = fcntl_getlk(filp, cmd, (struct flock __user *) arg); err = fcntl_getlk(filp, cmd, (struct flock __user *) arg);
break; break;
#if BITS_PER_LONG != 32 #if BITS_PER_LONG != 32
/* 32-bit arches must use fcntl64() */ /* 32-bit arches must use fcntl64() */
case F_SETLKP: case F_OFD_SETLK:
case F_SETLKPW: case F_OFD_SETLKW:
#endif #endif
/* Fallthrough */ /* Fallthrough */
case F_SETLK: case F_SETLK:
...@@ -399,13 +399,13 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd, ...@@ -399,13 +399,13 @@ SYSCALL_DEFINE3(fcntl64, unsigned int, fd, unsigned int, cmd,
switch (cmd) { switch (cmd) {
case F_GETLK64: case F_GETLK64:
case F_GETLKP: case F_OFD_GETLK:
err = fcntl_getlk64(f.file, cmd, (struct flock64 __user *) arg); err = fcntl_getlk64(f.file, cmd, (struct flock64 __user *) arg);
break; break;
case F_SETLK64: case F_SETLK64:
case F_SETLKW64: case F_SETLKW64:
case F_SETLKP: case F_OFD_SETLK:
case F_SETLKPW: case F_OFD_SETLKW:
err = fcntl_setlk64(fd, f.file, cmd, err = fcntl_setlk64(fd, f.file, cmd,
(struct flock64 __user *) arg); (struct flock64 __user *) arg);
break; break;
......
...@@ -1941,7 +1941,7 @@ int fcntl_getlk(struct file *filp, unsigned int cmd, struct flock __user *l) ...@@ -1941,7 +1941,7 @@ int fcntl_getlk(struct file *filp, unsigned int cmd, struct flock __user *l)
if (error) if (error)
goto out; goto out;
if (cmd == F_GETLKP) { if (cmd == F_OFD_GETLK) {
error = -EINVAL; error = -EINVAL;
if (flock.l_pid != 0) if (flock.l_pid != 0)
goto out; goto out;
...@@ -2076,7 +2076,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd, ...@@ -2076,7 +2076,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
* FL_FILE_PVT flag and override the owner. * FL_FILE_PVT flag and override the owner.
*/ */
switch (cmd) { switch (cmd) {
case F_SETLKP: case F_OFD_SETLK:
error = -EINVAL; error = -EINVAL;
if (flock.l_pid != 0) if (flock.l_pid != 0)
goto out; goto out;
...@@ -2085,7 +2085,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd, ...@@ -2085,7 +2085,7 @@ int fcntl_setlk(unsigned int fd, struct file *filp, unsigned int cmd,
file_lock->fl_flags |= FL_FILE_PVT; file_lock->fl_flags |= FL_FILE_PVT;
file_lock->fl_owner = (fl_owner_t)filp; file_lock->fl_owner = (fl_owner_t)filp;
break; break;
case F_SETLKPW: case F_OFD_SETLKW:
error = -EINVAL; error = -EINVAL;
if (flock.l_pid != 0) if (flock.l_pid != 0)
goto out; goto out;
...@@ -2143,7 +2143,7 @@ int fcntl_getlk64(struct file *filp, unsigned int cmd, struct flock64 __user *l) ...@@ -2143,7 +2143,7 @@ int fcntl_getlk64(struct file *filp, unsigned int cmd, struct flock64 __user *l)
if (error) if (error)
goto out; goto out;
if (cmd == F_GETLKP) { if (cmd == F_OFD_GETLK) {
error = -EINVAL; error = -EINVAL;
if (flock.l_pid != 0) if (flock.l_pid != 0)
goto out; goto out;
...@@ -2211,7 +2211,7 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd, ...@@ -2211,7 +2211,7 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
* FL_FILE_PVT flag and override the owner. * FL_FILE_PVT flag and override the owner.
*/ */
switch (cmd) { switch (cmd) {
case F_SETLKP: case F_OFD_SETLK:
error = -EINVAL; error = -EINVAL;
if (flock.l_pid != 0) if (flock.l_pid != 0)
goto out; goto out;
...@@ -2220,7 +2220,7 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd, ...@@ -2220,7 +2220,7 @@ int fcntl_setlk64(unsigned int fd, struct file *filp, unsigned int cmd,
file_lock->fl_flags |= FL_FILE_PVT; file_lock->fl_flags |= FL_FILE_PVT;
file_lock->fl_owner = (fl_owner_t)filp; file_lock->fl_owner = (fl_owner_t)filp;
break; break;
case F_SETLKPW: case F_OFD_SETLKW:
error = -EINVAL; error = -EINVAL;
if (flock.l_pid != 0) if (flock.l_pid != 0)
goto out; goto out;
...@@ -2413,7 +2413,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl, ...@@ -2413,7 +2413,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
if (fl->fl_flags & FL_ACCESS) if (fl->fl_flags & FL_ACCESS)
seq_printf(f, "ACCESS"); seq_printf(f, "ACCESS");
else if (IS_FILE_PVT(fl)) else if (IS_FILE_PVT(fl))
seq_printf(f, "FLPVT "); seq_printf(f, "OFDLCK");
else else
seq_printf(f, "POSIX "); seq_printf(f, "POSIX ");
......
...@@ -133,20 +133,20 @@ ...@@ -133,20 +133,20 @@
#endif #endif
/* /*
* fd "private" POSIX locks. * Open File Description Locks
* *
* Usually POSIX locks held by a process are released on *any* close and are * Usually record locks held by a process are released on *any* close and are
* not inherited across a fork(). * not inherited across a fork().
* *
* These cmd values will set locks that conflict with normal POSIX locks, but * These cmd values will set locks that conflict with process-associated
* are "owned" by the opened file, not the process. This means that they are * record locks, but are "owned" by the open file description, not the
* inherited across fork() like BSD (flock) locks, and they are only released * process. This means that they are inherited across fork() like BSD (flock)
* automatically when the last reference to the the open file against which * locks, and they are only released automatically when the last reference to
* they were acquired is put. * the the open file against which they were acquired is put.
*/ */
#define F_GETLKP 36 #define F_OFD_GETLK 36
#define F_SETLKP 37 #define F_OFD_SETLK 37
#define F_SETLKPW 38 #define F_OFD_SETLKW 38
#define F_OWNER_TID 0 #define F_OWNER_TID 0
#define F_OWNER_PID 1 #define F_OWNER_PID 1
......
...@@ -3317,9 +3317,9 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd, ...@@ -3317,9 +3317,9 @@ static int selinux_file_fcntl(struct file *file, unsigned int cmd,
case F_GETLK: case F_GETLK:
case F_SETLK: case F_SETLK:
case F_SETLKW: case F_SETLKW:
case F_GETLKP: case F_OFD_GETLK:
case F_SETLKP: case F_OFD_SETLK:
case F_SETLKPW: case F_OFD_SETLKW:
#if BITS_PER_LONG == 32 #if BITS_PER_LONG == 32
case F_GETLK64: case F_GETLK64:
case F_SETLK64: case F_SETLK64:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment