aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c27
1 files changed, 20 insertions, 7 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index ee73efe75423..62d49705d140 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -28,6 +28,7 @@
28#include "volumes.h" 28#include "volumes.h"
29#include "locking.h" 29#include "locking.h"
30#include "ref-cache.h" 30#include "ref-cache.h"
31#include "compat.h"
31 32
32#define PENDING_EXTENT_INSERT 0 33#define PENDING_EXTENT_INSERT 0
33#define PENDING_EXTENT_DELETE 1 34#define PENDING_EXTENT_DELETE 1
@@ -899,6 +900,17 @@ static int noinline remove_extent_backref(struct btrfs_trans_handle *trans,
899 return ret; 900 return ret;
900} 901}
901 902
903static void btrfs_issue_discard(struct block_device *bdev,
904 u64 start, u64 len)
905{
906#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28)
907 blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL);
908#else
909 blkdev_issue_discard(bdev, start >> 9, len >> 9);
910#endif
911}
912
913
902static int noinline free_extents(struct btrfs_trans_handle *trans, 914static int noinline free_extents(struct btrfs_trans_handle *trans,
903 struct btrfs_root *extent_root, 915 struct btrfs_root *extent_root,
904 struct list_head *del_list) 916 struct list_head *del_list)
@@ -1108,6 +1120,7 @@ search:
1108 BUG_ON(ret); 1120 BUG_ON(ret);
1109 1121
1110#ifdef BIO_RW_DISCARD 1122#ifdef BIO_RW_DISCARD
1123 map_length = tmp->num_bytes;
1111 ret = btrfs_map_block(&info->mapping_tree, READ, 1124 ret = btrfs_map_block(&info->mapping_tree, READ,
1112 tmp->bytenr, &map_length, &multi, 1125 tmp->bytenr, &map_length, &multi,
1113 0); 1126 0);
@@ -1115,16 +1128,16 @@ search:
1115 struct btrfs_bio_stripe *stripe; 1128 struct btrfs_bio_stripe *stripe;
1116 int i; 1129 int i;
1117 1130
1118 stripe = multi->stripe; 1131 stripe = multi->stripes;
1119 1132
1120 if (map_length > tmp->num_bytes) 1133 if (map_length > tmp->num_bytes)
1121 map_length = tmp->num_bytes; 1134 map_length = tmp->num_bytes;
1122 1135
1123 for (i = 0; i < multi->num_stripes; 1136 for (i = 0; i < multi->num_stripes;
1124 i++, stripe++) 1137 i++, stripe++)
1125 blkdev_issue_discard(stripe->dev->bdev, 1138 btrfs_issue_discard(stripe->dev->bdev,
1126 stripe->physical >> 9, 1139 stripe->physical,
1127 map_length >> 9); 1140 map_length);
1128 kfree(multi); 1141 kfree(multi);
1129 } 1142 }
1130#endif 1143#endif
@@ -2498,9 +2511,9 @@ static int __free_extent(struct btrfs_trans_handle *trans,
2498 map_length = num_bytes; 2511 map_length = num_bytes;
2499 2512
2500 for (i = 0; i < multi->num_stripes; i++, stripe++) { 2513 for (i = 0; i < multi->num_stripes; i++, stripe++) {
2501 blkdev_issue_discard(stripe->dev->bdev, 2514 btrfs_issue_discard(stripe->dev->bdev,
2502 stripe->physical >> 9, 2515 stripe->physical,
2503 map_length >> 9); 2516 map_length);
2504 } 2517 }
2505 kfree(multi); 2518 kfree(multi);
2506 } 2519 }