dm-mpath.c (63f6e6fd05624a1c915ae95dfb81264f659914d8) | dm-mpath.c (d0442f8039ee54716dd3f3100cfd8e11d9a2486c) |
---|---|
1/* 2 * Copyright (C) 2003 Sistina Software Limited. 3 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. 4 * 5 * This file is released under the GPL. 6 */ 7 8#include <linux/device-mapper.h> --- 264 unchanged lines hidden (view full) --- 273 return bio_details; 274} 275 276static void multipath_init_per_bio_data(struct bio *bio, struct dm_mpath_io **mpio_p) 277{ 278 struct dm_mpath_io *mpio = get_mpio_from_bio(bio); 279 struct dm_bio_details *bio_details = get_bio_details_from_bio(bio); 280 | 1/* 2 * Copyright (C) 2003 Sistina Software Limited. 3 * Copyright (C) 2004-2005 Red Hat, Inc. All rights reserved. 4 * 5 * This file is released under the GPL. 6 */ 7 8#include <linux/device-mapper.h> --- 264 unchanged lines hidden (view full) --- 273 return bio_details; 274} 275 276static void multipath_init_per_bio_data(struct bio *bio, struct dm_mpath_io **mpio_p) 277{ 278 struct dm_mpath_io *mpio = get_mpio_from_bio(bio); 279 struct dm_bio_details *bio_details = get_bio_details_from_bio(bio); 280 |
281 memset(mpio, 0, sizeof(*mpio)); 282 memset(bio_details, 0, sizeof(*bio_details)); 283 dm_bio_record(bio_details, bio); | 281 mpio->nr_bytes = bio->bi_iter.bi_size; 282 mpio->pgpath = NULL; 283 *mpio_p = mpio; |
284 | 284 |
285 if (mpio_p) 286 *mpio_p = mpio; | 285 dm_bio_record(bio_details, bio); |
287} 288 289/*----------------------------------------------- 290 * Path selection 291 *-----------------------------------------------*/ 292 293static int __pg_init_all_paths(struct multipath *m) 294{ --- 218 unchanged lines hidden (view full) --- 513 return DM_MAPIO_KILL; 514 } else if (test_bit(MPATHF_QUEUE_IO, &m->flags) || 515 test_bit(MPATHF_PG_INIT_REQUIRED, &m->flags)) { 516 if (pg_init_all_paths(m)) 517 return DM_MAPIO_DELAY_REQUEUE; 518 return DM_MAPIO_REQUEUE; 519 } 520 | 286} 287 288/*----------------------------------------------- 289 * Path selection 290 *-----------------------------------------------*/ 291 292static int __pg_init_all_paths(struct multipath *m) 293{ --- 218 unchanged lines hidden (view full) --- 512 return DM_MAPIO_KILL; 513 } else if (test_bit(MPATHF_QUEUE_IO, &m->flags) || 514 test_bit(MPATHF_PG_INIT_REQUIRED, &m->flags)) { 515 if (pg_init_all_paths(m)) 516 return DM_MAPIO_DELAY_REQUEUE; 517 return DM_MAPIO_REQUEUE; 518 } 519 |
521 memset(mpio, 0, sizeof(*mpio)); | |
522 mpio->pgpath = pgpath; 523 mpio->nr_bytes = nr_bytes; 524 525 bdev = pgpath->path.dev->bdev; 526 q = bdev_get_queue(bdev); 527 clone = blk_get_request(q, rq->cmd_flags | REQ_NOMERGE, GFP_ATOMIC); 528 if (IS_ERR(clone)) { 529 /* EBUSY, ENODEV or EWOULDBLOCK: requeue */ --- 21 unchanged lines hidden (view full) --- 551 blk_put_request(clone); 552} 553 554/* 555 * Map cloned bios (bio-based multipath) 556 */ 557static int __multipath_map_bio(struct multipath *m, struct bio *bio, struct dm_mpath_io *mpio) 558{ | 520 mpio->pgpath = pgpath; 521 mpio->nr_bytes = nr_bytes; 522 523 bdev = pgpath->path.dev->bdev; 524 q = bdev_get_queue(bdev); 525 clone = blk_get_request(q, rq->cmd_flags | REQ_NOMERGE, GFP_ATOMIC); 526 if (IS_ERR(clone)) { 527 /* EBUSY, ENODEV or EWOULDBLOCK: requeue */ --- 21 unchanged lines hidden (view full) --- 549 blk_put_request(clone); 550} 551 552/* 553 * Map cloned bios (bio-based multipath) 554 */ 555static int __multipath_map_bio(struct multipath *m, struct bio *bio, struct dm_mpath_io *mpio) 556{ |
559 size_t nr_bytes = bio->bi_iter.bi_size; | |
560 struct pgpath *pgpath; 561 unsigned long flags; 562 bool queue_io; 563 564 /* Do we need to select a new pgpath? */ 565 pgpath = READ_ONCE(m->current_pgpath); 566 queue_io = test_bit(MPATHF_QUEUE_IO, &m->flags); 567 if (!pgpath || !queue_io) | 557 struct pgpath *pgpath; 558 unsigned long flags; 559 bool queue_io; 560 561 /* Do we need to select a new pgpath? */ 562 pgpath = READ_ONCE(m->current_pgpath); 563 queue_io = test_bit(MPATHF_QUEUE_IO, &m->flags); 564 if (!pgpath || !queue_io) |
568 pgpath = choose_pgpath(m, nr_bytes); | 565 pgpath = choose_pgpath(m, mpio->nr_bytes); |
569 570 if ((pgpath && queue_io) || 571 (!pgpath && test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags))) { 572 /* Queue for the daemon to resubmit */ 573 spin_lock_irqsave(&m->lock, flags); 574 bio_list_add(&m->queued_bios, bio); 575 spin_unlock_irqrestore(&m->lock, flags); 576 /* PG_INIT_REQUIRED cannot be set without QUEUE_IO */ --- 7 unchanged lines hidden (view full) --- 584 if (!pgpath) { 585 if (must_push_back_bio(m)) 586 return DM_MAPIO_REQUEUE; 587 dm_report_EIO(m); 588 return DM_MAPIO_KILL; 589 } 590 591 mpio->pgpath = pgpath; | 566 567 if ((pgpath && queue_io) || 568 (!pgpath && test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags))) { 569 /* Queue for the daemon to resubmit */ 570 spin_lock_irqsave(&m->lock, flags); 571 bio_list_add(&m->queued_bios, bio); 572 spin_unlock_irqrestore(&m->lock, flags); 573 /* PG_INIT_REQUIRED cannot be set without QUEUE_IO */ --- 7 unchanged lines hidden (view full) --- 581 if (!pgpath) { 582 if (must_push_back_bio(m)) 583 return DM_MAPIO_REQUEUE; 584 dm_report_EIO(m); 585 return DM_MAPIO_KILL; 586 } 587 588 mpio->pgpath = pgpath; |
592 mpio->nr_bytes = nr_bytes; | |
593 594 bio->bi_status = 0; 595 bio_set_dev(bio, pgpath->path.dev->bdev); 596 bio->bi_opf |= REQ_FAILFAST_TRANSPORT; 597 598 if (pgpath->pg->ps.type->start_io) 599 pgpath->pg->ps.type->start_io(&pgpath->pg->ps, 600 &pgpath->path, | 589 590 bio->bi_status = 0; 591 bio_set_dev(bio, pgpath->path.dev->bdev); 592 bio->bi_opf |= REQ_FAILFAST_TRANSPORT; 593 594 if (pgpath->pg->ps.type->start_io) 595 pgpath->pg->ps.type->start_io(&pgpath->pg->ps, 596 &pgpath->path, |
601 nr_bytes); | 597 mpio->nr_bytes); |
602 return DM_MAPIO_REMAPPED; 603} 604 605static int multipath_map_bio(struct dm_target *ti, struct bio *bio) 606{ 607 struct multipath *m = ti->private; 608 struct dm_mpath_io *mpio = NULL; 609 --- 1433 unchanged lines hidden --- | 598 return DM_MAPIO_REMAPPED; 599} 600 601static int multipath_map_bio(struct dm_target *ti, struct bio *bio) 602{ 603 struct multipath *m = ti->private; 604 struct dm_mpath_io *mpio = NULL; 605 --- 1433 unchanged lines hidden --- |