From patchwork Wed Jun 7 08:47:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 104355 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp113928vqr; Wed, 7 Jun 2023 02:04:12 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5QikCoaP26hY69ia/yryTmY0MahbpFO+E6EPQIl7GIQiaeimMtKg05rmSKSCB51JCFPWWh X-Received: by 2002:a81:74c2:0:b0:565:eacf:a58d with SMTP id p185-20020a8174c2000000b00565eacfa58dmr6857186ywc.38.1686128652086; Wed, 07 Jun 2023 02:04:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686128652; cv=none; d=google.com; s=arc-20160816; b=iF9rZTSB0pkvUU6KNHKvBOUfhHBWY8iHfP5VfJKT+WVx6MgdkYMC70W1AEMeYZuj7S cbV7uO8xw+gLPmOfFUv2javQTHI2dlTpVfN2TlrDVuk/lceU9EGegb0UrmSVNiP61nhm ZhBLQz7p6nygH793iaKypojLaxAIAP89v4DDcvIqUnqSyNjeaLkPRzHjL7RibCgKP6HM MJWyYHxnaimye4MjpqeDWjvIpNGF/PAyiaCU219oucxEzSvu2azEY6L6G+4zXIBftvoy rWkpf+/on+0e4EODfVg64i0+ieCE0h0Fi6pmFTevpFatL0QqcJggJQl7/mVcoUjMw13g qOyw== 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=8b14LlHo3zt86QE7i50t7gWF3Pe+IncdMmgq5VH/CA4=; b=Fg3BWZiT7dgeUqvxfr7ri3ZTLf+b4JPN/nwb6s5gQCrWEdzjPd6HCXL5YLtMbgyhtl XyaQ4K7Fn+VZyjFJs/w9DDnWug6IrtXmxQyNEZy/VwaFVEtoYBgVKvNE0bp9XE63899o kcjENNTijJr6qOBT22WAnCEFrnZM4qwUan9Aeu5JNcSlDejiA/GaJ3UaJ0/FhyAy7oNx W2Q7dlsvcXG1MIoWVHenfumwRFNFdMKnXuat50Jc5oYXPWjaok+dUcJJhJLYn+l6h+KJ Z4/MWPdclBgLIA7ZKpNHEE2C1DhxyTccIbYxBORJg69MyaCOUoB1SKvMywMrdy4A2W0Z IKwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MWPsrQdc; 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 z22-20020a17090a541600b00259a5a5b211si862371pjh.3.2023.06.07.02.03.59; Wed, 07 Jun 2023 02:04:12 -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=MWPsrQdc; 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 S239332AbjFGIsK (ORCPT + 99 others); Wed, 7 Jun 2023 04:48:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239301AbjFGIsI (ORCPT ); Wed, 7 Jun 2023 04:48:08 -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 A3B8911F for ; Wed, 7 Jun 2023 01:47:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1686127642; 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=8b14LlHo3zt86QE7i50t7gWF3Pe+IncdMmgq5VH/CA4=; b=MWPsrQdcsKzUKkNS+vS+Lfq/0sLRKVzv4hlG9gucV1d3hvcKgIB1tXu8wqgMBKosRTKos+ r3FmOZcsD5Hk+M01KE7iNEK0P7hGF1BYVST9MWsDTd3hdizCfdsKXoUPVT/7vm7a4VmE0E +DKqcG5v1JP0n/YLUwgtsPopHAvjTZY= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-418-xw3_LTiZMzKbmW33Oy1jXQ-1; Wed, 07 Jun 2023 04:47:15 -0400 X-MC-Unique: xw3_LTiZMzKbmW33Oy1jXQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9527B1C0171B; Wed, 7 Jun 2023 08:47:14 +0000 (UTC) Received: from warthog.procyon.org.uk (unknown [10.42.28.182]) by smtp.corp.redhat.com (Postfix) with ESMTP id AE3AB40CFD46; Wed, 7 Jun 2023 08:47:13 +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 To: torvalds@linux-foundation.org cc: dhowells@redhat.com, Jeffrey Altman , Marc Dionne , 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-ID: <2004569.1686127633.1@warthog.procyon.org.uk> Date: Wed, 07 Jun 2023 09:47:13 +0100 Message-ID: <2004570.1686127633@warthog.procyon.org.uk> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.1 X-Spam-Status: No, score=-2.1 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=unavailable 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1768034037294560808?= X-GMAIL-MSGID: =?utf-8?q?1768034037294560808?= kafs incorrectly passes a zero mtime (ie. 1st Jan 1970) to the server when creating a file, dir or symlink because the mtime recorded in the afs_operation struct gets passed to the server by the marshalling routines, but the afs_mkdir(), afs_create() and afs_symlink() functions don't set it. This gets masked if a file or directory is subsequently modified. Fix this by filling in op->mtime before calling the create op. Fixes: e49c7b2f6de7 ("afs: Build an abstraction around an "operation" concept") Signed-off-by: David Howells Reviewed-by: Jeffrey Altman Reviewed-by: Marc Dionne 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: