Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 104297
b: refs/heads/master
c: 7bc3447
h: refs/heads/master
i:
  104295: bae8f69
v: v3
  • Loading branch information
Milan Broz authored and Alasdair G Kergon committed Jul 21, 2008
1 parent 91acd03 commit 6005343
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: f6fccb1213ba3d661baeb2a5eee0a9701dc03e1b
refs/heads/master: 7bc3447b692185c5ea78bee93d0ef1dee2fd7ce7
38 changes: 33 additions & 5 deletions trunk/drivers/md/dm-linear.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,25 @@ static void linear_dtr(struct dm_target *ti)
kfree(lc);
}

static int linear_map(struct dm_target *ti, struct bio *bio,
union map_info *map_context)
static sector_t linear_map_sector(struct dm_target *ti, sector_t bi_sector)
{
struct linear_c *lc = (struct linear_c *) ti->private;
struct linear_c *lc = ti->private;

return lc->start + (bi_sector - ti->begin);
}

static void linear_map_bio(struct dm_target *ti, struct bio *bio)
{
struct linear_c *lc = ti->private;

bio->bi_bdev = lc->dev->bdev;
bio->bi_sector = lc->start + (bio->bi_sector - ti->begin);
bio->bi_sector = linear_map_sector(ti, bio->bi_sector);
}

static int linear_map(struct dm_target *ti, struct bio *bio,
union map_info *map_context)
{
linear_map_bio(ti, bio);

return DM_MAPIO_REMAPPED;
}
Expand Down Expand Up @@ -114,15 +126,31 @@ static int linear_ioctl(struct dm_target *ti, struct inode *inode,
return blkdev_driver_ioctl(bdev->bd_inode, &fake_file, bdev->bd_disk, cmd, arg);
}

static int linear_merge(struct dm_target *ti, struct bvec_merge_data *bvm,
struct bio_vec *biovec, int max_size)
{
struct linear_c *lc = ti->private;
struct request_queue *q = bdev_get_queue(lc->dev->bdev);

if (!q->merge_bvec_fn)
return max_size;

bvm->bi_bdev = lc->dev->bdev;
bvm->bi_sector = linear_map_sector(ti, bvm->bi_sector);

return min(max_size, q->merge_bvec_fn(q, bvm, biovec));
}

static struct target_type linear_target = {
.name = "linear",
.version= {1, 0, 2},
.version= {1, 0, 3},
.module = THIS_MODULE,
.ctr = linear_ctr,
.dtr = linear_dtr,
.map = linear_map,
.status = linear_status,
.ioctl = linear_ioctl,
.merge = linear_merge,
};

int __init dm_linear_init(void)
Expand Down

0 comments on commit 6005343

Please sign in to comment.