Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2329741imm; Fri, 7 Sep 2018 14:46:57 -0700 (PDT) X-Google-Smtp-Source: ANB0VdYs0blveHfq2one0C6n1XmzTovYrC+MlQqxgvBz2zMeABvEMeRXEyZ9I8VsXgSvAc1Zcg+P X-Received: by 2002:a17:902:744a:: with SMTP id e10-v6mr10103094plt.165.1536356817643; Fri, 07 Sep 2018 14:46:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1536356817; cv=none; d=google.com; s=arc-20160816; b=h4nsf+cN89+FrDBM6m36GWp3DwEILqkg+uBAHS1kBDhar0Eq/IbUw9UyDcZYJpegA+ 81gkzqAKWtnGc5ik6iG4/0RHiRIw60hu072n+u6VxXl42krO0dvGgaTIRXFNELl0u5pi DojTv4hPWHeM9sp1mTfLgnsWR7e4so7wPCNxYlUvIQ0N80EOrEYlEiQYKGoRitMY19zZ RogBG501t3Bm10YhaKkBTQ68rtgYjgh8G+8PLJWAipJZiGlDWbp/i+NYEzHAR7x3z23B xs1D+UwgBjEQieusEdirZZWPTjrcW4RT5EAJhMm/9oOWS4j4knJ53yd5DxI2GgZAo3HK /irg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from; bh=Zu5uPkgBXL/kjOlaMEZxfmnpF/nioDCQPRthEqu4/sg=; b=er5cOsRVElfHogrGziJgpeT+dQKELEFquI87WK4vVqTldovNsIz6hiFL77ILnhUJAV MfRaTVNahRHN1As5CMmIhO/UsxBH5VtOjVf8Opqz9zz82+sUn0Vx86IAZyfcHqxtte1Q ZRLcTQfoOa5Dr+N0gV9r1puFFadQbKfXTq1o8jAb+Yny136vXLZbo+BULDyJXpE5+F+Y 042yKE2UDrC/dOFF1jRNb5eQB3fLnDqodQFfqrcWE8/mWqtohEt2q3ImODy4NJdJhNoU jabQalq//BugTJqqwM35ZwcTR8IH0Nk2vfut3zufsjkOtTj1JhbgxVTqU0R4sMmIDvRe jFfg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f76-v6si9911196pfh.33.2018.09.07.14.46.42; Fri, 07 Sep 2018 14:46:57 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731031AbeIHC1r (ORCPT + 99 others); Fri, 7 Sep 2018 22:27:47 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:57908 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726568AbeIHC1r (ORCPT ); Fri, 7 Sep 2018 22:27:47 -0400 Received: from localhost (ip-213-127-74-90.ip.prioritytelecom.net [213.127.74.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 1ECA9F36; Fri, 7 Sep 2018 21:44:50 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Shan Hai , Coly Li , Shenghui Wang , Jens Axboe Subject: [PATCH 3.18 29/29] bcache: release dc->writeback_lock properly in bch_writeback_thread() Date: Fri, 7 Sep 2018 23:10:50 +0200 Message-Id: <20180907210911.420133477@linuxfoundation.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180907210909.523240901@linuxfoundation.org> References: <20180907210909.523240901@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Shan Hai commit 3943b040f11ed0cc6d4585fd286a623ca8634547 upstream. 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) Signed-off-by: Shan Hai Signed-off-by: Coly Li Tested-by: Shenghui Wang Cc: stable@vger.kernel.org #4.17+ Signed-off-by: Jens Axboe Signed-off-by: Greg Kroah-Hartman --- drivers/md/bcache/writeback.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) --- a/drivers/md/bcache/writeback.c +++ b/drivers/md/bcache/writeback.c @@ -462,8 +462,10 @@ static int bch_writeback_thread(void *ar * 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);