Message ID | 808140.1685573412@warthog.procyon.org.uk |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:6358:3046:b0:115:7a1d:dabb with SMTP id p6csp765193rwl; Wed, 31 May 2023 16:16:26 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ45YhcZRjSqPAaErsZ9Dd+/lUYE3vWV4f6PO5RA5slULzivfAdnvAQHiyTskmcX4ScZJzER X-Received: by 2002:a05:6358:7f09:b0:125:87b0:8888 with SMTP id p9-20020a0563587f0900b0012587b08888mr2206450rwn.17.1685574986623; Wed, 31 May 2023 16:16:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685574986; cv=none; d=google.com; s=arc-20160816; b=cL3DLOlTnIQRXgNmK0X8unCWBt2EfE47zaOuOfo0x7YqSpfQgMOqRpTXVWQzxTP3Zw PFEZzpDg8JLCpM9oqf2fQNO/Nl6s0yP8tQ+iIRsb6vTLmonEVZ2JxpsH3lbX9KmdB+b4 wYjXiSIxyAaANFKKotiMa9eyxrk+dl8HWsmI0+tr2cNs4JX3tII+geG9Rvspqw2Xpb8R ZVRRRR5kdOwUm0VBEqrwx+blNKJsl+Y0F+ljXgNJJ6kGV/onA0NdsHmZMFd+eQRs7OYI 12vVf278/jut2j8GYtN7P8MhzeHYDSUtXE701O1wqFg9S+abBbt9NVXF//hTz1Yr6jy7 62+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:content-transfer-encoding :content-id:mime-version:subject:cc:to:from:organization :dkim-signature; bh=zpHJAAZtdS1eGDoBPdNCfJy7V4CHGDGY+NY0zDJG5HY=; b=hhJdegeuIn1DYI3RYFiFFrB8JDMHkCEEAfrnBKK/NRvb4kzGV7PSkSbksyfFDvlO6h dpSz2f4WiNCE8ga28JUlgAA3wjRF0h10+lEw2jFANt8BV62vGH9PlhzW8A0ww3fnc9e9 AHmktKR+SfjH1te7OCdCAwS7qLlxw1QYkkjlzD1AUnAbJNMyUSZuQpVa09M2mayucyi9 jMQDLGhdN3P5CQdTS24KpucSLmi/SMBXr4afWCGubZzCsrppeshySy/xUjh1VfGrhbtZ XG2PIn7fqyjQHzw5uUA6lrvI/JiR+3N6j4NX5iQgx/wdkDLJnpVJjPP43VsewzsXTG2E Ci3g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=XxN7dlzJ; 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=redhat.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l64-20020a633e43000000b0053fcc4f96cesi1863702pga.844.2023.05.31.16.16.12; Wed, 31 May 2023 16:16:26 -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=@redhat.com header.s=mimecast20190719 header.b=XxN7dlzJ; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229702AbjEaWvE (ORCPT <rfc822;andrewvogler123@gmail.com> + 99 others); Wed, 31 May 2023 18:51:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229603AbjEaWvC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Wed, 31 May 2023 18:51:02 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 68D759F for <linux-kernel@vger.kernel.org>; Wed, 31 May 2023 15:50:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1685573415; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=zpHJAAZtdS1eGDoBPdNCfJy7V4CHGDGY+NY0zDJG5HY=; b=XxN7dlzJepmhs2+dOo1erZYTkHUU6dnVAh+N5dqjZpRK4ZWNA1YJKp5qd1dM2aNTN/S/sw uyG566EOsgWmMolGMimrBFCt+XmbpE+bHz7KTU9fwIVTa+ef2lOrxo30T1qeIVgbOKupVz AAh0IJuhy1Q90eQcxW+mQI0IpMirZ9A= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-584-7f37sz9DMzaFOEFZovZXsQ-1; Wed, 31 May 2023 18:50:14 -0400 X-MC-Unique: 7f37sz9DMzaFOEFZovZXsQ-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 948E6800159; Wed, 31 May 2023 22:50:13 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id EE2932166B25; Wed, 31 May 2023 22:50:12 +0000 (UTC) Organization: Red Hat UK Ltd. Registered Address: Red Hat UK Ltd, Amberley Place, 107-111 Peascod Street, Windsor, Berkshire, SI4 1TE, United Kingdom. Registered in England and Wales under Company Registration No. 3798903 From: David Howells <dhowells@redhat.com> To: Marc Dionne <marc.dionne@auristor.com> cc: dhowells@redhat.com, linux-afs@lists.infradead.org, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] afs: Fix setting of mtime when creating a file/dir/symlink MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <808139.1685573412.1@warthog.procyon.org.uk> Content-Transfer-Encoding: quoted-printable Date: Wed, 31 May 2023 23:50:12 +0100 Message-ID: <808140.1685573412@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.6 X-Spam-Status: No, score=-2.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_NONE,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?1767453477236745298?= X-GMAIL-MSGID: =?utf-8?q?1767453477236745298?= |
Series |
afs: Fix setting of mtime when creating a file/dir/symlink
|
|
Commit Message
David Howells
May 31, 2023, 10:50 p.m. UTC
kafs incorrectly passes a zero mtime (ie. 1st Jan 1970) to the server when
creating a file, dir or symlink because commit 52af7105eceb caused the
mtime recorded in the afs_operation struct to be passed to the server, but
didn't modify the afs_mkdir(), afs_create() and afs_symlink() functions to
set it first.
Those functions were written with the assumption that the mtime would be
obtained from the server - but that fell foul of malsynchronised clocks, so
it was decided that the mtime should be set from the client instead.
Fix this by filling in op->mtime before calling the create op.
Fixes: 52af7105eceb ("afs: Set mtime from the client for yfs create operations")
Signed-off-by: David Howells <dhowells@redhat.com>
cc: Marc Dionne <marc.dionne@auristor.com>
cc: linux-afs@lists.infradead.org
cc: linux-fsdevel@vger.kernel.org
---
fs/afs/dir.c | 3 +++
1 file changed, 3 insertions(+)
Comments
On 5/31/2023 6:50 PM, David Howells wrote: > > kafs incorrectly passes a zero mtime (ie. 1st Jan 1970) to the server when > creating a file, dir or symlink because commit 52af7105eceb caused the > mtime recorded in the afs_operation struct to be passed to the server, but > didn't modify the afs_mkdir(), afs_create() and afs_symlink() functions to > set it first. > > Those functions were written with the assumption that the mtime would be > obtained from the server - but that fell foul of malsynchronised clocks, so > it was decided that the mtime should be set from the client instead. > > Fix this by filling in op->mtime before calling the create op. > > Fixes: 52af7105eceb ("afs: Set mtime from the client for yfs create operations") > Signed-off-by: David Howells <dhowells@redhat.com> > cc: Marc Dionne <marc.dionne@auristor.com> > cc: linux-afs@lists.infradead.org > cc: linux-fsdevel@vger.kernel.org > --- > fs/afs/dir.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/afs/dir.c b/fs/afs/dir.c > index 4dd97afa536c..5219182e52e1 100644 > --- a/fs/afs/dir.c > +++ b/fs/afs/dir.c > @@ -1358,6 +1358,7 @@ static int afs_mkdir(struct mnt_idmap *idmap, struct inode *dir, > op->dentry = dentry; > op->create.mode = S_IFDIR | mode; > op->create.reason = afs_edit_dir_for_mkdir; > + op->mtime = current_time(dir); > op->ops = &afs_mkdir_operation; > return afs_do_sync_operation(op); > } > @@ -1661,6 +1662,7 @@ static int afs_create(struct mnt_idmap *idmap, struct inode *dir, > op->dentry = dentry; > op->create.mode = S_IFREG | mode; > op->create.reason = afs_edit_dir_for_create; > + op->mtime = current_time(dir); > op->ops = &afs_create_operation; > return afs_do_sync_operation(op); > > @@ -1796,6 +1798,7 @@ static int afs_symlink(struct mnt_idmap *idmap, struct inode *dir, > op->ops = &afs_symlink_operation; > op->create.reason = afs_edit_dir_for_symlink; > op->create.symlink = content; > + op->mtime = current_time(dir); > return afs_do_sync_operation(op); > > error: > Reviewed-by: Jeffrey Altman <jaltman@auristor.com>
On Wed, May 31, 2023 at 7:50 PM David Howells <dhowells@redhat.com> wrote: > > > kafs incorrectly passes a zero mtime (ie. 1st Jan 1970) to the server when > creating a file, dir or symlink because commit 52af7105eceb caused the > mtime recorded in the afs_operation struct to be passed to the server, but > didn't modify the afs_mkdir(), afs_create() and afs_symlink() functions to > set it first. > > Those functions were written with the assumption that the mtime would be > obtained from the server - but that fell foul of malsynchronised clocks, so > it was decided that the mtime should be set from the client instead. > > Fix this by filling in op->mtime before calling the create op. > > Fixes: 52af7105eceb ("afs: Set mtime from the client for yfs create operations") > Signed-off-by: David Howells <dhowells@redhat.com> > cc: Marc Dionne <marc.dionne@auristor.com> > cc: linux-afs@lists.infradead.org > cc: linux-fsdevel@vger.kernel.org > --- > fs/afs/dir.c | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/fs/afs/dir.c b/fs/afs/dir.c > index 4dd97afa536c..5219182e52e1 100644 > --- a/fs/afs/dir.c > +++ b/fs/afs/dir.c > @@ -1358,6 +1358,7 @@ static int afs_mkdir(struct mnt_idmap *idmap, struct inode *dir, > op->dentry = dentry; > op->create.mode = S_IFDIR | mode; > op->create.reason = afs_edit_dir_for_mkdir; > + op->mtime = current_time(dir); > op->ops = &afs_mkdir_operation; > return afs_do_sync_operation(op); > } > @@ -1661,6 +1662,7 @@ static int afs_create(struct mnt_idmap *idmap, struct inode *dir, > op->dentry = dentry; > op->create.mode = S_IFREG | mode; > op->create.reason = afs_edit_dir_for_create; > + op->mtime = current_time(dir); > op->ops = &afs_create_operation; > return afs_do_sync_operation(op); > > @@ -1796,6 +1798,7 @@ static int afs_symlink(struct mnt_idmap *idmap, struct inode *dir, > op->ops = &afs_symlink_operation; > op->create.reason = afs_edit_dir_for_symlink; > op->create.symlink = content; > + op->mtime = current_time(dir); > return afs_do_sync_operation(op); > > error: The fix looks good, but as we discussed privately, the issue that this fixes predates commit 52af7105eceb. That commit only touched the yfs client code and made it rely on the op mtime rather than letting the server set the time. This made it inherit the issue that was already present for the non yfs client code. Marc
diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 4dd97afa536c..5219182e52e1 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -1358,6 +1358,7 @@ static int afs_mkdir(struct mnt_idmap *idmap, struct inode *dir, op->dentry = dentry; op->create.mode = S_IFDIR | mode; op->create.reason = afs_edit_dir_for_mkdir; + op->mtime = current_time(dir); op->ops = &afs_mkdir_operation; return afs_do_sync_operation(op); } @@ -1661,6 +1662,7 @@ static int afs_create(struct mnt_idmap *idmap, struct inode *dir, op->dentry = dentry; op->create.mode = S_IFREG | mode; op->create.reason = afs_edit_dir_for_create; + op->mtime = current_time(dir); op->ops = &afs_create_operation; return afs_do_sync_operation(op); @@ -1796,6 +1798,7 @@ static int afs_symlink(struct mnt_idmap *idmap, struct inode *dir, op->ops = &afs_symlink_operation; op->create.reason = afs_edit_dir_for_symlink; op->create.symlink = content; + op->mtime = current_time(dir); return afs_do_sync_operation(op); error: