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 <rich...@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 via email to