From patchwork Wed Mar 4 16:48:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boaz Harrosh X-Patchwork-Id: 5938411 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 6F41CBF440 for ; Wed, 4 Mar 2015 16:48:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 9CA1320212 for ; Wed, 4 Mar 2015 16:48:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 12E41202DD for ; Wed, 4 Mar 2015 16:48:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755901AbbCDQsL (ORCPT ); Wed, 4 Mar 2015 11:48:11 -0500 Received: from mail-wi0-f174.google.com ([209.85.212.174]:45814 "EHLO mail-wi0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751326AbbCDQsK (ORCPT ); Wed, 4 Mar 2015 11:48:10 -0500 Received: by wibbs8 with SMTP id bs8so710458wib.4 for ; Wed, 04 Mar 2015 08:48:08 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:content-type :content-transfer-encoding; bh=VyGHVvfn2wV5eKlQlJI0zK1DxcLMUb0dZNKZkCWijO4=; b=BvPf90EOcll3AByqhcjndM9+9vXK1YMLY707BkhGeYPO3eyEwJqvPT8YNmhWSM1cQd Fpj0U1Bq9AxXqOcpdTvoHF+PczIQlu5Umk44GlwonrkNG6Uq58Qg+wBxgxpmc26AjKzA NM2xwnjSbNgANRHay78rLwslhEsTqiMudQ8OpNpRmOe9ePg2ejtR6e1I1DbqWVqltk1c It2KBGgC0PWRwAROL8uqXoiXsiocyCQDLYm0ibKW2SbzxPdvlid1G5R72+WdB8/fw4Hy ozdpFqvdylOTvogYJAz6zVe32KfOqxj/ijQtScYG2NIzj3fmm9i2rpoO468YvtDloZ/U nZMQ== X-Gm-Message-State: ALoCoQmcDbkSOGhrx4wWwSmN85ZTqPTmHqQIwnjBfCB1Kv1Z7hGn/dKkZqTog0aYwMkca0yyK/u6 X-Received: by 10.180.74.39 with SMTP id q7mr56541853wiv.73.1425487688648; Wed, 04 Mar 2015 08:48:08 -0800 (PST) Received: from [10.0.0.5] ([207.232.55.62]) by mx.google.com with ESMTPSA id m4sm7835571wik.20.2015.03.04.08.48.07 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Mar 2015 08:48:08 -0800 (PST) Message-ID: <54F73746.5020300@plexistor.com> Date: Wed, 04 Mar 2015 18:48:06 +0200 From: Boaz Harrosh User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.5.0 MIME-Version: 1.0 To: Dave Chinner , Matthew Wilcox , Andrew Morton , "Kirill A. Shutemov" , Jan Kara , Hugh Dickins , Mel Gorman , linux-mm@kvack.org, linux-nvdimm , linux-fsdevel Subject: [PATCH 3/3] DAX: use pfn_mkwrite to update c/mtime References: <54F733BD.7060807@plexistor.com> In-Reply-To: <54F733BD.7060807@plexistor.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, T_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: Yigal Korman Without this patch, c/mtime is not updated correctly when mmap'ed page is first read from and then written to. A new xfstest is submitted for testing this (generic/080) Signed-off-by: Yigal Korman Signed-off-by: Boaz Harrosh --- fs/dax.c | 13 +++++++++++++ fs/ext2/file.c | 1 + fs/ext4/file.c | 1 + include/linux/fs.h | 1 + 4 files changed, 16 insertions(+) diff --git a/fs/dax.c b/fs/dax.c index ed1619e..cd63adc 100644 --- a/fs/dax.c +++ b/fs/dax.c @@ -464,6 +464,19 @@ int dax_fault(struct vm_area_struct *vma, struct vm_fault *vmf, EXPORT_SYMBOL_GPL(dax_fault); /** + * dax_pfn_mkwrite - handle first write to DAX page + * @vma: The virtual memory area where the fault occurred + * @vmf: The description of the fault + * + */ +int dax_pfn_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) +{ + file_update_time(vma->vm_file); + return VM_FAULT_NOPAGE; +} +EXPORT_SYMBOL_GPL(dax_pfn_mkwrite); + +/** * dax_zero_page_range - zero a range within a page of a DAX file * @inode: The file being truncated * @from: The file offset that is being truncated to diff --git a/fs/ext2/file.c b/fs/ext2/file.c index e317017..866a3ce 100644 --- a/fs/ext2/file.c +++ b/fs/ext2/file.c @@ -39,6 +39,7 @@ static int ext2_dax_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) static const struct vm_operations_struct ext2_dax_vm_ops = { .fault = ext2_dax_fault, .page_mkwrite = ext2_dax_mkwrite, + .pfn_mkwrite = dax_pfn_mkwrite, }; static int ext2_file_mmap(struct file *file, struct vm_area_struct *vma) diff --git a/fs/ext4/file.c b/fs/ext4/file.c index 33a09da..b43a7a6 100644 --- a/fs/ext4/file.c +++ b/fs/ext4/file.c @@ -206,6 +206,7 @@ static int ext4_dax_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) static const struct vm_operations_struct ext4_dax_vm_ops = { .fault = ext4_dax_fault, .page_mkwrite = ext4_dax_mkwrite, + .pfn_mkwrite = dax_pfn_mkwrite, }; #else #define ext4_dax_vm_ops ext4_file_vm_ops diff --git a/include/linux/fs.h b/include/linux/fs.h index b4d71b5..24af817 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -2597,6 +2597,7 @@ int dax_clear_blocks(struct inode *, sector_t block, long size); int dax_zero_page_range(struct inode *, loff_t from, unsigned len, get_block_t); int dax_truncate_page(struct inode *, loff_t from, get_block_t); int dax_fault(struct vm_area_struct *, struct vm_fault *, get_block_t); +int dax_pfn_mkwrite(struct vm_area_struct *, struct vm_fault *); #define dax_mkwrite(vma, vmf, gb) dax_fault(vma, vmf, gb) #ifdef CONFIG_BLOCK