diff options
author | Shaohua Li <shli@fusionio.com> | 2012-10-10 22:08:44 -0400 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2012-10-10 22:08:44 -0400 |
commit | f1cad2b68ed12c0f82d3f56e150691f62b6f5edf (patch) | |
tree | 4c0cd9e8f502576db6a87dec86d24fccf5b3b2e4 /drivers/md | |
parent | bc78c57388e7f447f58e30d60b1505ddaaaf3a7d (diff) |
md: linear supports TRIM
This makes md linear support TRIM.
Signed-off-by: Shaohua Li <shli@fusionio.com>
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/linear.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/md/linear.c b/drivers/md/linear.c index 92c64d162a92..21014836bdbf 100644 --- a/drivers/md/linear.c +++ b/drivers/md/linear.c | |||
@@ -138,6 +138,7 @@ static struct linear_conf *linear_conf(struct mddev *mddev, int raid_disks) | |||
138 | struct linear_conf *conf; | 138 | struct linear_conf *conf; |
139 | struct md_rdev *rdev; | 139 | struct md_rdev *rdev; |
140 | int i, cnt; | 140 | int i, cnt; |
141 | bool discard_supported = false; | ||
141 | 142 | ||
142 | conf = kzalloc (sizeof (*conf) + raid_disks*sizeof(struct dev_info), | 143 | conf = kzalloc (sizeof (*conf) + raid_disks*sizeof(struct dev_info), |
143 | GFP_KERNEL); | 144 | GFP_KERNEL); |
@@ -171,6 +172,8 @@ static struct linear_conf *linear_conf(struct mddev *mddev, int raid_disks) | |||
171 | conf->array_sectors += rdev->sectors; | 172 | conf->array_sectors += rdev->sectors; |
172 | cnt++; | 173 | cnt++; |
173 | 174 | ||
175 | if (blk_queue_discard(bdev_get_queue(rdev->bdev))) | ||
176 | discard_supported = true; | ||
174 | } | 177 | } |
175 | if (cnt != raid_disks) { | 178 | if (cnt != raid_disks) { |
176 | printk(KERN_ERR "md/linear:%s: not enough drives present. Aborting!\n", | 179 | printk(KERN_ERR "md/linear:%s: not enough drives present. Aborting!\n", |
@@ -178,6 +181,11 @@ static struct linear_conf *linear_conf(struct mddev *mddev, int raid_disks) | |||
178 | goto out; | 181 | goto out; |
179 | } | 182 | } |
180 | 183 | ||
184 | if (!discard_supported) | ||
185 | queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, mddev->queue); | ||
186 | else | ||
187 | queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, mddev->queue); | ||
188 | |||
181 | /* | 189 | /* |
182 | * Here we calculate the device offsets. | 190 | * Here we calculate the device offsets. |
183 | */ | 191 | */ |
@@ -331,6 +339,14 @@ static void linear_make_request(struct mddev *mddev, struct bio *bio) | |||
331 | bio->bi_sector = bio->bi_sector - start_sector | 339 | bio->bi_sector = bio->bi_sector - start_sector |
332 | + tmp_dev->rdev->data_offset; | 340 | + tmp_dev->rdev->data_offset; |
333 | rcu_read_unlock(); | 341 | rcu_read_unlock(); |
342 | |||
343 | if (unlikely((bio->bi_rw & REQ_DISCARD) && | ||
344 | !blk_queue_discard(bdev_get_queue(bio->bi_bdev)))) { | ||
345 | /* Just ignore it */ | ||
346 | bio_endio(bio, 0); | ||
347 | return; | ||
348 | } | ||
349 | |||
334 | generic_make_request(bio); | 350 | generic_make_request(bio); |
335 | } | 351 | } |
336 | 352 | ||