Merge tag 'locks-v4.19-1' of git://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux
Pull file locking updates from Jeff Layton: "Just a couple of patches from Konstantin to fix /proc/locks when the process that set the lock has exited, and a new tracepoint for the flock() codepath. Also threw in mailmap entries for my addresses and a comment cleanup" * tag 'locks-v4.19-1' of git://git.kernel.org/pub/scm/linux/kernel/git/jlayton/linux: locks: remove misleading obsolete comment mailmap: remap some of my email addresses to kernel.org address locks: add tracepoint in flock codepath fs/lock: show locks taken by processes from another pidns fs/lock: skip lock owner pid translation in case we are in init_pid_ns
This commit is contained in:
20
fs/locks.c
20
fs/locks.c
@@ -202,10 +202,6 @@ static DEFINE_HASHTABLE(blocked_hash, BLOCKED_HASH_BITS);
|
||||
* we often hold the flc_lock as well. In certain cases, when reading the fields
|
||||
* protected by this lock, we can skip acquiring it iff we already hold the
|
||||
* flc_lock.
|
||||
*
|
||||
* In particular, adding an entry to the fl_block list requires that you hold
|
||||
* both the flc_lock and the blocked_lock_lock (acquired in that order).
|
||||
* Deleting an entry from the list however only requires the file_lock_lock.
|
||||
*/
|
||||
static DEFINE_SPINLOCK(blocked_lock_lock);
|
||||
|
||||
@@ -990,6 +986,7 @@ out:
|
||||
if (new_fl)
|
||||
locks_free_lock(new_fl);
|
||||
locks_dispose_list(&dispose);
|
||||
trace_flock_lock_inode(inode, request, error);
|
||||
return error;
|
||||
}
|
||||
|
||||
@@ -2072,6 +2069,13 @@ static pid_t locks_translate_pid(struct file_lock *fl, struct pid_namespace *ns)
|
||||
return -1;
|
||||
if (IS_REMOTELCK(fl))
|
||||
return fl->fl_pid;
|
||||
/*
|
||||
* If the flock owner process is dead and its pid has been already
|
||||
* freed, the translation below won't work, but we still want to show
|
||||
* flock owner pid number in init pidns.
|
||||
*/
|
||||
if (ns == &init_pid_ns)
|
||||
return (pid_t)fl->fl_pid;
|
||||
|
||||
rcu_read_lock();
|
||||
pid = find_pid_ns(fl->fl_pid, &init_pid_ns);
|
||||
@@ -2626,12 +2630,10 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
|
||||
|
||||
fl_pid = locks_translate_pid(fl, proc_pidns);
|
||||
/*
|
||||
* If there isn't a fl_pid don't display who is waiting on
|
||||
* the lock if we are called from locks_show, or if we are
|
||||
* called from __show_fd_info - skip lock entirely
|
||||
* If lock owner is dead (and pid is freed) or not visible in current
|
||||
* pidns, zero is shown as a pid value. Check lock info from
|
||||
* init_pid_ns to get saved lock pid value.
|
||||
*/
|
||||
if (fl_pid == 0)
|
||||
return;
|
||||
|
||||
if (fl->fl_file != NULL)
|
||||
inode = locks_inode(fl->fl_file);
|
||||
|
Reference in New Issue
Block a user