All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 0/2] ceph: flush the mdlog for filesystem sync
@ 2022-04-18 13:02 Xiubo Li
  2022-04-18 13:02 ` [PATCH v3 1/2] ceph: rename unsafe_request_wait() Xiubo Li
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Xiubo Li @ 2022-04-18 13:02 UTC (permalink / raw)
  To: jlayton; +Cc: idryomov, vshankar, ceph-devel, Xiubo Li

V2:
- unsafe_request_wait() --> flush_mdlog_and_wait_inode_unsafe_requests()
- wait_unsafe_requests() -> flush_mdlog_and_wait_inode_unsafe_requests()


Xiubo Li (2):
  ceph: rename unsafe_request_wait()
  ceph: flush the mdlog for filesystem sync

 fs/ceph/caps.c       |  8 ++++----
 fs/ceph/mds_client.c | 27 +++++++++++++++++++++------
 2 files changed, 25 insertions(+), 10 deletions(-)

-- 
2.36.0.rc1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v3 1/2] ceph: rename unsafe_request_wait()
  2022-04-18 13:02 [PATCH v3 0/2] ceph: flush the mdlog for filesystem sync Xiubo Li
@ 2022-04-18 13:02 ` Xiubo Li
  2022-04-18 13:02 ` [PATCH v3 2/2] ceph: flush the mdlog for filesystem sync Xiubo Li
  2022-04-18 13:09 ` [PATCH v3 0/2] " Jeff Layton
  2 siblings, 0 replies; 4+ messages in thread
From: Xiubo Li @ 2022-04-18 13:02 UTC (permalink / raw)
  To: jlayton; +Cc: idryomov, vshankar, ceph-devel, Xiubo Li

Rename it to flush_mdlog_and_wait_inode_unsafe_requests() to make
it more descriptive.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
 fs/ceph/caps.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/fs/ceph/caps.c b/fs/ceph/caps.c
index 69af17df59be..f16f6274b150 100644
--- a/fs/ceph/caps.c
+++ b/fs/ceph/caps.c
@@ -2277,9 +2277,9 @@ static int caps_are_flushed(struct inode *inode, u64 flush_tid)
 }
 
 /*
- * wait for any unsafe requests to complete.
+ * flush the mdlog and wait for any unsafe requests to complete.
  */
-static int unsafe_request_wait(struct inode *inode)
+static int flush_mdlog_and_wait_inode_unsafe_requests(struct inode *inode)
 {
 	struct ceph_mds_client *mdsc = ceph_sb_to_client(inode->i_sb)->mdsc;
 	struct ceph_inode_info *ci = ceph_inode(inode);
@@ -2391,7 +2391,7 @@ static int unsafe_request_wait(struct inode *inode)
 		kfree(sessions);
 	}
 
-	dout("unsafe_request_wait %p wait on tid %llu %llu\n",
+	dout("%s %p wait on tid %llu %llu\n", __func__,
 	     inode, req1 ? req1->r_tid : 0ULL, req2 ? req2->r_tid : 0ULL);
 	if (req1) {
 		ret = !wait_for_completion_timeout(&req1->r_safe_completion,
@@ -2435,7 +2435,7 @@ int ceph_fsync(struct file *file, loff_t start, loff_t end, int datasync)
 	dirty = try_flush_caps(inode, &flush_tid);
 	dout("fsync dirty caps are %s\n", ceph_cap_string(dirty));
 
-	err = unsafe_request_wait(inode);
+	err = flush_mdlog_and_wait_inode_unsafe_requests(inode);
 
 	/*
 	 * only wait on non-file metadata writeback (the mds
-- 
2.36.0.rc1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v3 2/2] ceph: flush the mdlog for filesystem sync
  2022-04-18 13:02 [PATCH v3 0/2] ceph: flush the mdlog for filesystem sync Xiubo Li
  2022-04-18 13:02 ` [PATCH v3 1/2] ceph: rename unsafe_request_wait() Xiubo Li
@ 2022-04-18 13:02 ` Xiubo Li
  2022-04-18 13:09 ` [PATCH v3 0/2] " Jeff Layton
  2 siblings, 0 replies; 4+ messages in thread
From: Xiubo Li @ 2022-04-18 13:02 UTC (permalink / raw)
  To: jlayton; +Cc: idryomov, vshankar, ceph-devel, Xiubo Li

Before waiting for a request's safe reply, we will send the mdlog
flush request to the relevant MDS. And this will also flush the
mdlog for all the other unsafe requests in the same session, so
we can record the last session and no need to flush mdlog again
in the next loop. But there still have cases that it may send the
mdlog flush requst twice or more, but that should be not often.

Rename wait_unsafe_requests() to flush_mdlog_and_wait_inode_unsafe_requests()
to make it more descriptive.

URL: https://tracker.ceph.com/issues/55284
Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
 fs/ceph/mds_client.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index 0da85c9ce73a..94bd4dd956fd 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -5093,15 +5093,17 @@ void ceph_mdsc_pre_umount(struct ceph_mds_client *mdsc)
 }
 
 /*
- * wait for all write mds requests to flush.
+ * flush the mdlog and wait for all write mds requests to flush.
  */
-static void wait_unsafe_requests(struct ceph_mds_client *mdsc, u64 want_tid)
+static void flush_mdlog_and_wait_mdsc_unsafe_requests(struct ceph_mds_client *mdsc,
+						 u64 want_tid)
 {
 	struct ceph_mds_request *req = NULL, *nextreq;
+	struct ceph_mds_session *last_session = NULL, *s;
 	struct rb_node *n;
 
 	mutex_lock(&mdsc->mutex);
-	dout("wait_unsafe_requests want %lld\n", want_tid);
+	dout("%s want %lld\n", __func__, want_tid);
 restart:
 	req = __get_oldest_req(mdsc);
 	while (req && req->r_tid <= want_tid) {
@@ -5117,8 +5119,20 @@ static void wait_unsafe_requests(struct ceph_mds_client *mdsc, u64 want_tid)
 			ceph_mdsc_get_request(req);
 			if (nextreq)
 				ceph_mdsc_get_request(nextreq);
+
+			s = req->r_session;
+			if (!s) {
+				req = nextreq;
+				continue;
+			}
+			/* send flush mdlog request to MDS */
+			if (last_session != s) {
+				send_flush_mdlog(s);
+				ceph_put_mds_session(last_session);
+				last_session = ceph_get_mds_session(s);
+			}
 			mutex_unlock(&mdsc->mutex);
-			dout("wait_unsafe_requests  wait on %llu (want %llu)\n",
+			dout("%s wait on %llu (want %llu)\n", __func__,
 			     req->r_tid, want_tid);
 			wait_for_completion(&req->r_safe_completion);
 			mutex_lock(&mdsc->mutex);
@@ -5135,7 +5149,8 @@ static void wait_unsafe_requests(struct ceph_mds_client *mdsc, u64 want_tid)
 		req = nextreq;
 	}
 	mutex_unlock(&mdsc->mutex);
-	dout("wait_unsafe_requests done\n");
+	ceph_put_mds_session(last_session);
+	dout("%s done\n", __func__);
 }
 
 void ceph_mdsc_sync(struct ceph_mds_client *mdsc)
@@ -5164,7 +5179,7 @@ void ceph_mdsc_sync(struct ceph_mds_client *mdsc)
 	dout("sync want tid %lld flush_seq %lld\n",
 	     want_tid, want_flush);
 
-	wait_unsafe_requests(mdsc, want_tid);
+	flush_mdlog_and_wait_mdsc_unsafe_requests(mdsc, want_tid);
 	wait_caps_flush(mdsc, want_flush);
 }
 
-- 
2.36.0.rc1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v3 0/2] ceph: flush the mdlog for filesystem sync
  2022-04-18 13:02 [PATCH v3 0/2] ceph: flush the mdlog for filesystem sync Xiubo Li
  2022-04-18 13:02 ` [PATCH v3 1/2] ceph: rename unsafe_request_wait() Xiubo Li
  2022-04-18 13:02 ` [PATCH v3 2/2] ceph: flush the mdlog for filesystem sync Xiubo Li
@ 2022-04-18 13:09 ` Jeff Layton
  2 siblings, 0 replies; 4+ messages in thread
From: Jeff Layton @ 2022-04-18 13:09 UTC (permalink / raw)
  To: Xiubo Li; +Cc: idryomov, vshankar, ceph-devel

On Mon, 2022-04-18 at 21:02 +0800, Xiubo Li wrote:
> V2:
> - unsafe_request_wait() --> flush_mdlog_and_wait_inode_unsafe_requests()
> - wait_unsafe_requests() -> flush_mdlog_and_wait_inode_unsafe_requests()
> 
> 
> Xiubo Li (2):
>   ceph: rename unsafe_request_wait()
>   ceph: flush the mdlog for filesystem sync
> 
>  fs/ceph/caps.c       |  8 ++++----
>  fs/ceph/mds_client.c | 27 +++++++++++++++++++++------
>  2 files changed, 25 insertions(+), 10 deletions(-)
> 

Reviewed-by: Jeff Layton <jlayton@kernel.org>

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-04-18 14:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-18 13:02 [PATCH v3 0/2] ceph: flush the mdlog for filesystem sync Xiubo Li
2022-04-18 13:02 ` [PATCH v3 1/2] ceph: rename unsafe_request_wait() Xiubo Li
2022-04-18 13:02 ` [PATCH v3 2/2] ceph: flush the mdlog for filesystem sync Xiubo Li
2022-04-18 13:09 ` [PATCH v3 0/2] " Jeff Layton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.