ceph: shut down mount on bad mdsmap or fsmap decode
authorJeff Layton <jlayton@kernel.org>
Thu, 14 Oct 2021 15:10:47 +0000 (11:10 -0400)
committerIlya Dryomov <idryomov@gmail.com>
Mon, 8 Nov 2021 02:29:52 +0000 (03:29 +0100)
As Greg pointed out, if we get a mangled mdsmap or fsmap, then something
has gone very wrong, and we should avoid doing any activity on the
filesystem.

When this occurs, shut down the mount the same way we would with a
forced umount by calling ceph_umount_begin when decoding fails on either
map. This causes most operations done against the filesystem to return
an error. Any dirty data or caps in the cache will be dropped as well.

The effect is not reversible, so the only remedy is to umount.

[ idryomov: print fsmap decoding error ]

URL: https://tracker.ceph.com/issues/52303
Signed-off-by: Jeff Layton <jlayton@kernel.org>
Acked-by: Greg Farnum <gfarnum@redhat.com>
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
fs/ceph/mds_client.c
fs/ceph/super.c
fs/ceph/super.h

index 522790c64db4cc8544a40b4c8728b070a9f8b9c8..250aad330a1062a5cbfef584f8c60819ffb5a929 100644 (file)
@@ -4983,7 +4983,8 @@ void ceph_mdsc_handle_fsmap(struct ceph_mds_client *mdsc, struct ceph_msg *msg)
        return;
 
 bad:
-       pr_err("error decoding fsmap\n");
+       pr_err("error decoding fsmap %d. Shutting down mount.\n", err);
+       ceph_umount_begin(mdsc->fsc->sb);
 err_out:
        mutex_lock(&mdsc->mutex);
        mdsc->mdsmap_err = err;
@@ -5050,7 +5051,8 @@ void ceph_mdsc_handle_mdsmap(struct ceph_mds_client *mdsc, struct ceph_msg *msg)
 bad_unlock:
        mutex_unlock(&mdsc->mutex);
 bad:
-       pr_err("error decoding mdsmap %d\n", err);
+       pr_err("error decoding mdsmap %d. Shutting down mount.\n", err);
+       ceph_umount_begin(mdsc->fsc->sb);
        return;
 }
 
index 5fe4d9f102e82890271082b346940206f9a3cdfb..f6cbbfcdf66d076e87449b9a1c207f6ece433782 100644 (file)
@@ -842,7 +842,7 @@ static void __ceph_umount_begin(struct ceph_fs_client *fsc)
  * ceph_umount_begin - initiate forced umount.  Tear down the
  * mount, skipping steps that may hang while waiting for server(s).
  */
-static void ceph_umount_begin(struct super_block *sb)
+void ceph_umount_begin(struct super_block *sb)
 {
        struct ceph_fs_client *fsc = ceph_sb_to_client(sb);
 
index 5c911586593d8e99c6a82fd980c6f246f682e5dd..93d313294ade8e358fbd5a1859e5ee8f0a794f5e 100644 (file)
@@ -941,6 +941,7 @@ extern void ceph_put_snapid_map(struct ceph_mds_client* mdsc,
                                struct ceph_snapid_map *sm);
 extern void ceph_trim_snapid_map(struct ceph_mds_client *mdsc);
 extern void ceph_cleanup_snapid_map(struct ceph_mds_client *mdsc);
+void ceph_umount_begin(struct super_block *sb);
 
 
 /*