public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>,
	Hulk Robot <hulkci@huawei.com>,
	Steve French <stfrench@microsoft.com>,
	Sasha Levin <sashal@kernel.org>,
	linux-cifs@vger.kernel.org, samba-technical@lists.samba.org
Subject: [PATCH AUTOSEL 4.9 10/13] cifs: update ctime and mtime during truncate
Date: Wed,  1 Jul 2020 21:27:09 -0400	[thread overview]
Message-ID: <20200702012712.2701986-10-sashal@kernel.org> (raw)
In-Reply-To: <20200702012712.2701986-1-sashal@kernel.org>

From: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>

[ 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 <hulkci@huawei.com>
Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@huawei.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 fs/cifs/inode.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c
index dfa85ad5b4814..5478902a01009 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -2188,6 +2188,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


  parent reply	other threads:[~2020-07-02  1:28 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-02  1:27 [PATCH AUTOSEL 4.9 01/13] gpu: host1x: Detach driver on unregister Sasha Levin
2020-07-02  1:27 ` [PATCH AUTOSEL 4.9 02/13] net: usb: ax88179_178a: fix packet alignment padding Sasha Levin
2020-07-02  1:27 ` [PATCH AUTOSEL 4.9 03/13] usb: usbtest: fix missing kfree(dev->buf) in usbtest_disconnect Sasha Levin
2020-07-02  1:27 ` [PATCH AUTOSEL 4.9 04/13] spi: spidev: fix a race between spidev_release and spidev_remove Sasha Levin
2020-07-02  1:27 ` [PATCH AUTOSEL 4.9 05/13] spi: spidev: fix a potential use-after-free in spidev_release() Sasha Levin
2020-07-02  1:27 ` [PATCH AUTOSEL 4.9 06/13] tg3: driver sleeps indefinitely when EEH errors exceed eeh_max_freezes Sasha Levin
2020-07-02  1:27 ` [PATCH AUTOSEL 4.9 07/13] usbnet: smsc95xx: Fix use-after-free after removal Sasha Levin
2020-07-02  1:27 ` [PATCH AUTOSEL 4.9 08/13] s390/kasan: fix early pgm check handler execution Sasha Levin
2020-07-02  1:27 ` [PATCH AUTOSEL 4.9 09/13] cifs: Fix double add page to memcg when cifs_readpages Sasha Levin
2020-07-02  1:27 ` Sasha Levin [this message]
2020-07-02  1:27 ` [PATCH AUTOSEL 4.9 11/13] ARM: imx6: add missing put_device() call in imx6q_suspend_init() Sasha Levin
2020-07-02  1:27 ` [PATCH AUTOSEL 4.9 12/13] scsi: mptscsih: Fix read sense data size Sasha Levin
2020-07-02  1:27 ` [PATCH AUTOSEL 4.9 13/13] kgdb: Avoid suspicious RCU usage warning Sasha Levin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200702012712.2701986-10-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=hulkci@huawei.com \
    --cc=linux-cifs@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=samba-technical@lists.samba.org \
    --cc=stable@vger.kernel.org \
    --cc=stfrench@microsoft.com \
    --cc=zhangxiaoxu5@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox