Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751928AbdFIUb6 (ORCPT ); Fri, 9 Jun 2017 16:31:58 -0400 Received: from mga06.intel.com ([134.134.136.31]:65344 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751858AbdFIUbk (ORCPT ); Fri, 9 Jun 2017 16:31:40 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,319,1493708400"; d="scan'208";a="112557533" Subject: [PATCH v3 13/14] filesystem-dax: gate calls to dax_flush() on QUEUE_FLAG_WC From: Dan Williams To: linux-nvdimm@lists.01.org Cc: Jan Kara , dm-devel@redhat.com, Matthew Wilcox , x86@kernel.org, linux-kernel@vger.kernel.org, Jeff Moyer , viro@zeniv.linux.org.uk, linux-fsdevel@vger.kernel.org, Ross Zwisler , hch@lst.de Date: Fri, 09 Jun 2017 13:24:56 -0700 Message-ID: <149703989611.20620.6907872165215640212.stgit@dwillia2-desk3.amr.corp.intel.com> In-Reply-To: <149703982465.20620.14881139332926778446.stgit@dwillia2-desk3.amr.corp.intel.com> References: <149703982465.20620.14881139332926778446.stgit@dwillia2-desk3.amr.corp.intel.com> User-Agent: StGit/0.17.1-9-g687f MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1632 Lines: 43 Some platforms arrange for cpu caches to be flushed on power-fail. On those platforms there is no requirement that the kernel track and flush potentially dirty cache lines. Given that we still insert entries into the radix for locking purposes this patch only disables the cache flush loop, not the dirty tracking. Userspace can override the default cache setting via the block device queue "write_cache" attribute in sysfs. Cc: Jan Kara Cc: Jeff Moyer Cc: Christoph Hellwig Cc: Matthew Wilcox Cc: Ross Zwisler Signed-off-by: Dan Williams --- fs/dax.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fs/dax.c b/fs/dax.c index 6d8699feae2e..c3140343ff7e 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -783,7 +783,8 @@ static int dax_writeback_one(struct block_device *bdev, } dax_mapping_entry_mkclean(mapping, index, pfn_t_to_pfn(pfn)); - dax_flush(dax_dev, pgoff, kaddr, size); + if (test_bit(QUEUE_FLAG_WC, &bdev->bd_queue->queue_flags)) + dax_flush(dax_dev, pgoff, kaddr, size); /* * After we have flushed the cache, we can clear the dirty tag. There * cannot be new dirty data in the pfn after the flush has completed as @@ -975,7 +976,8 @@ int __dax_zero_page_range(struct block_device *bdev, return rc; } memset(kaddr + offset, 0, size); - dax_flush(dax_dev, pgoff, kaddr + offset, size); + if (test_bit(QUEUE_FLAG_WC, &bdev->bd_queue->queue_flags)) + dax_flush(dax_dev, pgoff, kaddr + offset, size); dax_read_unlock(id); } return 0;