From: Xiubo Li Date: Tue, 22 Feb 2022 03:46:44 +0000 (+0800) Subject: client: do not release the global snaprealm until unmounting X-Git-Tag: v18.0.0~1051^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=51171365839373d5ee4fb6fb8fbba2a471c5bc8f;p=ceph.git client: do not release the global snaprealm until unmounting The global snaprealm would be created and then destroyed immediately every time when updating it. Fixes: https://tracker.ceph.com/issues/54362 Signed-off-by: Xiubo Li --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 806293aad8271..8434380fe8ef5 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -4907,10 +4907,20 @@ void Client::invalidate_snaprealm_and_children(SnapRealm *realm) SnapRealm *Client::get_snap_realm(inodeno_t r) { SnapRealm *realm = snap_realms[r]; - if (!realm) + + ldout(cct, 20) << __func__ << " " << r << " " << realm << ", nref was " + << (realm ? realm->nref : 0) << dendl; + if (!realm) { snap_realms[r] = realm = new SnapRealm(r); - ldout(cct, 20) << __func__ << " " << r << " " << realm << " " << realm->nref << " -> " << (realm->nref + 1) << dendl; + + // Do not release the global snaprealm until unmounting. + if (r == CEPH_INO_GLOBAL_SNAPREALM) + realm->nref++; + } + realm->nref++; + ldout(cct, 20) << __func__ << " " << r << " " << realm << ", nref now is " + << realm->nref << dendl; return realm; } @@ -6598,6 +6608,13 @@ void Client::_unmount(bool abort) _close_sessions(); + // release the global snapshot realm + SnapRealm *global_realm = snap_realms[CEPH_INO_GLOBAL_SNAPREALM]; + if (global_realm) { + ceph_assert(global_realm->nref == 1); + put_snap_realm(global_realm); + } + mref_writer.update_state(CLIENT_UNMOUNTED); ldout(cct, 2) << "unmounted." << dendl;