From nobody Sat Nov 30 00:38:29 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) client-ip=192.237.175.120; envelope-from=xen-devel-bounces@lists.xenproject.org; helo=lists.xenproject.org; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass(p=quarantine dis=none) header.from=suse.com ARC-Seal: i=1; a=rsa-sha256; t=1620900209; cv=none; d=zohomail.com; s=zohoarc; b=RwFGrih7OWPv6xowkFVmiL5kYQMUt/2g1cpRET4KrQmZ+yXyaiLyHl8IZ722hDJwVhMXYI+6OdumIuUVJq99GJJQux7eytytNsnsSn/1MHcexJJCgxLEN//MIlkEY2zvaLWgfLYb3ZfvCLk8I2XbBR/OC/V43drz3r9jJOo/az4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620900209; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=lutTQX8ZA5u3khaAXqUgHLKbfap899noTeivh9Sx9NQ=; b=VhlwNnekkXXMVm8vuxDw8RwgR06MAaEAKzB5dsZQ3zrACv7vKpxvYpANiJQeRoNnJqoXgCGhLq7ZxEUdfsOZlMZm4YHNMw/tcCzRgmVnKx00HnxWhdZ36SFNODOoMzagEvo6BLt+3ntUNhzgz1kVkPPdQLBVwxXcqL2F4D9xmpk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of lists.xenproject.org designates 192.237.175.120 as permitted sender) smtp.mailfrom=xen-devel-bounces@lists.xenproject.org; dmarc=pass header.from= (p=quarantine dis=none) header.from= Return-Path: Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) by mx.zohomail.com with SMTPS id 162090020971868.23437857683484; Thu, 13 May 2021 03:03:29 -0700 (PDT) Received: from list by lists.xenproject.org with outflank-mailman.126807.238297 (Exim 4.92) (envelope-from ) id 1lh8BV-0004WH-JW; Thu, 13 May 2021 10:03:13 +0000 Received: by outflank-mailman (output) from mailman id 126807.238297; Thu, 13 May 2021 10:03:13 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lh8BV-0004W2-Ex; Thu, 13 May 2021 10:03:13 +0000 Received: by outflank-mailman (input) for mailman id 126807; Thu, 13 May 2021 10:03:12 +0000 Received: from us1-rack-iad1.inumbo.com ([172.99.69.81]) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1lh8BU-0003vg-2p for xen-devel@lists.xenproject.org; Thu, 13 May 2021 10:03:12 +0000 Received: from mx2.suse.de (unknown [195.135.220.15]) by us1-rack-iad1.inumbo.com (Halon) with ESMTPS id 29589f22-b6ae-440a-94dd-2a81fbe2126e; Thu, 13 May 2021 10:03:06 +0000 (UTC) Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id B132FAFF5; Thu, 13 May 2021 10:03:05 +0000 (UTC) X-Outflank-Mailman: Message body and most headers restored to incoming version X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 29589f22-b6ae-440a-94dd-2a81fbe2126e X-Virus-Scanned: by amavisd-new at test-mx.suse.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1620900185; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=lutTQX8ZA5u3khaAXqUgHLKbfap899noTeivh9Sx9NQ=; b=X9zTq81SYVIejJbZ3hqVnPgnP7pcUDx2BE/zHP4wRq7hBon4FcfafyN+fXITzioqYy+QoR pBz0uhcESpMAUzIdg50l7VW/TsBGw3s6HDsmczQ3YLqYI5+JC1vvrfRDwWsaYqSOxIH89y FBMrmVY8k7hSXXCMQGggw+D5zhxq8r4= From: Juergen Gross To: xen-devel@lists.xenproject.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Juergen Gross , Konrad Rzeszutek Wilk , =?UTF-8?q?Roger=20Pau=20Monn=C3=A9?= , Boris Ostrovsky , Stefano Stabellini , Jens Axboe Subject: [PATCH 2/8] xen/blkfront: read response from backend only once Date: Thu, 13 May 2021 12:02:56 +0200 Message-Id: <20210513100302.22027-3-jgross@suse.com> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20210513100302.22027-1-jgross@suse.com> References: <20210513100302.22027-1-jgross@suse.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @suse.com) Content-Type: text/plain; charset="utf-8" In order to avoid problems in case the backend is modifying a response on the ring page while the frontend has already seen it, just read the response into a local buffer in one go and then operate on that buffer only. Signed-off-by: Juergen Gross Reviewed-by: Jan Beulich --- drivers/block/xen-blkfront.c | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index 10df39a8b18d..a8b56c153330 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c @@ -1557,7 +1557,7 @@ static bool blkif_completion(unsigned long *id, static irqreturn_t blkif_interrupt(int irq, void *dev_id) { struct request *req; - struct blkif_response *bret; + struct blkif_response bret; RING_IDX i, rp; unsigned long flags; struct blkfront_ring_info *rinfo =3D (struct blkfront_ring_info *)dev_id; @@ -1574,8 +1574,9 @@ static irqreturn_t blkif_interrupt(int irq, void *dev= _id) for (i =3D rinfo->ring.rsp_cons; i !=3D rp; i++) { unsigned long id; =20 - bret =3D RING_GET_RESPONSE(&rinfo->ring, i); - id =3D bret->id; + RING_COPY_RESPONSE(&rinfo->ring, i, &bret); + id =3D bret.id; + /* * The backend has messed up and given us an id that we would * never have given to it (we stamp it up to BLK_RING_SIZE - @@ -1583,39 +1584,39 @@ static irqreturn_t blkif_interrupt(int irq, void *d= ev_id) */ if (id >=3D BLK_RING_SIZE(info)) { WARN(1, "%s: response to %s has incorrect id (%ld)\n", - info->gd->disk_name, op_name(bret->operation), id); + info->gd->disk_name, op_name(bret.operation), id); /* We can't safely get the 'struct request' as * the id is busted. */ continue; } req =3D rinfo->shadow[id].request; =20 - if (bret->operation !=3D BLKIF_OP_DISCARD) { + if (bret.operation !=3D BLKIF_OP_DISCARD) { /* * We may need to wait for an extra response if the * I/O request is split in 2 */ - if (!blkif_completion(&id, rinfo, bret)) + if (!blkif_completion(&id, rinfo, &bret)) continue; } =20 if (add_id_to_freelist(rinfo, id)) { WARN(1, "%s: response to %s (id %ld) couldn't be recycled!\n", - info->gd->disk_name, op_name(bret->operation), id); + info->gd->disk_name, op_name(bret.operation), id); continue; } =20 - if (bret->status =3D=3D BLKIF_RSP_OKAY) + if (bret.status =3D=3D BLKIF_RSP_OKAY) blkif_req(req)->error =3D BLK_STS_OK; else blkif_req(req)->error =3D BLK_STS_IOERR; =20 - switch (bret->operation) { + switch (bret.operation) { case BLKIF_OP_DISCARD: - if (unlikely(bret->status =3D=3D BLKIF_RSP_EOPNOTSUPP)) { + if (unlikely(bret.status =3D=3D BLKIF_RSP_EOPNOTSUPP)) { struct request_queue *rq =3D info->rq; printk(KERN_WARNING "blkfront: %s: %s op failed\n", - info->gd->disk_name, op_name(bret->operation)); + info->gd->disk_name, op_name(bret.operation)); blkif_req(req)->error =3D BLK_STS_NOTSUPP; info->feature_discard =3D 0; info->feature_secdiscard =3D 0; @@ -1625,15 +1626,15 @@ static irqreturn_t blkif_interrupt(int irq, void *d= ev_id) break; case BLKIF_OP_FLUSH_DISKCACHE: case BLKIF_OP_WRITE_BARRIER: - if (unlikely(bret->status =3D=3D BLKIF_RSP_EOPNOTSUPP)) { + if (unlikely(bret.status =3D=3D BLKIF_RSP_EOPNOTSUPP)) { printk(KERN_WARNING "blkfront: %s: %s op failed\n", - info->gd->disk_name, op_name(bret->operation)); + info->gd->disk_name, op_name(bret.operation)); blkif_req(req)->error =3D BLK_STS_NOTSUPP; } - if (unlikely(bret->status =3D=3D BLKIF_RSP_ERROR && + if (unlikely(bret.status =3D=3D BLKIF_RSP_ERROR && rinfo->shadow[id].req.u.rw.nr_segments =3D=3D 0)) { printk(KERN_WARNING "blkfront: %s: empty %s op failed\n", - info->gd->disk_name, op_name(bret->operation)); + info->gd->disk_name, op_name(bret.operation)); blkif_req(req)->error =3D BLK_STS_NOTSUPP; } if (unlikely(blkif_req(req)->error)) { @@ -1646,9 +1647,9 @@ static irqreturn_t blkif_interrupt(int irq, void *dev= _id) fallthrough; case BLKIF_OP_READ: case BLKIF_OP_WRITE: - if (unlikely(bret->status !=3D BLKIF_RSP_OKAY)) + if (unlikely(bret.status !=3D BLKIF_RSP_OKAY)) dev_dbg(&info->xbdev->dev, "Bad return from blkdev data " - "request: %x\n", bret->status); + "request: %x\n", bret.status); =20 break; default: --=20 2.26.2