From patchwork Thu Jul 7 14:31:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Haris Iqbal X-Patchwork-Id: 12909742 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB8D1CCA47F for ; Thu, 7 Jul 2022 14:32:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235663AbiGGOcL (ORCPT ); Thu, 7 Jul 2022 10:32:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53828 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235571AbiGGOcK (ORCPT ); Thu, 7 Jul 2022 10:32:10 -0400 Received: from mail-ed1-x529.google.com (mail-ed1-x529.google.com [IPv6:2a00:1450:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7CE6E2F66B for ; Thu, 7 Jul 2022 07:32:09 -0700 (PDT) Received: by mail-ed1-x529.google.com with SMTP id e15so2454172edj.2 for ; Thu, 07 Jul 2022 07:32:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ionos.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=vSWux/CT76fiybw73+n4C/BDvuDrcx1Ye1vpoy0jMgU=; b=A9JOo25dVOjwj++H+WU3hqo9MtLwBbhoU+fekMY7/HkdrpUrmO4+DgSE4xGyFt5Lpe b8JhK/hHHbHeZPr/uk9jGBV38KygudUF4KZE6CJSKrl1X9xzCixG4gQjCN3gRRbm1s6G K3Zr+jR5VvaEyvKgvcAOwD+cOulb9eVpFIL6DGJm/CNgAhrXZRNGa1Ry5ZIYxaX176qB olNP7djap0vkqrSCZNJ9/0344PwPJQWSSR8FmOW/VMyDDhLUz8vTpDjamLqA7FsYR3a2 44olR0PlREKvExYhh1O3pjoXuNE1YGoOjbsG9mnnjRJZzTcSglYaMBYuIFmfDsgbq4HA ZUSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=vSWux/CT76fiybw73+n4C/BDvuDrcx1Ye1vpoy0jMgU=; b=Fst7sN37aUSiDnDqAsfF2JwnF4zDq8l4qbcjFW4+T6tUNF8BSPDt2uwD8d9y+Eh2qn p+QSobKzFyRZs5ZLKEQAgjqFctT+g7vAAi0oqlnprbzo2/QfNc8GhtpcYWP7Ss/5PhOD Pwwxk0Mxw2/IZNbAPtopDnRP47TdRougbsydySHM9Z8zIUibVMpzy6TGMJWt+U71haGW UNtHTIcEEMBcGvxw7bGIPENI4Il+Qu9S/7vecOGpfiYoFq41JYEJB+97IFI84SbXJ5sl yIXyNx7qDha8dVBpyPovMdb7PVcOFLjj05rjNF7KLJH9qNLNsbqGAb6WyOoEdIQW994N g0UQ== X-Gm-Message-State: AJIora/iuddyXchQDgjHbpedzeo6M4zp9+vIlnTyWeOU08JKb5862ATO 7paIp59St6AGr5tKahrBDDIiF84lEgUHvg== X-Google-Smtp-Source: AGRyM1tui1J84F9nU/zJ4FTJMBtJmv4CBiUBpuC7FCucg91ZLtdmWsVaJ14OTpOcUm6f6H1IfPsVJQ== X-Received: by 2002:a05:6402:360d:b0:435:710a:2531 with SMTP id el13-20020a056402360d00b00435710a2531mr61518552edb.377.1657204328053; Thu, 07 Jul 2022 07:32:08 -0700 (PDT) Received: from lb01533.fkb.profitbricks.net ([85.214.13.132]) by smtp.gmail.com with ESMTPSA id i11-20020aa7c70b000000b0043a5004e714sm9970896edq.64.2022.07.07.07.32.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Jul 2022 07:32:07 -0700 (PDT) From: Md Haris Iqbal To: linux-block@vger.kernel.org Cc: axboe@kernel.dk, hch@infradead.org, sagi@grimberg.me, bvanassche@acm.org, haris.iqbal@ionos.com, jinpu.wang@ionos.com, gi-oh.kim@ionos.com Subject: [PATCH for-next 1/2] block/rnbd-srv: Set keep_id to true after mutex_trylock Date: Thu, 7 Jul 2022 16:31:21 +0200 Message-Id: <20220707143122.460362-2-haris.iqbal@ionos.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220707143122.460362-1-haris.iqbal@ionos.com> References: <20220707143122.460362-1-haris.iqbal@ionos.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org After setting keep_id if the mutex trylock fails, the keep_id stays set for the rest of the sess_dev lifetime. Therefore, set keep_id to true after mutex_trylock succeeds, so that a failure of trylock does'nt touch keep_id. Fixes: b168e1d85cf3 ("block/rnbd-srv: Prevent a deadlock generated by accessing sysfs in parallel") Cc: gi-oh.kim@ionos.com Signed-off-by: Md Haris Iqbal Signed-off-by: Jack Wang --- drivers/block/rnbd/rnbd-srv.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/block/rnbd/rnbd-srv.c b/drivers/block/rnbd/rnbd-srv.c index beaef43a67b9..cf9e29a08db2 100644 --- a/drivers/block/rnbd/rnbd-srv.c +++ b/drivers/block/rnbd/rnbd-srv.c @@ -323,10 +323,11 @@ void rnbd_srv_sess_dev_force_close(struct rnbd_srv_sess_dev *sess_dev, { struct rnbd_srv_session *sess = sess_dev->sess; - sess_dev->keep_id = true; /* It is already started to close by client's close message. */ if (!mutex_trylock(&sess->lock)) return; + + sess_dev->keep_id = true; /* first remove sysfs itself to avoid deadlock */ sysfs_remove_file_self(&sess_dev->kobj, &attr->attr); rnbd_srv_destroy_dev_session_sysfs(sess_dev);