Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!border1.nntp.ams1.giganews.com!nntp.giganews.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod From: Matthew Wilcox Newsgroups: linux.kernel Subject: [PATCH 03/11] dax: Improve comment about truncate race Date: Tue, 04 Aug 2015 22:00:03 +0200 Message-ID: References: X-Original-To: Andrew Morton , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mm@kvack.org X-Extloop1: 1 X-Ironport-Av: E=Sophos;i="5.15,610,1432623600"; d="scan'208";a="619267249" X-Mailer: git-send-email 2.4.6 Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 37 Organization: linux.* mail to news gateway X-Original-Cc: Matthew Wilcox X-Original-Date: Tue, 4 Aug 2015 15:57:57 -0400 X-Original-Message-ID: <1438718285-21168-4-git-send-email-matthew.r.wilcox@intel.com> X-Original-References: <1438718285-21168-1-git-send-email-matthew.r.wilcox@intel.com> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1200255 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; -- 2.1.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/