Skip to contentSkip to conversation

bcache: release dc->writeback_lock properly in bch_writeback_thread()

PATCH In review Coly Li 2 participants 3 messages Aug 22, 2018

Subsystems (3)
lore
Share & tools
lore

Coly Li

author
#0 lore raw

PATCH v2 1/1 bcache: release dc->writeback_lock properly in bch_writeback_thread()

From: Shan Hai <[email protected]>

The writeback thread would exit with a lock held when the cache device is detached via sysfs interface, fix it by releasing the held lock before exiting the while-loop.

Fixes fadd94e05c02 (bcache: quit dc->writeback_thread when BCACHE_DEV_DETACHING is set)

---
Changelog:
v2: add Fixes tag by Coly Li.
v1: initial patch from Shan Hai.

 drivers/md/bcache/writeback.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/bcache/writeback.c +3 -1
index 6be05bd7ca67..08c3a9f9676c 100644
@@ -685,8 +685,10 @@ static int bch_writeback_thread(void *arg)
 			 * data on cache. BCACHE_DEV_DETACHING flag is set in
 			 * bch_cached_dev_detach().
 			 */
-			if (test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags))
+			if (test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags)) {
+				up_write(&dc->writeback_lock);
 				break;
+			}
 		}
 
 		up_write(&dc->writeback_lock);
Signature · 1 line
2.18.0
author
#1 lore raw
Quoted 11 lines · Coly Li

From: Shan Hai <[email protected]>

The writeback thread would exit with a lock held when the cache device is detached via sysfs interface, fix it by releasing the held lock before exiting the while-loop.

Fixes fadd94e05c02 (bcache: quit dc->writeback_thread when BCACHE_DEV_DETACHING is set)
Quoted 4 lines

---
Changelog:
v2: add Fixes tag by Coly Li.
v1: initial patch from Shan Hai.

Hi Jens,

Please pick this patch for your next pull request. The change from Shan Hai fixes a real issue which is reported and lately verified by Shenghui Wang.

Thanks in advance.

Coly Li

Quoted 21 lines
 drivers/md/bcache/writeback.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/md/bcache/writeback.c +3 -1
index 6be05bd7ca67..08c3a9f9676c 100644
@@ -685,8 +685,10 @@ static int bch_writeback_thread(void *arg)
 			 * data on cache. BCACHE_DEV_DETACHING flag is set in
 			 * bch_cached_dev_detach().
 			 */
-			if (test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags))
+			if (test_bit(BCACHE_DEV_DETACHING, &dc->disk.flags)) {
+				up_write(&dc->writeback_lock);
 				break;
+			}
 		}
 
 		up_write(&dc->writeback_lock);
maintainer
#2 lore raw
Quoted 17 lines · Coly Li
Quoted 11 lines · Coly Li

From: Shan Hai <[email protected]>

The writeback thread would exit with a lock held when the cache device is detached via sysfs interface, fix it by releasing the held lock before exiting the while-loop.

Fixes fadd94e05c02 (bcache: quit dc->writeback_thread when BCACHE_DEV_DETACHING is set)
Quoted 4 lines

---
Changelog:
v2: add Fixes tag by Coly Li.
v1: initial patch from Shan Hai.

Quoted 5 lines

Hi Jens,

Please pick this patch for your next pull request. The change from Shan Hai fixes a real issue which is reported and lately verified by Shenghui Wang.

Applied - but I fixed up the commit message. Please keep lines at 72 characters for git commits.

Signature · 1 line
Jens Axboe