mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2025-01-21 05:14:52 +08:00
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>
This commit is contained in:
parent
ca73852a13
commit
625104ea21
@ -1428,6 +1428,24 @@ static int bch2_remount(struct super_block *sb, int *flags, char *data)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int bch2_show_devname(struct seq_file *seq, struct dentry *root)
|
||||
{
|
||||
struct bch_fs *c = root->d_sb->s_fs_info;
|
||||
struct bch_dev *ca;
|
||||
unsigned i;
|
||||
bool first = true;
|
||||
|
||||
for_each_online_member(ca, c, i) {
|
||||
if (!first)
|
||||
seq_putc(seq, ':');
|
||||
first = false;
|
||||
seq_puts(seq, "/dev/");
|
||||
seq_puts(seq, ca->name);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int bch2_show_options(struct seq_file *seq, struct dentry *root)
|
||||
{
|
||||
struct bch_fs *c = root->d_sb->s_fs_info;
|
||||
@ -1451,7 +1469,6 @@ static int bch2_show_options(struct seq_file *seq, struct dentry *root)
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
static const struct super_operations bch_super_operations = {
|
||||
@ -1461,6 +1478,7 @@ static const struct super_operations bch_super_operations = {
|
||||
.evict_inode = bch2_evict_inode,
|
||||
.sync_fs = bch2_sync_fs,
|
||||
.statfs = bch2_statfs,
|
||||
.show_devname = bch2_show_devname,
|
||||
.show_options = bch2_show_options,
|
||||
.remount_fs = bch2_remount,
|
||||
#if 0
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user