Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 209166
b: refs/heads/master
c: 56a67df
h: refs/heads/master
v: v3
  • Loading branch information
Mike Snitzer authored and Alasdair G Kergon committed Aug 12, 2010
1 parent 30a3c52 commit 4c9f3f1
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 9 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: 06a426cee9b35505aeb7516a67bd26496ca7ed08
refs/heads/master: 56a67df766039666f61fb15b079f713e44a735ae
26 changes: 18 additions & 8 deletions trunk/drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1030,17 +1030,27 @@ static void end_clone_request(struct request *clone, int error)
dm_complete_request(clone, error);
}

static sector_t max_io_len(struct mapped_device *md,
sector_t sector, struct dm_target *ti)
/*
* Return maximum size of I/O possible at the supplied sector up to the current
* target boundary.
*/
static sector_t max_io_len_target_boundary(sector_t sector, struct dm_target *ti)
{
sector_t target_offset = dm_target_offset(ti, sector);

return ti->len - target_offset;
}

static sector_t max_io_len(sector_t sector, struct dm_target *ti)
{
sector_t offset = sector - ti->begin;
sector_t len = ti->len - offset;
sector_t len = max_io_len_target_boundary(sector, ti);

/*
* Does the target need to split even further ?
*/
if (ti->split_io) {
sector_t boundary;
sector_t offset = dm_target_offset(ti, sector);
boundary = ((offset + ti->split_io) & ~(ti->split_io - 1))
- offset;
if (len > boundary)
Expand Down Expand Up @@ -1258,7 +1268,7 @@ static int __clone_and_map_discard(struct clone_info *ci)
if (!ti->num_discard_requests)
return -EOPNOTSUPP;

max = max_io_len(ci->md, ci->sector, ti);
max = max_io_len(ci->sector, ti);

if (ci->sector_count > max)
/*
Expand Down Expand Up @@ -1290,7 +1300,7 @@ static int __clone_and_map(struct clone_info *ci)
if (!dm_target_is_valid(ti))
return -EIO;

max = max_io_len(ci->md, ci->sector, ti);
max = max_io_len(ci->sector, ti);

if (ci->sector_count <= max) {
/*
Expand Down Expand Up @@ -1341,7 +1351,7 @@ static int __clone_and_map(struct clone_info *ci)
if (!dm_target_is_valid(ti))
return -EIO;

max = max_io_len(ci->md, ci->sector, ti);
max = max_io_len(ci->sector, ti);
}

len = min(remaining, max);
Expand Down Expand Up @@ -1428,7 +1438,7 @@ static int dm_merge_bvec(struct request_queue *q,
/*
* Find maximum amount of I/O that won't need splitting
*/
max_sectors = min(max_io_len(md, bvm->bi_sector, ti),
max_sectors = min(max_io_len(bvm->bi_sector, ti),
(sector_t) BIO_MAX_SECTORS);
max_size = (max_sectors << SECTOR_SHIFT) - bvm->bi_size;
if (max_size < 0)
Expand Down
6 changes: 6 additions & 0 deletions trunk/include/linux/device-mapper.h
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,12 @@ void *dm_vcalloc(unsigned long nmemb, unsigned long elem_size);
#define dm_array_too_big(fixed, obj, num) \
((num) > (UINT_MAX - (fixed)) / (obj))

/*
* Sector offset taken relative to the start of the target instead of
* relative to the start of the device.
*/
#define dm_target_offset(ti, sector) ((sector) - (ti)->begin)

static inline sector_t to_sector(unsigned long n)
{
return (n >> SECTOR_SHIFT);
Expand Down

0 comments on commit 4c9f3f1

Please sign in to comment.