From patchwork Tue Aug 4 19:57:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Wilcox, Matthew R" X-Patchwork-Id: 6943911 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 D3C14C05AD for ; Tue, 4 Aug 2015 20:01:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 138A5203AA for ; Tue, 4 Aug 2015 20:01:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D92452053C for ; Tue, 4 Aug 2015 20:01:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753924AbbHDT6O (ORCPT ); Tue, 4 Aug 2015 15:58:14 -0400 Received: from mga11.intel.com ([192.55.52.93]:20469 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752621AbbHDT6M (ORCPT ); Tue, 4 Aug 2015 15:58:12 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP; 04 Aug 2015 12:58:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,610,1432623600"; d="scan'208";a="619267249" Received: from wfmiller-mobl.amr.corp.intel.com (HELO thog.int.wil.cx) ([10.252.207.212]) by orsmga003.jf.intel.com with SMTP; 04 Aug 2015 12:58:11 -0700 Received: by thog.int.wil.cx (Postfix, from userid 1000) id 819A55F9D3; Tue, 4 Aug 2015 15:58:10 -0400 (EDT) From: Matthew Wilcox To: Andrew Morton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org Cc: Matthew Wilcox Subject: [PATCH 03/11] dax: Improve comment about truncate race Date: Tue, 4 Aug 2015 15:57:57 -0400 Message-Id: <1438718285-21168-4-git-send-email-matthew.r.wilcox@intel.com> X-Mailer: git-send-email 2.4.6 In-Reply-To: <1438718285-21168-1-git-send-email-matthew.r.wilcox@intel.com> References: <1438718285-21168-1-git-send-email-matthew.r.wilcox@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=-7.0 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 From: Matthew Wilcox Jan Kara pointed out I should be more explicit here about the perils of racing against truncate. The comment is mostly the same as for the PTE case. Signed-off-by: Matthew Wilcox --- fs/dax.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/fs/dax.c b/fs/dax.c index 15f8ffc..0a13118 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -553,7 +553,12 @@ int __dax_pmd_fault(struct vm_area_struct *vma, unsigned long address, if (!buffer_size_valid(&bh) || bh.b_size < PMD_SIZE) goto fallback; - /* Guard against a race with truncate */ + /* + * If a truncate happened while we were allocating blocks, we may + * leave blocks allocated to the file that are beyond EOF. We can't + * take i_mutex here, so just leave them hanging; they'll be freed + * when the file is deleted. + */ size = (i_size_read(inode) + PAGE_SIZE - 1) >> PAGE_SHIFT; if (pgoff >= size) { result = VM_FAULT_SIGBUS;