From patchwork Thu Oct 29 20:12:12 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Zwisler X-Patchwork-Id: 7520671 Return-Path: X-Original-To: patchwork-linux-nvdimm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id F1DC9BF90C for ; Thu, 29 Oct 2015 20:12:38 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 29BEE20897 for ; Thu, 29 Oct 2015 20:12:38 +0000 (UTC) Received: from ml01.01.org (ml01.01.org [198.145.21.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 05F4220927 for ; Thu, 29 Oct 2015 20:12:37 +0000 (UTC) Received: from ml01.vlan14.01.org (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id EE0B61A20E7; Thu, 29 Oct 2015 13:12:36 -0700 (PDT) X-Original-To: linux-nvdimm@lists.01.org Delivered-To: linux-nvdimm@lists.01.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by ml01.01.org (Postfix) with ESMTP id 2ADE71A20DE for ; Thu, 29 Oct 2015 13:12:36 -0700 (PDT) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 29 Oct 2015 13:12:35 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,215,1444719600"; d="scan'208";a="838730653" Received: from theros.lm.intel.com ([10.232.112.192]) by fmsmga002.fm.intel.com with ESMTP; 29 Oct 2015 13:12:34 -0700 From: Ross Zwisler To: linux-kernel@vger.kernel.org Subject: [RFC 08/11] fs: add get_block() to struct inode_operations Date: Thu, 29 Oct 2015 14:12:12 -0600 Message-Id: <1446149535-16200-9-git-send-email-ross.zwisler@linux.intel.com> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1446149535-16200-1-git-send-email-ross.zwisler@linux.intel.com> References: <1446149535-16200-1-git-send-email-ross.zwisler@linux.intel.com> Cc: Jeff Layton , x86@kernel.org, Theodore Ts'o , Andrew Morton , Thomas Gleixner , linux-nvdimm@lists.01.org, Jan Kara , Dave Chinner , xfs@oss.sgi.com, "J. Bruce Fields" , linux-mm@kvack.org, Ingo Molnar , Andreas Dilger , Alexander Viro , "H. Peter Anvin" , linux-fsdevel@vger.kernel.org, linux-ext4@vger.kernel.org, Matthew Wilcox X-BeenThere: linux-nvdimm@lists.01.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: "Linux-nvdimm developer list." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: linux-nvdimm-bounces@lists.01.org Sender: "Linux-nvdimm" X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To be able to flush dirty pages to media as part of the fsync/msync path DAX needs to be able to map file offsets to kernel addresses via a combination of the filesystem's get_block() routine and bdev_direct_access(). This currently happens in the DAX fault handlers which receive a get_block() callback directly from the filesystem via a function parameter. For the fsync/msync path this doesn't work, though, because DAX is called not by the filesystem but by the writeback infrastructure which doesn't know about the filesystem specific get_block() routine. To handle this we make get_block() an entry in the struct inode_operations table so that we can access the correct get_block() routine in the context of the writeback infrastructure. Signed-off-by: Ross Zwisler --- fs/ext2/file.c | 1 + fs/ext4/file.c | 1 + fs/xfs/xfs_iops.c | 1 + include/linux/fs.h | 4 ++-- 4 files changed, 5 insertions(+), 2 deletions(-) diff --git a/fs/ext2/file.c b/fs/ext2/file.c index 11a42c5..fc1418c 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -202,4 +202,5 @@ const struct inode_operations ext2_file_inode_operations = { .get_acl = ext2_get_acl, .set_acl = ext2_set_acl, .fiemap = ext2_fiemap, + .get_block = ext2_get_block, }; diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 113837e..54d7729 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -720,5 +720,6 @@ const struct inode_operations ext4_file_inode_operations = { .get_acl = ext4_get_acl, .set_acl = ext4_set_acl, .fiemap = ext4_fiemap, + .get_block = ext4_get_block_dax, }; diff --git a/fs/xfs/xfs_iops.c b/fs/xfs/xfs_iops.c index 8294132..c58c270 100644 --- a/fs/xfs/xfs_iops.c +++ b/fs/xfs/xfs_iops.c @@ -1112,6 +1112,7 @@ static const struct inode_operations xfs_inode_operations = { .listxattr = xfs_vn_listxattr, .fiemap = xfs_vn_fiemap, .update_time = xfs_vn_update_time, + .get_block = xfs_get_blocks_direct, }; static const struct inode_operations xfs_dir_inode_operations = { diff --git a/include/linux/fs.h b/include/linux/fs.h index f791698..1dca85b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -1679,8 +1679,8 @@ struct inode_operations { umode_t create_mode, int *opened); int (*tmpfile) (struct inode *, struct dentry *, umode_t); int (*set_acl)(struct inode *, struct posix_acl *, int); - - /* WARNING: probably going away soon, do not use! */ + int (*get_block)(struct inode *inode, sector_t iblock, + struct buffer_head *bh_result, int create); } ____cacheline_aligned; ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector,