Skip to content

Commit d04c6b8

Browse files
jeffmahoneymasoncl
authored andcommitted
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 <[email protected]> Reviewed-by: Filipe Manana <[email protected]> Tested-by: Filipe Manana <[email protected]> Signed-off-by: Chris Mason <[email protected]>
1 parent 00d80e3 commit d04c6b8

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

fs/btrfs/extent-tree.c

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1883,10 +1883,17 @@ static int remove_extent_backref(struct btrfs_trans_handle *trans,
18831883
return ret;
18841884
}
18851885

1886-
static int btrfs_issue_discard(struct block_device *bdev,
1887-
u64 start, u64 len)
1886+
static int btrfs_issue_discard(struct block_device *bdev, u64 start, u64 len,
1887+
u64 *discarded_bytes)
18881888
{
1889-
return blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_NOFS, 0);
1889+
int ret = 0;
1890+
1891+
*discarded_bytes = 0;
1892+
ret = blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_NOFS, 0);
1893+
if (!ret)
1894+
*discarded_bytes = len;
1895+
1896+
return ret;
18901897
}
18911898

18921899
int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr,
@@ -1907,14 +1914,16 @@ int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr,
19071914

19081915

19091916
for (i = 0; i < bbio->num_stripes; i++, stripe++) {
1917+
u64 bytes;
19101918
if (!stripe->dev->can_discard)
19111919
continue;
19121920

19131921
ret = btrfs_issue_discard(stripe->dev->bdev,
19141922
stripe->physical,
1915-
stripe->length);
1923+
stripe->length,
1924+
&bytes);
19161925
if (!ret)
1917-
discarded_bytes += stripe->length;
1926+
discarded_bytes += bytes;
19181927
else if (ret != -EOPNOTSUPP)
19191928
break; /* Logic errors or -ENOMEM, or -EIO but I don't know how that could happen JDM */
19201929

0 commit comments

Comments
 (0)