From patchwork Mon May 7 08:44:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dongsheng Yang X-Patchwork-Id: 10383549 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 4704260353 for ; Mon, 7 May 2018 08:45:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3D62E286DF for ; Mon, 7 May 2018 08:45:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 31C8428A96; Mon, 7 May 2018 08:45:18 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D2F44286DF for ; Mon, 7 May 2018 08:45:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752549AbeEGIpQ (ORCPT ); Mon, 7 May 2018 04:45:16 -0400 Received: from m97136.mail.qiye.163.com ([220.181.97.136]:5479 "EHLO m97136.mail.qiye.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752548AbeEGIoW (ORCPT ); Mon, 7 May 2018 04:44:22 -0400 Received: from atest-guest.localdomain (unknown [218.94.118.90]) by smtp2 (Coremail) with SMTP id iOCowAD3D8riEfBa7U7qAA--.740S7; Mon, 07 May 2018 16:44:20 +0800 (CST) From: Dongsheng Yang To: ceph-devel@vger.kernel.org, idryomov@gmail.com Cc: Dongsheng Yang Subject: [PATCH 5/9] rbd: protect flag bit of RBD_DEV_FLAG_BLACKLISTED with lock_rwsem Date: Mon, 7 May 2018 04:44:01 -0400 Message-Id: <1525682645-30510-6-git-send-email-dongsheng.yang@easystack.cn> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1525682645-30510-1-git-send-email-dongsheng.yang@easystack.cn> References: <1525682645-30510-1-git-send-email-dongsheng.yang@easystack.cn> X-CM-TRANSID: iOCowAD3D8riEfBa7U7qAA--.740S7 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjfUpZaPUUUUU X-Originating-IP: [218.94.118.90] X-CM-SenderInfo: 5grqw2pkhqwhp1dqwq5hdv52pwdfyhdfq/1tbidwQ-eln5c7cssAAAsO Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Dongsheng Yang --- drivers/block/rbd.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 70ca81d..a13bb06 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -3025,7 +3025,9 @@ static void rbd_acquire_lock(struct work_struct *work) * want to block. */ if (!(rbd_dev->disk->flags & GENHD_FL_UP)) { + down_write(&rbd_dev->lock_rwsem); set_bit(RBD_DEV_FLAG_BLACKLISTED, &rbd_dev->flags); + up_write(&rbd_dev->lock_rwsem); /* wake "rbd map --exclusive" process */ wake_requests(rbd_dev, false); } @@ -3471,7 +3473,9 @@ static void rbd_reregister_watch(struct work_struct *work) if (ret) { rbd_warn(rbd_dev, "failed to reregister watch: %d", ret); if (ret == -EBLACKLISTED || ret == -ENOENT) { + down_write(&rbd_dev->lock_rwsem); set_bit(RBD_DEV_FLAG_BLACKLISTED, &rbd_dev->flags); + up_write(&rbd_dev->lock_rwsem); wake_requests(rbd_dev, true); } else { queue_delayed_work(rbd_dev->task_wq,