The patch titled dm snapshot: tidy pending_complete has been added to the -mm tree. Its filename is dm-snapshot-tidy-pending_complete.patch See http://www.zip.com.au/~akpm/linux/patches/stuff/added-to-mm.txt to find out what to do about this ------------------------------------------------------ Subject: dm snapshot: tidy pending_complete From: Alasdair G Kergon <agk@xxxxxxxxxx> This patch rearranges the pending_complete() code so that the functional changes in subsequent patches are clearer. By consolidating the error and the non-error paths, we can move error_snapshot_bios() and __flush_bios() in line. Signed-off-by: Alasdair G Kergon <agk@xxxxxxxxxx> Signed-off-by: Mark McLoughlin <markmc@xxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxx> --- drivers/md/dm-snap.c | 76 ++++++++++++++++------------------------- 1 files changed, 30 insertions(+), 46 deletions(-) diff -puN drivers/md/dm-snap.c~dm-snapshot-tidy-pending_complete drivers/md/dm-snap.c --- a/drivers/md/dm-snap.c~dm-snapshot-tidy-pending_complete +++ a/drivers/md/dm-snap.c @@ -609,26 +609,6 @@ static void error_bios(struct bio *bio) } } -static inline void error_snapshot_bios(struct pending_exception *pe) -{ - error_bios(bio_list_get(&pe->snapshot_bios)); -} - -static struct bio *__flush_bios(struct pending_exception *pe) -{ - /* - * If this pe is involved in a write to the origin and - * it is the last sibling to complete then release - * the bios for the original write to the origin. - */ - - if (pe->primary_pe && - atomic_dec_and_test(&pe->primary_pe->sibling_count)) - return bio_list_get(&pe->primary_pe->origin_bios); - - return NULL; -} - static void __invalidate_snapshot(struct dm_snapshot *s, struct pending_exception *pe, int err) { @@ -656,16 +636,15 @@ static void pending_complete(struct pend struct exception *e; struct pending_exception *primary_pe; struct dm_snapshot *s = pe->snap; - struct bio *flush = NULL; + struct bio *origin_bios = NULL; + struct bio *snapshot_bios = NULL; + int error = 0; if (!success) { /* Read/write error - snapshot is unusable */ down_write(&s->lock); __invalidate_snapshot(s, pe, -EIO); - flush = __flush_bios(pe); - up_write(&s->lock); - - error_snapshot_bios(pe); + error = 1; goto out; } @@ -673,42 +652,40 @@ static void pending_complete(struct pend if (!e) { down_write(&s->lock); __invalidate_snapshot(s, pe, -ENOMEM); - flush = __flush_bios(pe); - up_write(&s->lock); - - error_snapshot_bios(pe); + error = 1; goto out; } *e = pe->e; - /* - * Add a proper exception, and remove the - * in-flight exception from the list. - */ down_write(&s->lock); if (!s->valid) { - flush = __flush_bios(pe); - up_write(&s->lock); - free_exception(e); - - error_snapshot_bios(pe); + error = 1; goto out; } + /* + * Add a proper exception, and remove the + * in-flight exception from the list. + */ insert_exception(&s->complete, e); remove_exception(&pe->e); - flush = __flush_bios(pe); - - up_write(&s->lock); - - /* Submit any pending write bios */ - flush_bios(bio_list_get(&pe->snapshot_bios)); out: + snapshot_bios = bio_list_get(&pe->snapshot_bios); + primary_pe = pe->primary_pe; /* + * If this pe is involved in a write to the origin and + * it is the last sibling to complete then release + * the bios for the original write to the origin. + */ + if (primary_pe && + atomic_dec_and_test(&primary_pe->sibling_count)) + origin_bios = bio_list_get(&primary_pe->origin_bios); + + /* * Free the pe if it's not linked to an origin write or if * it's not itself a primary pe. */ @@ -721,8 +698,15 @@ static void pending_complete(struct pend if (primary_pe && !atomic_read(&primary_pe->sibling_count)) free_pending_exception(primary_pe); - if (flush) - flush_bios(flush); + up_write(&s->lock); + + /* Submit any pending write bios */ + if (error) + error_bios(snapshot_bios); + else + flush_bios(snapshot_bios); + + flush_bios(origin_bios); } static void commit_callback(void *context, int success) _ Patches currently in -mm which might be from agk@xxxxxxxxxx are dm-support-ioctls-on-mapped-devices.patch dm-linear-support-ioctls.patch dm-mpath-support-ioctls.patch dm-export-blkdev_driver_ioctl.patch dm-support-ioctls-on-mapped-devices-fix-with-fake-file.patch dm-fix-alloc_dev-error-path.patch dm-snapshot-fix-invalidation-enomem.patch dm-snapshot-allow-zero-chunk_size.patch dm-snapshot-fix-metadata-error-handling.patch dm-snapshot-make-read-and-write-exception-functions-void.patch dm-snapshot-fix-metadata-writing-when-suspending.patch dm-snapshot-tidy-snapshot_map.patch dm-snapshot-tidy-pending_complete.patch dm-snapshot-add-workqueue.patch dm-snapshot-tidy-pe-ref-counting.patch dm-snapshot-fix-freeing-pending-exception.patch dm-mirror-remove-trailing-space-from-table.patch dm-mpath-tidy-ctr.patch dm-mpath-use-kzalloc.patch dm-add-uevent-change-event-on-resume.patch dm-add-debug-macro.patch dm-table-add-target-preresume.patch dm-crypt-add-key-msg.patch dm-crypt-restructure-for-workqueue-change.patch dm-crypt-restructure-write-processing.patch dm-crypt-move-io-to-workqueue.patch dm-crypt-use-private-biosets.patch dm-use-private-biosets.patch dm-extract-device-limit-setting.patch dm-table-add-target-flush.patch md-dm-reduce-stack-usage-with-stacked-block-devices.patch - To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html