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.14 12/17] cifs: update ctime and mtime during truncate
Date: Wed, 1 Jul 2020 21:26:44 -0400 [thread overview]
Message-ID: <20200702012649.2701799-12-sashal@kernel.org> (raw)
In-Reply-To: <20200702012649.2701799-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 bdce714e94489..b76e733952997 100644
--- a/fs/cifs/inode.c
+++ b/fs/cifs/inode.c
@@ -2210,6 +2210,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
next prev parent reply other threads:[~2020-07-02 1:30 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-07-02 1:26 [PATCH AUTOSEL 4.14 01/17] ARM: dts: omap4-droid4: Fix spi configuration and increase rate Sasha Levin
2020-07-02 1:26 ` [PATCH AUTOSEL 4.14 02/17] gpu: host1x: Detach driver on unregister Sasha Levin
2020-07-02 1:26 ` [PATCH AUTOSEL 4.14 03/17] net: usb: ax88179_178a: fix packet alignment padding Sasha Levin
2020-07-02 1:26 ` [PATCH AUTOSEL 4.14 04/17] usb: usbtest: fix missing kfree(dev->buf) in usbtest_disconnect Sasha Levin
2020-07-02 1:26 ` [PATCH AUTOSEL 4.14 05/17] spi: spidev: fix a race between spidev_release and spidev_remove Sasha Levin
2020-07-02 1:26 ` [PATCH AUTOSEL 4.14 06/17] spi: spidev: fix a potential use-after-free in spidev_release() Sasha Levin
2020-07-02 1:26 ` [PATCH AUTOSEL 4.14 07/17] tg3: driver sleeps indefinitely when EEH errors exceed eeh_max_freezes Sasha Levin
2020-07-02 1:26 ` [PATCH AUTOSEL 4.14 08/17] ixgbe: protect ring accesses with READ- and WRITE_ONCE Sasha Levin
2020-07-02 1:26 ` [PATCH AUTOSEL 4.14 09/17] usbnet: smsc95xx: Fix use-after-free after removal Sasha Levin
2020-07-02 1:26 ` [PATCH AUTOSEL 4.14 10/17] s390/kasan: fix early pgm check handler execution Sasha Levin
2020-07-02 1:26 ` [PATCH AUTOSEL 4.14 11/17] cifs: Fix double add page to memcg when cifs_readpages Sasha Levin
2020-07-02 1:26 ` Sasha Levin [this message]
2020-07-02 1:26 ` [PATCH AUTOSEL 4.14 13/17] ARM: imx6: add missing put_device() call in imx6q_suspend_init() Sasha Levin
2020-07-02 1:26 ` [PATCH AUTOSEL 4.14 14/17] scsi: mptscsih: Fix read sense data size Sasha Levin
2020-07-02 1:26 ` [PATCH AUTOSEL 4.14 15/17] nvme-rdma: assign completion vector correctly Sasha Levin
2020-07-02 1:26 ` [PATCH AUTOSEL 4.14 16/17] x86/entry: Increase entry_stack size to a full page Sasha Levin
2020-07-02 1:26 ` [PATCH AUTOSEL 4.14 17/17] 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=20200702012649.2701799-12-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