Skip to content

Commit 631ed4b

Browse files
jtlaytonidryomov
authored andcommitted
ceph: shut down mount on bad mdsmap or fsmap decode
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 <[email protected]> Acked-by: Greg Farnum <[email protected]> Signed-off-by: Ilya Dryomov <[email protected]>
1 parent 0e24421 commit 631ed4b

File tree

3 files changed

+6
-3
lines changed

3 files changed

+6
-3
lines changed

fs/ceph/mds_client.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4983,7 +4983,8 @@ void ceph_mdsc_handle_fsmap(struct ceph_mds_client *mdsc, struct ceph_msg *msg)
49834983
return;
49844984

49854985
bad:
4986-
pr_err("error decoding fsmap\n");
4986+
pr_err("error decoding fsmap %d. Shutting down mount.\n", err);
4987+
ceph_umount_begin(mdsc->fsc->sb);
49874988
err_out:
49884989
mutex_lock(&mdsc->mutex);
49894990
mdsc->mdsmap_err = err;
@@ -5050,7 +5051,8 @@ void ceph_mdsc_handle_mdsmap(struct ceph_mds_client *mdsc, struct ceph_msg *msg)
50505051
bad_unlock:
50515052
mutex_unlock(&mdsc->mutex);
50525053
bad:
5053-
pr_err("error decoding mdsmap %d\n", err);
5054+
pr_err("error decoding mdsmap %d. Shutting down mount.\n", err);
5055+
ceph_umount_begin(mdsc->fsc->sb);
50545056
return;
50555057
}
50565058

fs/ceph/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -842,7 +842,7 @@ static void __ceph_umount_begin(struct ceph_fs_client *fsc)
842842
* ceph_umount_begin - initiate forced umount. Tear down the
843843
* mount, skipping steps that may hang while waiting for server(s).
844844
*/
845-
static void ceph_umount_begin(struct super_block *sb)
845+
void ceph_umount_begin(struct super_block *sb)
846846
{
847847
struct ceph_fs_client *fsc = ceph_sb_to_client(sb);
848848

fs/ceph/super.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -941,6 +941,7 @@ extern void ceph_put_snapid_map(struct ceph_mds_client* mdsc,
941941
struct ceph_snapid_map *sm);
942942
extern void ceph_trim_snapid_map(struct ceph_mds_client *mdsc);
943943
extern void ceph_cleanup_snapid_map(struct ceph_mds_client *mdsc);
944+
void ceph_umount_begin(struct super_block *sb);
944945

945946

946947
/*

0 commit comments

Comments
 (0)