~ubuntu-branches/ubuntu/precise/linux-lowlatency/precise-proposed

« back to all changes in this revision

Viewing changes to drivers/md/dm-crypt.c

  • Committer: Package Import Robot
  • Author(s): Luke Yelavich, Luke Yelavich, Upstream Kernel Changes
  • Date: 2012-04-04 18:49:36 UTC
  • Revision ID: package-import@ubuntu.com-20120404184936-tqu735914muv4wpg
Tags: 3.2.0-22.30
[ Luke Yelavich ]

* [Config] Update configs after rebase against Ubuntu-3.2.0-22.35

[ Upstream Kernel Changes ]

* Low-latency: Rebase against Ubuntu-3.2.0-22.35

Show diffs side-by-side

added added

removed removed

Lines of Context:
176
176
 
177
177
#define MIN_IOS        16
178
178
#define MIN_POOL_PAGES 32
179
 
#define MIN_BIO_PAGES  8
180
179
 
181
180
static struct kmem_cache *_crypt_io_pool;
182
181
 
848
847
                }
849
848
 
850
849
                /*
851
 
                 * if additional pages cannot be allocated without waiting,
852
 
                 * return a partially allocated bio, the caller will then try
853
 
                 * to allocate additional bios while submitting this partial bio
 
850
                 * If additional pages cannot be allocated without waiting,
 
851
                 * return a partially-allocated bio.  The caller will then try
 
852
                 * to allocate more bios while submitting this partial bio.
854
853
                 */
855
 
                if (i == (MIN_BIO_PAGES - 1))
856
 
                        gfp_mask = (gfp_mask | __GFP_NOWARN) & ~__GFP_WAIT;
 
854
                gfp_mask = (gfp_mask | __GFP_NOWARN) & ~__GFP_WAIT;
857
855
 
858
856
                len = (size > PAGE_SIZE) ? PAGE_SIZE : size;
859
857
 
1046
1044
        queue_work(cc->io_queue, &io->work);
1047
1045
}
1048
1046
 
1049
 
static void kcryptd_crypt_write_io_submit(struct dm_crypt_io *io,
1050
 
                                          int error, int async)
 
1047
static void kcryptd_crypt_write_io_submit(struct dm_crypt_io *io, int async)
1051
1048
{
1052
1049
        struct bio *clone = io->ctx.bio_out;
1053
1050
        struct crypt_config *cc = io->target->private;
1054
1051
 
1055
 
        if (unlikely(error < 0)) {
 
1052
        if (unlikely(io->error < 0)) {
1056
1053
                crypt_free_buffer_pages(cc, clone);
1057
1054
                bio_put(clone);
1058
 
                io->error = -EIO;
1059
1055
                crypt_dec_pending(io);
1060
1056
                return;
1061
1057
        }
1106
1102
                sector += bio_sectors(clone);
1107
1103
 
1108
1104
                crypt_inc_pending(io);
 
1105
 
1109
1106
                r = crypt_convert(cc, &io->ctx);
 
1107
                if (r < 0)
 
1108
                        io->error = -EIO;
 
1109
 
1110
1110
                crypt_finished = atomic_dec_and_test(&io->ctx.pending);
1111
1111
 
1112
1112
                /* Encryption was already finished, submit io now */
1113
1113
                if (crypt_finished) {
1114
 
                        kcryptd_crypt_write_io_submit(io, r, 0);
 
1114
                        kcryptd_crypt_write_io_submit(io, 0);
1115
1115
 
1116
1116
                        /*
1117
1117
                         * If there was an error, do not try next fragments.
1162
1162
        crypt_dec_pending(io);
1163
1163
}
1164
1164
 
1165
 
static void kcryptd_crypt_read_done(struct dm_crypt_io *io, int error)
 
1165
static void kcryptd_crypt_read_done(struct dm_crypt_io *io)
1166
1166
{
1167
 
        if (unlikely(error < 0))
1168
 
                io->error = -EIO;
1169
 
 
1170
1167
        crypt_dec_pending(io);
1171
1168
}
1172
1169
 
1181
1178
                           io->sector);
1182
1179
 
1183
1180
        r = crypt_convert(cc, &io->ctx);
 
1181
        if (r < 0)
 
1182
                io->error = -EIO;
1184
1183
 
1185
1184
        if (atomic_dec_and_test(&io->ctx.pending))
1186
 
                kcryptd_crypt_read_done(io, r);
 
1185
                kcryptd_crypt_read_done(io);
1187
1186
 
1188
1187
        crypt_dec_pending(io);
1189
1188
}
1204
1203
        if (!error && cc->iv_gen_ops && cc->iv_gen_ops->post)
1205
1204
                error = cc->iv_gen_ops->post(cc, iv_of_dmreq(cc, dmreq), dmreq);
1206
1205
 
 
1206
        if (error < 0)
 
1207
                io->error = -EIO;
 
1208
 
1207
1209
        mempool_free(req_of_dmreq(cc, dmreq), cc->req_pool);
1208
1210
 
1209
1211
        if (!atomic_dec_and_test(&ctx->pending))
1210
1212
                return;
1211
1213
 
1212
1214
        if (bio_data_dir(io->base_bio) == READ)
1213
 
                kcryptd_crypt_read_done(io, error);
 
1215
                kcryptd_crypt_read_done(io);
1214
1216
        else
1215
 
                kcryptd_crypt_write_io_submit(io, error, 1);
 
1217
                kcryptd_crypt_write_io_submit(io, 1);
1216
1218
}
1217
1219
 
1218
1220
static void kcryptd_crypt(struct work_struct *work)