format: Do a 'udevadm trigger' after formatting
Some checks failed
build / bcachefs-tools-rpm (push) Has been cancelled
build / bcachefs-tools-deb (ubuntu-24.04) (push) Has been cancelled
build / bcachefs-tools-msrv (push) Has been cancelled
Nix Flake actions / nix-matrix (push) Has been cancelled
Nix Flake actions / ${{ matrix.name }} (${{ matrix.system }}) (push) Has been cancelled

This causes the new filesystem UUID to be picked up; without this, mount
can fail if it's a multidevice filesystem.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
Kent Overstreet 2025-09-03 16:02:11 -04:00
parent e65dd86e41
commit 31c7a7398a
2 changed files with 19 additions and 1 deletions

View File

@ -480,6 +480,14 @@ int cmd_recover_super(int argc, char *argv[])
if (args.yes || ask_yn())
bch2_super_write(dev_fd, sb);
/*
* Ensure that 'bcachefs mount' sees the newly formatted devices when
* scanning by UUID in the udev database:
*/
CLASS(printbuf, udevadm_cmd)();
prt_printf(&udevadm_cmd, "udevadm trigger --settle %s", dev_path);
system(udevadm_cmd.buf);
if (args.src_device)
printf("Recovered device will no longer have a journal, please run fsck\n");

View File

@ -205,7 +205,7 @@ struct bch_sb *bch2_format(struct bch_opt_strs fs_opt_strs,
/* calculate block size: */
if (!opt_defined(fs_opts, block_size)) {
unsigned max_dev_block_size = 0;
darray_for_each(devs, i)
max_dev_block_size = max(max_dev_block_size, get_blocksize(i->bdev->bd_fd));
@ -357,6 +357,16 @@ struct bch_sb *bch2_format(struct bch_opt_strs fs_opt_strs,
xclose(i->bdev->bd_fd);
}
/*
* Ensure that 'bcachefs mount' sees the newly formatted devices when
* scanning by UUID in the udev database:
*/
CLASS(printbuf, udevadm_cmd)();
prt_str(&udevadm_cmd, "udevadm trigger --settle");
darray_for_each(devs, i)
prt_printf(&udevadm_cmd, " %s", i->path);
system(udevadm_cmd.buf);
return sb.sb;
}