Commit d04c6b88 authored by Jeff Mahoney's avatar Jeff Mahoney Committed by Chris Mason

btrfs: make btrfs_issue_discard return bytes discarded

Initially this will just be the length argument passed to it,
but the following patches will adjust that to reflect re-alignment
and skipped blocks.
Signed-off-by: default avatarJeff Mahoney <jeffm@suse.com>
Reviewed-by: default avatarFilipe Manana <fdmanana@suse.com>
Tested-by: default avatarFilipe Manana <fdmanana@suse.com>
Signed-off-by: default avatarChris Mason <clm@fb.com>
parent 00d80e34
...@@ -1883,10 +1883,17 @@ static int remove_extent_backref(struct btrfs_trans_handle *trans, ...@@ -1883,10 +1883,17 @@ static int remove_extent_backref(struct btrfs_trans_handle *trans,
return ret; return ret;
} }
static int btrfs_issue_discard(struct block_device *bdev, static int btrfs_issue_discard(struct block_device *bdev, u64 start, u64 len,
u64 start, u64 len) u64 *discarded_bytes)
{ {
return blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_NOFS, 0); int ret = 0;
*discarded_bytes = 0;
ret = blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_NOFS, 0);
if (!ret)
*discarded_bytes = len;
return ret;
} }
int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr, int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr,
...@@ -1907,14 +1914,16 @@ int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr, ...@@ -1907,14 +1914,16 @@ int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr,
for (i = 0; i < bbio->num_stripes; i++, stripe++) { for (i = 0; i < bbio->num_stripes; i++, stripe++) {
u64 bytes;
if (!stripe->dev->can_discard) if (!stripe->dev->can_discard)
continue; continue;
ret = btrfs_issue_discard(stripe->dev->bdev, ret = btrfs_issue_discard(stripe->dev->bdev,
stripe->physical, stripe->physical,
stripe->length); stripe->length,
&bytes);
if (!ret) if (!ret)
discarded_bytes += stripe->length; discarded_bytes += bytes;
else if (ret != -EOPNOTSUPP) else if (ret != -EOPNOTSUPP)
break; /* Logic errors or -ENOMEM, or -EIO but I don't know how that could happen JDM */ break; /* Logic errors or -ENOMEM, or -EIO but I don't know how that could happen JDM */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment