btrfs-progs: check if device supports trim
The message about trim was printed unconditionally, we should check if trim is supported at all. Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: David Sterba <dsterba@suse.cz> Signed-off-by: Chris Mason <chris.mason@fusionio.com>
This commit is contained in:
parent
b5efa4c3c9
commit
25d82d2229
11
utils.c
11
utils.c
|
@ -597,14 +597,17 @@ int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret,
|
|||
}
|
||||
|
||||
if (discard) {
|
||||
/*
|
||||
* We intentionally ignore errors from the discard ioctl. It
|
||||
* is not necessary for the mkfs functionality but just an
|
||||
* optimization.
|
||||
*/
|
||||
if (discard_blocks(fd, 0, 0) == 0) {
|
||||
fprintf(stderr, "Performing full device TRIM (%s) ...\n",
|
||||
pretty_size(block_count));
|
||||
/*
|
||||
* We intentionally ignore errors from the discard ioctl. It is
|
||||
* not necessary for the mkfs functionality but just an optimization.
|
||||
*/
|
||||
discard_blocks(fd, 0, block_count);
|
||||
}
|
||||
}
|
||||
|
||||
ret = zero_dev_start(fd);
|
||||
if (ret) {
|
||||
|
|
Loading…
Reference in New Issue