Skip to content

Commit bc1d72e

Browse files
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>
1 parent 805f11a commit bc1d72e

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

‎arch/um/drivers/ubd_kern.c‎

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,12 +1252,28 @@ static void prepare_flush_request(struct request *req,
12521252
io_req->op = UBD_FLUSH;
12531253
}
12541254

1255+
static 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+
12551272
/* Called with dev->lock held */
12561273
static void do_ubd_request(struct request_queue *q)
12571274
{
12581275
struct io_thread_req *io_req;
12591276
struct request *req;
1260-
int n;
12611277

12621278
while(1){
12631279
struct ubd *dev = q->queuedata;
@@ -1283,8 +1299,7 @@ static void do_ubd_request(struct request_queue *q)
12831299
return;
12841300
}
12851301
prepare_flush_request(req, io_req);
1286-
os_write_file(thread_fd, &io_req,
1287-
sizeof(struct io_thread_req *));
1302+
submit_request(io_req, dev);
12881303
}
12891304

12901305
while(dev->start_sg < dev->end_sg){
@@ -1301,17 +1316,8 @@ static void do_ubd_request(struct request_queue *q)
13011316
(unsigned long long)dev->rq_pos << 9,
13021317
sg->offset, sg->length, sg_page(sg));
13031318

1304-
n = os_write_file(thread_fd, &io_req,
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);
1319+
if (submit_request(io_req, dev) == false)
13131320
return;
1314-
}
13151321

13161322
dev->rq_pos += sg->length >> 9;
13171323
dev->start_sg++;

0 commit comments

Comments
 (0)