diff options
author | Jeff Mahoney <jeffm@suse.com> | 2015-06-15 09:41:14 -0400 |
---|---|---|
committer | Chris Mason <clm@fb.com> | 2015-07-29 08:15:22 -0700 |
commit | d04c6b88320debb403bff8d8b634a1efa48b8d3d (patch) | |
tree | 31dbc36b458bfbeb7d640b0a2a183d4057699df4 /fs | |
parent | 00d80e342c0f4f1990ab69f594ee1e2348e51dd9 (diff) | |
download | linux-d04c6b88320debb403bff8d8b634a1efa48b8d3d.tar.gz linux-d04c6b88320debb403bff8d8b634a1efa48b8d3d.tar.bz2 linux-d04c6b88320debb403bff8d8b634a1efa48b8d3d.zip |
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: Jeff Mahoney <jeffm@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Tested-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Chris Mason <clm@fb.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/btrfs/extent-tree.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 07204bf601ed..16655bb5f293 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c @@ -1883,10 +1883,17 @@ static int remove_extent_backref(struct btrfs_trans_handle *trans, return ret; } -static int btrfs_issue_discard(struct block_device *bdev, - u64 start, u64 len) +static int btrfs_issue_discard(struct block_device *bdev, 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, @@ -1907,14 +1914,16 @@ int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr, for (i = 0; i < bbio->num_stripes; i++, stripe++) { + u64 bytes; if (!stripe->dev->can_discard) continue; ret = btrfs_issue_discard(stripe->dev->bdev, stripe->physical, - stripe->length); + stripe->length, + &bytes); if (!ret) - discarded_bytes += stripe->length; + discarded_bytes += bytes; else if (ret != -EOPNOTSUPP) break; /* Logic errors or -ENOMEM, or -EIO but I don't know how that could happen JDM */ |