dm.c (f31c21e4365c02ccf7226c33ea978cd5dbfc351e) | dm.c (318716ddea0829d3be566efc69d31029c40d51e2) |
---|---|
1/* 2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. 3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. 4 * 5 * This file is released under the GPL. 6 */ 7 8#include "dm-core.h" --- 1250 unchanged lines hidden (view full) --- 1259 clone->bi_iter.bi_size = to_bytes(len); 1260 1261 if (unlikely(bio_integrity(bio) != NULL)) 1262 bio_integrity_trim(clone); 1263 1264 return 0; 1265} 1266 | 1/* 2 * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. 3 * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. 4 * 5 * This file is released under the GPL. 6 */ 7 8#include "dm-core.h" --- 1250 unchanged lines hidden (view full) --- 1259 clone->bi_iter.bi_size = to_bytes(len); 1260 1261 if (unlikely(bio_integrity(bio) != NULL)) 1262 bio_integrity_trim(clone); 1263 1264 return 0; 1265} 1266 |
1267static struct dm_target_io *alloc_tio(struct clone_info *ci, 1268 struct dm_target *ti, 1269 unsigned target_bio_nr) | 1267static struct dm_target_io *alloc_tio(struct clone_info *ci, struct dm_target *ti, 1268 unsigned target_bio_nr, gfp_t gfp_mask) |
1270{ 1271 struct dm_target_io *tio; 1272 struct bio *clone; 1273 | 1269{ 1270 struct dm_target_io *tio; 1271 struct bio *clone; 1272 |
1274 clone = bio_alloc_bioset(GFP_NOIO, 0, ci->md->bs); 1275 tio = container_of(clone, struct dm_target_io, clone); | 1273 clone = bio_alloc_bioset(gfp_mask, 0, ci->md->bs); 1274 if (!clone) 1275 return NULL; |
1276 | 1276 |
1277 tio = container_of(clone, struct dm_target_io, clone); |
|
1277 tio->io = ci->io; 1278 tio->ti = ti; 1279 tio->target_bio_nr = target_bio_nr; 1280 1281 return tio; 1282} 1283 | 1278 tio->io = ci->io; 1279 tio->ti = ti; 1280 tio->target_bio_nr = target_bio_nr; 1281 1282 return tio; 1283} 1284 |
1285static void alloc_multiple_bios(struct bio_list *blist, struct clone_info *ci, 1286 struct dm_target *ti, unsigned num_bios) 1287{ 1288 struct dm_target_io *tio; 1289 int try; 1290 1291 if (!num_bios) 1292 return; 1293 1294 if (num_bios == 1) { 1295 tio = alloc_tio(ci, ti, 0, GFP_NOIO); 1296 bio_list_add(blist, &tio->clone); 1297 return; 1298 } 1299 1300 for (try = 0; try < 2; try++) { 1301 int bio_nr; 1302 struct bio *bio; 1303 1304 if (try) 1305 mutex_lock(&ci->md->table_devices_lock); 1306 for (bio_nr = 0; bio_nr < num_bios; bio_nr++) { 1307 tio = alloc_tio(ci, ti, bio_nr, try ? GFP_NOIO : GFP_NOWAIT); 1308 if (!tio) 1309 break; 1310 1311 bio_list_add(blist, &tio->clone); 1312 } 1313 if (try) 1314 mutex_unlock(&ci->md->table_devices_lock); 1315 if (bio_nr == num_bios) 1316 return; 1317 1318 while ((bio = bio_list_pop(blist))) { 1319 tio = container_of(bio, struct dm_target_io, clone); 1320 free_tio(tio); 1321 } 1322 } 1323} 1324 |
|
1284static void __clone_and_map_simple_bio(struct clone_info *ci, | 1325static void __clone_and_map_simple_bio(struct clone_info *ci, |
1285 struct dm_target *ti, 1286 unsigned target_bio_nr, unsigned *len) | 1326 struct dm_target_io *tio, unsigned *len) |
1287{ | 1327{ |
1288 struct dm_target_io *tio = alloc_tio(ci, ti, target_bio_nr); | |
1289 struct bio *clone = &tio->clone; 1290 1291 tio->len_ptr = len; 1292 1293 __bio_clone_fast(clone, ci->bio); 1294 if (len) 1295 bio_setup_sector(clone, ci->sector, *len); 1296 1297 __map_bio(tio); 1298} 1299 1300static void __send_duplicate_bios(struct clone_info *ci, struct dm_target *ti, 1301 unsigned num_bios, unsigned *len) 1302{ | 1328 struct bio *clone = &tio->clone; 1329 1330 tio->len_ptr = len; 1331 1332 __bio_clone_fast(clone, ci->bio); 1333 if (len) 1334 bio_setup_sector(clone, ci->sector, *len); 1335 1336 __map_bio(tio); 1337} 1338 1339static void __send_duplicate_bios(struct clone_info *ci, struct dm_target *ti, 1340 unsigned num_bios, unsigned *len) 1341{ |
1303 unsigned target_bio_nr; | 1342 struct bio_list blist = BIO_EMPTY_LIST; 1343 struct bio *bio; 1344 struct dm_target_io *tio; |
1304 | 1345 |
1305 for (target_bio_nr = 0; target_bio_nr < num_bios; target_bio_nr++) 1306 __clone_and_map_simple_bio(ci, ti, target_bio_nr, len); | 1346 alloc_multiple_bios(&blist, ci, ti, num_bios); 1347 1348 while ((bio = bio_list_pop(&blist))) { 1349 tio = container_of(bio, struct dm_target_io, clone); 1350 __clone_and_map_simple_bio(ci, tio, len); 1351 } |
1307} 1308 1309static int __send_empty_flush(struct clone_info *ci) 1310{ 1311 unsigned target_nr = 0; 1312 struct dm_target *ti; 1313 1314 BUG_ON(bio_has_data(ci->bio)); --- 5 unchanged lines hidden (view full) --- 1320 1321static int __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti, 1322 sector_t sector, unsigned *len) 1323{ 1324 struct bio *bio = ci->bio; 1325 struct dm_target_io *tio; 1326 int r; 1327 | 1352} 1353 1354static int __send_empty_flush(struct clone_info *ci) 1355{ 1356 unsigned target_nr = 0; 1357 struct dm_target *ti; 1358 1359 BUG_ON(bio_has_data(ci->bio)); --- 5 unchanged lines hidden (view full) --- 1365 1366static int __clone_and_map_data_bio(struct clone_info *ci, struct dm_target *ti, 1367 sector_t sector, unsigned *len) 1368{ 1369 struct bio *bio = ci->bio; 1370 struct dm_target_io *tio; 1371 int r; 1372 |
1328 tio = alloc_tio(ci, ti, 0); | 1373 tio = alloc_tio(ci, ti, 0, GFP_NOIO); |
1329 tio->len_ptr = len; 1330 r = clone_bio(tio, bio, sector, *len); 1331 if (r < 0) { 1332 free_tio(tio); 1333 return r; 1334 } 1335 __map_bio(tio); 1336 --- 1661 unchanged lines hidden --- | 1374 tio->len_ptr = len; 1375 r = clone_bio(tio, bio, sector, *len); 1376 if (r < 0) { 1377 free_tio(tio); 1378 return r; 1379 } 1380 __map_bio(tio); 1381 --- 1661 unchanged lines hidden --- |