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 X-Spam-Level: X-Spam-Status: No, score=-13.0 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8337EC433E2 for ; Tue, 14 Jul 2020 18:46:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5903922B2E for ; Tue, 14 Jul 2020 18:46:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594752382; bh=n/RZAlzXDH8rUSbrW3Nyf4sfqxn/njQDPwIOh6b0um0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=omDvtiphfY6C4GyBtThyEzmCmckE9SrN7os7KBCdXFaKgP3efjCcZGDRNw6oR/hQm eMrOOmmnHCyYdoszvbtZz5uZRc/1H4oZw2DE83C/B5A4V/qS5kSdIWYGluFyre6Bnx eQTwfODV5k7UUq3uGv6sFnvh4Silyyed3tgWTask= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729436AbgGNSqU (ORCPT ); Tue, 14 Jul 2020 14:46:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:40826 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729393AbgGNSqO (ORCPT ); Tue, 14 Jul 2020 14:46:14 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id EA55422282; Tue, 14 Jul 2020 18:46:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1594752374; bh=n/RZAlzXDH8rUSbrW3Nyf4sfqxn/njQDPwIOh6b0um0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nPmEdS9BzH1enn4a8yVnvrtwg0qOn8GIVyUnHFlEY03Pull/yx+/sjui6c8AJMcfZ RFp+6gnLzYsgTgUU0oMcjl3XsG9wLy5gVGd6Mi6nDoN4uL7CY87oyrol+ZK6sVKTY1 4zTPVB+bX6TmcteL11FPfrG0kSQX3sdEv/CUkdZ4= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Hulk Robot , Zhang Xiaoxu , Steve French , Sasha Levin Subject: [PATCH 4.19 18/58] cifs: update ctime and mtime during truncate Date: Tue, 14 Jul 2020 20:43:51 +0200 Message-Id: <20200714184057.061438764@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200714184056.149119318@linuxfoundation.org> References: <20200714184056.149119318@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 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 44fb9ae6d1055..1d951936b0923 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -2225,6 +2225,15 @@ set_size_out: 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