aboutsummaryrefslogtreecommitdiff
path: root/fs/bcachefs/super.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2020-09-06 22:58:28 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:08:44 -0400
commit625104ea21386361b60d20ae696b9df6111236f5 (patch)
treed08f2aa05d7a501a6a5ce6365ea8e4978d5936b5 /fs/bcachefs/super.c
parentca73852a1341534e2bf00cfbdc853bb3b1095af8 (diff)
bcachefs: Don't fail mount if device has been removed
Also - make sure to show the devices we actually have open in /proc Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/super.c')
-rw-r--r--fs/bcachefs/super.c16
1 files changed, 14 insertions, 2 deletions
diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c
index 7377f44f15df..cb2b719165ce 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -1790,7 +1790,6 @@ err:
/* return with ref on ca->ref: */
struct bch_dev *bch2_dev_lookup(struct bch_fs *c, const char *path)
{
-
struct bch_dev *ca;
dev_t dev;
unsigned i;
@@ -1816,6 +1815,7 @@ struct bch_fs *bch2_fs_open(char * const *devices, unsigned nr_devices,
{
struct bch_sb_handle *sb = NULL;
struct bch_fs *c = NULL;
+ struct bch_sb_field_members *mi;
unsigned i, best_sb = 0;
const char *err;
int ret = -ENOMEM;
@@ -1851,10 +1851,22 @@ struct bch_fs *bch2_fs_open(char * const *devices, unsigned nr_devices,
le64_to_cpu(sb[best_sb].sb->seq))
best_sb = i;
- for (i = 0; i < nr_devices; i++) {
+ mi = bch2_sb_get_members(sb[best_sb].sb);
+
+ i = 0;
+ while (i < nr_devices) {
+ if (i != best_sb &&
+ !bch2_dev_exists(sb[best_sb].sb, mi, sb[i].sb->dev_idx)) {
+ pr_info("%pg has been removed, skipping", sb[i].bdev);
+ bch2_free_super(&sb[i]);
+ array_remove_item(sb, nr_devices, i);
+ continue;
+ }
+
err = bch2_dev_in_fs(sb[best_sb].sb, sb[i].sb);
if (err)
goto err_print;
+ i++;
}
ret = -ENOMEM;