From patchwork Wed Jul 24 06:29:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 13740614 Received: from mail-wm1-f46.google.com (mail-wm1-f46.google.com [209.85.128.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BB7E3482FF for ; Wed, 24 Jul 2024 06:29:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721802579; cv=none; b=UMDqUqZiqq2bYYRbCWtmEr/m1iW0Cvb7NCNmTnpnGEH4wGMIsLRk2IcQzv8PfmyiLKxkSQd5owsLqKicbIZsKn2oTC+WvvcwpqoQbABE33A34BnHIS2ICMNDXbFigwbB985wPch6GmqnRsQG3EUagzV1QTFDTQhbnAmhKzF3E+c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721802579; c=relaxed/simple; bh=ciP+1a8w2PyUHFjhBB6XCT20WH0C/BTtRfPS3euy248=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TAbPBeUmQprqSirqueFytjsBWYnFmoWx85YxsbPUcOE2lIYaWhH84mWO2GUE4kcvL+Dp24gtIYcgaxTnABPvZoTbtfU1juvD+5J8v21idh8rMgZo7MoLBuhz6jEt+PiQ3PvZ3GJg88Qvv07pPeVVtU/uuyXQkTF/RguQYbjAyYY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=cp0dmJWg; arc=none smtp.client-ip=209.85.128.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cp0dmJWg" Received: by mail-wm1-f46.google.com with SMTP id 5b1f17b1804b1-427b4c621b9so42714025e9.1 for ; Tue, 23 Jul 2024 23:29:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721802576; x=1722407376; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=RF2v8EzbqsV+xr4JQfgeYUQFiH7nOch+iX5ufPPKKrg=; b=cp0dmJWgMeXS1LUMdA5ODPt6kPBk/6/DzPIIzvCSLYMpa6NUFKeNezLjvC2pI8LfcV 9gsYrjsmofhfsgVTb+TG8gakhCsd3cWveyuF2/BY3pOd3l7NEhBWmeLYMLPvlEVBtFiO 49og9oySZzKtjcAmqtYzF67+scRiPVlLYgiaTbkL0Ix4JPIGgbw7h9dsrB7N+/A6as2V pwjzX/FwZCnR3f8pxaPvQaFKmBNFQnTVzugWajoC4yQlOgSZLXR9XXxGM5WG6P6CQBeq IuNfi2IE/XeEnbe3r/cTELuQVm8mYp7MdWNWyIZeSwAh7sWnYGX0VIIuMgqgb6yXupJx rcVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721802576; x=1722407376; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=RF2v8EzbqsV+xr4JQfgeYUQFiH7nOch+iX5ufPPKKrg=; b=tYXA5VYyMad9Dsat0j8D4sOieAM9hA26i2pJuoYX7IBkoPPj1p9MzQaagfraF/i6GE 7kPh6lGY2+jrkcRwXtsQ18u0hvXyhBHAzReGeEdGEuiWJJmiUkT5VdFmSOQzBpOFAkWp bEHWnZXt7kphM33PdGsyM3CHE0jpdNPJHjdpkr63ER3PYTxZB3eKrOzPgRkCz67EKZqH 0Ev4py5l+BM+x/67NVcacsfdnisV7fNSJ7AM+aEZ9cKCFbkG/27GxGZneupiyD8fY3qM YxEtpmMtSOpOtlTt5jAJzNYr85oR3oEBCu4dHfMx2+xx6opKZFS69L3xRP6oMl2Ox7rB 6cjg== X-Gm-Message-State: AOJu0Yz2dTZsmkB5ictNVR1Vj/4JGmCV3ZKuySCsnj9qhHtFpau8H3iF MDYVCacA/RUxCHXZ5bKNYU+SnoFW3OVQ6Zc6xaJEBlkkzm07f0kkJbL5KQ== X-Google-Smtp-Source: AGHT+IFAYBFVriE+5Zm8fWR+H+3p0WR/dqImSMy9BXNuVNnv+CpEnMF/cM1RL1zs8BDw3TVHsE5aIQ== X-Received: by 2002:a05:600c:4fc2:b0:426:6617:ae4a with SMTP id 5b1f17b1804b1-427f955db6bmr7347255e9.22.1721802575774; Tue, 23 Jul 2024 23:29:35 -0700 (PDT) Received: from localhost.localdomain (ip-94-112-167-15.bb.vodafone.cz. [94.112.167.15]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f9359516sm14160325e9.2.2024.07.23.23.29.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 23:29:35 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Cc: Dongsheng Yang Subject: [PATCH 1/3] rbd: rename RBD_LOCK_STATE_RELEASING and releasing_wait Date: Wed, 24 Jul 2024 08:29:09 +0200 Message-ID: <20240724062914.667734-2-idryomov@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240724062914.667734-1-idryomov@gmail.com> References: <20240724062914.667734-1-idryomov@gmail.com> Precedence: bulk X-Mailing-List: ceph-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 ... to RBD_LOCK_STATE_QUIESCING to quiescing_wait to recognize that this state and the associated completion are backing rbd_quiesce_lock(), which isn't specific to releasing the lock. While exclusive lock does get quiesced before it's released, it also gets quiesced before an attempt to update the cookie is made and there the lock is not released as long as ceph_cls_set_cookie() succeeds. Signed-off-by: Ilya Dryomov Reviewed-by: Dongsheng Yang --- drivers/block/rbd.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 9c6cff54831f..77a9f19a0035 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -362,7 +362,7 @@ enum rbd_watch_state { enum rbd_lock_state { RBD_LOCK_STATE_UNLOCKED, RBD_LOCK_STATE_LOCKED, - RBD_LOCK_STATE_RELEASING, + RBD_LOCK_STATE_QUIESCING, }; /* WatchNotify::ClientId */ @@ -422,7 +422,7 @@ struct rbd_device { struct list_head running_list; struct completion acquire_wait; int acquire_err; - struct completion releasing_wait; + struct completion quiescing_wait; spinlock_t object_map_lock; u8 *object_map; @@ -525,7 +525,7 @@ static bool __rbd_is_lock_owner(struct rbd_device *rbd_dev) lockdep_assert_held(&rbd_dev->lock_rwsem); return rbd_dev->lock_state == RBD_LOCK_STATE_LOCKED || - rbd_dev->lock_state == RBD_LOCK_STATE_RELEASING; + rbd_dev->lock_state == RBD_LOCK_STATE_QUIESCING; } static bool rbd_is_lock_owner(struct rbd_device *rbd_dev) @@ -3458,12 +3458,12 @@ static void rbd_lock_del_request(struct rbd_img_request *img_req) spin_lock(&rbd_dev->lock_lists_lock); if (!list_empty(&img_req->lock_item)) { list_del_init(&img_req->lock_item); - need_wakeup = (rbd_dev->lock_state == RBD_LOCK_STATE_RELEASING && + need_wakeup = (rbd_dev->lock_state == RBD_LOCK_STATE_QUIESCING && list_empty(&rbd_dev->running_list)); } spin_unlock(&rbd_dev->lock_lists_lock); if (need_wakeup) - complete(&rbd_dev->releasing_wait); + complete(&rbd_dev->quiescing_wait); } static int rbd_img_exclusive_lock(struct rbd_img_request *img_req) @@ -4181,16 +4181,16 @@ static bool rbd_quiesce_lock(struct rbd_device *rbd_dev) /* * Ensure that all in-flight IO is flushed. */ - rbd_dev->lock_state = RBD_LOCK_STATE_RELEASING; - rbd_assert(!completion_done(&rbd_dev->releasing_wait)); + rbd_dev->lock_state = RBD_LOCK_STATE_QUIESCING; + rbd_assert(!completion_done(&rbd_dev->quiescing_wait)); if (list_empty(&rbd_dev->running_list)) return true; up_write(&rbd_dev->lock_rwsem); - wait_for_completion(&rbd_dev->releasing_wait); + wait_for_completion(&rbd_dev->quiescing_wait); down_write(&rbd_dev->lock_rwsem); - if (rbd_dev->lock_state != RBD_LOCK_STATE_RELEASING) + if (rbd_dev->lock_state != RBD_LOCK_STATE_QUIESCING) return false; rbd_assert(list_empty(&rbd_dev->running_list)); @@ -5383,7 +5383,7 @@ static struct rbd_device *__rbd_dev_create(struct rbd_spec *spec) INIT_LIST_HEAD(&rbd_dev->acquiring_list); INIT_LIST_HEAD(&rbd_dev->running_list); init_completion(&rbd_dev->acquire_wait); - init_completion(&rbd_dev->releasing_wait); + init_completion(&rbd_dev->quiescing_wait); spin_lock_init(&rbd_dev->object_map_lock); From patchwork Wed Jul 24 06:29:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 13740615 Received: from mail-lj1-f180.google.com (mail-lj1-f180.google.com [209.85.208.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E979153368 for ; Wed, 24 Jul 2024 06:29:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721802580; cv=none; b=u3tmh5aDHltEoAtEzkb+5TN/gwNJxjOq/4D248kxU+dsE5kKxR/Si5SZLuFStULyFgo1NfMoHZoMindIM2gjtGplya+sJyC9NuuSjL2Rd3ThT5ddwMSm3XRr0FiFhW4GxLDxeZJuknGzsT/IBapTbNP07JkmGog9ZIbMtTq1hm8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721802580; c=relaxed/simple; bh=wp+ZqFjrziMqIpPgyJIjCuVtTdGjwa1bbrHpxrzfX/0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KB0P7/jATnt0A8r3QLn2fuXSODVaF94D5xhg3zMMnpwn0TFO/L79L1EcvEXVtrcK5fNwcnXEtNuSekoL6bLOnJWRDPVxs4LOXUkGa2VOOLadcHoHrYzYTqs3JRW6iC/cgmIDXGp20eoihnfmp9GIbbLXMhgbD2nCzyJ2Ka3L+7Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=hhMVXQYF; arc=none smtp.client-ip=209.85.208.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hhMVXQYF" Received: by mail-lj1-f180.google.com with SMTP id 38308e7fff4ca-2ef2d582e31so33112041fa.2 for ; Tue, 23 Jul 2024 23:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721802577; x=1722407377; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=euhuSlCtu3gNSc7TeGUs2Z08XPAtseZVybmA4bpYMjs=; b=hhMVXQYFf5UtLb2tJ31rTrSfVHyy7zrqzfj2zLGVIZ0HHKYj4tplVxtADXj+d8w2Vt +2T+zhlMeqL0peO/GzX+aWlohDd9iMero6EKV+USJJIBlQ34v14D3+OilFD1DSUvuAhX pjTm/P48roEoS+Deyh4ZyRPvR2qE2EY0cnWaaZ+HN7Iwk76vXqkconCcG3QSls2n9OOR o37jpe3HUVywsp4AYH99u2SklY0e25b8gqC5f0PWTwcVVRTQzEMqw3DQlXWGpxFm2aF8 r4LaL2jRrlz4mMhufESCFHwYzwIT0Ov/m/isJJXsJrMFFHLMJLrsptsN0xi/r/Qgbkw/ Sfhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721802577; x=1722407377; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=euhuSlCtu3gNSc7TeGUs2Z08XPAtseZVybmA4bpYMjs=; b=r9kHArOPGMJtqfSKe6tV4cv5Rg2pZQXq9oRL7AM251LPvEM9cihs0wX+JJwHtXE8/j Jlxkd+/yttbvC0tPVtMUq0dY+9fwZvQfuz06U8VouE/fQuDH+zsfequu3U6buU7kJAJS XyvssKOK1TJrsKDh0T8ZAfCYUX5sgsayyDGNaKJDqKH5pQhI/oD5rKA3b5tRFayOFt1J JuUvKBIetJCVF9qx39/sByKrVqV4VExS/TZoJLvJ4c1DkK9iA2cFywL7bTxK78wj5LX6 tfOwgIdtmYeVlZH2HKP07sAPtEi4MGakbneKlEEntXMSjVT76wGBpN42IrGiJsUcsbTS xXCg== X-Gm-Message-State: AOJu0Yyq58fJV5oSeQI//pGbw04OF0I4R1UbB8JZTW+plfoL/sAHgjzv 4bk7foBK5CU7MmHE+mPXDPVbxitPWgxfIviPEywVJwvMGT9Wx9QiuN24Xg== X-Google-Smtp-Source: AGHT+IEkKrTEqRn0uTmlpkxJ9BSd3AoOcrbCEPhYGFN0KrCkWmiP3kbbuiOd1cH/KF4rRgORgTXmuw== X-Received: by 2002:a2e:2206:0:b0:2ef:32b9:85f6 with SMTP id 38308e7fff4ca-2f02b71e810mr13149341fa.11.1721802576721; Tue, 23 Jul 2024 23:29:36 -0700 (PDT) Received: from localhost.localdomain (ip-94-112-167-15.bb.vodafone.cz. [94.112.167.15]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f9359516sm14160325e9.2.2024.07.23.23.29.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 23:29:36 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Cc: Dongsheng Yang Subject: [PATCH 2/3] rbd: don't assume RBD_LOCK_STATE_LOCKED for exclusive mappings Date: Wed, 24 Jul 2024 08:29:10 +0200 Message-ID: <20240724062914.667734-3-idryomov@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240724062914.667734-1-idryomov@gmail.com> References: <20240724062914.667734-1-idryomov@gmail.com> Precedence: bulk X-Mailing-List: ceph-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Every time a watch is reestablished after getting lost, we need to update the cookie which involves quiescing exclusive lock. For this, we transition from RBD_LOCK_STATE_LOCKED to RBD_LOCK_STATE_QUIESCING roughly for the duration of rbd_reacquire_lock() call. If the mapping is exclusive and I/O happens to arrive in this time window, it's failed with EROFS (later translated to EIO) based on the wrong assumption in rbd_img_exclusive_lock() -- "lock got released?" check there stopped making sense with commit a2b1da09793d ("rbd: lock should be quiesced on reacquire"). To make it worse, any such I/O is added to the acquiring list before EROFS is returned and this sets up for violating rbd_lock_del_request() precondition that the request is either on the running list or not on any list at all -- see commit ded080c86b3f ("rbd: don't move requests to the running list on errors"). rbd_lock_del_request() ends up processing these requests as if they were on the running list which screws up quiescing_wait completion counter and ultimately leads to rbd_assert(!completion_done(&rbd_dev->quiescing_wait)); being triggered on the next watch error. Signed-off-by: Ilya Dryomov --- drivers/block/rbd.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 77a9f19a0035..dc4ddae4f7eb 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -3457,6 +3457,7 @@ static void rbd_lock_del_request(struct rbd_img_request *img_req) lockdep_assert_held(&rbd_dev->lock_rwsem); spin_lock(&rbd_dev->lock_lists_lock); if (!list_empty(&img_req->lock_item)) { + rbd_assert(!list_empty(&rbd_dev->running_list)); list_del_init(&img_req->lock_item); need_wakeup = (rbd_dev->lock_state == RBD_LOCK_STATE_QUIESCING && list_empty(&rbd_dev->running_list)); @@ -3476,11 +3477,6 @@ static int rbd_img_exclusive_lock(struct rbd_img_request *img_req) if (rbd_lock_add_request(img_req)) return 1; - if (rbd_dev->opts->exclusive) { - WARN_ON(1); /* lock got released? */ - return -EROFS; - } - /* * Note the use of mod_delayed_work() in rbd_acquire_lock() * and cancel_delayed_work() in wake_lock_waiters(). @@ -4601,6 +4597,10 @@ static void rbd_reacquire_lock(struct rbd_device *rbd_dev) rbd_warn(rbd_dev, "failed to update lock cookie: %d", ret); + if (rbd_dev->opts->exclusive) + rbd_warn(rbd_dev, + "temporarily releasing lock on exclusive mapping"); + /* * Lock cookie cannot be updated on older OSDs, so do * a manual release and queue an acquire. From patchwork Wed Jul 24 06:29:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 13740616 Received: from mail-wm1-f54.google.com (mail-wm1-f54.google.com [209.85.128.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B769054670 for ; Wed, 24 Jul 2024 06:29:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721802581; cv=none; b=ccskicys6Vl+UuwTcQb7pqCmuRKxSPDJF+Hf7eczmq2updCQEfImk3e8cJPTQ2ffC80D7+s8AcHUhGEqampnS6iRkV1tXehNkBXYzi8ORozLeZr6mmF5KI0UQGNNct3xx/nYM7QGDN18b+GLzWcDHQHYpK/gZZhpO98KmfaDfr8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1721802581; c=relaxed/simple; bh=g6C0XvR83OIysdY7Xlzkn0d1IuJVfuvyx7o14YIZcHI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iyHzWSKmXe7gsFv6UjFFwCsChYaLNnB8Hzl+rswg36GVoI5YgUKLcPv9vD9w8eZcgrxVUTuDAweo3NqzG6HtgFyRDlyZ00SD0qYxVqqvt6s70Pp9jJrH5bHlShIDQKiKTBIFVS0QyWgXv4TKBE1az/JGeprZxcOhEg5lWPUM7VY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=Zr4NifKx; arc=none smtp.client-ip=209.85.128.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Zr4NifKx" Received: by mail-wm1-f54.google.com with SMTP id 5b1f17b1804b1-4257d5fc9b7so55534585e9.2 for ; Tue, 23 Jul 2024 23:29:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1721802578; x=1722407378; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=XXgRJ3BoCz2zxEcveCDlnOETA3pLSI/q6a5Q+E7vtI0=; b=Zr4NifKx68mP2DNW4jELZ07g/w1DPrULo4t45VAF1Ni2qhquLTxB2RNCTb8LqdsuEc 8fQLs9KIdWOCj/arQ03lMkRiXzlKtT1MHPqDr1XD1nPAQkx6ez7HvsnEWZa6GJ43sgM3 YmssCUsPvGnZIlGCW5p1Dq+yHBeA5VhTBSemr7sNmRNHfq2EObi4O/s1dLJXaQftAL58 e3nSfyCPtv5/h2gGUZFZDKdUV0FX+Y8IC8neX+PN0RFIW6HkukvQezEj4kaY63Bth+sz X/utgy40Dtp8F15FwZc/pRLQbIhPFUKYsQZtrkVE5jrPWlvB2OwFZ61wb5LvNAiZ6TsV nXqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721802578; x=1722407378; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=XXgRJ3BoCz2zxEcveCDlnOETA3pLSI/q6a5Q+E7vtI0=; b=JLo2MwF7STytcaLSj1fyTseATNX5sMYJCWRiXnq6PUD4M0UXsC76lPKI3zPuGg2HEJ LHPK9gxoyoh+8s+/6mi2MKcgewsj/nHoXU6WwAEcydMcACKTigPhPan1xO5GbkxlW0G/ xDBRQiEjnUnub3WYNb83ry5/OK8WgdPAzYWPTcYAjsYmOgYmGUu1QrxSGpf+iZwMqNY9 StWsZlPbsNxqBtbPvQLZZwHIi9sPa1Stw4XGCpFmI5Yv1dYbzFW8JBmeTs1F9zI6JTkq XhRAVubQ8C4GyhPQEm4EE6Q9kNlBjoxHbnnftX4w1pUaBESJhZkqLlGjat83vOvPFdYb 3Nsw== X-Gm-Message-State: AOJu0YyW60TW5GFu46hzkDuW8yiLPRP9HTyWS76BZqW+9MUwENp/dZsm oIoW8X+h5Gs2VTIhJh9s6hjIIEQyfBKYO6OKUWA5Fg2IYGesby3hEPzrpQ== X-Google-Smtp-Source: AGHT+IEP3DUVzSfneHtoEo6lHlXRFrFIqN+X+Lt2b0S6zCAQBQi8/4YxaeeZmgVn5fGVC0UJBvdNtw== X-Received: by 2002:a05:600c:4713:b0:426:6714:5415 with SMTP id 5b1f17b1804b1-427f7ad5432mr13332235e9.30.1721802577918; Tue, 23 Jul 2024 23:29:37 -0700 (PDT) Received: from localhost.localdomain (ip-94-112-167-15.bb.vodafone.cz. [94.112.167.15]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-427f9359516sm14160325e9.2.2024.07.23.23.29.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Jul 2024 23:29:37 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Cc: Dongsheng Yang Subject: [PATCH 3/3] rbd: don't assume rbd_is_lock_owner() for exclusive mappings Date: Wed, 24 Jul 2024 08:29:11 +0200 Message-ID: <20240724062914.667734-4-idryomov@gmail.com> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240724062914.667734-1-idryomov@gmail.com> References: <20240724062914.667734-1-idryomov@gmail.com> Precedence: bulk X-Mailing-List: ceph-devel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Expanding on the previous commit, assuming that rbd_is_lock_owner() always returns true (i.e. that we are either in RBD_LOCK_STATE_LOCKED or RBD_LOCK_STATE_QUIESCING) if the mapping is exclusive is wrong too. In case ceph_cls_set_cookie() fails, the lock would be temporarily released even if the mapping is exclusive, meaning that we can end up even in RBD_LOCK_STATE_UNLOCKED. IOW, exclusive mappings are really "just" about disabling automatic lock transitions (as documented in the man page), not about grabbing the lock and holding on to it whatever it takes. Signed-off-by: Ilya Dryomov Reviewed-by: Dongsheng Yang --- drivers/block/rbd.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index dc4ddae4f7eb..b8e6700d65f8 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -6589,11 +6589,6 @@ static int rbd_add_acquire_lock(struct rbd_device *rbd_dev) if (ret) return ret; - /* - * The lock may have been released by now, unless automatic lock - * transitions are disabled. - */ - rbd_assert(!rbd_dev->opts->exclusive || rbd_is_lock_owner(rbd_dev)); return 0; }