From patchwork Tue Jul 31 21:10:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Fasheh X-Patchwork-Id: 10551475 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id AB0ED139A for ; Tue, 31 Jul 2018 21:11:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CCDC2B66A for ; Tue, 31 Jul 2018 21:11:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9156A2B677; Tue, 31 Jul 2018 21:11:12 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F2012B670 for ; Tue, 31 Jul 2018 21:11:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732345AbeGaWxW (ORCPT ); Tue, 31 Jul 2018 18:53:22 -0400 Received: from mx2.suse.de ([195.135.220.15]:35870 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725886AbeGaWxV (ORCPT ); Tue, 31 Jul 2018 18:53:21 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id EF41AAE4C; Tue, 31 Jul 2018 21:11:06 +0000 (UTC) From: Mark Fasheh To: Al Viro , linux-fsdevel@vger.kernel.org Cc: linux-btrfs@vger.kernel.org, Andrew Morton , Amir Goldstein , linux-unionfs@vger.kernel.org, Jeff Mahoney , linux-nfs@vger.kernel.org, Mark Fasheh Subject: [PATCH 4/4] locks: map correct ino/dev pairs when exporting to userspace Date: Tue, 31 Jul 2018 14:10:45 -0700 Message-Id: <20180731211045.5671-5-mfasheh@suse.de> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180731211045.5671-1-mfasheh@suse.de> References: <20180731211045.5671-1-mfasheh@suse.de> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP /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 --- 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 :0 ", fl_pid); }