From patchwork Wed Aug 17 16:11:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ross Zwisler X-Patchwork-Id: 660177 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3sDvNt481Yz9t2H for ; Thu, 18 Aug 2016 02:11:26 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753386AbcHQQLI (ORCPT ); Wed, 17 Aug 2016 12:11:08 -0400 Received: from mga03.intel.com ([134.134.136.65]:17007 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753214AbcHQQLG (ORCPT ); Wed, 17 Aug 2016 12:11:06 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 17 Aug 2016 09:11:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,529,1464678000"; d="scan'208";a="867029659" Received: from theros.lm.intel.com ([10.232.112.92]) by orsmga003.jf.intel.com with ESMTP; 17 Aug 2016 09:11:05 -0700 From: Ross Zwisler To: linux-kernel@vger.kernel.org Cc: Ross Zwisler , "Theodore Ts'o" , Andreas Dilger , Dan Williams , Jan Kara , linux-ext4@vger.kernel.org, linux-nvdimm@lists.01.org Subject: [PATCH] ext4: allow DAX writeback for hole punch Date: Wed, 17 Aug 2016 10:11:02 -0600 Message-Id: <20160817161102.2185-1-ross.zwisler@linux.intel.com> X-Mailer: git-send-email 2.9.0 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org Currently when doing a DAX hole punch with ext4 we fail to do a writeback. This is because the logic around filemap_write_and_wait_range() in ext4_punch_hole() only looks for dirty page cache pages in the radix tree, not for dirty DAX exceptional entries. Signed-off-by: Ross Zwisler Reviewed-by: Jan Kara --- I found this while testing my PMD patches (https://lkml.org/lkml/2016/8/15/613), but this fix applies equally to the 4k-only case. I'm sending this separately from that series because I think that this should probably be merged for v4.8 as it corrects an existing bug and should have very low risk. Regarding the other two supported DAX filesystems, XFS already properly does this writeback and ext2 doesn't support hole punch so it doesn't have to worry about this issue. --- fs/ext4/inode.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 3131747..8550416 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c @@ -3890,7 +3890,7 @@ int ext4_update_disksize_before_punch(struct inode *inode, loff_t offset, } /* - * ext4_punch_hole: punches a hole in a file by releaseing the blocks + * ext4_punch_hole: punches a hole in a file by releasing the blocks * associated with the given offset and length * * @inode: File inode @@ -3919,7 +3919,9 @@ int ext4_punch_hole(struct inode *inode, loff_t offset, loff_t length) * Write out all dirty pages to avoid race conditions * Then release them. */ - if (mapping->nrpages && mapping_tagged(mapping, PAGECACHE_TAG_DIRTY)) { + if (mapping_tagged(mapping, PAGECACHE_TAG_DIRTY) && + ((!dax_mapping(mapping) && mapping->nrpages) || + (dax_mapping(mapping) && mapping->nrexceptional))) { ret = filemap_write_and_wait_range(mapping, offset, offset + length - 1); if (ret)