From patchwork Tue Apr 25 09:33:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9697775 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 CF19C601D3 for ; Tue, 25 Apr 2017 09:34:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBF0E28438 for ; Tue, 25 Apr 2017 09:34:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C0BD028452; Tue, 25 Apr 2017 09:34:45 +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 B3DF728438 for ; Tue, 25 Apr 2017 09:34:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1428721AbdDYJek (ORCPT ); Tue, 25 Apr 2017 05:34:40 -0400 Received: from mail-qt0-f196.google.com ([209.85.216.196]:35655 "EHLO mail-qt0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1428699AbdDYJeQ (ORCPT ); Tue, 25 Apr 2017 05:34:16 -0400 Received: by mail-qt0-f196.google.com with SMTP id o36so24161483qtb.2 for ; Tue, 25 Apr 2017 02:34:15 -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=4t9no2zQLrFjoV5Rf5QYeqBEbm3CCPK+ME0ikAeH0ZI=; b=uU53ZoZ55s60njivYzUqR/8KAWVgL3R28cuR8vmZhnMumZbuANrfHJmwKmVZjUUBJd kQg+lRM5+sKCNcs93AWr1AIbuPLfpDgqFJGMg/hUr0WBaxFePWxqwZWtkbR+iXG3wmab IISt28wG8HUXvCXjBKS4NyPhjoNthLPIkkR/Md4lVz053Lzoz/zxb7gWXrZzkGFTFBnw dQRcSaZ4CDa13XLoPplMA+q/C647cTY3DhqmBBKXwh5iy69awHkQakHY5LDYAPGKnHPp HaYz6Un3bVIV7fLHnYy36iS7P79jN0xXGWjFhOt8WLfegTeY6GsryF1I/QosE4V916BN XI8g== 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=4t9no2zQLrFjoV5Rf5QYeqBEbm3CCPK+ME0ikAeH0ZI=; b=AWdzlleXi0o4Nb+r84BkoiYY4zC33jYHd3rHzKf3APRMEcfokvB4FLBlk86pWoktDF DpCiGpu/qt24cuQLn2KST6Vx9TS6Bo69tY0r2vDxT85Tf5tvQSl7gmklTULZtKYI+yEo bUXEA/eW1F1juQoqKU/w1smYe8jUBwkTdEgB/LLiUT1LfVl5MtnIFqMrzEMhQeDoLtBK eqNsbBdVj6/Ef853iEk1wtGOzSi3Qpujal/XR2U3B4Cbg5+7uiK9IpB7IXHneLW5HeGQ 1sbyzNIL+vsaCpJf/cdqqnDrSCwOxe/rP3cM15+G5CiijUW3uCno6fif84jXcDS6+bJY LUXQ== X-Gm-Message-State: AN3rC/49b2KjhWF6P6vL0JFRSxAoZK1CqWJlONfvfIFccfZXvG5YFzlO eWZTFMezyoHzV94WqQ8= X-Received: by 10.200.47.108 with SMTP id k41mr32565250qta.92.1493112855253; Tue, 25 Apr 2017 02:34:15 -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.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 25 Apr 2017 02:34:14 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH 4/9] rbd: ignore unlock errors Date: Tue, 25 Apr 2017 11:33:40 +0200 Message-Id: <1493112825-16403-5-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 lock_state is set to UNLOCKED (preventing further I/O), but RELEASED_LOCK notification isn't sent. Be consistent with userspace and treat ceph_cls_unlock() errors as the image is unlocked. Signed-off-by: Ilya Dryomov --- drivers/block/rbd.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index aadf35451be7..4b72286c4be6 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -3097,7 +3097,7 @@ static int rbd_lock(struct rbd_device *rbd_dev) /* * lock_rwsem must be held for write */ -static int rbd_unlock(struct rbd_device *rbd_dev) +static void rbd_unlock(struct rbd_device *rbd_dev) { struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; char cookie[32]; @@ -3105,19 +3105,16 @@ static int rbd_unlock(struct rbd_device *rbd_dev) WARN_ON(!__rbd_is_lock_owner(rbd_dev)); - rbd_dev->lock_state = RBD_LOCK_STATE_UNLOCKED; - format_lock_cookie(rbd_dev, cookie); ret = ceph_cls_unlock(osdc, &rbd_dev->header_oid, &rbd_dev->header_oloc, RBD_LOCK_NAME, cookie); - if (ret && ret != -ENOENT) { - rbd_warn(rbd_dev, "cls_unlock failed: %d", ret); - return ret; - } + if (ret && ret != -ENOENT) + rbd_warn(rbd_dev, "failed to unlock: %d", ret); + /* treat errors as the image is unlocked */ + rbd_dev->lock_state = RBD_LOCK_STATE_UNLOCKED; rbd_set_owner_cid(rbd_dev, &rbd_empty_cid); queue_work(rbd_dev->task_wq, &rbd_dev->released_lock_work); - return 0; } static int __rbd_notify_op_lock(struct rbd_device *rbd_dev, @@ -3490,16 +3487,15 @@ static bool rbd_release_lock(struct rbd_device *rbd_dev) if (rbd_dev->lock_state != RBD_LOCK_STATE_RELEASING) return false; - if (!rbd_unlock(rbd_dev)) - /* - * Give others a chance to grab the lock - we would re-acquire - * almost immediately if we got new IO during ceph_osdc_sync() - * otherwise. We need to ack our own notifications, so this - * lock_dwork will be requeued from rbd_wait_state_locked() - * after wake_requests() in rbd_handle_released_lock(). - */ - cancel_delayed_work(&rbd_dev->lock_dwork); - + rbd_unlock(rbd_dev); + /* + * Give others a chance to grab the lock - we would re-acquire + * almost immediately if we got new IO during ceph_osdc_sync() + * otherwise. We need to ack our own notifications, so this + * lock_dwork will be requeued from rbd_wait_state_locked() + * after wake_requests() in rbd_handle_released_lock(). + */ + cancel_delayed_work(&rbd_dev->lock_dwork); return true; }