]> err.no Git - linux-2.6/blobdiff - drivers/md/dm-crypt.c
Merge branch 'upstream' of git://ftp.linux-mips.org/pub/scm/upstream-linus
[linux-2.6] / drivers / md / dm-crypt.c
index 7b0fcfc9eaa5fc0f724d3313360a304b6bbab3a6..8216a6f75be57fcd234e50a21b3491c6054d9a80 100644 (file)
@@ -30,7 +30,7 @@
 /*
  * per bio private data
  */
-struct crypt_io {
+struct dm_crypt_io {
        struct dm_target *target;
        struct bio *base_bio;
        struct work_struct work;
@@ -106,7 +106,7 @@ struct crypt_config {
 
 static struct kmem_cache *_crypt_io_pool;
 
-static void clone_init(struct crypt_io *, struct bio *);
+static void clone_init(struct dm_crypt_io *, struct bio *);
 
 /*
  * Different IV generation algorithms:
@@ -382,7 +382,7 @@ static int crypt_convert(struct crypt_config *cc,
 
  static void dm_crypt_bio_destructor(struct bio *bio)
  {
-       struct crypt_io *io = bio->bi_private;
+       struct dm_crypt_io *io = bio->bi_private;
        struct crypt_config *cc = io->target->private;
 
        bio_free(bio, cc->bs);
@@ -393,7 +393,7 @@ static int crypt_convert(struct crypt_config *cc,
  * This should never violate the device limitations
  * May return a smaller bio when running out of pages
  */
-static struct bio *crypt_alloc_buffer(struct crypt_io *io, unsigned int size)
+static struct bio *crypt_alloc_buffer(struct dm_crypt_io *io, unsigned size)
 {
        struct crypt_config *cc = io->target->private;
        struct bio *clone;
@@ -479,7 +479,7 @@ static void crypt_free_buffer_pages(struct crypt_config *cc,
  * One of the bios was finished. Check for completion of
  * the whole request and correctly clean up the buffer.
  */
-static void dec_pending(struct crypt_io *io, int error)
+static void dec_pending(struct dm_crypt_io *io, int error)
 {
        struct crypt_config *cc = (struct crypt_config *) io->target->private;
 
@@ -489,7 +489,7 @@ static void dec_pending(struct crypt_io *io, int error)
        if (!atomic_dec_and_test(&io->pending))
                return;
 
-       bio_endio(io->base_bio, io->base_bio->bi_size, io->error);
+       bio_endio(io->base_bio, io->error);
 
        mempool_free(io, cc->io_pool);
 }
@@ -503,31 +503,25 @@ static void dec_pending(struct crypt_io *io, int error)
 static struct workqueue_struct *_kcryptd_workqueue;
 static void kcryptd_do_work(struct work_struct *work);
 
-static void kcryptd_queue_io(struct crypt_io *io)
+static void kcryptd_queue_io(struct dm_crypt_io *io)
 {
        INIT_WORK(&io->work, kcryptd_do_work);
        queue_work(_kcryptd_workqueue, &io->work);
 }
 
-static int crypt_endio(struct bio *clone, unsigned int done, int error)
+static void crypt_endio(struct bio *clone, int error)
 {
-       struct crypt_io *io = clone->bi_private;
+       struct dm_crypt_io *io = clone->bi_private;
        struct crypt_config *cc = io->target->private;
        unsigned read_io = bio_data_dir(clone) == READ;
 
        /*
-        * free the processed pages, even if
-        * it's only a partially completed write
+        * free the processed pages
         */
-       if (!read_io)
-               crypt_free_buffer_pages(cc, clone, done);
-
-       /* keep going - not finished yet */
-       if (unlikely(clone->bi_size))
-               return 1;
-
-       if (!read_io)
+       if (!read_io) {
+               crypt_free_buffer_pages(cc, clone, clone->bi_size);
                goto out;
+       }
 
        if (unlikely(!bio_flagged(clone, BIO_UPTODATE))) {
                error = -EIO;
@@ -537,15 +531,14 @@ static int crypt_endio(struct bio *clone, unsigned int done, int error)
        bio_put(clone);
        io->post_process = 1;
        kcryptd_queue_io(io);
-       return 0;
+       return;
 
 out:
        bio_put(clone);
        dec_pending(io, error);
-       return error;
 }
 
-static void clone_init(struct crypt_io *io, struct bio *clone)
+static void clone_init(struct dm_crypt_io *io, struct bio *clone)
 {
        struct crypt_config *cc = io->target->private;
 
@@ -556,7 +549,7 @@ static void clone_init(struct crypt_io *io, struct bio *clone)
        clone->bi_destructor = dm_crypt_bio_destructor;
 }
 
-static void process_read(struct crypt_io *io)
+static void process_read(struct dm_crypt_io *io)
 {
        struct crypt_config *cc = io->target->private;
        struct bio *base_bio = io->base_bio;
@@ -587,7 +580,7 @@ static void process_read(struct crypt_io *io)
        generic_make_request(clone);
 }
 
-static void process_write(struct crypt_io *io)
+static void process_write(struct dm_crypt_io *io)
 {
        struct crypt_config *cc = io->target->private;
        struct bio *base_bio = io->base_bio;
@@ -644,7 +637,7 @@ static void process_write(struct crypt_io *io)
        }
 }
 
-static void process_read_endio(struct crypt_io *io)
+static void process_read_endio(struct dm_crypt_io *io)
 {
        struct crypt_config *cc = io->target->private;
        struct convert_context ctx;
@@ -657,7 +650,7 @@ static void process_read_endio(struct crypt_io *io)
 
 static void kcryptd_do_work(struct work_struct *work)
 {
-       struct crypt_io *io = container_of(work, struct crypt_io, work);
+       struct dm_crypt_io *io = container_of(work, struct dm_crypt_io, work);
 
        if (io->post_process)
                process_read_endio(io);
@@ -920,6 +913,8 @@ static void crypt_dtr(struct dm_target *ti)
 {
        struct crypt_config *cc = (struct crypt_config *) ti->private;
 
+       flush_workqueue(_kcryptd_workqueue);
+
        bioset_free(cc->bs);
        mempool_destroy(cc->page_pool);
        mempool_destroy(cc->io_pool);
@@ -939,10 +934,7 @@ static int crypt_map(struct dm_target *ti, struct bio *bio,
                     union map_info *map_context)
 {
        struct crypt_config *cc = ti->private;
-       struct crypt_io *io;
-
-       if (bio_barrier(bio))
-               return -EOPNOTSUPP;
+       struct dm_crypt_io *io;
 
        io = mempool_alloc(cc->io_pool, GFP_NOIO);
        io->target = ti;
@@ -1062,9 +1054,7 @@ static int __init dm_crypt_init(void)
 {
        int r;
 
-       _crypt_io_pool = kmem_cache_create("dm-crypt_io",
-                                          sizeof(struct crypt_io),
-                                          0, 0, NULL, NULL);
+       _crypt_io_pool = KMEM_CACHE(dm_crypt_io, 0);
        if (!_crypt_io_pool)
                return -ENOMEM;