[PATCH] blkcg: retry in case of locking failure in blkcg_css_offline()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Commit 4c6994806f70 ("blk-throttle: fix race between blkcg_bio_issue_check() and cgroup_rmdir()")
changed a loop inside blkcg_css_offline() from "while (!hlist_empty(list))"
to "hlist_for_each_entry(list)" as the old condition wouldn't work anymore
due to list elements no longer being removed inside the loop.

However, this means that the code effectively lost an automatic retry in
case of queue_lock locking failure.
Let's put the lock retry back there.

Signed-off-by: Maciej S. Szmigiero <mail@xxxxxxxxxxxxxxxxxxxxx>
Fixes: 4c6994806f70 ("blk-throttle: fix race between blkcg_bio_issue_check() and cgroup_rmdir()").
Cc: stable@xxxxxxxxxxxxxxx
---
 block/blk-cgroup.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 694595b29b8f..db4b3331d01a 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1073,16 +1073,23 @@ static void blkcg_css_offline(struct cgroup_subsys_state *css)
 	spin_lock_irq(&blkcg->lock);
 
 	hlist_for_each_entry(blkg, &blkcg->blkg_list, blkcg_node) {
+		bool retry;
 		struct request_queue *q = blkg->q;
 
+again:
 		if (spin_trylock(q->queue_lock)) {
 			blkg_pd_offline(blkg);
 			spin_unlock(q->queue_lock);
+			retry = false;
 		} else {
 			spin_unlock_irq(&blkcg->lock);
 			cpu_relax();
 			spin_lock_irq(&blkcg->lock);
+			retry = true;
 		}
+
+		if (retry)
+			goto again;
 	}
 
 	spin_unlock_irq(&blkcg->lock);



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux