From patchwork Wed Jul 5 19:00:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Layton X-Patchwork-Id: 116353 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:9f45:0:b0:3ea:f831:8777 with SMTP id v5csp2095911vqx; Wed, 5 Jul 2023 12:41:24 -0700 (PDT) X-Google-Smtp-Source: APBJJlFBhMle/iugvSAmB3BGAimWKAKZl3uYDNqheX73pyXUQ5b8Sx39sBUImOZHFrjpP3V+VbVt X-Received: by 2002:a05:6870:e30a:b0:1b3:7e8e:2b1b with SMTP id z10-20020a056870e30a00b001b37e8e2b1bmr14273438oad.34.1688586084260; Wed, 05 Jul 2023 12:41:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688586084; cv=none; d=google.com; s=arc-20160816; b=M+civEVA3ZisD1zqoqJy08nBLw9DIcNOiVJqXUZBFWwKuwzJNU402Jhfh8cBZtitoa Qc+qJe78XwT5UVpfTjTBiiilR7zP1pXhIFbxEQq+d7i5R5T/EIGs6Jq0UoZIrZtFJGPn zxxNltifKq4aPzBsUFQ1oazkcXiXIowS1prXAGYQ5lsDwt9PjJFYO8U7OyQT3KEcsMaf hzQWcgtMwn0USD7kVHg2DK0OfAySnda5sLlcdJGkOfNZmCMU789Rishi/SAntjnnOMaa TWgOzqMHB+WioOpMHlCcJP3HDlLwB6pJB41bc/9I863GeL5oRK1oYVpqq5FQt0U5Ecse CXRg== 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:cc:to:from :dkim-signature; bh=8Ssa5BFBaotn67tU9LP9BNcL9E4TvvWBLxGHxw/lMtM=; fh=MYHhJWcCrEI17NrYhhhi6DAK8KszBjyyGgT2rjwDsi8=; b=Lj5B3UbKbjIZ5wDRgI+M5AfTy3gny/kmhTvptbiUlRLN0uExnY8LSH9wl4MrqYZ4vQ P6rI+nPXlSLiNkZPN+IsKFdsN1/kmDIGFxseWLYbBK9HzcqMcK4NnbjcgO5xd7PnJo88 kKtpbioq6E7A+rKiZWH4ZA0xhNAK3chBvgkIG6/Im2NJagjP4fKc+0I+gTyB+KzXwxG0 PlRYYPB5aGbbN17fx2z3Gf38qtL0L4RKJanRF03SjQ1cfu6ezoOJUbqu8ycd2nZnOw36 xWryMQs7NyQMk65zZcZ6YFTbp09Tcw+x/G8JlrwwwaXW/eu+gTLuL9yrkdkedEaePpxq J2sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=YeMu90xY; 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 bh21-20020a17090b049500b002637d779bf3si2251534pjb.17.2023.07.05.12.41.11; Wed, 05 Jul 2023 12:41:24 -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=YeMu90xY; 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 S233498AbjGETDt (ORCPT + 99 others); Wed, 5 Jul 2023 15:03:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42974 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233484AbjGETD3 (ORCPT ); Wed, 5 Jul 2023 15:03:29 -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 000C419A9; Wed, 5 Jul 2023 12:03:22 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D3F20616F9; Wed, 5 Jul 2023 19:03:22 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 94634C433C8; Wed, 5 Jul 2023 19:03:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688583802; bh=xf8Hi6LLQ8Uft364NbD0ve0c8ZqVR4Xzt1FbU/Spvec=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YeMu90xYX+J/DSpr4IEpPdjE0VhxjToh+dxnB6lIUKKzFPcDwLtfLqKprheME36Au GwtAsEj1J48EJ+u7bhE8nllzBjY6eaN33Z7CFu7g9eBJBejJ9bJayxiBj/WF4aqxR1 ev8b72N50v378o9db6zZTHiX/IHmwUKC2RbwSvs+YbfDWVAWa+2HfqyyLEdQE8H6hH sLvE6sIM7+NfFVYFnqbPdsVR3GGg6Nd+De74SfHuZRvzgUXYOA3NicY4g1GrO+AubB x9RH15V52pkaLIQ5VhK+BEDjWAP0FZpk8dpHisGouC+BG+MA2V60Iplhx1Vt2GRlgB 4+1tVVOQCzaRA== From: Jeff Layton To: Christian Brauner , Richard Weinberger Cc: Al Viro , Jan Kara , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [PATCH v2 10/92] ubifs: convert to simple_rename_timestamp Date: Wed, 5 Jul 2023 15:00:35 -0400 Message-ID: <20230705190309.579783-8-jlayton@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230705190309.579783-1-jlayton@kernel.org> References: <20230705185755.579053-1-jlayton@kernel.org> <20230705190309.579783-1-jlayton@kernel.org> MIME-Version: 1.0 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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770610841773023405?= X-GMAIL-MSGID: =?utf-8?q?1770610841773023405?= A rename potentially involves updating 4 different inode timestamps. Convert to the new simple_rename_timestamp helper function. Signed-off-by: Jeff Layton Reviewed-by: Jan Kara Reviewed-by: Zhihao Cheng --- fs/ubifs/dir.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/fs/ubifs/dir.c b/fs/ubifs/dir.c index ef0499edc248..7ec25310bd8a 100644 --- a/fs/ubifs/dir.c +++ b/fs/ubifs/dir.c @@ -1414,8 +1414,7 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry, * Like most other Unix systems, set the @i_ctime for inodes on a * rename. */ - time = current_time(old_dir); - old_inode->i_ctime = time; + simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry); /* We must adjust parent link count when renaming directories */ if (is_dir) { @@ -1444,13 +1443,11 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry, old_dir->i_size -= old_sz; ubifs_inode(old_dir)->ui_size = old_dir->i_size; - old_dir->i_mtime = old_dir->i_ctime = time; - new_dir->i_mtime = new_dir->i_ctime = time; /* * And finally, if we unlinked a direntry which happened to have the * same name as the moved direntry, we have to decrement @i_nlink of - * the unlinked inode and change its ctime. + * the unlinked inode. */ if (unlink) { /* @@ -1462,7 +1459,6 @@ static int do_rename(struct inode *old_dir, struct dentry *old_dentry, clear_nlink(new_inode); else drop_nlink(new_inode); - new_inode->i_ctime = time; } else { new_dir->i_size += new_sz; ubifs_inode(new_dir)->ui_size = new_dir->i_size; @@ -1557,7 +1553,6 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry, int sync = IS_DIRSYNC(old_dir) || IS_DIRSYNC(new_dir); struct inode *fst_inode = d_inode(old_dentry); struct inode *snd_inode = d_inode(new_dentry); - struct timespec64 time; int err; struct fscrypt_name fst_nm, snd_nm; @@ -1588,11 +1583,7 @@ static int ubifs_xrename(struct inode *old_dir, struct dentry *old_dentry, lock_4_inodes(old_dir, new_dir, NULL, NULL); - time = current_time(old_dir); - fst_inode->i_ctime = time; - snd_inode->i_ctime = time; - old_dir->i_mtime = old_dir->i_ctime = time; - new_dir->i_mtime = new_dir->i_ctime = time; + simple_rename_timestamp(old_dir, old_dentry, new_dir, new_dentry); if (old_dir != new_dir) { if (S_ISDIR(fst_inode->i_mode) && !S_ISDIR(snd_inode->i_mode)) {