From patchwork Fri May 13 23:18:48 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Fasheh X-Patchwork-Id: 784482 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4DNM6bv023360 for ; Fri, 13 May 2011 23:22:06 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758404Ab1EMXV7 (ORCPT ); Fri, 13 May 2011 19:21:59 -0400 Received: from cantor.suse.de ([195.135.220.2]:58572 "EHLO mx1.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758353Ab1EMXV6 (ORCPT ); Fri, 13 May 2011 19:21:58 -0400 Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id BDD885362F; Sat, 14 May 2011 01:21:55 +0200 (CEST) From: Mark Fasheh To: linux-btrfs Cc: Chris Mason , linux-fsdevel , Mark Fasheh Subject: [RFC][PATCH 1/2] vfs: allow /proc/pid/maps to return a custom device Date: Fri, 13 May 2011 16:18:48 -0700 Message-Id: <1305328729-9995-2-git-send-email-mfasheh@suse.com> X-Mailer: git-send-email 1.6.4.2 In-Reply-To: <1305328729-9995-1-git-send-email-mfasheh@suse.com> References: <1305328729-9995-1-git-send-email-mfasheh@suse.com> Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 13 May 2011 23:22:06 +0000 (UTC) This patch introduces a callback in the super_operations structure, 'get_maps_dev' which is then used by procfs to query which device to return for reporting in /proc/[PID]/maps. btrfs wants this so that it can return the same device as it uses from stat(2) calls. Signed-off-by: Mark Fasheh --- fs/proc/task_mmu.c | 2 +- fs/proc/task_nommu.c | 2 +- include/linux/fs.h | 8 ++++++++ 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 2e7addf..c0acc19 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c @@ -220,7 +220,7 @@ static void show_map_vma(struct seq_file *m, struct vm_area_struct *vma) if (file) { struct inode *inode = vma->vm_file->f_path.dentry->d_inode; - dev = inode->i_sb->s_dev; + dev = get_maps_dev(inode); ino = inode->i_ino; pgoff = ((loff_t)vma->vm_pgoff) << PAGE_SHIFT; } diff --git a/fs/proc/task_nommu.c b/fs/proc/task_nommu.c index 980de54..6769efe 100644 --- a/fs/proc/task_nommu.c +++ b/fs/proc/task_nommu.c @@ -148,7 +148,7 @@ static int nommu_vma_show(struct seq_file *m, struct vm_area_struct *vma) if (file) { struct inode *inode = vma->vm_file->f_path.dentry->d_inode; - dev = inode->i_sb->s_dev; + dev = get_maps_dev(inode); ino = inode->i_ino; pgoff = (loff_t)vma->vm_pgoff << PAGE_SHIFT; } diff --git a/include/linux/fs.h b/include/linux/fs.h index dbd860a..ad683ad 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1637,8 +1637,16 @@ struct super_operations { ssize_t (*quota_write)(struct super_block *, int, const char *, size_t, loff_t); #endif int (*bdev_try_to_free_page)(struct super_block*, struct page*, gfp_t); + dev_t (*get_maps_dev)(struct inode *); }; +static inline dev_t get_maps_dev(struct inode *inode) +{ + if (inode->i_sb->s_op->get_maps_dev) + return inode->i_sb->s_op->get_maps_dev(inode); + return inode->i_sb->s_dev; +} + /* * Inode state bits. Protected by inode->i_lock *