From patchwork Thu Jan 4 17:20:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Amir Goldstein X-Patchwork-Id: 10145245 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 6CC5D6034B for ; Thu, 4 Jan 2018 17:21:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52F2128761 for ; Thu, 4 Jan 2018 17:21:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46B7628791; Thu, 4 Jan 2018 17:21:08 +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 E096528761 for ; Thu, 4 Jan 2018 17:21:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752477AbeADRVG (ORCPT ); Thu, 4 Jan 2018 12:21:06 -0500 Received: from mail-wr0-f194.google.com ([209.85.128.194]:42692 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752463AbeADRU6 (ORCPT ); Thu, 4 Jan 2018 12:20:58 -0500 Received: by mail-wr0-f194.google.com with SMTP id w107so2139421wrb.9; Thu, 04 Jan 2018 09:20: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=jLX2dqrMgj0y9iY0FfdQGqjeQHOo38cYWFplLCqd86M=; b=PpDkvqdvPuXyzA2lsoE5FeytqNpA6gJb+nzEoBXGIo+0UOwsiWWmAF+cqtTDK+2pFb 8Qw2JtXPcs8o+39RMqv/SZIrG9wMknIO5I8WtzsiQDNQD3YgvzRCHurnyc9UTqGCs5XM 9yzm1js1oJrwm8/kOyVBc5MAWLZoPOWwOAXhMokEImLdYlL5a6Gk3i7oEy+tJZIHnlPv uMuRPO5HRPu/w/DwF37aSyyj5dk4syJsRHTCBt/FRmH2GCDZgC/OMjrbruUnjpN/ZM0j FNMosXWCzVbeSwwGBKNbkvM8qAMCf1oBezVLfQYqpgYlr7mA6QA5I353VuHDtlq6q0zC F7Gg== 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=jLX2dqrMgj0y9iY0FfdQGqjeQHOo38cYWFplLCqd86M=; b=WJVyaFUjGAKmISDxTOZuDNlOjIEVbGVxB7Uu5mXTZRVi4vDAzVsPrFvmNOBEnD0jLo EbaG7GLjnjxLNibG7IK037DMck05dDn3j/02/lKC9K/A5h8ZoGDIfcrQ9Xqq/BUtxuFx bmTaTdrjwCiubqIH5e+/n39pcnCHmyrVMPSgiiMeu+dOndJtrSAvWOTcJ+A2zWKh+moA VH0x/TBgSVrhjygt99I2erDtP2njbRO6FcTn8fnBX4oql43xNTW3CqDGSWrvUk2MHyP9 C4XYkVfwNPAROslTxhcKDLryWRVK5e7VGIUdDK9kLK9S+P+lNsrqfor7TYdW225vVsRk /iLw== X-Gm-Message-State: AKGB3mLTCuuif6Tkl748ig7H8oPQrTuSyEdeajofLLLO35Xgu0v0AHl4 PvzuStbfR3ZjhGnPfjxGi5Q= X-Google-Smtp-Source: ACJfBouB/s/Hihw2SppTaYNV37aQBkJ+she9b4dvFeJUXfZkT3d4NofvDGGI9HkYcnRI+riHlDUzeA== X-Received: by 10.223.141.169 with SMTP id o38mr243889wrb.131.1515086457546; Thu, 04 Jan 2018 09:20: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 c6sm2777750wmd.21.2018.01.04.09.20.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 04 Jan 2018 09:20:57 -0800 (PST) From: Amir Goldstein To: Miklos Szeredi Cc: Jeff Layton , "J . Bruce Fields" , linux-unionfs@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: [PATCH v2 17/17] nfsd: encode stat->mtime for getattr instead of inode->i_mtime Date: Thu, 4 Jan 2018 19:20:49 +0200 Message-Id: <1515086449-26563-18-git-send-email-amir73il@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515086449-26563-1-git-send-email-amir73il@gmail.com> References: <1515086449-26563-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 The values of stat->mtime and inode->i_mtime may differ for overlayfs and stat->mtime is the correct value to use when encoding getattr. This is also consistent with the fact that other attr times are also encoded from stat values. Both callers of lease_get_mtime() already have the value of stat->mtime, so the only needed change is that lease_get_mtime() will not overwrite this value with inode->i_mtime in case the inode does not have an exclusive lease. Reviewed-by: Jeff Layton Signed-off-by: Amir Goldstein --- fs/locks.c | 6 ++---- fs/nfsd/nfsxdr.c | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/fs/locks.c b/fs/locks.c index 21b4dfa289ee..d6ff4beb70ce 100644 --- a/fs/locks.c +++ b/fs/locks.c @@ -1554,9 +1554,9 @@ int __break_lease(struct inode *inode, unsigned int mode, unsigned int type) EXPORT_SYMBOL(__break_lease); /** - * lease_get_mtime - get the last modified time of an inode + * lease_get_mtime - update modified time of an inode with exclusive lease * @inode: the inode - * @time: pointer to a timespec which will contain the last modified time + * @time: pointer to a timespec which contains the last modified time * * This is to force NFS clients to flush their caches for files with * exclusive leases. The justification is that if someone has an @@ -1580,8 +1580,6 @@ void lease_get_mtime(struct inode *inode, struct timespec *time) if (has_lease) *time = current_time(inode); - else - *time = inode->i_mtime; } EXPORT_SYMBOL(lease_get_mtime); diff --git a/fs/nfsd/nfsxdr.c b/fs/nfsd/nfsxdr.c index 644a0342f0e0..79b6064f8977 100644 --- a/fs/nfsd/nfsxdr.c +++ b/fs/nfsd/nfsxdr.c @@ -188,6 +188,7 @@ encode_fattr(struct svc_rqst *rqstp, __be32 *p, struct svc_fh *fhp, *p++ = htonl((u32) stat->ino); *p++ = htonl((u32) stat->atime.tv_sec); *p++ = htonl(stat->atime.tv_nsec ? stat->atime.tv_nsec / 1000 : 0); + time = stat->mtime; lease_get_mtime(d_inode(dentry), &time); *p++ = htonl((u32) time.tv_sec); *p++ = htonl(time.tv_nsec ? time.tv_nsec / 1000 : 0);