From: Mark Fasheh <mfasheh@suse.de>
To: Al Viro <viro@ZenIV.linux.org.uk>, linux-fsdevel@vger.kernel.org
Cc: linux-btrfs@vger.kernel.org,
Andrew Morton <akpm@linux-foundation.org>,
Amir Goldstein <amir73il@gmail.com>,
linux-unionfs@vger.kernel.org, Jeff Mahoney <jeffm@suse.com>,
linux-nfs@vger.kernel.org, Mark Fasheh <mfasheh@suse.de>
Subject: [PATCH 4/4] locks: map correct ino/dev pairs when exporting to userspace
Date: Tue, 31 Jul 2018 14:10:45 -0700 [thread overview]
Message-ID: <20180731211045.5671-5-mfasheh@suse.de> (raw)
In-Reply-To: <20180731211045.5671-1-mfasheh@suse.de>
/proc/locks does not always print the correct inode number/device pair.
Update lock_get_status() to use vfs_map_unique_ino_dev() to get the real,
unique values for userspace.
Signed-off-by: Mark Fasheh <mfasheh@suse.de>
---
fs/locks.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/fs/locks.c b/fs/locks.c
index db7b6917d9c5..3a012df87fd8 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -2621,6 +2621,7 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
loff_t id, char *pfx)
{
struct inode *inode = NULL;
+ struct dentry *dentry;
unsigned int fl_pid;
struct pid_namespace *proc_pidns = file_inode(f->file)->i_sb->s_fs_info;
@@ -2633,8 +2634,10 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
if (fl_pid == 0)
return;
- if (fl->fl_file != NULL)
+ if (fl->fl_file != NULL) {
inode = locks_inode(fl->fl_file);
+ dentry = file_dentry(fl->fl_file);
+ }
seq_printf(f, "%lld:%s ", id, pfx);
if (IS_POSIX(fl)) {
@@ -2681,10 +2684,13 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
: (fl->fl_type == F_WRLCK) ? "WRITE" : "READ ");
}
if (inode) {
+ __u64 ino;
+ dev_t dev;
+
+ vfs_map_unique_ino_dev(dentry, &ino, &dev);
/* userspace relies on this representation of dev_t */
seq_printf(f, "%d %02x:%02x:%ld ", fl_pid,
- MAJOR(inode->i_sb->s_dev),
- MINOR(inode->i_sb->s_dev), inode->i_ino);
+ MAJOR(dev), MINOR(dev), inode->i_ino);
} else {
seq_printf(f, "%d <none>:0 ", fl_pid);
}
--
2.15.1
next prev parent reply other threads:[~2018-07-31 22:53 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-31 21:10 [RFC PATCH 0/4] vfs: map unique ino/dev pairs for user space Mark Fasheh
2018-07-31 21:10 ` [PATCH 1/4] vfs: introduce function to map unique ino/dev pairs Mark Fasheh
2018-07-31 23:21 ` Mark Fasheh
2018-08-01 5:41 ` Amir Goldstein
2018-08-01 15:59 ` Mark Fasheh
2018-07-31 21:10 ` [PATCH 2/4] nfs: check for NULL vfsmount in nfs_getattr Mark Fasheh
2018-07-31 22:16 ` Al Viro
2018-07-31 22:51 ` Mark Fasheh
2018-08-02 0:43 ` Al Viro
2018-08-03 2:04 ` Mark Fasheh
2018-07-31 21:10 ` [PATCH 3/4] proc: use vfs helper to get ino/dev pairs for maps file Mark Fasheh
2018-07-31 21:10 ` Mark Fasheh [this message]
2018-08-01 5:37 ` [PATCH 4/4] locks: map correct ino/dev pairs when exporting to userspace Amir Goldstein
2018-08-01 17:45 ` Mark Fasheh
2018-08-01 11:03 ` Jeff Layton
2018-08-01 20:38 ` Mark Fasheh
2018-08-02 0:24 ` [RFC PATCH 0/4] vfs: map unique ino/dev pairs for user space J. R. Okajima
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180731211045.5671-5-mfasheh@suse.de \
--to=mfasheh@suse.de \
--cc=akpm@linux-foundation.org \
--cc=amir73il@gmail.com \
--cc=jeffm@suse.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-nfs@vger.kernel.org \
--cc=linux-unionfs@vger.kernel.org \
--cc=viro@ZenIV.linux.org.uk \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).