Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 75101
b: refs/heads/master
c: 512875b
h: refs/heads/master
i:
  75099: 2d1633c
v: v3
  • Loading branch information
Jun'ichi Nomura authored and Alasdair G Kergon committed Dec 20, 2007
1 parent e95f1ed commit 37ba5e3
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 15 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: 3c378158d4cd2125b42fe2b8bb23d512fdff6fe6
refs/heads/master: 512875bd9661368da6f993205a61213b79ba1df0
10 changes: 3 additions & 7 deletions trunk/drivers/md/dm-ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -1250,21 +1250,17 @@ static int target_message(struct dm_ioctl *param, size_t param_size)
if (!table)
goto out_argv;

if (tmsg->sector >= dm_table_get_size(table)) {
ti = dm_table_find_target(table, tmsg->sector);
if (!dm_target_is_valid(ti)) {
DMWARN("Target message sector outside device.");
r = -EINVAL;
goto out_table;
}

ti = dm_table_find_target(table, tmsg->sector);
if (ti->type->message)
} else if (ti->type->message)
r = ti->type->message(ti, argc, argv);
else {
DMWARN("Target type does not support messages");
r = -EINVAL;
}

out_table:
dm_table_put(table);
out_argv:
kfree(argv);
Expand Down
7 changes: 6 additions & 1 deletion trunk/drivers/md/dm-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,10 @@ static int alloc_targets(struct dm_table *t, unsigned int num)

/*
* Allocate both the target array and offset array at once.
* Append an empty entry to catch sectors beyond the end of
* the device.
*/
n_highs = (sector_t *) dm_vcalloc(num, sizeof(struct dm_target) +
n_highs = (sector_t *) dm_vcalloc(num + 1, sizeof(struct dm_target) +
sizeof(sector_t));
if (!n_highs)
return -ENOMEM;
Expand Down Expand Up @@ -867,6 +869,9 @@ struct dm_target *dm_table_get_target(struct dm_table *t, unsigned int index)

/*
* Search the btree for the correct target.
*
* Caller should check returned pointer with dm_target_is_valid()
* to trap I/O beyond end of device.
*/
struct dm_target *dm_table_find_target(struct dm_table *t, sector_t sector)
{
Expand Down
24 changes: 18 additions & 6 deletions trunk/drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -672,13 +672,19 @@ static struct bio *clone_bio(struct bio *bio, sector_t sector,
return clone;
}

static void __clone_and_map(struct clone_info *ci)
static int __clone_and_map(struct clone_info *ci)
{
struct bio *clone, *bio = ci->bio;
struct dm_target *ti = dm_table_find_target(ci->map, ci->sector);
sector_t len = 0, max = max_io_len(ci->md, ci->sector, ti);
struct dm_target *ti;
sector_t len = 0, max;
struct dm_target_io *tio;

ti = dm_table_find_target(ci->map, ci->sector);
if (!dm_target_is_valid(ti))
return -EIO;

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

/*
* Allocate a target io object.
*/
Expand Down Expand Up @@ -736,6 +742,9 @@ static void __clone_and_map(struct clone_info *ci)
do {
if (offset) {
ti = dm_table_find_target(ci->map, ci->sector);
if (!dm_target_is_valid(ti))
return -EIO;

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

tio = alloc_tio(ci->md);
Expand All @@ -759,6 +768,8 @@ static void __clone_and_map(struct clone_info *ci)

ci->idx++;
}

return 0;
}

/*
Expand All @@ -767,6 +778,7 @@ static void __clone_and_map(struct clone_info *ci)
static int __split_bio(struct mapped_device *md, struct bio *bio)
{
struct clone_info ci;
int error = 0;

ci.map = dm_get_table(md);
if (unlikely(!ci.map))
Expand All @@ -784,11 +796,11 @@ static int __split_bio(struct mapped_device *md, struct bio *bio)
ci.idx = bio->bi_idx;

start_io_acct(ci.io);
while (ci.sector_count)
__clone_and_map(&ci);
while (ci.sector_count && !error)
error = __clone_and_map(&ci);

/* drop the extra reference count */
dec_pending(ci.io, 0);
dec_pending(ci.io, error);
dm_table_put(ci.map);

return 0;
Expand Down
5 changes: 5 additions & 0 deletions trunk/drivers/md/dm.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ int dm_table_resume_targets(struct dm_table *t);
int dm_table_any_congested(struct dm_table *t, int bdi_bits);
void dm_table_unplug_all(struct dm_table *t);

/*
* To check the return value from dm_table_find_target().
*/
#define dm_target_is_valid(t) ((t)->table)

/*-----------------------------------------------------------------
* A registry of target types.
*---------------------------------------------------------------*/
Expand Down
1 change: 1 addition & 0 deletions trunk/fs/binfmt_aout.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ static int load_aout_binary(struct linux_binprm * bprm, struct pt_regs * regs)
current->mm->free_area_cache = current->mm->mmap_base;
current->mm->cached_hole_size = 0;

current->mm->mmap = NULL;
compute_creds(bprm);
current->flags &= ~PF_FORKNOEXEC;
#ifdef __sparc__
Expand Down

0 comments on commit 37ba5e3

Please sign in to comment.