Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp1082479ybt; Wed, 1 Jul 2020 18:25:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw/5AjxVln34pQI81xHSzTWBBe2YIdhpcPeumh3xzKv69IDE4we2EtmMKuVgQspxTVR9a2n X-Received: by 2002:a17:907:20f8:: with SMTP id rh24mr5692088ejb.309.1593653102317; Wed, 01 Jul 2020 18:25:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593653102; cv=none; d=google.com; s=arc-20160816; b=tVQxln9Kd/IQtKWyhrB/cH8m9avtjbO5ze9Nanee6XveCIh0mDvlMUdhEANwQwSK0n aJrkOXa0qGlEyUJq2xq2irYJCQuTiruBKeNaNF0qkt/bLFLgEc5ZhawsZHlQQOPsglcB Cw2P6mqPm+7O9eqNR6gJn5aEQnXC6yUF/jmZkFZKK6cz0P85w+0rW7qjgpHgR+8N80pm m+9fCp5GY843msEU/GZOr5S0hvYie3EIpolaCWIv0QJdAL0jB449vDH3FL24J3galgDo uM6RG0WU1jaKD2gytUnbuUStMeyNVndGXaiBlekJ3KRPW2+mFglFF6hAn7qOAgArQvVv nqbQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=ciMDx5FAAsH8TB3Wmu30D67vGmNFZH1h9JbAjyAoLiU=; b=UKWuDwW2isupBZGNkaUiIWhAmAQRoMkSPHKchih+Lz49SY+r6aecbW6VUoSVdDF0ut Aphq4sYg8dWMnw9zCpL1x6WKSjDzW3HcctnVRevf1bo9uc7mYKT9B34aXPM4Bao0eHnV /VMnPJ7leJ1ZTD64f75cJKV1qeAc026Js6aUXqXaCoT/ri/huMof5OvZe5cM7YLsu4XL aiMIjonqNNMVzpo1zLHG8/mpezYpZdNRo4SMwY3ycTKnx5jz4dEjyx7x8brcRBZIaCAZ eaeVlOvDj03ox50atQW8bPdSx4KesS9sYLBcF80u8bU3ZJi2hvy/nXGo/dX8tbXZ3dpg tsSg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hksPhBe6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id m9si4901298ejj.109.2020.07.01.18.24.39; Wed, 01 Jul 2020 18:25:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=hksPhBe6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S1728533AbgGBBXz (ORCPT + 99 others); Wed, 1 Jul 2020 21:23:55 -0400 Received: from mail.kernel.org ([198.145.29.99]:54502 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728458AbgGBBXp (ORCPT ); Wed, 1 Jul 2020 21:23:45 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 173F820A8B; Thu, 2 Jul 2020 01:23:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1593653024; bh=DMIw2NQxQj0v1MMUPu9aLiSDpGBMnBr7a2uEcG43WkA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hksPhBe6gUXbM32jmBzzNg+tNBg5HJpv1LtpOrDeGFXeB1tThX84iJhJaofIASkPA ge/XQw5tbVhmUKVw48Zdx6TUtXpJsbXEkhKeR+yN121SEqy3cT50/aDN7XPaz1GrR7 V5FhFcStGeiAvweJiCRwxluU9L69XwGEDANbDShM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Zhang Xiaoxu , Hulk Robot , Steve French , Sasha Levin , linux-cifs@vger.kernel.org, samba-technical@lists.samba.org Subject: [PATCH AUTOSEL 5.7 40/53] cifs: update ctime and mtime during truncate Date: Wed, 1 Jul 2020 21:21:49 -0400 Message-Id: <20200702012202.2700645-40-sashal@kernel.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200702012202.2700645-1-sashal@kernel.org> References: <20200702012202.2700645-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Zhang Xiaoxu [ Upstream commit 5618303d8516f8ac5ecfe53ee8e8bc9a40eaf066 ] As the man description of the truncate, if the size changed, then the st_ctime and st_mtime fields should be updated. But in cifs, we doesn't do it. It lead the xfstests generic/313 failed. So, add the ATTR_MTIME|ATTR_CTIME flags on attrs when change the file size Reported-by: Hulk Robot Signed-off-by: Zhang Xiaoxu Signed-off-by: Steve French Signed-off-by: Sasha Levin --- fs/cifs/inode.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 5d2965a237305..15f2cdc71ac98 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -2344,6 +2344,15 @@ cifs_set_file_size(struct inode *inode, struct iattr *attrs, if (rc == 0) { cifsInode->server_eof = attrs->ia_size; cifs_setsize(inode, attrs->ia_size); + + /* + * The man page of truncate says if the size changed, + * then the st_ctime and st_mtime fields for the file + * are updated. + */ + attrs->ia_ctime = attrs->ia_mtime = current_time(inode); + attrs->ia_valid |= ATTR_CTIME | ATTR_MTIME; + cifs_truncate_page(inode->i_mapping, inode->i_size); } -- 2.25.1