From patchwork Tue Jan 2 12:26:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10140483 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id AFDE16034B for ; Tue, 2 Jan 2018 12:26:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EF88286B1 for ; Tue, 2 Jan 2018 12:26:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 93A5E28B28; Tue, 2 Jan 2018 12:26:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4145D286B1 for ; Tue, 2 Jan 2018 12:26:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752591AbeABM0F (ORCPT ); Tue, 2 Jan 2018 07:26:05 -0500 Received: from mail-wr0-f195.google.com ([209.85.128.195]:35418 "EHLO mail-wr0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752445AbeABM0D (ORCPT ); Tue, 2 Jan 2018 07:26:03 -0500 Received: by mail-wr0-f195.google.com with SMTP id l19so35990594wrc.2; Tue, 02 Jan 2018 04:26:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5F/oxoaNwFenWfg08tNUegoOEfFql+LkieCTkIBTIfs=; b=KZr/kHksIjsoVk/JjLwNlbRWd5y/lVyTeyW6HqbZf6rwuG0Vgv2MusiLhKMOHsvl/E hFmW4K3ZkbKUbj4OPK9OhCYQL7xU3MtjnnxuPt/gCQunxFJkvyPdKVu6Qn3Oae2reRHS QD/fnps+fFFUEYBeUwPC5fFi4eYwpSELbeh+MBvJ0QOP3WBzgJxhcSIShu0C+atbJhv6 kdeXslVbOqnOyBCOOT50YDBNWcEh6mH5pwA/wo1y8liD3iHNfPeUOkB+vEV+rh2fX3BX Xsn2ZarOAUVsVxQlEO9V/sSppl9NrKtgeTZ9QnXGu/RwnmSdub9uMarUrKXwV0183w8g 22iw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=5F/oxoaNwFenWfg08tNUegoOEfFql+LkieCTkIBTIfs=; b=N52eqY3eHaIZeATS8gvmm6B0WkJx/jA2uRvVglIadIiAZdxPOp2ct4aNEu947RewkD CO73aspojVFTj+gD6TVacPfdExPKQf4hkgJ2rZRSl8j9hjoYOJ6U0RRtfszCii82NFmk pVp3ygn8BIKLawJDQibrKGmohw5ViHLCkHjCZcUOeAOQtTi8xfSykHnNDfUc+GwE4LgO QrTuGfrytwJZ/HVqGWPIu2jkSpKajmiImdPC3nJuzmeMvOEPbU2xiXcCic2R19FFdG+1 PG9NUPSCzqSI8W02BAAOg+Ppcke8pfrho6rkEPJhzsl06lXYBQmOvUlXS8P5BXi8pOPX +y0w== X-Gm-Message-State: AKGB3mLpk9jH5DM5dX362VAv9RM8jvY3g7WHrGr6b98LUaTn+c30Ye61 IQrJoDbvIJoeQF7+lnvHSnU= X-Google-Smtp-Source: ACJfBot8T4fPnwY30W6+1yQra6f0ILI8UDUFSf/4vkI4oj4V/x9ILkGGlGR4xHJwT7eKWRgI+aHH8Q== X-Received: by 10.223.133.230 with SMTP id 35mr34143063wru.188.1514895962134; Tue, 02 Jan 2018 04:26:02 -0800 (PST) Received: from localhost.localdomain (bzq-166-168-31-246.red.bezeqint.net. [31.168.166.246]) by smtp.gmail.com with ESMTPSA id n65sm79312752wrb.17.2018.01.02.04.26.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 02 Jan 2018 04:26:01 -0800 (PST) From: Amir Goldstein To: Jeff Layton , "J . Bruce Fields" Cc: Miklos Szeredi , linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [RFC][PATCH 1/2] vfs: update overlay inode times on write Date: Tue, 2 Jan 2018 14:26:48 +0200 Message-Id: <1514896009-11468-2-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514896009-11468-1-git-send-email-amir73il@gmail.com> References: <1514896009-11468-1-git-send-email-amir73il@gmail.com> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Currently with overlayfs, the real upper inode's i_mtime is updated on write, but not overlay vfs inode. The vfs inode's i_mtime is used by nfsd to check if nfs client cache is stale, so updating the overlay vfs inode i_mtime on write is required for overlayfs NFS export support. The non uptodate mtime issue was found and verified with the nfstest_posix test when run over NFS exported overlayfs: $ nfstest_posix --runtest=write ... FAIL: write - file st_mtime should be updated Signed-off-by: Amir Goldstein --- fs/inode.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index 03102d6ef044..a252256f4e51 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1567,8 +1567,7 @@ EXPORT_SYMBOL(bmap); /* * Update times in overlayed inode from underlying real inode */ -static void update_ovl_inode_times(struct dentry *dentry, struct inode *inode, - bool rcu) +static void update_ovl_d_inode_times(struct dentry *dentry, bool rcu) { struct dentry *upperdentry; @@ -1585,6 +1584,7 @@ static void update_ovl_inode_times(struct dentry *dentry, struct inode *inode, * stale mtime/ctime. */ if (upperdentry) { + struct inode *inode = d_inode(dentry); struct inode *realinode = d_inode(upperdentry); if ((!timespec_equal(&inode->i_mtime, &realinode->i_mtime) || @@ -1607,7 +1607,8 @@ static int relatime_need_update(const struct path *path, struct inode *inode, if (!(path->mnt->mnt_flags & MNT_RELATIME)) return 1; - update_ovl_inode_times(path->dentry, inode, rcu); + update_ovl_d_inode_times(path->dentry, rcu); + /* * Is mtime younger than atime? If yes, update atime: */ @@ -1876,6 +1877,8 @@ int file_update_time(struct file *file) ret = update_time(inode, &now, sync_it); __mnt_drop_write_file(file); + update_ovl_d_inode_times(file->f_path.dentry, false); + return ret; } EXPORT_SYMBOL(file_update_time);