aboutsummaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorRichard Weinberger <richard@nod.at>2013-08-18 07:30:07 -0400
committerRichard Weinberger <richard@nod.at>2013-09-07 04:56:55 -0400
commitbc1d72e73be63a7c4a07eb10cf51e91f20bf6076 (patch)
tree12c51927d7fd92b9585071c988a3b8e61ffd7d20 /arch/um
parent805f11a0d515658106bfbfadceff0eb30bd90ad2 (diff)
um: ubd: Introduce submit_request()
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>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/drivers/ubd_kern.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index d27c703be1a1..1812bc81715b 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,
1252 io_req->op = UBD_FLUSH; 1252 io_req->op = UBD_FLUSH;
1253} 1253}
1254 1254
1255static bool submit_request(struct io_thread_req *io_req, struct ubd *dev)
1256{
1257 int n = os_write_file(thread_fd, &io_req,
1258 sizeof(io_req));
1259 if (n != sizeof(io_req)) {
1260 if (n != -EAGAIN)
1261 printk("write to io thread failed, "
1262 "errno = %d\n", -n);
1263 else if (list_empty(&dev->restart))
1264 list_add(&dev->restart, &restart);
1265
1266 kfree(io_req);
1267 return false;
1268 }
1269 return true;
1270}
1271
1255/* Called with dev->lock held */ 1272/* Called with dev->lock held */
1256static void do_ubd_request(struct request_queue *q) 1273static void do_ubd_request(struct request_queue *q)
1257{ 1274{
1258 struct io_thread_req *io_req; 1275 struct io_thread_req *io_req;
1259 struct request *req; 1276 struct request *req;
1260 int n;
1261 1277
1262 while(1){ 1278 while(1){
1263 struct ubd *dev = q->queuedata; 1279 struct ubd *dev = q->queuedata;
@@ -1283,8 +1299,7 @@ static void do_ubd_request(struct request_queue *q)
1283 return; 1299 return;
1284 } 1300 }
1285 prepare_flush_request(req, io_req); 1301 prepare_flush_request(req, io_req);
1286 os_write_file(thread_fd, &io_req, 1302 submit_request(io_req, dev);
1287 sizeof(struct io_thread_req *));
1288 } 1303 }
1289 1304
1290 while(dev->start_sg < dev->end_sg){ 1305 while(dev->start_sg < dev->end_sg){
@@ -1301,17 +1316,8 @@ static void do_ubd_request(struct request_queue *q)
1301 (unsigned long long)dev->rq_pos << 9, 1316 (unsigned long long)dev->rq_pos << 9,
1302 sg->offset, sg->length, sg_page(sg)); 1317 sg->offset, sg->length, sg_page(sg));
1303 1318
1304 n = os_write_file(thread_fd, &io_req, 1319 if (submit_request(io_req, dev) == false)
1305 sizeof(struct io_thread_req *));
1306 if(n != sizeof(struct io_thread_req *)){
1307 if(n != -EAGAIN)
1308 printk("write to io thread failed, "
1309 "errno = %d\n", -n);
1310 else if(list_empty(&dev->restart))
1311 list_add(&dev->restart, &restart);
1312 kfree(io_req);
1313 return; 1320 return;
1314 }
1315 1321
1316 dev->rq_pos += sg->length >> 9; 1322 dev->rq_pos += sg->length >> 9;
1317 dev->start_sg++; 1323 dev->start_sg++;