From: xiubli@redhat.com
To: jlayton@kernel.org
Cc: idryomov@gmail.com, vshankar@redhat.com,
ceph-devel@vger.kernel.org, Xiubo Li <xiubli@redhat.com>
Subject: [PATCH 3/3] ceph: do no update snapshot context when there is no new snapshot
Date: Tue, 15 Feb 2022 20:23:16 +0800 [thread overview]
Message-ID: <20220215122316.7625-4-xiubli@redhat.com> (raw)
In-Reply-To: <20220215122316.7625-1-xiubli@redhat.com>
From: Xiubo Li <xiubli@redhat.com>
No need to update snapshot context when any of the following two
cases happens:
1: if my context seq matches realm's seq and realm has no parent.
2: if my context seq equals or is larger than my parent's, this
works because we rebuild_snap_realms() works _downward_ in
hierarchy after each update.
This fix will avoid those inodes which accidently calling
ceph_queue_cap_snap() and make no sense, for exmaple:
There have 6 directories like:
/dir_X1/dir_X2/dir_X3/
/dir_Y1/dir_Y2/dir_Y3/
Firstly, make a snapshot under /dir_X1/dir_X2/.snap/snap_X2, then
make a root snapshot under /.snap/root_snap. And every time when
we make snapshots under /dir_Y1/..., the kclient will always try
to rebuild the snap context for snap_X2 realm and finally will
always try to queue cap snaps for dir_Y2 and dir_Y3, which makes
no sense.
That's because the snap_X2's seq is 2 and root_snap's seq is 3.
So when creating a new snapshot under /dir_Y1/... the new seq
will be 4, and then the mds will send kclient a snapshot backtrace
in _downward_ in hierarchy: seqs 4, 3. Then in ceph_update_snap_trace()
it will always rebuild the from the last realm, that's the root_snap.
So later when rebuilding the snap context it will always rebuild
the snap_X2 realm and then try to queue cap snaps for all the inodes
related in snap_X2 realm, and we are seeing the logs like:
"ceph: queue_cap_snap 00000000a42b796b nothing dirty|writing"
URL: https://tracker.ceph.com/issues/44100
Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
fs/ceph/snap.c | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/fs/ceph/snap.c b/fs/ceph/snap.c
index d075d3ce5f6d..1f24a5de81e7 100644
--- a/fs/ceph/snap.c
+++ b/fs/ceph/snap.c
@@ -341,14 +341,16 @@ static int build_snap_context(struct ceph_snap_realm *realm,
num += parent->cached_context->num_snaps;
}
- /* do i actually need to update? not if my context seq
- matches realm seq, and my parents' does to. (this works
- because we rebuild_snap_realms() works _downward_ in
- hierarchy after each update.) */
+ /* do i actually need to update? No need when any of the following
+ * two cases:
+ * #1: if my context seq matches realm's seq and realm has no parent.
+ * #2: if my context seq equals or is larger than my parent's, this
+ * works because we rebuild_snap_realms() works _downward_ in
+ * hierarchy after each update.
+ */
if (realm->cached_context &&
- realm->cached_context->seq == realm->seq &&
- (!parent ||
- realm->cached_context->seq >= parent->cached_context->seq)) {
+ ((realm->cached_context->seq == realm->seq && !parent) ||
+ (parent && realm->cached_context->seq >= parent->cached_context->seq))) {
dout("build_snap_context %llx %p: %p seq %lld (%u snaps)"
" (unchanged)\n",
realm->ino, realm, realm->cached_context,
--
2.27.0
next prev parent reply other threads:[~2022-02-15 12:23 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-02-15 12:23 [PATCH 0/3] ceph: fix cephfs rsync kworker high load issue xiubli
2022-02-15 12:23 ` [PATCH 1/3] ceph: move to a dedicated slabcache for ceph_cap_snap xiubli
2022-02-15 15:29 ` Jeff Layton
2022-02-16 14:58 ` Jeff Layton
2022-02-17 0:54 ` Xiubo Li
2022-02-18 18:11 ` Luís Henriques
2022-02-18 18:56 ` Jeff Layton
2022-02-15 12:23 ` [PATCH 2/3] ceph: move kzalloc under i_ceph_lock with GFP_ATOMIC flag xiubli
2022-02-15 16:57 ` Jeff Layton
2022-02-16 0:29 ` Xiubo Li
2022-02-15 12:23 ` xiubli [this message]
2022-02-15 17:05 ` [PATCH 3/3] ceph: do no update snapshot context when there is no new snapshot Jeff Layton
2022-02-16 0:30 ` Xiubo Li
2022-02-15 18:35 ` Jeff Layton
2022-02-16 0:36 ` Xiubo Li
2022-02-17 3:03 ` Yan, Zheng
2022-02-17 10:55 ` Jeff Layton
2022-02-17 15:28 ` Yan, Zheng
2022-02-18 1:46 ` Xiubo Li
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=20220215122316.7625-4-xiubli@redhat.com \
--to=xiubli@redhat.com \
--cc=ceph-devel@vger.kernel.org \
--cc=idryomov@gmail.com \
--cc=jlayton@kernel.org \
--cc=vshankar@redhat.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