linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Miklos Szeredi <mszeredi@redhat.com>
To: linux-fsdevel@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>
Subject: [PATCH] proc/locks: getattr dev and ino
Date: Wed, 20 Sep 2017 11:25:25 +0200	[thread overview]
Message-ID: <1505899525-21443-1-git-send-email-mszeredi@redhat.com> (raw)

/proc/locks reports incorrect device/ino for overlayfs.  Same is true for
several filesystems that use a different value for i_ino as for st_ino.
Also btrfs uses different st_dev values for subvolumes.

Do a getattr for getting the correct dev/ino information.  Make sure
filesystem doesn't start network traffic and does not return fields which
are expensive to calculate.

Signed-off-by: Miklos Szeredi <mszeredi@redhat.com>
---
 fs/locks.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/fs/locks.c b/fs/locks.c
index 1bd71c4d663a..d4caea5268dc 100644
--- a/fs/locks.c
+++ b/fs/locks.c
@@ -2683,11 +2683,20 @@ static void lock_get_status(struct seq_file *f, struct file_lock *fl,
 			       : (fl->fl_type == F_WRLCK) ? "WRITE" : "READ ");
 	}
 	if (inode) {
+		struct kstat st;
+		int err;
+
+		err = vfs_getattr(&fl->fl_file->f_path, &st,
+				  STATX_INO, AT_STATX_DONT_SYNC);
+		if (err)
+			goto nostat;
+
 		/* 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);
+		seq_printf(f, "%d %02x:%02x:%lld ", fl_pid,
+			   MAJOR(st.dev), MINOR(st.dev),
+			   (unsigned long long) st.ino);
 	} else {
+nostat:
 		seq_printf(f, "%d <none>:0 ", fl_pid);
 	}
 	if (IS_POSIX(fl)) {
-- 
2.5.5

             reply	other threads:[~2017-09-20  9:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-20  9:25 Miklos Szeredi [this message]
2017-10-12  6:54 ` [lkp-robot] [proc/locks] 1dc17d8d81: dmesg.BUG:sleeping_function_called_from_invalid_context_at_security/selinux/hooks.c kernel test robot

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=1505899525-21443-1-git-send-email-mszeredi@redhat.com \
    --to=mszeredi@redhat.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@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).