diff options
author | Ilya Dryomov <idryomov@gmail.com> | 2018-01-20 04:30:10 -0500 |
---|---|---|
committer | Ilya Dryomov <idryomov@gmail.com> | 2018-04-02 04:12:39 -0400 |
commit | df6ba7015dd3a64a2e74353d1e7d19871af86f38 (patch) | |
tree | f1f5fb4f8fc70801e94cecdbfd3382d26188c40b /drivers/block/rbd.c | |
parent | 5359a17d2706b86da2af83027343d5eb256f7670 (diff) |
rbd: remove bio cloning helpers
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
Reviewed-by: Alex Elder <elder@linaro.org>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r-- | drivers/block/rbd.c | 141 |
1 files changed, 0 insertions, 141 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 8eaebf609611..8b9047369ab9 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c | |||
@@ -444,8 +444,6 @@ static DEFINE_SPINLOCK(rbd_client_list_lock); | |||
444 | static struct kmem_cache *rbd_img_request_cache; | 444 | static struct kmem_cache *rbd_img_request_cache; |
445 | static struct kmem_cache *rbd_obj_request_cache; | 445 | static struct kmem_cache *rbd_obj_request_cache; |
446 | 446 | ||
447 | static struct bio_set *rbd_bio_clone; | ||
448 | |||
449 | static int rbd_major; | 447 | static int rbd_major; |
450 | static DEFINE_IDA(rbd_dev_id_ida); | 448 | static DEFINE_IDA(rbd_dev_id_ida); |
451 | 449 | ||
@@ -1277,49 +1275,6 @@ static void zero_bios(struct ceph_bio_iter *bio_pos, u32 off, u32 bytes) | |||
1277 | } | 1275 | } |
1278 | 1276 | ||
1279 | /* | 1277 | /* |
1280 | * bio helpers | ||
1281 | */ | ||
1282 | |||
1283 | static void bio_chain_put(struct bio *chain) | ||
1284 | { | ||
1285 | struct bio *tmp; | ||
1286 | |||
1287 | while (chain) { | ||
1288 | tmp = chain; | ||
1289 | chain = chain->bi_next; | ||
1290 | bio_put(tmp); | ||
1291 | } | ||
1292 | } | ||
1293 | |||
1294 | /* | ||
1295 | * zeros a bio chain, starting at specific offset | ||
1296 | */ | ||
1297 | static void zero_bio_chain(struct bio *chain, int start_ofs) | ||
1298 | { | ||
1299 | struct bio_vec bv; | ||
1300 | struct bvec_iter iter; | ||
1301 | unsigned long flags; | ||
1302 | void *buf; | ||
1303 | int pos = 0; | ||
1304 | |||
1305 | while (chain) { | ||
1306 | bio_for_each_segment(bv, chain, iter) { | ||
1307 | if (pos + bv.bv_len > start_ofs) { | ||
1308 | int remainder = max(start_ofs - pos, 0); | ||
1309 | buf = bvec_kmap_irq(&bv, &flags); | ||
1310 | memset(buf + remainder, 0, | ||
1311 | bv.bv_len - remainder); | ||
1312 | flush_dcache_page(bv.bv_page); | ||
1313 | bvec_kunmap_irq(buf, &flags); | ||
1314 | } | ||
1315 | pos += bv.bv_len; | ||
1316 | } | ||
1317 | |||
1318 | chain = chain->bi_next; | ||
1319 | } | ||
1320 | } | ||
1321 | |||
1322 | /* | ||
1323 | * similar to zero_bio_chain(), zeros data defined by a page array, | 1278 | * similar to zero_bio_chain(), zeros data defined by a page array, |
1324 | * starting at the given byte offset from the start of the array and | 1279 | * starting at the given byte offset from the start of the array and |
1325 | * continuing up to the given end offset. The pages array is | 1280 | * continuing up to the given end offset. The pages array is |
@@ -1352,90 +1307,6 @@ static void zero_pages(struct page **pages, u64 offset, u64 end) | |||
1352 | } | 1307 | } |
1353 | 1308 | ||
1354 | /* | 1309 | /* |
1355 | * Clone a portion of a bio, starting at the given byte offset | ||
1356 | * and continuing for the number of bytes indicated. | ||
1357 | */ | ||
1358 | static struct bio *bio_clone_range(struct bio *bio_src, | ||
1359 | unsigned int offset, | ||
1360 | unsigned int len, | ||
1361 | gfp_t gfpmask) | ||
1362 | { | ||
1363 | struct bio *bio; | ||
1364 | |||
1365 | bio = bio_clone_fast(bio_src, gfpmask, rbd_bio_clone); | ||
1366 | if (!bio) | ||
1367 | return NULL; /* ENOMEM */ | ||
1368 | |||
1369 | bio_advance(bio, offset); | ||
1370 | bio->bi_iter.bi_size = len; | ||
1371 | |||
1372 | return bio; | ||
1373 | } | ||
1374 | |||
1375 | /* | ||
1376 | * Clone a portion of a bio chain, starting at the given byte offset | ||
1377 | * into the first bio in the source chain and continuing for the | ||
1378 | * number of bytes indicated. The result is another bio chain of | ||
1379 | * exactly the given length, or a null pointer on error. | ||
1380 | * | ||
1381 | * The bio_src and offset parameters are both in-out. On entry they | ||
1382 | * refer to the first source bio and the offset into that bio where | ||
1383 | * the start of data to be cloned is located. | ||
1384 | * | ||
1385 | * On return, bio_src is updated to refer to the bio in the source | ||
1386 | * chain that contains first un-cloned byte, and *offset will | ||
1387 | * contain the offset of that byte within that bio. | ||
1388 | */ | ||
1389 | static struct bio *bio_chain_clone_range(struct bio **bio_src, | ||
1390 | unsigned int *offset, | ||
1391 | unsigned int len, | ||
1392 | gfp_t gfpmask) | ||
1393 | { | ||
1394 | struct bio *bi = *bio_src; | ||
1395 | unsigned int off = *offset; | ||
1396 | struct bio *chain = NULL; | ||
1397 | struct bio **end; | ||
1398 | |||
1399 | /* Build up a chain of clone bios up to the limit */ | ||
1400 | |||
1401 | if (!bi || off >= bi->bi_iter.bi_size || !len) | ||
1402 | return NULL; /* Nothing to clone */ | ||
1403 | |||
1404 | end = &chain; | ||
1405 | while (len) { | ||
1406 | unsigned int bi_size; | ||
1407 | struct bio *bio; | ||
1408 | |||
1409 | if (!bi) { | ||
1410 | rbd_warn(NULL, "bio_chain exhausted with %u left", len); | ||
1411 | goto out_err; /* EINVAL; ran out of bio's */ | ||
1412 | } | ||
1413 | bi_size = min_t(unsigned int, bi->bi_iter.bi_size - off, len); | ||
1414 | bio = bio_clone_range(bi, off, bi_size, gfpmask); | ||
1415 | if (!bio) | ||
1416 | goto out_err; /* ENOMEM */ | ||
1417 | |||
1418 | *end = bio; | ||
1419 | end = &bio->bi_next; | ||
1420 | |||
1421 | off += bi_size; | ||
1422 | if (off == bi->bi_iter.bi_size) { | ||
1423 | bi = bi->bi_next; | ||
1424 | off = 0; | ||
1425 | } | ||
1426 | len -= bi_size; | ||
1427 | } | ||
1428 | *bio_src = bi; | ||
1429 | *offset = off; | ||
1430 | |||
1431 | return chain; | ||
1432 | out_err: | ||
1433 | bio_chain_put(chain); | ||
1434 | |||
1435 | return NULL; | ||
1436 | } | ||
1437 | |||
1438 | /* | ||
1439 | * The default/initial value for all object request flags is 0. For | 1310 | * The default/initial value for all object request flags is 0. For |
1440 | * each flag, once its value is set to 1 it is never reset to 0 | 1311 | * each flag, once its value is set to 1 it is never reset to 0 |
1441 | * again. | 1312 | * again. |
@@ -6390,16 +6261,8 @@ static int rbd_slab_init(void) | |||
6390 | if (!rbd_obj_request_cache) | 6261 | if (!rbd_obj_request_cache) |
6391 | goto out_err; | 6262 | goto out_err; |
6392 | 6263 | ||
6393 | rbd_assert(!rbd_bio_clone); | ||
6394 | rbd_bio_clone = bioset_create(BIO_POOL_SIZE, 0, 0); | ||
6395 | if (!rbd_bio_clone) | ||
6396 | goto out_err_clone; | ||
6397 | |||
6398 | return 0; | 6264 | return 0; |
6399 | 6265 | ||
6400 | out_err_clone: | ||
6401 | kmem_cache_destroy(rbd_obj_request_cache); | ||
6402 | rbd_obj_request_cache = NULL; | ||
6403 | out_err: | 6266 | out_err: |
6404 | kmem_cache_destroy(rbd_img_request_cache); | 6267 | kmem_cache_destroy(rbd_img_request_cache); |
6405 | rbd_img_request_cache = NULL; | 6268 | rbd_img_request_cache = NULL; |
@@ -6415,10 +6278,6 @@ static void rbd_slab_exit(void) | |||
6415 | rbd_assert(rbd_img_request_cache); | 6278 | rbd_assert(rbd_img_request_cache); |
6416 | kmem_cache_destroy(rbd_img_request_cache); | 6279 | kmem_cache_destroy(rbd_img_request_cache); |
6417 | rbd_img_request_cache = NULL; | 6280 | rbd_img_request_cache = NULL; |
6418 | |||
6419 | rbd_assert(rbd_bio_clone); | ||
6420 | bioset_free(rbd_bio_clone); | ||
6421 | rbd_bio_clone = NULL; | ||
6422 | } | 6281 | } |
6423 | 6282 | ||
6424 | static int __init rbd_init(void) | 6283 | static int __init rbd_init(void) |