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: 7520811 Return-Path: X-Original-To: patchwork-linux-fsdevel@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 BD7A3BEEA4 for ; Thu, 29 Oct 2015 20:15:49 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DB0C12052F for ; Thu, 29 Oct 2015 20:15:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DA9BB2052D for ; Thu, 29 Oct 2015 20:15:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757643AbbJ2UOu (ORCPT ); Thu, 29 Oct 2015 16:14:50 -0400 Received: from mga01.intel.com ([192.55.52.88]:56848 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750753AbbJ2UMg (ORCPT ); Thu, 29 Oct 2015 16:12:36 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga101.fm.intel.com with ESMTP; 29 Oct 2015 13:12:36 -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 Cc: Ross Zwisler , "H. Peter Anvin" , "J. Bruce Fields" , "Theodore Ts'o" , Alexander Viro , Andreas Dilger , Dan Williams , Dave Chinner , Ingo Molnar , Jan Kara , Jeff Layton , Matthew Wilcox , Thomas Gleixner , linux-ext4@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, linux-nvdimm@lists.01.org, x86@kernel.org, xfs@oss.sgi.com, Andrew Morton , Matthew Wilcox 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> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, 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,