From mboxrd@z Thu Jan 1 00:00:00 1970 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 4F08DC43334 for ; Thu, 2 Jun 2022 08:19:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232122AbiFBITR (ORCPT ); Thu, 2 Jun 2022 04:19:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44176 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232108AbiFBITO (ORCPT ); Thu, 2 Jun 2022 04:19:14 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AF1F39FF1 for ; Thu, 2 Jun 2022 01:18:57 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id k36-20020a05600c1ca400b0039c2a3394caso678039wms.2 for ; Thu, 02 Jun 2022 01:18:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel-dk.20210112.gappssmtp.com; s=20210112; h=message-id:date:mime-version:user-agent:subject:content-language:to :cc:references:from:in-reply-to:content-transfer-encoding; bh=grBv/gpdLam/wFPbL6YIo2ry7eetDeeb1gTECl6N5a0=; b=e+JfYtJUswtJB0x8AUiFMyZUjpBuIgki6tjiKQkbEvFjujCQo2sSU2IpdLbTxjZzGf DGPUUuWxaQ2oZ/qlncmtlAIqODbKjyLQyZIH3ILINgLZdqPiB+9OcYmfxZ5e1yOZGDVz JQHBa0ibO6Q47Cb/hux7noKKg9qNMwGB1wHrKfoRLBSs8vMIlBpeegC9nfI1mwPwCKgu IEnsF6qZ6nIobllJjjd6V8/hMiBN2tWpy8TNqdYTcJDMw1ETljCq/KzRkaRhQZ2dNIxn YXgDD43SUcRO4QlWkWCYqqVkmEctRY/AXCw7kmyOMpdq3rkl29tPafdPz1v21R8uE8mu JmUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=grBv/gpdLam/wFPbL6YIo2ry7eetDeeb1gTECl6N5a0=; b=jwf3puP+rA1WVA4wMPoKBEjVGK+rJSOg68z2OWeoJIXnIwLk3+O2SMlh2DxMyj2CbT BK2ugAKN+6RdLzwgzp//G+2Eaz0vsABzDTHatDOGhgTm9h1/dJED+LVoGLzPH6J1RbBo 91VpzchOlFK3ObBYXbCILlfzfrQCrEweeRB/gQ4Jsw8zF2mMVI6Epdl7Twu0f4JJY/n6 kgDkJmv06JsQZqt1eSO3yXlok4pdem0hBA6X/GfNu5KSE2bWIbRssVwh1UJQg3TYLR20 eAMFJN7H5vZcz6rvdtzRwe7PUFaXMkor/6s3/2UjNxS7M5GgxA6HBBBW1GvxT9Hqjyoi YI1w== X-Gm-Message-State: AOAM533xyyHOYb2J9mWhJ7vHeSqAlk1XqzpQD0MLCvLmVaWC2JnjFFn4 bSw/KUOFHNS0LKuKFRlMbpDSRX20jriX6789 X-Google-Smtp-Source: ABdhPJxPBSxtMAL0eFt5HtWjrSQGq6vvRTkHzimcZatsdY+SMZ31DPKqDNJcbU2ReLbfFuBYvhvQrA== X-Received: by 2002:a05:600c:acf:b0:397:345f:fe10 with SMTP id c15-20020a05600c0acf00b00397345ffe10mr2909296wmr.15.1654157936135; Thu, 02 Jun 2022 01:18:56 -0700 (PDT) Received: from [10.40.36.78] ([193.52.24.5]) by smtp.gmail.com with ESMTPSA id a4-20020a5d5084000000b002102f2fac37sm3786342wrt.51.2022.06.02.01.18.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Jun 2022 01:18:55 -0700 (PDT) Message-ID: <7cf7a9ce-525d-3b90-2b49-6eae6189da6e@kernel.dk> Date: Thu, 2 Jun 2022 02:18:54 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 Subject: Re: bioset_exit poison from dm_destroy Content-Language: en-US To: Christoph Hellwig , Mike Snitzer Cc: Matthew Wilcox , dm-devel@redhat.com, linux-block@vger.kernel.org, david@fromorbit.com References: <2523e5b0-d89c-552e-40a6-6d414418749d@kernel.dk> From: Jens Axboe In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org On 6/2/22 2:12 AM, Christoph Hellwig wrote: > On Wed, Jun 01, 2022 at 10:13:34AM -0400, Mike Snitzer wrote: >> Please take the time to look at the code and save your judgement until >> you do. That said, I'm not in love with the complexity of how DM >> handles bioset initialization. But both you and Jens keep taking >> shots at DM for doing things wrong without actually looking. > > I'm not taking shots. I'm just saying we should kill this API. In > the worse case the caller can keep track of if a bioset is initialized, > but in most cases we should be able to deduct it in a nicer way. Yeah ditto, it's more an observation on needing something like this_foo_was_initialized() is just a bad way to program it to begin with. The caller should know this already, rather than us needing functions and state in the struct to tell you about it. >> DM uses bioset_init_from_src(). Yet you've both assumed double frees >> and such (while not entirely wrong your glossing over the detail that >> there is intervening reinitialization of DM's biosets between the >> bioset_exit()s) > > And looking at the code, that use of bioset_init_from_src is completely > broken. It does not actually preallocated anything as intended by > dm (maybe that isn't actually needed) but just uses the biosets in > dm_md_mempools as an awkward way to carry parameters. And completely > loses bringing over the integrity allocations. And no, this is not > intended as a "cheap shot" against Jens who did that either.. > > This is what I think should fix this, and will allow us to remove > bioset_init_from_src which was a bad idea from the start: Based on a quick look, seems good to me. -- Jens Axboe From mboxrd@z Thu Jan 1 00:00:00 1970 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 us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B8768C433EF for ; Thu, 2 Jun 2022 08:19:08 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-380-wqjwEizSNdC3VkDwRBcRww-1; Thu, 02 Jun 2022 04:19:04 -0400 X-MC-Unique: wqjwEizSNdC3VkDwRBcRww-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BFE5F802804; Thu, 2 Jun 2022 08:19:02 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 170BD416366; Thu, 2 Jun 2022 08:19:01 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D45561947B84; Thu, 2 Jun 2022 08:19:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D47AC1947B83 for ; Thu, 2 Jun 2022 08:18:59 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A1AB42166B33; Thu, 2 Jun 2022 08:18:59 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast10.extmail.prod.ext.rdu2.redhat.com [10.11.55.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9B7A52166B2C for ; Thu, 2 Jun 2022 08:18:59 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 7A18E1C04B63 for ; Thu, 2 Jun 2022 08:18:59 +0000 (UTC) Received: from mail-wm1-f41.google.com (mail-wm1-f41.google.com [209.85.128.41]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-614--18W3CgWN1iO3YYC9dgNcQ-1; Thu, 02 Jun 2022 04:18:57 -0400 X-MC-Unique: -18W3CgWN1iO3YYC9dgNcQ-1 Received: by mail-wm1-f41.google.com with SMTP id h62-20020a1c2141000000b0039aa4d054e2so4374760wmh.1 for ; Thu, 02 Jun 2022 01:18:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:date:mime-version:user-agent:subject :content-language:to:cc:references:from:in-reply-to :content-transfer-encoding; bh=grBv/gpdLam/wFPbL6YIo2ry7eetDeeb1gTECl6N5a0=; b=gmUIo75TOUagv/DSWhj8yHlRmYmdvf8LUPjV8nBPqOebAwcWJg8l/3a9+uF1iivvT1 yn2BoUg8DPm1WcfrTHon+TKPmsJ7SljZxKx5bhH5sVo23KIqPPCDjzIuxqL5DA9+YAPO jntJY6IcSXMH89U+Ey/2/tCM+AX/QujR3rJpuMvEi86SZXaWf8mlQPuhvxFaFbud57ho G3yKazhl/uqJSb3qcvYBCm39orqLAI31aZt6cQQl+K/uQAepjeLX7FGD/wI5qYBwoofD OVzERp7UjUzqnZPS10wMzYdEDbRprvyVt+1CfYmst8Qyf4sz5bAZNSGZIOV2BjVXTr5Z AQjA== X-Gm-Message-State: AOAM531SIAoEmUelzdJ4SoqX4VQvResjvTGLfABRGYT4GmjN7LipTqEa +SvMANJje7hFYPA91cfImin4Fw== X-Google-Smtp-Source: ABdhPJxPBSxtMAL0eFt5HtWjrSQGq6vvRTkHzimcZatsdY+SMZ31DPKqDNJcbU2ReLbfFuBYvhvQrA== X-Received: by 2002:a05:600c:acf:b0:397:345f:fe10 with SMTP id c15-20020a05600c0acf00b00397345ffe10mr2909296wmr.15.1654157936135; Thu, 02 Jun 2022 01:18:56 -0700 (PDT) Received: from [10.40.36.78] ([193.52.24.5]) by smtp.gmail.com with ESMTPSA id a4-20020a5d5084000000b002102f2fac37sm3786342wrt.51.2022.06.02.01.18.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 02 Jun 2022 01:18:55 -0700 (PDT) Message-ID: <7cf7a9ce-525d-3b90-2b49-6eae6189da6e@kernel.dk> Date: Thu, 2 Jun 2022 02:18:54 -0600 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:91.0) Gecko/20100101 Thunderbird/91.9.0 To: Christoph Hellwig , Mike Snitzer References: <2523e5b0-d89c-552e-40a6-6d414418749d@kernel.dk> From: Jens Axboe In-Reply-To: X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Subject: Re: [dm-devel] bioset_exit poison from dm_destroy X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-block@vger.kernel.org, dm-devel@redhat.com, david@fromorbit.com, Matthew Wilcox Errors-To: dm-devel-bounces@redhat.com Sender: "dm-devel" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dm-devel-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit On 6/2/22 2:12 AM, Christoph Hellwig wrote: > On Wed, Jun 01, 2022 at 10:13:34AM -0400, Mike Snitzer wrote: >> Please take the time to look at the code and save your judgement until >> you do. That said, I'm not in love with the complexity of how DM >> handles bioset initialization. But both you and Jens keep taking >> shots at DM for doing things wrong without actually looking. > > I'm not taking shots. I'm just saying we should kill this API. In > the worse case the caller can keep track of if a bioset is initialized, > but in most cases we should be able to deduct it in a nicer way. Yeah ditto, it's more an observation on needing something like this_foo_was_initialized() is just a bad way to program it to begin with. The caller should know this already, rather than us needing functions and state in the struct to tell you about it. >> DM uses bioset_init_from_src(). Yet you've both assumed double frees >> and such (while not entirely wrong your glossing over the detail that >> there is intervening reinitialization of DM's biosets between the >> bioset_exit()s) > > And looking at the code, that use of bioset_init_from_src is completely > broken. It does not actually preallocated anything as intended by > dm (maybe that isn't actually needed) but just uses the biosets in > dm_md_mempools as an awkward way to carry parameters. And completely > loses bringing over the integrity allocations. And no, this is not > intended as a "cheap shot" against Jens who did that either.. > > This is what I think should fix this, and will allow us to remove > bioset_init_from_src which was a bad idea from the start: Based on a quick look, seems good to me. -- Jens Axboe -- dm-devel mailing list dm-devel@redhat.com https://listman.redhat.com/mailman/listinfo/dm-devel