[lustre-devel] [PATCH 13/42] lustre: llite: update statx size/ctime for fallocate

James Simmons <[email protected]>
Newsgroups org.lustre.lists.lustre-devel
Message-ID <[email protected]>
From: Qian Yingjin <[email protected]>

In the VFS interface ->fallocate(), it should update i_size and
i_ctime returned by statx() accordingly when the file size grows.

fallocate() call does not update the attributes on MDT.
We use STATX with cached-always mode to verify it as it will not
send Glimpse lock RPCs to OSTs to obtain file size information
and use the caching attributes (size) on the client side as much
as possible.

WC-bug-id: https://jira.whamcloud.com/browse/LU-16334
Lustre-commit: 51851705e936b2dbc ("LU-16334 llite: update statx size/ctime for fallocate")
Signed-off-by: Qian Yingjin <[email protected]>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49221
Reviewed-by: Oleg Drokin <[email protected]>
Reviewed-by: Arshad Hussain <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
Signed-off-by: James Simmons <[email protected]>
---
 fs/lustre/llite/vvp_io.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/fs/lustre/llite/vvp_io.c b/fs/lustre/llite/vvp_io.c
index be6f17f5f072..317704172080 100644
--- a/fs/lustre/llite/vvp_io.c
+++ b/fs/lustre/llite/vvp_io.c
@@ -754,15 +754,25 @@ static void vvp_io_setattr_end(const struct lu_env *env,
 	struct cl_io *io = ios->cis_io;
 	struct inode *inode = vvp_object_inode(io->ci_obj);
 	struct ll_inode_info *lli = ll_i2info(inode);
+	loff_t size = io->u.ci_setattr.sa_attr.lvb_size;
 
 	if (cl_io_is_trunc(io)) {
 		/* Truncate in memory pages - they must be clean pages
 		 * because osc has already notified to destroy osc_extents.
 		 */
-		vvp_do_vmtruncate(inode, io->u.ci_setattr.sa_attr.lvb_size);
+		vvp_do_vmtruncate(inode, size);
 		mutex_unlock(&lli->lli_setattr_mutex);
 		trunc_sem_up_write(&lli->lli_trunc_sem);
 	} else if (cl_io_is_fallocate(io)) {
+		int mode = io->u.ci_setattr.sa_falloc_mode;
+
+		if (!(mode & FALLOC_FL_KEEP_SIZE) &&
+		    size > i_size_read(inode)) {
+			ll_inode_size_lock(inode);
+			i_size_write(inode, size);
+			ll_inode_size_unlock(inode);
+		}
+		inode->i_ctime = current_time(inode);
 		mutex_unlock(&lli->lli_setattr_mutex);
 		trunc_sem_up_write(&lli->lli_trunc_sem);
 	} else {
-- 
2.27.0

_______________________________________________
lustre-devel mailing list
[email protected]
http://lists.lustre.org/listinfo.cgi/lustre-devel-lustre.org
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.