diff mbox series

[04/27] lustre: flr: mmap write/punch does not stale other mirrors

Message ID 1623625897-17706-5-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: sync to 2.14.52 | expand

Commit Message

James Simmons June 13, 2021, 11:11 p.m. UTC
From: Bobi Jam <bobijam@whamcloud.com>

mmap write and punch/fallocate do not stale other mirrors and makes
FLR file contains different content in different mirrors.

WC-bug-id: https://jira.whamcloud.com/browse/LU-14647
Lustre-commit: 03511484c668355c ("LU-14647 flr: mmap write/punch does not stale other mirrors")
Signed-off-by: Bobi Jam <bobijam@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/43470
Reviewed-by: Wang Shilong <wshilong@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/include/cl_object.h | 5 +++++
 fs/lustre/llite/llite_mmap.c  | 4 +++-
 fs/lustre/llite/vvp_io.c      | 3 ++-
 fs/lustre/lov/lov_io.c        | 8 +++++---
 4 files changed, 15 insertions(+), 5 deletions(-)
diff mbox series

Patch

diff --git a/fs/lustre/include/cl_object.h b/fs/lustre/include/cl_object.h
index b69c04a..c615091 100644
--- a/fs/lustre/include/cl_object.h
+++ b/fs/lustre/include/cl_object.h
@@ -2456,6 +2456,11 @@  int cl_io_lru_reserve(const struct lu_env *env, struct cl_io *io,
 int cl_io_read_ahead(const struct lu_env *env, struct cl_io *io,
 		     pgoff_t start, struct cl_read_ahead *ra);
 
+static inline int cl_io_is_fault_writable(const struct cl_io *io)
+{
+	return io->ci_type == CIT_FAULT && io->u.ci_fault.ft_writable;
+}
+
 /**
  * True, if @io is an O_APPEND write(2).
  */
diff --git a/fs/lustre/llite/llite_mmap.c b/fs/lustre/llite/llite_mmap.c
index a234a83..ebcb8d9 100644
--- a/fs/lustre/llite/llite_mmap.c
+++ b/fs/lustre/llite/llite_mmap.c
@@ -117,6 +117,9 @@  struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr,
 	else if (vma->vm_flags & VM_RAND_READ)
 		io->ci_rand_read = 1;
 
+	if (vma->vm_flags & VM_WRITE)
+		fio->ft_writable = 1;
+
 	rc = cl_io_init(env, io, CIT_FAULT, io->ci_obj);
 	if (rc == 0) {
 		struct vvp_io *vio = vvp_env_io(env);
@@ -128,7 +131,6 @@  struct vm_area_struct *our_vma(struct mm_struct *mm, unsigned long addr,
 		io->ci_lockreq = CILR_MANDATORY;
 		vio->vui_fd = fd;
 	} else {
-		LASSERT(rc < 0);
 		cl_io_fini(env, io);
 		if (io->ci_need_restart)
 			goto restart;
diff --git a/fs/lustre/llite/vvp_io.c b/fs/lustre/llite/vvp_io.c
index 12a28d9..12314fd 100644
--- a/fs/lustre/llite/vvp_io.c
+++ b/fs/lustre/llite/vvp_io.c
@@ -363,7 +363,8 @@  static void vvp_io_fini(const struct lu_env *env, const struct cl_io_slice *ios)
 		io->ci_need_write_intent = 0;
 
 		LASSERT(io->ci_type == CIT_WRITE || cl_io_is_fallocate(io) ||
-			cl_io_is_trunc(io) || cl_io_is_mkwrite(io));
+			cl_io_is_trunc(io) || cl_io_is_mkwrite(io) ||
+			cl_io_is_fault_writable(io));
 
 		CDEBUG(D_VFSTRACE, DFID" write layout, type %u " DEXT "\n",
 		       PFID(lu_object_fid(&obj->co_lu)), io->ci_type,
diff --git a/fs/lustre/lov/lov_io.c b/fs/lustre/lov/lov_io.c
index 86e3fbd..9012ad6 100644
--- a/fs/lustre/lov/lov_io.c
+++ b/fs/lustre/lov/lov_io.c
@@ -221,8 +221,9 @@  static int lov_io_mirror_write_intent(struct lov_io *lio,
 	*ext = (typeof(*ext)) { lio->lis_pos, lio->lis_endpos };
 	io->ci_need_write_intent = 0;
 
-	if (!(io->ci_type == CIT_WRITE || cl_io_is_trunc(io) ||
-	      cl_io_is_mkwrite(io)))
+	if (!(io->ci_type == CIT_WRITE || cl_io_is_mkwrite(io) ||
+	      cl_io_is_fallocate(io) || cl_io_is_trunc(io) ||
+	      cl_io_is_fault_writable(io)))
 		return 0;
 
 	/* FLR: check if it needs to send a write intent RPC to server.
@@ -574,7 +575,8 @@  static int lov_io_slice_init(struct lov_io *lio, struct lov_object *obj,
 	/* check if it needs to instantiate layout */
 	if (!(io->ci_type == CIT_WRITE || cl_io_is_mkwrite(io) ||
 	      cl_io_is_fallocate(io) ||
-	      (cl_io_is_trunc(io) && io->u.ci_setattr.sa_attr.lvb_size > 0))) {
+	      (cl_io_is_trunc(io) && io->u.ci_setattr.sa_attr.lvb_size > 0)) ||
+	      cl_io_is_fault_writable(io)) {
 		result = 0;
 		goto out;
 	}