The patch titled dm snapshot: add workqueue has been added to the -mm tree. Its filename is dm-snapshot-add-workqueue.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: add workqueue From: Alasdair G Kergon <agk@xxxxxxxxxx> Add a workqueue so that I/O can be queued up to be flushed from a separate thread (e.g. if local interrupts are disabled). A new per-snapshot spinlock pe_lock is introduced to protect queued_bios. 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 | 33 +++++++++++++++++++++++++++++++++ drivers/md/dm-snap.h | 12 ++++++++++++ 2 files changed, 45 insertions(+) diff -puN drivers/md/dm-snap.c~dm-snapshot-add-workqueue drivers/md/dm-snap.c --- a/drivers/md/dm-snap.c~dm-snapshot-add-workqueue +++ a/drivers/md/dm-snap.c @@ -39,6 +39,9 @@ */ #define SNAPSHOT_PAGES 256 +struct workqueue_struct *ksnapd; +static void flush_queued_bios(void *data); + struct pending_exception { struct exception e; @@ -488,6 +491,7 @@ static int snapshot_ctr(struct dm_target s->active = 0; s->last_percent = 0; init_rwsem(&s->lock); + spin_lock_init(&s->pe_lock); s->table = ti->table; /* Allocate hash table for COW data */ @@ -523,6 +527,9 @@ static int snapshot_ctr(struct dm_target goto bad6; } + bio_list_init(&s->queued_bios); + INIT_WORK(&s->queued_bios_work, flush_queued_bios, s); + /* Add snapshot to the list of snapshots for this origin */ /* Exceptions aren't triggered till snapshot_resume() is called */ if (register_snapshot(s)) { @@ -561,6 +568,8 @@ static void snapshot_dtr(struct dm_targe { struct dm_snapshot *s = (struct dm_snapshot *) ti->private; + flush_workqueue(ksnapd); + /* Prevent further origin writes from using this snapshot. */ /* After this returns there can be no new kcopyd jobs. */ unregister_snapshot(s); @@ -594,6 +603,19 @@ static void flush_bios(struct bio *bio) } } +static void flush_queued_bios(void *data) +{ + struct dm_snapshot *s = (struct dm_snapshot *) data; + struct bio *queued_bios; + unsigned long flags; + + spin_lock_irqsave(&s->pe_lock, flags); + queued_bios = bio_list_get(&s->queued_bios); + spin_unlock_irqrestore(&s->pe_lock, flags); + + flush_bios(queued_bios); +} + /* * Error a list of buffers. */ @@ -1240,8 +1262,17 @@ static int __init dm_snapshot_init(void) goto bad5; } + ksnapd = create_singlethread_workqueue("ksnapd"); + if (!ksnapd) { + DMERR("Failed to create ksnapd workqueue."); + r = -ENOMEM; + goto bad6; + } + return 0; + bad6: + mempool_destroy(pending_pool); bad5: kmem_cache_destroy(pending_cache); bad4: @@ -1259,6 +1290,8 @@ static void __exit dm_snapshot_exit(void { int r; + destroy_workqueue(ksnapd); + r = dm_unregister_target(&snapshot_target); if (r) DMERR("snapshot unregister failed %d", r); diff -puN drivers/md/dm-snap.h~dm-snapshot-add-workqueue drivers/md/dm-snap.h --- a/drivers/md/dm-snap.h~dm-snapshot-add-workqueue +++ a/drivers/md/dm-snap.h @@ -10,7 +10,9 @@ #define DM_SNAPSHOT_H #include "dm.h" +#include "dm-bio-list.h" #include <linux/blkdev.h> +#include <linux/workqueue.h> struct exception_table { uint32_t hash_mask; @@ -112,10 +114,20 @@ struct dm_snapshot { struct exception_table pending; struct exception_table complete; + /* + * pe_lock protects all pending_exception operations and access + * as well as the snapshot_bios list. + */ + spinlock_t pe_lock; + /* The on disk metadata handler */ struct exception_store store; struct kcopyd_client *kcopyd_client; + + /* Queue of snapshot writes for ksnapd to flush */ + struct bio_list queued_bios; + struct work_struct queued_bios_work; }; /* _ 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