From patchwork Tue Apr 25 09:33:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9697783 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 73B53601D3 for ; Tue, 25 Apr 2017 09:35:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 70B85283FB for ; Tue, 25 Apr 2017 09:35:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65A152843B; Tue, 25 Apr 2017 09:35:06 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 15AD1283FB for ; Tue, 25 Apr 2017 09:35:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1428678AbdDYJfE (ORCPT ); Tue, 25 Apr 2017 05:35:04 -0400 Received: from mail-qk0-f193.google.com ([209.85.220.193]:36665 "EHLO mail-qk0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1428702AbdDYJeT (ORCPT ); Tue, 25 Apr 2017 05:34:19 -0400 Received: by mail-qk0-f193.google.com with SMTP id y63so15639407qkd.3 for ; Tue, 25 Apr 2017 02:34:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=HtVM4rNN+o6bLxrfBnCFhMbv7gR0+Sem2LX95664Wrk=; b=TOcHnyUBGammonZPziAYgOUuMeDmL5+t4z+DAUfDZJjbH4iTjAk60sSQpHEX008VW0 JRFMwRPR03Yp+S58z1e5U9CIh0P6yAeN2eQDk18GjB2Yj5DL2TNlOhV9QkJ2aIi7Xj8R 1GWgaEHKX67mRQ8TxeKBVl3vIwbBSCtfN1xXub5X0BRX9NUCU6ym8haUmx9wDMwaw1+O 2OsQNtb8zxTFGdeEaYTYURVbtoQCGiyZjUNLU9mNzJAh5CVld2UM+A38qiOlpq9PbfBL gPJ615L9Ldvy9HXaPjRPSmnPIZWhPwfGZQmEMhEWkzXs3ApOj59D6vgWhKrrMbdsbWLz upQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=HtVM4rNN+o6bLxrfBnCFhMbv7gR0+Sem2LX95664Wrk=; b=EIiZAglQl7h8wsJBf3Z5RM++ElkKSMc5TmtWA9ghAnXAVllzvoPhl/LfNahR+6Fqj+ /qRI8XIdXOfjnJcWEM+eMjVoCnqAbtnFJrjVyZsQWwyPG7I8BWq7dCFQAGxA9h0wmnr2 X0YHa9G/U9bCOrOBBtvYJzueR/poBoSV3zsKzj9Bzn8c28t1cb1Jqeb9lqPJoinj34cW vC6VbqWLTGZQnYDbhq42C+64NdxNj5fvv3IXWLbf1mNlsmwLFSuSHFr37YIMPtuhjWRa gWF53bMHoRVw3rRjzULJJ1tqaY12WcVF/vn8kokYuk3EDYvKQr6xGfnfeVHbDVFaqxZL +wEg== X-Gm-Message-State: AN3rC/4dBvfZ79yOKIDRAlQPgQ1Ujkocc6X2UH1c98lkZqJeWJgvHxLZ VkXC2FUpIT8kvO0Dins= X-Received: by 10.55.4.13 with SMTP id 13mr13540069qke.88.1493112858013; Tue, 25 Apr 2017 02:34:18 -0700 (PDT) Received: from orange.brq.redhat.com. (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id w6sm7461396qta.50.2017.04.25.02.34.17 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Apr 2017 02:34:17 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 7/9] rbd: kill rbd_is_lock_supported() Date: Tue, 25 Apr 2017 11:33:43 +0200 Message-Id: <1493112825-16403-8-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1493112825-16403-1-git-send-email-idryomov@gmail.com> References: <1493112825-16403-1-git-send-email-idryomov@gmail.com> 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 Currently the exclusive lock is acquired only if the mapping is writable, i.e. an image HEAD mapped in rw mode. This means that we don't acquire the lock for executing a read from a snapshot or an image HEAD mapped in ro mode, even if lock_on_read is set. This is somewhat weird and inconsistent with "no automatic exclusive lock transfers" mode, where the lock is acquired unconditionally. Signed-off-by: Ilya Dryomov --- drivers/block/rbd.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index b859ce00ee1e..bcc43fb8a9b3 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -478,13 +478,6 @@ static int minor_to_rbd_dev_id(int minor) return minor >> RBD_SINGLE_MAJOR_PART_SHIFT; } -static bool rbd_is_lock_supported(struct rbd_device *rbd_dev) -{ - return (rbd_dev->header.features & RBD_FEATURE_EXCLUSIVE_LOCK) && - rbd_dev->spec->snap_id == CEPH_NOSNAP && - !rbd_dev->mapping.read_only; -} - static bool __rbd_is_lock_owner(struct rbd_device *rbd_dev) { return rbd_dev->lock_state == RBD_LOCK_STATE_LOCKED || @@ -4052,10 +4045,6 @@ static void rbd_queue_workfn(struct work_struct *work) if (op_type != OBJ_OP_READ) { snapc = rbd_dev->header.snapc; ceph_get_snap_context(snapc); - must_be_locked = rbd_is_lock_supported(rbd_dev); - } else { - must_be_locked = rbd_dev->opts->lock_on_read && - rbd_is_lock_supported(rbd_dev); } up_read(&rbd_dev->header_rwsem); @@ -4066,6 +4055,9 @@ static void rbd_queue_workfn(struct work_struct *work) goto err_rq; } + must_be_locked = + (rbd_dev->header.features & RBD_FEATURE_EXCLUSIVE_LOCK) && + (op_type != OBJ_OP_READ || rbd_dev->opts->lock_on_read); if (must_be_locked) { down_read(&rbd_dev->lock_rwsem); if (rbd_dev->lock_state != RBD_LOCK_STATE_LOCKED &&