dm.c (743598f049df473869138d599d6ad3b7c740a73f) dm.c (018b05ebbff4f3ed611e950fe5f8760d2348b814)
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"

--- 551 unchanged lines hidden (view full) ---

560{
561 bio_put(&io->tio.clone);
562}
563
564static struct bio *alloc_tio(struct clone_info *ci, struct dm_target *ti,
565 unsigned target_bio_nr, unsigned *len, gfp_t gfp_mask)
566{
567 struct dm_target_io *tio;
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"

--- 551 unchanged lines hidden (view full) ---

560{
561 bio_put(&io->tio.clone);
562}
563
564static struct bio *alloc_tio(struct clone_info *ci, struct dm_target *ti,
565 unsigned target_bio_nr, unsigned *len, gfp_t gfp_mask)
566{
567 struct dm_target_io *tio;
568 struct bio *clone;
568
569 if (!ci->io->tio.io) {
570 /* the dm_target_io embedded in ci->io is available */
571 tio = &ci->io->tio;
569
570 if (!ci->io->tio.io) {
571 /* the dm_target_io embedded in ci->io is available */
572 tio = &ci->io->tio;
573 /* alloc_io() already initialized embedded clone */
574 clone = &tio->clone;
572 } else {
575 } else {
573 struct bio *clone = bio_alloc_clone(ci->bio->bi_bdev, ci->bio,
574 gfp_mask, &ci->io->md->bs);
576 clone = bio_alloc_clone(ci->bio->bi_bdev, ci->bio,
577 gfp_mask, &ci->io->md->bs);
575 if (!clone)
576 return NULL;
577
578 tio = clone_to_tio(clone);
579 tio->inside_dm_io = false;
580 }
581
582 tio->magic = DM_TIO_MAGIC;
583 tio->io = ci->io;
584 tio->ti = ti;
585 tio->target_bio_nr = target_bio_nr;
586 tio->len_ptr = len;
587 tio->old_sector = 0;
588
578 if (!clone)
579 return NULL;
580
581 tio = clone_to_tio(clone);
582 tio->inside_dm_io = false;
583 }
584
585 tio->magic = DM_TIO_MAGIC;
586 tio->io = ci->io;
587 tio->ti = ti;
588 tio->target_bio_nr = target_bio_nr;
589 tio->len_ptr = len;
590 tio->old_sector = 0;
591
589 return &tio->clone;
592 if (len) {
593 clone->bi_iter.bi_size = to_bytes(*len);
594 if (bio_integrity(clone))
595 bio_integrity_trim(clone);
596 }
597
598 return clone;
590}
591
592static void free_tio(struct bio *clone)
593{
594 if (clone_to_tio(clone)->inside_dm_io)
595 return;
596 bio_put(clone);
597}

--- 634 unchanged lines hidden (view full) ---

1232 struct bio_list blist = BIO_EMPTY_LIST;
1233 struct bio *clone;
1234
1235 switch (num_bios) {
1236 case 0:
1237 break;
1238 case 1:
1239 clone = alloc_tio(ci, ti, 0, len, GFP_NOIO);
599}
600
601static void free_tio(struct bio *clone)
602{
603 if (clone_to_tio(clone)->inside_dm_io)
604 return;
605 bio_put(clone);
606}

--- 634 unchanged lines hidden (view full) ---

1241 struct bio_list blist = BIO_EMPTY_LIST;
1242 struct bio *clone;
1243
1244 switch (num_bios) {
1245 case 0:
1246 break;
1247 case 1:
1248 clone = alloc_tio(ci, ti, 0, len, GFP_NOIO);
1240 if (len)
1241 clone->bi_iter.bi_size = to_bytes(*len);
1242 __map_bio(clone);
1243 break;
1244 default:
1245 alloc_multiple_bios(&blist, ci, ti, num_bios, len);
1249 __map_bio(clone);
1250 break;
1251 default:
1252 alloc_multiple_bios(&blist, ci, ti, num_bios, len);
1246 while ((clone = bio_list_pop(&blist))) {
1247 if (len)
1248 clone->bi_iter.bi_size = to_bytes(*len);
1253 while ((clone = bio_list_pop(&blist)))
1249 __map_bio(clone);
1254 __map_bio(clone);
1250 }
1251 break;
1252 }
1253}
1254
1255static int __send_empty_flush(struct clone_info *ci)
1256{
1257 unsigned target_nr = 0;
1258 struct dm_target *ti;

--- 98 unchanged lines hidden (view full) ---

1357 ti = dm_table_find_target(ci->map, ci->sector);
1358 if (!ti)
1359 return -EIO;
1360
1361 if (__process_abnormal_io(ci, ti, &r))
1362 return r;
1363
1364 len = min_t(sector_t, max_io_len(ti, ci->sector), ci->sector_count);
1255 break;
1256 }
1257}
1258
1259static int __send_empty_flush(struct clone_info *ci)
1260{
1261 unsigned target_nr = 0;
1262 struct dm_target *ti;

--- 98 unchanged lines hidden (view full) ---

1361 ti = dm_table_find_target(ci->map, ci->sector);
1362 if (!ti)
1363 return -EIO;
1364
1365 if (__process_abnormal_io(ci, ti, &r))
1366 return r;
1367
1368 len = min_t(sector_t, max_io_len(ti, ci->sector), ci->sector_count);
1365
1366 clone = alloc_tio(ci, ti, 0, &len, GFP_NOIO);
1369 clone = alloc_tio(ci, ti, 0, &len, GFP_NOIO);
1367 clone->bi_iter.bi_size = to_bytes(len);
1368 if (bio_integrity(clone))
1369 bio_integrity_trim(clone);
1370
1371 __map_bio(clone);
1372
1373 ci->sector += len;
1374 ci->sector_count -= len;
1375
1376 return 0;
1377}
1378

--- 1565 unchanged lines hidden ---
1370 __map_bio(clone);
1371
1372 ci->sector += len;
1373 ci->sector_count -= len;
1374
1375 return 0;
1376}
1377

--- 1565 unchanged lines hidden ---