Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 132428
b: refs/heads/master
c: b35f8ca
h: refs/heads/master
v: v3
  • Loading branch information
Milan Broz authored and Alasdair G Kergon committed Mar 16, 2009
1 parent 4e6f221 commit 1919186
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 21 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: b2174eebd1fadb76454dad09a1dacbc17081e6b0
refs/heads/master: b35f8caa0890169000fec22902290d9a15274cbd
17 changes: 10 additions & 7 deletions trunk/drivers/md/dm-crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -568,19 +568,22 @@ static void crypt_inc_pending(struct dm_crypt_io *io)
static void crypt_dec_pending(struct dm_crypt_io *io)
{
struct crypt_config *cc = io->target->private;
struct bio *base_bio = io->base_bio;
struct dm_crypt_io *base_io = io->base_io;
int error = io->error;

if (!atomic_dec_and_test(&io->pending))
return;

if (likely(!io->base_io))
bio_endio(io->base_bio, io->error);
mempool_free(io, cc->io_pool);

if (likely(!base_io))
bio_endio(base_bio, error);
else {
if (io->error && !io->base_io->error)
io->base_io->error = io->error;
crypt_dec_pending(io->base_io);
if (error && !base_io->error)
base_io->error = error;
crypt_dec_pending(base_io);
}

mempool_free(io, cc->io_pool);
}

/*
Expand Down
32 changes: 19 additions & 13 deletions trunk/drivers/md/dm.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,9 +525,12 @@ static int __noflush_suspending(struct mapped_device *md)
static void dec_pending(struct dm_io *io, int error)
{
unsigned long flags;
int io_error;
struct bio *bio;
struct mapped_device *md = io->md;

/* Push-back supersedes any I/O errors */
if (error && !(io->error > 0 && __noflush_suspending(io->md)))
if (error && !(io->error > 0 && __noflush_suspending(md)))
io->error = error;

if (atomic_dec_and_test(&io->io_count)) {
Expand All @@ -537,31 +540,35 @@ static void dec_pending(struct dm_io *io, int error)
* This must be handled before the sleeper on
* suspend queue merges the pushback list.
*/
spin_lock_irqsave(&io->md->pushback_lock, flags);
if (__noflush_suspending(io->md))
bio_list_add(&io->md->pushback, io->bio);
spin_lock_irqsave(&md->pushback_lock, flags);
if (__noflush_suspending(md))
bio_list_add(&md->pushback, io->bio);
else
/* noflush suspend was interrupted. */
io->error = -EIO;
spin_unlock_irqrestore(&io->md->pushback_lock, flags);
spin_unlock_irqrestore(&md->pushback_lock, flags);
}

end_io_acct(io);

if (io->error != DM_ENDIO_REQUEUE) {
trace_block_bio_complete(io->md->queue, io->bio);
io_error = io->error;
bio = io->bio;

bio_endio(io->bio, io->error);
}
free_io(md, io);

if (io_error != DM_ENDIO_REQUEUE) {
trace_block_bio_complete(md->queue, bio);

free_io(io->md, io);
bio_endio(bio, io_error);
}
}
}

static void clone_endio(struct bio *bio, int error)
{
int r = 0;
struct dm_target_io *tio = bio->bi_private;
struct dm_io *io = tio->io;
struct mapped_device *md = tio->io->md;
dm_endio_fn endio = tio->ti->type->end_io;

Expand All @@ -585,15 +592,14 @@ static void clone_endio(struct bio *bio, int error)
}
}

dec_pending(tio->io, error);

/*
* Store md for cleanup instead of tio which is about to get freed.
*/
bio->bi_private = md->bs;

bio_put(bio);
free_tio(md, tio);
bio_put(bio);
dec_pending(io, error);
}

static sector_t max_io_len(struct mapped_device *md,
Expand Down

0 comments on commit 1919186

Please sign in to comment.