8 #include <linux/module.h>
12 #include <linux/slab.h>
15 #define DM_MSG_PREFIX "linear"
28 static int linear_ctr(
struct dm_target *ti,
unsigned int argc,
char **argv)
31 unsigned long long tmp;
35 ti->
error =
"Invalid argument count";
41 ti->
error =
"dm-linear: Cannot allocate linear context";
45 if (
sscanf(argv[1],
"%llu%c", &tmp, &dummy) != 1) {
46 ti->
error =
"dm-linear: Invalid device sector";
52 ti->
error =
"dm-linear: Device lookup failed";
66 static void linear_dtr(
struct dm_target *ti)
81 static void linear_map_bio(
struct dm_target *ti,
struct bio *bio)
85 bio->bi_bdev = lc->
dev->bdev;
87 bio->bi_sector = linear_map_sector(ti, bio->bi_sector);
90 static int linear_map(
struct dm_target *ti,
struct bio *bio,
93 linear_map_bio(ti, bio);
99 unsigned status_flags,
char *
result,
unsigned maxlen)
110 (
unsigned long long)lc->
start);
116 static int linear_ioctl(
struct dm_target *ti,
unsigned int cmd,
133 static int linear_merge(
struct dm_target *ti,
struct bvec_merge_data *bvm,
134 struct bio_vec *biovec,
int max_size)
139 if (!q->merge_bvec_fn)
142 bvm->bi_bdev = lc->
dev->bdev;
143 bvm->bi_sector = linear_map_sector(ti, bvm->bi_sector);
145 return min(max_size, q->merge_bvec_fn(q, bvm, biovec));
148 static int linear_iterate_devices(
struct dm_target *ti,
158 .version = {1, 1, 0},
163 .status = linear_status,
164 .ioctl = linear_ioctl,
165 .merge = linear_merge,
166 .iterate_devices = linear_iterate_devices,
174 DMERR(
"register failed %d", r);