btrfs-progs: replace start: add option -K/--nodiscard
The commands initializing a new device (mkfs, device add) do discard by default, while this is missing from replace start. For parity add the options with same name and semantics. Issue: #390 Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
c50c448518
commit
2d50b98189
|
@ -55,6 +55,10 @@ never allowed to be used as the <targetdev>.
|
|||
no background replace.
|
||||
--enqueue::::
|
||||
wait if there's another exclusive operation running, otherwise continue
|
||||
-K|--nodiscard::::
|
||||
Do not perform whole device TRIM operation on devices that are capable of that.
|
||||
This does not affect discard/trim operation when the filesystem is mounted.
|
||||
Please see the mount option 'discard' for that in `btrfs`(5).
|
||||
|
||||
*status* [-1] <mount_point>::
|
||||
Print status and progress information of a running device replace operation.
|
||||
|
|
|
@ -116,6 +116,7 @@ static const char *const cmd_replace_start_usage[] = {
|
|||
"-B do not background",
|
||||
"--enqueue wait if there's another exclusive operation running,",
|
||||
" otherwise continue",
|
||||
"-K|--nodiscard do not perform whole device TRIM",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -141,6 +142,7 @@ static int cmd_replace_start(const struct cmd_struct *cmd,
|
|||
u64 srcdev_size;
|
||||
u64 dstdev_size;
|
||||
bool enqueue = false;
|
||||
bool discard = true;
|
||||
|
||||
optind = 0;
|
||||
while (1) {
|
||||
|
@ -148,16 +150,20 @@ static int cmd_replace_start(const struct cmd_struct *cmd,
|
|||
enum { GETOPT_VAL_ENQUEUE = 256 };
|
||||
static const struct option long_options[] = {
|
||||
{ "enqueue", no_argument, NULL, GETOPT_VAL_ENQUEUE},
|
||||
{ "nodiscard", no_argument, NULL, 'K' },
|
||||
{ NULL, 0, NULL, 0}
|
||||
};
|
||||
|
||||
c = getopt_long(argc, argv, "Brf", long_options, NULL);
|
||||
c = getopt_long(argc, argv, "BKrf", long_options, NULL);
|
||||
if (c < 0)
|
||||
break;
|
||||
switch (c) {
|
||||
case 'B':
|
||||
do_not_background = 1;
|
||||
break;
|
||||
case 'K':
|
||||
discard = false;
|
||||
break;
|
||||
case 'r':
|
||||
avoid_reading_from_srcdev = 1;
|
||||
break;
|
||||
|
@ -297,6 +303,7 @@ static int cmd_replace_start(const struct cmd_struct *cmd,
|
|||
BTRFS_DEVICE_PATH_NAME_MAX);
|
||||
ret = btrfs_prepare_device(fddstdev, dstdev, &dstdev_block_count, 0,
|
||||
PREP_DEVICE_ZERO_END | PREP_DEVICE_VERBOSE |
|
||||
(discard ? PREP_DEVICE_DISCARD : 0) |
|
||||
(zoned ? PREP_DEVICE_ZONED : 0));
|
||||
if (ret)
|
||||
goto leave_with_error;
|
||||
|
|
Loading…
Reference in New Issue