get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/1902594/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 1902594,
    "url": "http://patchwork.ozlabs.org/api/patches/1902594/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linux-um/patch/20240222072417.3773131-8-hch@lst.de/",
    "project": {
        "id": 60,
        "url": "http://patchwork.ozlabs.org/api/projects/60/?format=api",
        "name": "User-mode Linux Development",
        "link_name": "linux-um",
        "list_id": "linux-um.lists.infradead.org",
        "list_email": "linux-um@lists.infradead.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20240222072417.3773131-8-hch@lst.de>",
    "list_archive_url": null,
    "date": "2024-02-22T07:24:17",
    "name": "[7/7] ubd: open the backing files in ubd_add",
    "commit_ref": null,
    "pull_url": null,
    "state": "handled-elsewhere",
    "archived": false,
    "hash": "fc7b29a1588aecf3584464c90b1651a7abf81646",
    "submitter": {
        "id": 82,
        "url": "http://patchwork.ozlabs.org/api/people/82/?format=api",
        "name": "Christoph Hellwig",
        "email": "hch@lst.de"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linux-um/patch/20240222072417.3773131-8-hch@lst.de/mbox/",
    "series": [
        {
            "id": 396078,
            "url": "http://patchwork.ozlabs.org/api/series/396078/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/linux-um/list/?series=396078",
            "date": "2024-02-22T07:24:13",
            "name": "[1/7] ubd: remove the ubd_gendisk array",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/396078/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/1902594/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/1902594/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "\n <linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n secure) header.d=lists.infradead.org header.i=@lists.infradead.org\n header.a=rsa-sha256 header.s=bombadil.20210309 header.b=jQlmXbQw;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=none (no SPF record) smtp.mailfrom=lists.infradead.org\n (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org;\n envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org;\n receiver=patchwork.ozlabs.org)"
        ],
        "Received": [
            "from bombadil.infradead.org (bombadil.infradead.org\n [IPv6:2607:7c80:54:3::133])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4TgPm93CzWz23d2\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 22 Feb 2024 18:24:41 +1100 (AEDT)",
            "from localhost ([::1] helo=bombadil.infradead.org)\n\tby bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux))\n\tid 1rd3Rf-00000003nmI-2R1G;\n\tThu, 22 Feb 2024 07:24:39 +0000",
            "from [2001:4bb8:19a:62b2:c70:4a89:bc61:3] (helo=localhost)\n\tby bombadil.infradead.org with esmtpsa (Exim 4.97.1 #2 (Red Hat Linux))\n\tid 1rd3Rd-00000003njL-0p4J;\n\tThu, 22 Feb 2024 07:24:37 +0000"
        ],
        "DKIM-Signature": "v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed;\n\td=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help\n\t:List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding:\n\tMIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:\n\tReply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From:\n\tResent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner;\n\tbh=Fn+HB6bbM1pjLkNl/fg3PCRANt5VA3yO0I85pvryFgs=; b=jQlmXbQwjwqPwzFCfLGSKYOiK6\n\tGwv/8MJzDmJAd02zBON9HeeQLS8KK0qzaf3QRB8LMXZgpyLDHm2aVOLDpkhy21Af2sdTGfoiklvKo\n\tNtNfZ6Pu4AJlYJx6IXFv11O+SPUphQ7dN/WIUMS/yFeWfaJxnjuujp6FAJsPCklzFiZgKwWnBZMIE\n\tVfBTrRD3kNzuA/w74YG0hRWn7FelNMKea+JdqScOXTQfzWJoDmhTFeE94w8WjddD7l2ZL+oe46HUE\n\tcnhsS8F+Zq2GNA67T1sS41UhVSer5mQ0ngc8UQo2anGWWLzx2HiWEQiNaW+Niu28Ynfs3By+QwT4H\n\tDH3lYrOQ==;",
        "From": "Christoph Hellwig <hch@lst.de>",
        "To": "Richard Weinberger <richard@nod.at>,\n\tAnton Ivanov <anton.ivanov@cambridgegreys.com>,\n\tJohannes Berg <johannes@sipsolutions.net>,\n\tJens Axboe <axboe@kernel.dk>",
        "Cc": "linux-um@lists.infradead.org,\n\tlinux-block@vger.kernel.org",
        "Subject": "[PATCH 7/7] ubd: open the backing files in ubd_add",
        "Date": "Thu, 22 Feb 2024 08:24:17 +0100",
        "Message-Id": "<20240222072417.3773131-8-hch@lst.de>",
        "X-Mailer": "git-send-email 2.39.2",
        "In-Reply-To": "<20240222072417.3773131-1-hch@lst.de>",
        "References": "<20240222072417.3773131-1-hch@lst.de>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "X-BeenThere": "linux-um@lists.infradead.org",
        "X-Mailman-Version": "2.1.34",
        "Precedence": "list",
        "List-Id": "<linux-um.lists.infradead.org>",
        "List-Unsubscribe": "<http://lists.infradead.org/mailman/options/linux-um>,\n <mailto:linux-um-request@lists.infradead.org?subject=unsubscribe>",
        "List-Archive": "<http://lists.infradead.org/pipermail/linux-um/>",
        "List-Post": "<mailto:linux-um@lists.infradead.org>",
        "List-Help": "<mailto:linux-um-request@lists.infradead.org?subject=help>",
        "List-Subscribe": "<http://lists.infradead.org/mailman/listinfo/linux-um>,\n <mailto:linux-um-request@lists.infradead.org?subject=subscribe>",
        "Sender": "\"linux-um\" <linux-um-bounces@lists.infradead.org>",
        "Errors-To": "linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org"
    },
    "content": "Opening the backing device only when the block device is opened is\na bit weird as no one configures block devices to not use them.\nOpend them at add time, close them at remove time and remove the\nnow superflous opened counter as remove can simply check for\ndisk_openers.\n\nSigned-off-by: Christoph Hellwig <hch@lst.de>\n---\n arch/um/drivers/ubd_kern.c | 58 +++++++++++---------------------------\n 1 file changed, 16 insertions(+), 42 deletions(-)",
    "diff": "diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c\nindex 9bf1d6a88bae59..63fc062add708c 100644\n--- a/arch/um/drivers/ubd_kern.c\n+++ b/arch/um/drivers/ubd_kern.c\n@@ -108,8 +108,6 @@ static inline void ubd_set_bit(__u64 bit, unsigned char *data)\n static DEFINE_MUTEX(ubd_lock);\n static DEFINE_MUTEX(ubd_mutex); /* replaces BKL, might not be needed */\n \n-static int ubd_open(struct gendisk *disk, blk_mode_t mode);\n-static void ubd_release(struct gendisk *disk);\n static int ubd_ioctl(struct block_device *bdev, blk_mode_t mode,\n \t\t     unsigned int cmd, unsigned long arg);\n static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo);\n@@ -118,8 +116,6 @@ static int ubd_getgeo(struct block_device *bdev, struct hd_geometry *geo);\n \n static const struct block_device_operations ubd_blops = {\n         .owner\t\t= THIS_MODULE,\n-        .open\t\t= ubd_open,\n-        .release\t= ubd_release,\n         .ioctl\t\t= ubd_ioctl,\n         .compat_ioctl\t= blkdev_compat_ptr_ioctl,\n \t.getgeo\t\t= ubd_getgeo,\n@@ -152,7 +148,6 @@ struct ubd {\n \t * backing or the cow file. */\n \tchar *file;\n \tchar *serial;\n-\tint count;\n \tint fd;\n \t__u64 size;\n \tstruct openflags boot_openflags;\n@@ -178,7 +173,6 @@ struct ubd {\n #define DEFAULT_UBD { \\\n \t.file = \t\tNULL, \\\n \t.serial =\t\tNULL, \\\n-\t.count =\t\t0, \\\n \t.fd =\t\t\t-1, \\\n \t.size =\t\t\t-1, \\\n \t.boot_openflags =\tOPEN_FLAGS, \\\n@@ -873,6 +867,13 @@ static int ubd_add(int n, char **error_out)\n \t\tgoto out;\n \t}\n \n+\terr = ubd_open_dev(ubd_dev);\n+\tif (err) {\n+\t\tpr_err(\"ubd%c: Can't open \\\"%s\\\": errno = %d\\n\",\n+\t\t\t'a' + n, ubd_dev->file, -err);\n+\t\tgoto out;\n+\t}\n+\n \tubd_dev->size = ROUND_BLOCK(ubd_dev->size);\n \n \tubd_dev->tag_set.ops = &ubd_mq_ops;\n@@ -884,7 +885,7 @@ static int ubd_add(int n, char **error_out)\n \n \terr = blk_mq_alloc_tag_set(&ubd_dev->tag_set);\n \tif (err)\n-\t\tgoto out;\n+\t\tgoto out_close;\n \n \tdisk = blk_mq_alloc_disk(&ubd_dev->tag_set, &lim, ubd_dev);\n \tif (IS_ERR(disk)) {\n@@ -919,6 +920,8 @@ static int ubd_add(int n, char **error_out)\n \tput_disk(disk);\n out_cleanup_tags:\n \tblk_mq_free_tag_set(&ubd_dev->tag_set);\n+out_close:\n+\tubd_close_dev(ubd_dev);\n out:\n \treturn err;\n }\n@@ -1014,13 +1017,14 @@ static int ubd_remove(int n, char **error_out)\n \tif(ubd_dev->file == NULL)\n \t\tgoto out;\n \n-\t/* you cannot remove a open disk */\n-\terr = -EBUSY;\n-\tif(ubd_dev->count > 0)\n-\t\tgoto out;\n-\n \tif (ubd_dev->disk) {\n+\t\t/* you cannot remove a open disk */\n+\t\terr = -EBUSY;\n+\t\tif (disk_openers(ubd_dev->disk))\n+\t\t\tgoto out;\n+\n \t\tdel_gendisk(ubd_dev->disk);\n+\t\tubd_close_dev(ubd_dev);\n \t\tput_disk(ubd_dev->disk);\n \t}\n \n@@ -1143,36 +1147,6 @@ static int __init ubd_driver_init(void){\n \n device_initcall(ubd_driver_init);\n \n-static int ubd_open(struct gendisk *disk, blk_mode_t mode)\n-{\n-\tstruct ubd *ubd_dev = disk->private_data;\n-\tint err = 0;\n-\n-\tmutex_lock(&ubd_mutex);\n-\tif(ubd_dev->count == 0){\n-\t\terr = ubd_open_dev(ubd_dev);\n-\t\tif(err){\n-\t\t\tprintk(KERN_ERR \"%s: Can't open \\\"%s\\\": errno = %d\\n\",\n-\t\t\t       disk->disk_name, ubd_dev->file, -err);\n-\t\t\tgoto out;\n-\t\t}\n-\t}\n-\tubd_dev->count++;\n-out:\n-\tmutex_unlock(&ubd_mutex);\n-\treturn err;\n-}\n-\n-static void ubd_release(struct gendisk *disk)\n-{\n-\tstruct ubd *ubd_dev = disk->private_data;\n-\n-\tmutex_lock(&ubd_mutex);\n-\tif(--ubd_dev->count == 0)\n-\t\tubd_close_dev(ubd_dev);\n-\tmutex_unlock(&ubd_mutex);\n-}\n-\n static void cowify_bitmap(__u64 io_offset, int length, unsigned long *cow_mask,\n \t\t\t  __u64 *cow_offset, unsigned long *bitmap,\n \t\t\t  __u64 bitmap_offset, unsigned long *bitmap_words,\n",
    "prefixes": [
        "7/7"
    ]
}