20 #include <linux/raid/md_u.h>
22 #include <linux/module.h>
23 #include <linux/slab.h>
52 return conf->
disks + lo;
64 struct bvec_merge_data *bvm,
65 struct bio_vec *biovec)
67 struct mddev *mddev = q->queuedata;
69 unsigned long maxsectors, bio_sectors = bvm->bi_size >> 9;
70 sector_t sector = bvm->bi_sector + get_start_sect(bvm->bi_bdev);
71 int maxbytes = biovec->bv_len;
75 dev0 = which_dev(mddev, sector);
77 subq = bdev_get_queue(dev0->
rdev->bdev);
78 if (subq->merge_bvec_fn) {
79 bvm->bi_bdev = dev0->
rdev->bdev;
81 maxbytes =
min(maxbytes, subq->merge_bvec_fn(subq, bvm,
86 if (maxsectors < bio_sectors)
89 maxsectors -= bio_sectors;
91 if (maxsectors <= (
PAGE_SIZE >> 9 ) && bio_sectors == 0)
94 if (maxsectors > (maxbytes >> 9))
97 return maxsectors << 9;
100 static int linear_congested(
void *
data,
int bits)
102 struct mddev *mddev =
data;
114 ret |= bdi_congested(&q->backing_dev_info, bits);
129 "%s does not support generic reshape\n", __func__);
141 bool discard_supported =
false;
143 conf = kzalloc (
sizeof (*conf) + raid_disks*
sizeof(
struct dev_info),
156 if (j < 0 || j >= raid_disks || disk->
rdev) {
157 printk(
KERN_ERR "md/linear:%s: disk numbering problem. Aborting!\n",
175 if (blk_queue_discard(bdev_get_queue(rdev->
bdev)))
176 discard_supported =
true;
178 if (cnt != raid_disks) {
179 printk(
KERN_ERR "md/linear:%s: not enough drives present. Aborting!\n",
184 if (!discard_supported)
185 queue_flag_clear_unlocked(QUEUE_FLAG_DISCARD, mddev->
queue);
187 queue_flag_set_unlocked(QUEUE_FLAG_DISCARD, mddev->
queue);
192 conf->
disks[0].end_sector = conf->
disks[0].rdev->sectors;
194 for (i = 1; i < raid_disks; i++)
195 conf->
disks[i].end_sector =
196 conf->
disks[i-1].end_sector +
197 conf->
disks[i].rdev->sectors;
206 static int linear_run (
struct mddev *mddev)
221 mddev->
queue->backing_dev_info.congested_fn = linear_congested;
222 mddev->
queue->backing_dev_info.congested_data = mddev;
232 static int linear_add(
struct mddev *mddev,
struct md_rdev *rdev)
267 static int linear_stop (
struct mddev *mddev)
289 static void linear_make_request(
struct mddev *mddev,
struct bio *bio)
300 tmp_dev = which_dev(mddev, bio->bi_sector);
305 || (bio->bi_sector < start_sector))) {
309 "md/linear:%s: make_request: Sector %llu out of bounds on "
310 "dev %s: %llu sectors, offset %llu\n",
312 (
unsigned long long)bio->bi_sector,
314 (
unsigned long long)tmp_dev->
rdev->sectors,
315 (
unsigned long long)start_sector);
320 if (
unlikely(bio->bi_sector + (bio->bi_size >> 9) >
330 bp =
bio_split(bio, end_sector - bio->bi_sector);
332 linear_make_request(mddev, &bp->bio1);
333 linear_make_request(mddev, &bp->bio2);
338 bio->bi_bdev = tmp_dev->
rdev->bdev;
339 bio->bi_sector = bio->bi_sector - start_sector
340 + tmp_dev->
rdev->data_offset;
344 !blk_queue_discard(bdev_get_queue(bio->bi_bdev)))) {
353 static void linear_status (
struct seq_file *seq,
struct mddev *mddev)
365 .make_request = linear_make_request,
368 .status = linear_status,
369 .hot_add_disk = linear_add,
373 static int __init linear_init (
void)
378 static void linear_exit (
void)