From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6EB0DC433EF for ; Mon, 31 Jan 2022 11:45:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378960AbiAaLnY (ORCPT ); Mon, 31 Jan 2022 06:43:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379805AbiAaLal (ORCPT ); Mon, 31 Jan 2022 06:30:41 -0500 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7654AC061357; Mon, 31 Jan 2022 03:21:31 -0800 (PST) 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 ams.source.kernel.org (Postfix) with ESMTPS id 3E7BCB82A5D; Mon, 31 Jan 2022 11:21:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4E501C340E8; Mon, 31 Jan 2022 11:21:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1643628089; bh=FC0HL9ckTH4WkOIPSHmL9p4xnio/Co3QBc9awdjyvTg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=KeSSAle7vtDHORnj71d64DUgpVnvyboerhoGIFaufb48LCjO3zzQ0G4K/S8OLvX8G IG/kKGKZe7nW0nbvBBeXNYuLzxRTdjcAFOgC1g5v6AtbNU3pAP+2uwecLYcAsMyW6a DM6WC5XZbYMfzM5WghtgSjyNTRoDrVn2+LsOfo+k= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Trond Myklebust , Anna Schumaker , Sasha Levin Subject: [PATCH 5.16 121/200] NFS: Ensure the server has an up to date ctime before hardlinking Date: Mon, 31 Jan 2022 11:56:24 +0100 Message-Id: <20220131105237.634620475@linuxfoundation.org> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220131105233.561926043@linuxfoundation.org> References: <20220131105233.561926043@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Trond Myklebust [ Upstream commit 204975036b34f55237bc44c8a302a88468ef21b5 ] Creating a hard link is required by POSIX to update the file ctime, so ensure that the file data is synced to disk so that we don't clobber the updated ctime by writing back after creating the hard link. Fixes: 9f7682728728 ("NFS: Move the delegation return down into nfs4_proc_link()") Signed-off-by: Trond Myklebust Signed-off-by: Anna Schumaker Signed-off-by: Sasha Levin --- fs/nfs/dir.c | 2 ++ 1 file changed, 2 insertions(+) --- a/fs/nfs/dir.c +++ b/fs/nfs/dir.c @@ -2397,6 +2397,8 @@ nfs_link(struct dentry *old_dentry, stru trace_nfs_link_enter(inode, dir, dentry); d_drop(dentry); + if (S_ISREG(inode->i_mode)) + nfs_sync_inode(inode); error = NFS_PROTO(dir)->link(inode, dir, &dentry->d_name); if (error == 0) { nfs_set_verifier(dentry, nfs_save_change_attribute(dir));