From patchwork Wed Jan 3 15:11:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10142481 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 C4CA1601A1 for ; Wed, 3 Jan 2018 15:11:55 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0DD728CCF for ; Wed, 3 Jan 2018 15:11:55 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AE5C7291D4; Wed, 3 Jan 2018 15:11:55 +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 D44062944B for ; Wed, 3 Jan 2018 15:11:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753339AbeACPLD (ORCPT ); Wed, 3 Jan 2018 10:11:03 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:40585 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752754AbeACPK7 (ORCPT ); Wed, 3 Jan 2018 10:10:59 -0500 Received: by mail-wr0-f194.google.com with SMTP id p17so1884259wre.7; Wed, 03 Jan 2018 07:10:58 -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=zDwZ8XX+Bh2quE0iiZVfcOOkfxSSc6/KLT+GNhLUYtg=; b=VUion0DOSTlzEdAPDQXjL+qLr4QYie7bQp5HVJyLTiyJWfe4Pe4gu+XahwoH0yW33u /OxhptNz6khqKtXTjLfkxsPvB4dXQxa2rgeGcraGRZXFrHykzVACXfEwXv/oiNtT2vjU 61f4VsqQ4B6VZ7oYikp08epoNaU/YcgD5EtpxyYE4rZ5xd5a++r03GqpelEX32opcxh3 MB9JHLYobPjPEoMIMJD4eb3R05Rmi1QynLBCRW18IdtvNJ+7iWfbCyhQqepmnZ3demAI EEBJO2IFa03fQhDASaeNplD9V6sIe9AHy2UfmORruGvVQVwCSmqifsQSKhitHMpTgj6z 7KOg== 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=zDwZ8XX+Bh2quE0iiZVfcOOkfxSSc6/KLT+GNhLUYtg=; b=BLyP0jzM+6tb6kDbOm6+ts5D5xvzWCkxh4hkC0ZbwvFItbnDNDniT6RRV3SDyP38pL FTBXJzUlfasP5ybr3rwvXy9l0+0tIgmN4OsZBYBhNz6ihaVZNnjr+Y17eLrrP1oHggeY q0e8MzMuZ7peUPRL6qxku1GOnD/6eHfXdV7fIgZz0WZ+FIpOTqXoAaJuTLWw36fUdsEc zRSNkuSInqIPixlCoJIraoG69zBB69tW4t83uUvZaONWMYUzUG/diWTIH7vPsjIMOQDj uMEfgdTAqlELQX4LkV2/HiuF2JOBebQrxYmMG5tMzXTOkaoXCG13yI8lbaEV0V5MTEM4 GB5Q== X-Gm-Message-State: AKGB3mJDOJcr1/4qCgequ04yRwnt3ighPvADQft+/+aabFvPWTQ3bcgd i3egXB7sbbQhBoglyaSYCws= X-Google-Smtp-Source: ACJfBosRaIRhAFXp91QpMDVopumv0rQFdQeVu+cjJpzAUROr3e+lFQuHqu+l81BFFCEvAfo5zrwkfg== X-Received: by 10.223.170.215 with SMTP id i23mr1937338wrc.69.1514992257675; Wed, 03 Jan 2018 07:10:57 -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 p90sm1241516wmf.3.2018.01.03.07.10.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 03 Jan 2018 07:10:57 -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 2/2] vfs: update overlay inode times on lease_get_mtime() Date: Wed, 3 Jan 2018 17:11:44 +0200 Message-Id: <1514992304-8021-3-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1514992304-8021-1-git-send-email-amir73il@gmail.com> References: <1514992304-8021-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 Instead of looking for all the places that update inode's m_time, update overlay inode i_mtime just before nfsd needs to read it. The non uptodate mtime issue was found and verified with the nfstest_posix test when run over NFS exported overlayfs: $ nfstest_posix --runtest=link,write ... FAIL: link - parent directory st_mtime should be updated FAIL: write - file st_mtime should be updated Signed-off-by: Amir Goldstein --- fs/inode.c | 10 ++++++++-- fs/internal.h | 1 + fs/locks.c | 12 +++++++++++- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/fs/inode.c b/fs/inode.c index a252256f4e51..ceb5f5cb9c79 100644 --- a/fs/inode.c +++ b/fs/inode.c @@ -1595,6 +1595,14 @@ static void update_ovl_d_inode_times(struct dentry *dentry, bool rcu) } } +void update_ovl_inode_times(struct inode *inode) +{ + struct dentry *alias = d_find_any_alias(inode); + + if (alias) + update_ovl_d_inode_times(alias, false); +} + /* * With relative atime, only update atime if the previous atime is * earlier than either the ctime or mtime or if at least a day has @@ -1877,8 +1885,6 @@ 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); diff --git a/fs/internal.h b/fs/internal.h index df262f41a0ef..a631fd49a1ee 100644 --- a/fs/internal.h +++ b/fs/internal.h @@ -122,6 +122,7 @@ extern long prune_icache_sb(struct super_block *sb, struct shrink_control *sc); extern void inode_add_lru(struct inode *inode); extern int dentry_needs_remove_privs(struct dentry *dentry); +extern void update_ovl_inode_times(struct inode *inode); extern bool __atime_needs_update(const struct path *, struct inode *, bool); static inline bool atime_needs_update_rcu(const struct path *path, struct inode *inode) diff --git a/fs/locks.c b/fs/locks.c index 21b4dfa289ee..e2f604839aaf 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -127,6 +127,7 @@ #include #include #include +#include "internal.h" #define CREATE_TRACE_POINTS #include @@ -1553,6 +1554,15 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) EXPORT_SYMBOL(__break_lease); +static struct timespec inode_mtime(struct inode *inode) +{ + /* TODO: use another SB_ flag and/or pass dentry to lease_get_mtime() */ + if (unlikely(inode->i_sb->s_flags & MS_NOREMOTELOCK)) + update_ovl_inode_times(inode); + + return inode->i_mtime; +} + /** * lease_get_mtime - get the last modified time of an inode * @inode: the inode @@ -1581,7 +1591,7 @@ void lease_get_mtime(struct inode *inode, struct timespec *time) if (has_lease) *time = current_time(inode); else - *time = inode->i_mtime; + *time = inode_mtime(inode); } EXPORT_SYMBOL(lease_get_mtime);