diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2020-04-25 16:42:09 -0400 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2020-04-25 16:42:09 -0400 |
commit | 6e9f4602408e9bcdb33bce6ab3a2d8562613d6ce (patch) | |
tree | cc5c2cfa875aa25d920d378eefd377c57d9ac3e3 /cmd_device.c | |
parent | b87ed383d3debe1462444cd78ff7bd533c99cc8d (diff) |
Set device read-only if necessary before evacuate
Diffstat (limited to 'cmd_device.c')
-rw-r--r-- | cmd_device.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/cmd_device.c b/cmd_device.c index 87ede0f6..959129a1 100644 --- a/cmd_device.c +++ b/cmd_device.c @@ -304,6 +304,13 @@ int cmd_device_evacuate(int argc, char *argv[]) unsigned dev_idx; struct bchfs_handle fs = bchu_fs_open_by_dev(dev_path, &dev_idx); + struct bch_ioctl_dev_usage u = bchu_dev_usage(fs, dev_idx); + + if (u.state == BCH_MEMBER_STATE_RW) { + printf("Setting %s readonly\n", dev_path); + bchu_disk_set_state(fs, dev_idx, BCH_MEMBER_STATE_RO, 0); + } + return bchu_data(fs, (struct bch_ioctl_data) { .op = BCH_DATA_OP_MIGRATE, .start = POS_MIN, |