mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-19 10:44:14 +08:00
dm snapshot: refactor __find_pending_exception
Move looking-up of a pending exception from __find_pending_exception to another function. Cc: stable@kernel.org Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
This commit is contained in:
parent
b64b6bf4fd
commit
2913808eb5
@ -972,6 +972,17 @@ static void start_copy(struct dm_snap_pending_exception *pe)
|
|||||||
&src, 1, &dest, 0, copy_callback, pe);
|
&src, 1, &dest, 0, copy_callback, pe);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static struct dm_snap_pending_exception *
|
||||||
|
__lookup_pending_exception(struct dm_snapshot *s, chunk_t chunk)
|
||||||
|
{
|
||||||
|
struct dm_snap_exception *e = lookup_exception(&s->pending, chunk);
|
||||||
|
|
||||||
|
if (!e)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return container_of(e, struct dm_snap_pending_exception, e);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Looks to see if this snapshot already has a pending exception
|
* Looks to see if this snapshot already has a pending exception
|
||||||
* for this chunk, otherwise it allocates a new one and inserts
|
* for this chunk, otherwise it allocates a new one and inserts
|
||||||
@ -983,20 +994,9 @@ static void start_copy(struct dm_snap_pending_exception *pe)
|
|||||||
static struct dm_snap_pending_exception *
|
static struct dm_snap_pending_exception *
|
||||||
__find_pending_exception(struct dm_snapshot *s, struct bio *bio)
|
__find_pending_exception(struct dm_snapshot *s, struct bio *bio)
|
||||||
{
|
{
|
||||||
struct dm_snap_exception *e;
|
struct dm_snap_pending_exception *pe, *pe2;
|
||||||
struct dm_snap_pending_exception *pe;
|
|
||||||
chunk_t chunk = sector_to_chunk(s, bio->bi_sector);
|
chunk_t chunk = sector_to_chunk(s, bio->bi_sector);
|
||||||
|
|
||||||
/*
|
|
||||||
* Is there a pending exception for this already ?
|
|
||||||
*/
|
|
||||||
e = lookup_exception(&s->pending, chunk);
|
|
||||||
if (e) {
|
|
||||||
/* cast the exception to a pending exception */
|
|
||||||
pe = container_of(e, struct dm_snap_pending_exception, e);
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create a new pending exception, we don't want
|
* Create a new pending exception, we don't want
|
||||||
* to hold the lock while we do this.
|
* to hold the lock while we do this.
|
||||||
@ -1010,11 +1010,10 @@ __find_pending_exception(struct dm_snapshot *s, struct bio *bio)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
e = lookup_exception(&s->pending, chunk);
|
pe2 = __lookup_pending_exception(s, chunk);
|
||||||
if (e) {
|
if (pe2) {
|
||||||
free_pending_exception(pe);
|
free_pending_exception(pe);
|
||||||
pe = container_of(e, struct dm_snap_pending_exception, e);
|
return pe2;
|
||||||
goto out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pe->e.old_chunk = chunk;
|
pe->e.old_chunk = chunk;
|
||||||
@ -1032,7 +1031,6 @@ __find_pending_exception(struct dm_snapshot *s, struct bio *bio)
|
|||||||
get_pending_exception(pe);
|
get_pending_exception(pe);
|
||||||
insert_exception(&s->pending, &pe->e);
|
insert_exception(&s->pending, &pe->e);
|
||||||
|
|
||||||
out:
|
|
||||||
return pe;
|
return pe;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1083,11 +1081,14 @@ static int snapshot_map(struct dm_target *ti, struct bio *bio,
|
|||||||
* writeable.
|
* writeable.
|
||||||
*/
|
*/
|
||||||
if (bio_rw(bio) == WRITE) {
|
if (bio_rw(bio) == WRITE) {
|
||||||
pe = __find_pending_exception(s, bio);
|
pe = __lookup_pending_exception(s, chunk);
|
||||||
if (!pe) {
|
if (!pe) {
|
||||||
__invalidate_snapshot(s, -ENOMEM);
|
pe = __find_pending_exception(s, bio);
|
||||||
r = -EIO;
|
if (!pe) {
|
||||||
goto out_unlock;
|
__invalidate_snapshot(s, -ENOMEM);
|
||||||
|
r = -EIO;
|
||||||
|
goto out_unlock;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
remap_exception(s, &pe->e, bio, chunk);
|
remap_exception(s, &pe->e, bio, chunk);
|
||||||
@ -1217,10 +1218,13 @@ static int __origin_write(struct list_head *snapshots, struct bio *bio)
|
|||||||
if (e)
|
if (e)
|
||||||
goto next_snapshot;
|
goto next_snapshot;
|
||||||
|
|
||||||
pe = __find_pending_exception(snap, bio);
|
pe = __lookup_pending_exception(snap, chunk);
|
||||||
if (!pe) {
|
if (!pe) {
|
||||||
__invalidate_snapshot(snap, -ENOMEM);
|
pe = __find_pending_exception(snap, bio);
|
||||||
goto next_snapshot;
|
if (!pe) {
|
||||||
|
__invalidate_snapshot(snap, -ENOMEM);
|
||||||
|
goto next_snapshot;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!primary_pe) {
|
if (!primary_pe) {
|
||||||
|
Loading…
Reference in New Issue
Block a user