diff options
author | David Sterba <dsterba@suse.cz> | 2012-07-06 10:11:10 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@fusionio.com> | 2012-07-06 10:11:10 -0400 |
commit | 8935d8436147f86dfbda3d8b8175a77b654b8abc (patch) | |
tree | 2ea7925246a070d8a3aa0c8e45cba9252c9ade8a /utils.c | |
parent | 134adafea227e35bdb14fd7563226170a9bfe10c (diff) |
btrfs-progs: mkfs: add option to skip trim
Signed-off-by: Chris Mason <chris.mason@fusionio.com>
Diffstat (limited to 'utils.c')
-rw-r--r-- | utils.c | 18 |
1 files changed, 13 insertions, 5 deletions
@@ -539,6 +539,12 @@ int btrfs_add_to_fsid(struct btrfs_trans_handle *trans, int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret, int *mixed) { + /* discard by default when called from 'device add' */ + return __btrfs_prepare_device(fd, file, zero_end, block_count_ret, mixed, 0); +} +int __btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret, + int *mixed, int nodiscard) +{ u64 block_count; u64 bytenr; struct stat st; @@ -564,11 +570,13 @@ int btrfs_prepare_device(int fd, char *file, int zero_end, u64 *block_count_ret, *mixed = 1; } - /* - * 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); + if (!nodiscard) { + /* + * 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) { |