diff options
author | Bart Van Assche <bart.vanassche@sandisk.com> | 2017-04-27 13:11:25 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2017-04-27 17:08:46 -0400 |
commit | 9a8ac3ae682e8760afebab71556a9a8d1b18f906 (patch) | |
tree | f5e1d37c0c4c9b924b94e191a753fb4cad928701 /drivers/md/dm-mpath.c | |
parent | ca5beb76c32af33e5be4e01c85c8bd5a067c4543 (diff) |
dm mpath: cleanup QUEUE_IF_NO_PATH bit manipulation by introducing assign_bit()
No functional change but makes the code easier to read.
Signed-off-by: Bart Van Assche <bart.vanassche@sandisk.com>
Reviewed-by: Hannes Reinecke <hare@suse.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Diffstat (limited to 'drivers/md/dm-mpath.c')
-rw-r--r-- | drivers/md/dm-mpath.c | 36 |
1 files changed, 15 insertions, 21 deletions
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index 5cb1beccd1e2..cc529537c8ce 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c | |||
@@ -612,6 +612,14 @@ static void process_queued_bios(struct work_struct *work) | |||
612 | blk_finish_plug(&plug); | 612 | blk_finish_plug(&plug); |
613 | } | 613 | } |
614 | 614 | ||
615 | static void assign_bit(bool value, long nr, unsigned long *addr) | ||
616 | { | ||
617 | if (value) | ||
618 | set_bit(nr, addr); | ||
619 | else | ||
620 | clear_bit(nr, addr); | ||
621 | } | ||
622 | |||
615 | /* | 623 | /* |
616 | * If we run out of usable paths, should we queue I/O or error it? | 624 | * If we run out of usable paths, should we queue I/O or error it? |
617 | */ | 625 | */ |
@@ -621,23 +629,11 @@ static int queue_if_no_path(struct multipath *m, bool queue_if_no_path, | |||
621 | unsigned long flags; | 629 | unsigned long flags; |
622 | 630 | ||
623 | spin_lock_irqsave(&m->lock, flags); | 631 | spin_lock_irqsave(&m->lock, flags); |
624 | 632 | assign_bit((save_old_value && test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) || | |
625 | if (save_old_value) { | 633 | (!save_old_value && queue_if_no_path), |
626 | if (test_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags)) | 634 | MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags); |
627 | set_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags); | 635 | assign_bit(queue_if_no_path || dm_noflush_suspending(m->ti), |
628 | else | 636 | MPATHF_QUEUE_IF_NO_PATH, &m->flags); |
629 | clear_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags); | ||
630 | } else { | ||
631 | if (queue_if_no_path) | ||
632 | set_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags); | ||
633 | else | ||
634 | clear_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags); | ||
635 | } | ||
636 | if (queue_if_no_path || dm_noflush_suspending(m->ti)) | ||
637 | set_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags); | ||
638 | else | ||
639 | clear_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags); | ||
640 | |||
641 | spin_unlock_irqrestore(&m->lock, flags); | 637 | spin_unlock_irqrestore(&m->lock, flags); |
642 | 638 | ||
643 | if (!queue_if_no_path) { | 639 | if (!queue_if_no_path) { |
@@ -1589,10 +1585,8 @@ static void multipath_resume(struct dm_target *ti) | |||
1589 | unsigned long flags; | 1585 | unsigned long flags; |
1590 | 1586 | ||
1591 | spin_lock_irqsave(&m->lock, flags); | 1587 | spin_lock_irqsave(&m->lock, flags); |
1592 | if (test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags)) | 1588 | assign_bit(test_bit(MPATHF_SAVED_QUEUE_IF_NO_PATH, &m->flags), |
1593 | set_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags); | 1589 | MPATHF_QUEUE_IF_NO_PATH, &m->flags); |
1594 | else | ||
1595 | clear_bit(MPATHF_QUEUE_IF_NO_PATH, &m->flags); | ||
1596 | spin_unlock_irqrestore(&m->lock, flags); | 1590 | spin_unlock_irqrestore(&m->lock, flags); |
1597 | } | 1591 | } |
1598 | 1592 | ||