linux-um archives
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: richard@nod.at
Cc: user-mode-linux-devel@lists.sourceforge.net
Subject: [uml-devel] [PATCH 2/4] um: ubd: Introduce submit_request()
Date: Sun, 18 Aug 2013 13:30:07 +0200	[thread overview]
Message-ID: <1376825409-18570-2-git-send-email-richard@nod.at> (raw)
In-Reply-To: <1376825409-18570-1-git-send-email-richard@nod.at>

Just a clean-up patch to remove the open coded
variants and to ensure that all requests are submitted the
same way.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 arch/um/drivers/ubd_kern.c | 32 +++++++++++++++++++-------------
 1 file changed, 19 insertions(+), 13 deletions(-)

diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index d27c703..1812bc8 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1252,12 +1252,28 @@ static void prepare_flush_request(struct request *req,
 	io_req->op = UBD_FLUSH;
 }
 
+static bool submit_request(struct io_thread_req *io_req, struct ubd *dev)
+{
+	int n = os_write_file(thread_fd, &io_req,
+			     sizeof(io_req));
+	if (n != sizeof(io_req)) {
+		if (n != -EAGAIN)
+			printk("write to io thread failed, "
+			       "errno = %d\n", -n);
+		else if (list_empty(&dev->restart))
+			list_add(&dev->restart, &restart);
+
+		kfree(io_req);
+		return false;
+	}
+	return true;
+}
+
 /* Called with dev->lock held */
 static void do_ubd_request(struct request_queue *q)
 {
 	struct io_thread_req *io_req;
 	struct request *req;
-	int n;
 
 	while(1){
 		struct ubd *dev = q->queuedata;
@@ -1283,8 +1299,7 @@ static void do_ubd_request(struct request_queue *q)
 				return;
 			}
 			prepare_flush_request(req, io_req);
-			os_write_file(thread_fd, &io_req,
-					  sizeof(struct io_thread_req *));
+			submit_request(io_req, dev);
 		}
 
 		while(dev->start_sg < dev->end_sg){
@@ -1301,17 +1316,8 @@ static void do_ubd_request(struct request_queue *q)
 					(unsigned long long)dev->rq_pos << 9,
 					sg->offset, sg->length, sg_page(sg));
 
-			n = os_write_file(thread_fd, &io_req,
-					  sizeof(struct io_thread_req *));
-			if(n != sizeof(struct io_thread_req *)){
-				if(n != -EAGAIN)
-					printk("write to io thread failed, "
-					       "errno = %d\n", -n);
-				else if(list_empty(&dev->restart))
-					list_add(&dev->restart, &restart);
-				kfree(io_req);
+			if (submit_request(io_req, dev) == false)
 				return;
-			}
 
 			dev->rq_pos += sg->length >> 9;
 			dev->start_sg++;
-- 
1.8.3.1


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
User-mode-linux-devel mailing list
User-mode-linux-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/user-mode-linux-devel


  reply	other threads:[~2013-08-18 11:30 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-18 11:30 [uml-devel] [PATCH 1/4] um: ubd: Add REQ_FLUSH suppport Richard Weinberger
2013-08-18 11:30 ` Richard Weinberger [this message]
2013-08-18 11:30 ` [uml-devel] [PATCH 3/4] um: Cleanup SIGTERM handling Richard Weinberger
2013-08-19  9:28   ` Richard W.M. Jones
2013-08-18 11:30 ` [uml-devel] [PATCH 4/4] um: Run UML in it's own session Richard Weinberger
2013-08-19  9:30   ` Richard W.M. Jones
2013-08-19 20:23     ` Richard Weinberger
2013-09-07 12:14     ` Richard W.M. Jones
2013-09-07 12:16       ` Richard Weinberger
2013-08-19  9:21 ` [uml-devel] [PATCH 1/4] um: ubd: Add REQ_FLUSH suppport Richard W.M. Jones

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1376825409-18570-2-git-send-email-richard@nod.at \
    --to=richard@nod.at \
    --cc=user-mode-linux-devel@lists.sourceforge.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox