From patchwork Tue Nov 13 11:59:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anton Ivanov X-Patchwork-Id: 997041 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=cambridgegreys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="dX6yjupd"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="VgtjoxYj"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 42vR5k2gmqz9s5c for ; Tue, 13 Nov 2018 23:00:26 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=F4zV0rdtxf2eO1pdYpdBh+zlp2HP5oV+i2nfOJ7eX/I=; b=dX6yjupdAe9Y/Y7DeFzSVYvZlw I5fWNvX4lMY53Ni962CI0Hf+4sPBXfxYnmdlCskJaUnsbrje12uxDNZU5AKGWGQSoko9Ac/wfyqUV 2jErmx3LM3R7X/sQpYDVVuE38eBRWFZmnjhQESi9sjPhCMCj+v0dQ1PpEq7FhR1p/vu9vgSy85Wwt 1pKd3l68bwI3NPsFO+vndPRWPkdFToP1iSU3DErAtQMpOlsux5IndtViwHghYmH1/hrl/S+6HQiyv 4Kj2L2yHPkFlwCRuEYFZhNlYd/IQ4T0kvTvJrnJJhlCTA5f/uqMpWu2joIZHblbhG4TbjolLxtd5d NL9JU+/g==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXMc-0005Lj-Im; Tue, 13 Nov 2018 12:00:14 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXMb-0005Ky-F2 for linux-um@bombadil.infradead.org; Tue, 13 Nov 2018 12:00:13 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=o+1abrHASjN4icLARufft2JoprufluiEhVeFN214iiY=; b=VgtjoxYj6NtbnGsp5iRBXtGtf xjHT2xPUY+eX5erEq3+GweOnVNJ0cfEjRPz49SceMPgZ9Z8ZEkgynKRNOFbc1Z84Tvdf5IlldFKnU ZILQxeyFJaEEUG2TUHhad4zFxiAdHMujXLzkvUXtPy0ef4fXfppKlNaMrfDTtQv3KuFn2FCAwFb+m POKlxFLSIk0L5CDA3Ep33LsCHi7ecNP00CJUb1+3JQOjye8WuLLa79R83jtouvgnbWUOARrw4dP5K KgWM20jqUDMf8FkQOLeKvWCzBZ7dcpXTK+xBuMhrRBJ80Jly0Z16PDMvhXK1wOJMBHXxGqUgypOLU JPnrva3Cw==; Received: from ivanoab6.miniserver.com ([5.153.251.140] helo=www.kot-begemot.co.uk) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMXMY-0004A2-DZ for linux-um@lists.infradead.org; Tue, 13 Nov 2018 12:00:11 +0000 Received: from [192.168.17.6] (helo=smaug.kot-begemot.co.uk) by www.kot-begemot.co.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1gMXMP-0000OS-95; Tue, 13 Nov 2018 12:00:01 +0000 Received: from amistad.kot-begemot.co.uk ([192.168.3.89]) by smaug.kot-begemot.co.uk with esmtp (Exim 4.89) (envelope-from ) id 1gMXMG-0004KO-Mt; Tue, 13 Nov 2018 11:59:54 +0000 From: anton.ivanov@cambridgegreys.com To: linux-um@lists.infradead.org Subject: [PATCH 2/4] um: Clean-up command processing in UML UBD driver Date: Tue, 13 Nov 2018 11:59:45 +0000 Message-Id: <20181113115947.19290-3-anton.ivanov@cambridgegreys.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20181113115947.19290-1-anton.ivanov@cambridgegreys.com> References: <20181113115947.19290-1-anton.ivanov@cambridgegreys.com> X-Spam-Score: -1.0 X-Spam-Score: -1.0 X-Clacks-Overhead: GNU Terry Pratchett X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181113_070010_598878_D062A13C X-CRM114-Status: GOOD ( 13.03 ) X-Spam-Score: 0.0 (/) X-Spam-Report: SpamAssassin version 3.4.2 on merlin.infradead.org summary: Content analysis details: (0.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- X-BeenThere: linux-um@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: axboe@kernel.dk, richard@nod.at, hch@lst.de, Anton Ivanov MIME-Version: 1.0 Sender: "linux-um" Errors-To: linux-um-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Anton Ivanov Clean-up command processing and return BLK_STS_NOTSUP for uknown commands. Signed-off-by: Anton Ivanov --- arch/um/drivers/ubd_kern.c | 64 ++++++++++++++++++++++++++++------------------ 1 file changed, 39 insertions(+), 25 deletions(-) diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index 331837f1f632..0f02373ef632 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c @@ -1307,21 +1307,25 @@ static int ubd_queue_one_vec(struct blk_mq_hw_ctx *hctx, struct request *req, io_req->fds[0] = dev->fd; io_req->error = 0; - if (req_op(req) != REQ_OP_FLUSH) { - io_req->fds[1] = dev->fd; - io_req->cow_offset = -1; - io_req->offset = off; + if (bvec != NULL) { io_req->length = bvec->bv_len; - io_req->sector_mask = 0; - io_req->offsets[0] = 0; - io_req->offsets[1] = dev->cow.data_offset; io_req->buffer = page_address(bvec->bv_page) + bvec->bv_offset; - io_req->sectorsize = 1 << 9; + } else { + io_req->buffer = NULL; + io_req->length = blk_rq_bytes(req); + } - if (dev->cow.file) { - cowify_req(io_req, dev->cow.bitmap, - dev->cow.bitmap_offset, dev->cow.bitmap_len); - } + io_req->sectorsize = UBD_SECTOR_SIZE; + io_req->fds[1] = dev->fd; + io_req->cow_offset = -1; + io_req->offset = off; + io_req->sector_mask = 0; + io_req->offsets[0] = 0; + io_req->offsets[1] = dev->cow.data_offset; + + if (dev->cow.file) { + cowify_req(io_req, dev->cow.bitmap, + dev->cow.bitmap_offset, dev->cow.bitmap_len); } ret = os_write_file(thread_fd, &io_req, sizeof(io_req)); @@ -1330,7 +1334,6 @@ static int ubd_queue_one_vec(struct blk_mq_hw_ctx *hctx, struct request *req, pr_err("write to io thread failed: %d\n", -ret); kfree(io_req); } - return ret; } @@ -1344,20 +1347,31 @@ static blk_status_t ubd_queue_rq(struct blk_mq_hw_ctx *hctx, blk_mq_start_request(req); spin_lock_irq(&ubd_dev->lock); - - if (req_op(req) == REQ_OP_FLUSH) { + switch (req_op(req)) { + /* operations with no lentgth/offset arguments */ + case REQ_OP_FLUSH: ret = ubd_queue_one_vec(hctx, req, 0, NULL); - } else { - struct req_iterator iter; - struct bio_vec bvec; - u64 off = (u64)blk_rq_pos(req) << 9; - - rq_for_each_segment(bvec, req, iter) { - ret = ubd_queue_one_vec(hctx, req, off, &bvec); - if (ret < 0) - goto out; - off += bvec.bv_len; + break; + /* operations with bio_vec arguments */ + case REQ_OP_READ: + case REQ_OP_WRITE: + { + struct req_iterator iter; + struct bio_vec bvec; + u64 off = (u64)blk_rq_pos(req) << 9; + + rq_for_each_segment(bvec, req, iter) { + ret = ubd_queue_one_vec(hctx, req, off, &bvec); + if (ret < 0) + goto out; + off += bvec.bv_len; + } } + break; + default: + WARN_ON_ONCE(1); + spin_unlock_irq(&ubd_dev->lock); + return BLK_STS_NOTSUPP; } out: spin_unlock_irq(&ubd_dev->lock);