[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v2 16/16] xen-blkback: Inform userspace that device has been opened
- To: Demi Marie Obenour <demi@xxxxxxxxxxxxxxxxxxxxxx>
- From: Roger Pau Monné <roger.pau@xxxxxxxxxx>
- Date: Tue, 6 Jun 2023 11:15:37 +0200
- Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=GboHwPOgZPWnbvOQ54qadWvGHJEDI4Btv6WWy6d1rJ0=; b=jQeYs+6dGby4ewOKeUWFJNpPfymCUaH2mRWYIqdCxVCrSKyWB9tvRaH5kUiTQpWZ2ZFN2hV2tFEVzZ8VrAVf4Rddarv1nGRWRAlo/hAVjyySxgfdptDogf55k5xvs3dF+ICR5SXa4g6Mgztn5ki4xfkezVF3xzhJS6NmuXyA67gtGnGlRgsLpRQHK3wyXgmrivyk2t/ZfO54XbBtZrdYcYmVglk5cTWARJUBs3+KKUx7imMQqMYsB8/720CY2/wR/zKjCiLpSaVZ7sfephHr+2cvRo+G4GuZzF10mSUMizg3h0rjOgMrxFm0tyKSbxeNWmG7u3xnSVPQcatSi9wB3A==
- Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=l+bZY2lHUOOnXecWHqWGuT8s/fEcYTOyc9c6AVBAw3JNkFdpt0oepI5yH8tiFhTn2IgbtdVaNNgAE0w1HniyYjKcSfip7UD05on6sz+Ew0RNih6WrfYfomTN3Z3oEjua+t0wnjI/PLcthJ6gq++dGeQ+x44HSJR47xkTkYTc5mvxhcgKu+mFgHdtYnMBLty1FC6zgTeGxTE4cRl6zKTx2kXRxS2O+GfKrNrHGvuO1Vq3MP+Qz8RzNE+VKqumbirXjlPbB8TvpjIj6iI39NEFXEHPrc1Cm9aCB4m0h9b7STtJcs5U+pCMXQKPJ3WvsJyHdRsyxL6k1o46aLNzyGsMrg==
- Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
- Cc: Jens Axboe <axboe@xxxxxxxxx>, Alasdair Kergon <agk@xxxxxxxxxx>, Mike Snitzer <snitzer@xxxxxxxxxx>, dm-devel@xxxxxxxxxx, Marek Marczykowski-Górecki <marmarek@xxxxxxxxxxxxxxxxxxxxxx>, linux-block@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, xen-devel@xxxxxxxxxxxxxxxxxxxx
- Delivery-date: Tue, 06 Jun 2023 09:16:12 +0000
- Ironport-data: A9a23:twFP+aD4uAgPQxVW/2vjw5YqxClBgxIJ4kV8jS/XYbTApDgi0DQHy GQeWm3QPv+JYzb8e4xzO4m/9k0PuMLRnYc3QQY4rX1jcSlH+JHPbTi7wuUcHAvJd5GeExg3h yk6QoOdRCzhZiaE/n9BCpC48T8nk/nOHuGmYAL9EngZbRd+Tys8gg5Ulec8g4p56fC0GArIs t7pyyHlEAbNNwVcbCRMs8pvlDs15K6p4G1A4ARnDRx2lAS2e0c9Xcp3yZ6ZdxMUcqEMdsamS uDKyq2O/2+x13/B3fv8z94X2mVTKlLjFVDmZkh+AsBOsTAbzsAG6Y4pNeJ0VKtio27hc+ada jl6ncfYpQ8BZsUgkQmGOvVSO3kW0aZuoNcrLZUj2CA6IoKvn3bEmp1T4E8K0YIwy8xvHFxz8 MUjdh8rTVOOp8+Qm7K7Y7w57igjBJGD0II3nFhFlGucIdN4BJfJTuPN+MNS2yo2ioZWB/HCa sEFaD1pKhPdfxlIPVRRA5U79AuqriCnL3sE9xTI9OxuvDW7IA9ZidABNPLPfdOHX4NNl1uwr WPa5WXpRBodMbRzzBLcqyrw17SUw36TtIQ6Jey7yKFYpBqqmGUpGk0qVWWK5tf6oxvrMz5YA wlOksY0loA++UmqZtj7QRyjoXSAswIcWtxfCOkz4keGza+8yw+JDG8JZj1MctorsIk6RlQC3 1CKt8nkCTxmrPueTnf13qySrC+gNDI9LmIYYyIACwwf7LHLrIR2gh/RQ9JLCqO5jtTpXzr3x liiqSEkgrwJgM0j1qOl/EvGiTahupjISAEu4gzdGGmi62tRYI+jepzt41zc5vVoMomUVB+Cs WIClszY6/oBZbmJlSqQUKAOEauv6vKtLjLRmxhsEoMn+jDr/GSsFahA7Tc7KEp3P8IsfT7yf FSVqQ5X/IVUPnahcelweY3ZNigx5a3pFNCgWvWKaNNLO8J1bFXeo3woYlOM1WfwlkRqibs4J ZqQbcerCzAdFLhjyz21Aewa1NfH2xwD+I8afrijpzzP7FZUTCT9pWstWLdWUt0E0Q==
- Ironport-hdrordr: A9a23:WlCXJ6izZomWYod5M3i6+IcOw3BQXvoji2hC6mlwRA09TyX4rb HUoB1/73XJYVkqKRYdcLy7WJVoBEmslqKdg7NhW4tKLTOW3VdARbsKheCC/9SjIVydygc379 YYT0ERMqyJMbG4t6rHCcuDfurIDOPpzImYwcHj8kxAZStKL5tNyDoRMHf+LqS+fmd7OaY=
- List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
On Tue, May 30, 2023 at 04:31:16PM -0400, Demi Marie Obenour wrote:
> Set "opened" to "0" before the hotplug script is called. Once the
> device node has been opened, set "opened" to "1".
>
> "opened" is used exclusively by userspace. It serves two purposes:
>
> 1. It tells userspace that the diskseq Xenstore entry is supported.
>
> 2. It tells userspace that it can wait for "opened" to be set to 1.
> Once "opened" is 1, blkback has a reference to the device, so
> userspace doesn't need to keep one.
>
> Together, these changes allow userspace to use block devices with
> delete-on-close behavior, such as loop devices with the autoclear flag
> set or device-mapper devices with the deferred-remove flag set.
There was some work in the past to allow reloading blkback as a
module, it's clear that using delete-on-close won't work if attempting
to reload blkback.
Isn't there some existing way to check whether a device is opened?
(stat syscall maybe?).
I would like to avoid adding more xenstore blkback state if such
information can be fetched from other methods.
> Signed-off-by: Demi Marie Obenour <demi@xxxxxxxxxxxxxxxxxxxxxx>
> ---
> drivers/block/xen-blkback/xenbus.c | 35 ++++++++++++++++++++++++++++++
> 1 file changed, 35 insertions(+)
>
> diff --git a/drivers/block/xen-blkback/xenbus.c
> b/drivers/block/xen-blkback/xenbus.c
> index
> 9c3eb148fbd802c74e626c3d7bcd69dcb09bd921..519a78aa9073d1faa1dce5c1b36e95ae58da534b
> 100644
> --- a/drivers/block/xen-blkback/xenbus.c
> +++ b/drivers/block/xen-blkback/xenbus.c
> @@ -3,6 +3,20 @@
> Copyright (C) 2005 Rusty Russell <rusty@xxxxxxxxxxxxxxx>
> Copyright (C) 2005 XenSource Ltd
>
> +In addition to the Xenstore nodes required by the Xen block device
> +specification, this implementation of blkback uses a new Xenstore
> +node: "opened". blkback sets "opened" to "0" before the hotplug script
> +is called. Once the device node has been opened, blkback sets "opened"
> +to "1".
> +
> +"opened" is read exclusively by userspace. It serves two purposes:
> +
> +1. It tells userspace that diskseq@major:minor syntax for "physical-device"
> is
> + supported.
> +
> +2. It tells userspace that it can wait for "opened" to be set to 1 after
> writing
> + "physical-device". Once "opened" is 1, blkback has a reference to the
> + device, so userspace doesn't need to keep one.
>
> */
>
> @@ -699,6 +713,14 @@ static int xen_blkbk_probe(struct xenbus_device *dev,
> if (err)
> pr_warn("%s write out 'max-ring-page-order' failed\n",
> __func__);
>
> + /*
> + * This informs userspace that the "opened" node will be set to "1" when
> + * the device has been opened successfully.
> + */
> + err = xenbus_write(XBT_NIL, dev->nodename, "opened", "0");
> + if (err)
> + goto fail;
> +
You would need to set "opened" before registering the xenstore backend
watch AFAICT, or else it could be racy.
Thanks, Roger.
|