[4/4] ceph: allow remounting aborted mount
diff mbox series

Message ID 20190604093908.30491-4-zyan@redhat.com
State New
Headers show
Series
  • [1/4] libceph: add function that reset client's entity addr
Related show

Commit Message

Yan, Zheng June 4, 2019, 9:39 a.m. UTC
When remounting aborted mount, also reset client's entity addr.
'umount -f /ceph; mount -o remount /ceph' can be used for recovering
from blacklist.

Signed-off-by: "Yan, Zheng" <zyan@redhat.com>
---
 fs/ceph/mds_client.c | 14 ++++++++++++--
 fs/ceph/super.c      | 23 +++++++++++++++++++++--
 2 files changed, 33 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c
index f5c3499fdec6..eb3976a742ac 100644
--- a/fs/ceph/mds_client.c
+++ b/fs/ceph/mds_client.c
@@ -1377,7 +1377,7 @@  static int remove_session_caps_cb(struct inode *inode, struct ceph_cap *cap,
 		struct ceph_cap_flush *cf;
 		struct ceph_mds_client *mdsc = fsc->mdsc;
 
-		if (ci->i_wrbuffer_ref > 0 &&
+		if (inode->i_data.nrpages > 0 &&
 		    READ_ONCE(fsc->mount_state) == CEPH_MOUNT_SHUTDOWN)
 			invalidate = true;
 
@@ -4347,6 +4347,7 @@  void ceph_mdsc_force_umount(struct ceph_mds_client *mdsc)
 {
 	struct ceph_mds_session *session;
 	int mds;
+       LIST_HEAD(requests);
 
 	dout("force umount\n");
 
@@ -4355,7 +4356,12 @@  void ceph_mdsc_force_umount(struct ceph_mds_client *mdsc)
 		session = __ceph_lookup_mds_session(mdsc, mds);
 		if (!session)
 			continue;
+
+		list_splice_init(&session->s_waiting, &requests);
+		if (session->s_state == CEPH_MDS_SESSION_REJECTED)
+			__unregister_session(mdsc, session);
 		mutex_unlock(&mdsc->mutex);
+
 		mutex_lock(&session->s_mutex);
 		__close_session(mdsc, session);
 		if (session->s_state == CEPH_MDS_SESSION_CLOSING) {
@@ -4364,10 +4370,14 @@  void ceph_mdsc_force_umount(struct ceph_mds_client *mdsc)
 		}
 		mutex_unlock(&session->s_mutex);
 		ceph_put_mds_session(session);
+
 		mutex_lock(&mdsc->mutex);
 		kick_requests(mdsc, mds);
 	}
-	__wake_requests(mdsc, &mdsc->waiting_for_map);
+
+       list_splice_init(&mdsc->waiting_for_map, &requests);
+       __wake_requests(mdsc, &requests);
+
 	mutex_unlock(&mdsc->mutex);
 }
 
diff --git a/fs/ceph/super.c b/fs/ceph/super.c
index 67eb9d592ab7..a6a3c065f697 100644
--- a/fs/ceph/super.c
+++ b/fs/ceph/super.c
@@ -833,8 +833,27 @@  static void ceph_umount_begin(struct super_block *sb)
 
 static int ceph_remount(struct super_block *sb, int *flags, char *data)
 {
-	sync_filesystem(sb);
-	return 0;
+	struct ceph_fs_client *fsc = ceph_sb_to_client(sb);
+
+	if (fsc->mount_state != CEPH_MOUNT_SHUTDOWN) {
+		sync_filesystem(sb);
+		return 0;
+	}
+
+	/* Make sure all page caches get invalidated.
+	 * see remove_session_caps_cb() */
+	flush_workqueue(fsc->inode_wq);
+	/* In case that we were blacklisted. This also reset
+	 * all mon/osd connections */
+	ceph_reset_client_addr(fsc->client);
+
+	ceph_osdc_clear_abort_err(&fsc->client->osdc);
+	fsc->mount_state = 0;
+
+	if (!sb->s_root)
+		return 0;
+	return __ceph_do_getattr(d_inode(sb->s_root), NULL,
+				 CEPH_STAT_CAP_INODE, true);
 }
 
 static const struct super_operations ceph_super_ops = {