Message ID | 20230612104524.17058-9-jlayton@kernel.org |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp2507012vqr; Mon, 12 Jun 2023 04:13:50 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4UJz4gsrwDuWMHNltdT3soduRT4yuzWZYaXcIYILpk7khuPB6R13hEoOjQu3bbHOAxEVRz X-Received: by 2002:a05:6a00:807:b0:656:e7a2:5362 with SMTP id m7-20020a056a00080700b00656e7a25362mr10883472pfk.16.1686568430380; Mon, 12 Jun 2023 04:13:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686568430; cv=none; d=google.com; s=arc-20160816; b=vi9kHa7LBc+SWD5tIZrDMBdX82kLJBfSeFibQcFU40AEul2xZrGW+WmuB/r1Ohkopd GmLMSgcQaUhb8Ce+GZss+GqUwWYioWtkVIO0G4veamW8sQNws8oxpIQGt5dVv2fj7dn7 Vc5BSsLJV4r/0qYK7CkE31dFnK7/2cdyCnjBYfQ5DDGJ7CN4XwoHFWBosrxyclWTNonZ k7+ldCHdnZwfTjEVooplN0ud9kzEm02mVB6eSoy+xWAYuMKd3e7TacBKZswXj7YmKTcm xNL6zMAYgW2plyqgEDdNX14xJdeKhrRozbvjHihC2OOr5l09jhalkfrP3Z7QFzp9vSmt O8jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=mfgvF3USLrLM58hEQTthmuf1ML45ry+tAJXJCUKDyMg=; b=kQoBHY79IG++Zy14lXSFV097URjiBRZRrvEmR07BJTLUPLRnTcZIC32b2E8rjCjm+r 1csfDfI44qxvsGJHTvZkfUsXQ9hXyJhBTr+GlWM1j6Hw7vyXes3IdWaGAn7N/LAfYUt7 ygKCB5fy5xk40FC8d0mJWcpLaHc4dn1D4e6dwdR1qzHDWJQdbsMjYgyk07ze1LKf56NA TD94O+OvAkq++JHBZWVnkEi4r3OwtUZJBBqZsMUkkK1SzwoRBT6QGZXYYwUjEtRtgffk IGhL5P24kaTr1JNGByx/pyfHzoIcrPB3HsRlU7RB1epi8dQuhQz9cxZl0gVAN17CRhjC ugDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q+YkQNa3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n6-20020aa79846000000b006629fe7edffsi6556163pfq.315.2023.06.12.04.13.37; Mon, 12 Jun 2023 04:13:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=q+YkQNa3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236825AbjFLK7L (ORCPT <rfc822;rust.linux@gmail.com> + 99 others); Mon, 12 Jun 2023 06:59:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236256AbjFLK5w (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 12 Jun 2023 06:57:52 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 186026EAB; Mon, 12 Jun 2023 03:45:55 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A1A6D62451; Mon, 12 Jun 2023 10:45:54 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2E347C433D2; Mon, 12 Jun 2023 10:45:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1686566754; bh=n83nlEjKdfIOBmYidDyhQMkFJfDZwR7ta+gYJd+TVCQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=q+YkQNa328pMVFsA2bRAmz5UMjgF+DnvTPqv88BK4VXVNKMksbd7Idlt4Ynx5ayzp 0mpe940TUN7nIlv6rm8JohB1cnuug/RTPS8ZSK+Gqpfo935WqDt6AQW29cfrzEWyI0 hntdqRNzxTdjhNixoS4zPOB7ooqWzN4tqKdIHQzS3XjVL+czdUWoPRcWhg6kxtbJ6I Cr9pv+DlyR4FK0jjAjwunzAxUmuLz2ahMFQjJr+odeexqZ9ZZh/jTAkvwuE5rDARGz WM34MHMRkkLBu8ZnBc5JXo2/ZX2kgl5ccHEvr2qcjhgn1OBiH3soWsvGTwYWhRxGiM bCPjv8pHoyx6w== From: Jeff Layton <jlayton@kernel.org> To: Christian Brauner <brauner@kernel.org>, Al Viro <viro@zeniv.linux.org.uk>, Brad Warrum <bwarrum@linux.ibm.com>, Ritu Agarwal <rituagar@linux.ibm.com>, Arnd Bergmann <arnd@arndb.de>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Ian Kent <raven@themaw.net>, "Tigran A. Aivazian" <aivazian.tigran@gmail.com>, Jeremy Kerr <jk@ozlabs.org>, Ard Biesheuvel <ardb@kernel.org>, Namjae Jeon <linkinjeon@kernel.org>, Sungjong Seo <sj1557.seo@samsung.com>, Steve French <sfrench@samba.org>, Paulo Alcantara <pc@manguebit.com>, Ronnie Sahlberg <lsahlber@redhat.com>, Shyam Prasad N <sprasad@microsoft.com>, Tom Talpey <tom@talpey.com>, John Johansen <john.johansen@canonical.com>, Paul Moore <paul@paul-moore.com>, James Morris <jmorris@namei.org>, "Serge E. Hallyn" <serge@hallyn.com>, Ruihan Li <lrh2000@pku.edu.cn>, Sebastian Reichel <sebastian.reichel@collabora.com>, Alan Stern <stern@rowland.harvard.edu>, Suren Baghdasaryan <surenb@google.com>, Wolfram Sang <wsa+renesas@sang-engineering.com>, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, autofs@vger.kernel.org, linux-efi@vger.kernel.org, linux-fsdevel@vger.kernel.org, linux-cifs@vger.kernel.org, samba-technical@lists.samba.org, apparmor@lists.ubuntu.com, linux-security-module@vger.kernel.org Subject: [PATCH v2 8/8] cifs: update the ctime on a partial page write Date: Mon, 12 Jun 2023 06:45:24 -0400 Message-Id: <20230612104524.17058-9-jlayton@kernel.org> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230612104524.17058-1-jlayton@kernel.org> References: <20230612104524.17058-1-jlayton@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768495178247769580?= X-GMAIL-MSGID: =?utf-8?q?1768495178247769580?= |
Series |
fs: add some missing ctime updates
|
|
Commit Message
Jeff Layton
June 12, 2023, 10:45 a.m. UTC
POSIX says:
"Upon successful completion, where nbyte is greater than 0, write()
shall mark for update the last data modification and last file status
change timestamps of the file..."
Add the missing ctime update.
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/smb/client/file.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Comments
On 6/12/2023 6:45 AM, Jeff Layton wrote: > POSIX says: > > "Upon successful completion, where nbyte is greater than 0, write() > shall mark for update the last data modification and last file status > change timestamps of the file..." > > Add the missing ctime update. > > Signed-off-by: Jeff Layton <jlayton@kernel.org> > --- > fs/smb/client/file.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c > index df88b8c04d03..a00038a326cf 100644 > --- a/fs/smb/client/file.c > +++ b/fs/smb/client/file.c > @@ -2596,7 +2596,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to) > write_data, to - from, &offset); > cifsFileInfo_put(open_file); > /* Does mm or vfs already set times? */ > - inode->i_atime = inode->i_mtime = current_time(inode); > + inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); Question. It appears that roughly half the filesystems in this series don't touch the i_atime in this case. And the other half do. Which is correct? Did they incorrectly set i_atime instead of i_ctime? Tom. > if ((bytes_written > 0) && (offset)) > rc = 0; > else if (bytes_written < 0)
On Mon, 2023-06-12 at 09:41 -0400, Tom Talpey wrote: > On 6/12/2023 6:45 AM, Jeff Layton wrote: > > POSIX says: > > > > "Upon successful completion, where nbyte is greater than 0, write() > > shall mark for update the last data modification and last file status > > change timestamps of the file..." > > > > Add the missing ctime update. > > > > Signed-off-by: Jeff Layton <jlayton@kernel.org> > > --- > > fs/smb/client/file.c | 2 +- > > 1 file changed, 1 insertion(+), 1 deletion(-) > > > > diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c > > index df88b8c04d03..a00038a326cf 100644 > > --- a/fs/smb/client/file.c > > +++ b/fs/smb/client/file.c > > @@ -2596,7 +2596,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to) > > write_data, to - from, &offset); > > cifsFileInfo_put(open_file); > > /* Does mm or vfs already set times? */ > > - inode->i_atime = inode->i_mtime = current_time(inode); > > + inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); > > Question. It appears that roughly half the filesystems in this series > don't touch the i_atime in this case. And the other half do. Which is > correct? Did they incorrectly set i_atime instead of i_ctime? > I noticed that too, and with this set, I decided to not make any atime changes since I wasn't sure. I think the answer to your question is "it depends". atime is supposed to be updated on reads, not writes, but sometimes a write requires a RMW cycle of some flavor so one can imagine that in some cases we'd need to update all three. In this case, I'm not sure that updating any of these times is the right thing to do. This is called from ->launder_folio, so the syscall that issued the write is long gone and we're in writeback here. With NFS, we generally leave timestamp updates to the server. Should any of these timestamps be updated by the (SMB1) client here?
diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index df88b8c04d03..a00038a326cf 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -2596,7 +2596,7 @@ static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to) write_data, to - from, &offset); cifsFileInfo_put(open_file); /* Does mm or vfs already set times? */ - inode->i_atime = inode->i_mtime = current_time(inode); + inode->i_atime = inode->i_mtime = inode->i_ctime = current_time(inode); if ((bytes_written > 0) && (offset)) rc = 0; else if (bytes_written < 0)