summaryrefslogtreecommitdiffstats
path: root/arch/um
diff options
context:
space:
mode:
authorAnton Ivanov <anton.ivanov@cambridgegreys.com>2018-11-14 13:41:08 -0500
committerRichard Weinberger <richard@nod.at>2018-12-27 16:48:20 -0500
commita41421edb926fcc8f212742b2e7a1f21c9047853 (patch)
treeef4205b7c195d874a879798a2319063456deda27 /arch/um
parent53766defb8c860a47e2a965f5b4b05ed2848e2d0 (diff)
um: Remove unsafe printks from the io thread
Printk out of the io thread has been proven to be unsafe. This is not surprising as the thread is part of the UML hypervisor code. It is not supposed to invoke any kernel code/resources. It is necesssary to pass the error to the block IO layer and let it Signed-off-by: Anton Ivanov <anton.ivanov@cambridgegreys.com> Signed-off-by: Richard Weinberger <richard@nod.at>
Diffstat (limited to 'arch/um')
-rw-r--r--arch/um/drivers/ubd_kern.c42
1 files changed, 17 insertions, 25 deletions
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c
index 58860ef6931a..1672e3c49bfb 100644
--- a/arch/um/drivers/ubd_kern.c
+++ b/arch/um/drivers/ubd_kern.c
@@ -1,4 +1,5 @@
1/* 1/*
2 * Copyright (C) 2018 Cambridge Greys Ltd
2 * Copyright (C) 2015-2016 Anton Ivanov (aivanov@brocade.com) 3 * Copyright (C) 2015-2016 Anton Ivanov (aivanov@brocade.com)
3 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com) 4 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
4 * Licensed under the GPL 5 * Licensed under the GPL
@@ -1440,6 +1441,19 @@ static int map_error(int error_code)
1440 return BLK_STS_IOERR; 1441 return BLK_STS_IOERR;
1441} 1442}
1442 1443
1444/*
1445 * Everything from here onwards *IS NOT PART OF THE KERNEL*
1446 *
1447 * The following functions are part of UML hypervisor code.
1448 * All functions from here onwards are executed as a helper
1449 * thread and are not allowed to execute any kernel functions.
1450 *
1451 * Any communication must occur strictly via shared memory and IPC.
1452 *
1453 * Do not add printks, locks, kernel memory operations, etc - it
1454 * will result in unpredictable behaviour and/or crashes.
1455 */
1456
1443static int update_bitmap(struct io_thread_req *req) 1457static int update_bitmap(struct io_thread_req *req)
1444{ 1458{
1445 int n; 1459 int n;
@@ -1449,11 +1463,8 @@ static int update_bitmap(struct io_thread_req *req)
1449 1463
1450 n = os_pwrite_file(req->fds[1], &req->bitmap_words, 1464 n = os_pwrite_file(req->fds[1], &req->bitmap_words,
1451 sizeof(req->bitmap_words), req->cow_offset); 1465 sizeof(req->bitmap_words), req->cow_offset);
1452 if(n != sizeof(req->bitmap_words)){ 1466 if(n != sizeof(req->bitmap_words))
1453 printk("do_io - bitmap update failed, err = %d fd = %d\n", -n,
1454 req->fds[1]);
1455 return map_error(-n); 1467 return map_error(-n);
1456 }
1457 1468
1458 return map_error(0); 1469 return map_error(0);
1459} 1470}
@@ -1467,12 +1478,7 @@ static void do_io(struct io_thread_req *req)
1467 1478
1468 if (req_op(req->req) == REQ_OP_FLUSH) { 1479 if (req_op(req->req) == REQ_OP_FLUSH) {
1469 /* fds[0] is always either the rw image or our cow file */ 1480 /* fds[0] is always either the rw image or our cow file */
1470 n = os_sync_file(req->fds[0]); 1481 req->error = map_error(-os_sync_file(req->fds[0]));
1471 if (n != 0) {
1472 printk("do_io - sync failed err = %d "
1473 "fd = %d\n", -n, req->fds[0]);
1474 req->error = map_error(-n);
1475 }
1476 return; 1482 return;
1477 } 1483 }
1478 1484
@@ -1497,9 +1503,7 @@ static void do_io(struct io_thread_req *req)
1497 buf = &buf[n]; 1503 buf = &buf[n];
1498 len -= n; 1504 len -= n;
1499 n = os_pread_file(req->fds[bit], buf, len, off); 1505 n = os_pread_file(req->fds[bit], buf, len, off);
1500 if (n < 0) { 1506 if(n < 0){
1501 printk("do_io - read failed, err = %d "
1502 "fd = %d\n", -n, req->fds[bit]);
1503 req->error = map_error(-n); 1507 req->error = map_error(-n);
1504 return; 1508 return;
1505 } 1509 }
@@ -1508,8 +1512,6 @@ static void do_io(struct io_thread_req *req)
1508 } else { 1512 } else {
1509 n = os_pwrite_file(req->fds[bit], buf, len, off); 1513 n = os_pwrite_file(req->fds[bit], buf, len, off);
1510 if(n != len){ 1514 if(n != len){
1511 printk("do_io - write failed err = %d "
1512 "fd = %d\n", -n, req->fds[bit]);
1513 req->error = map_error(-n); 1515 req->error = map_error(-n);
1514 return; 1516 return;
1515 } 1517 }
@@ -1547,11 +1549,6 @@ int io_thread(void *arg)
1547 if (n == -EAGAIN) { 1549 if (n == -EAGAIN) {
1548 ubd_read_poll(-1); 1550 ubd_read_poll(-1);
1549 continue; 1551 continue;
1550 } else {
1551 printk("io_thread - read failed, fd = %d, "
1552 "err = %d,"
1553 "reminder = %d\n",
1554 kernel_fd, -n, io_remainder_size);
1555 } 1552 }
1556 } 1553 }
1557 1554
@@ -1566,11 +1563,6 @@ int io_thread(void *arg)
1566 res = os_write_file(kernel_fd, ((char *) io_req_buffer) + written, n); 1563 res = os_write_file(kernel_fd, ((char *) io_req_buffer) + written, n);
1567 if (res >= 0) { 1564 if (res >= 0) {
1568 written += res; 1565 written += res;
1569 } else {
1570 if (res != -EAGAIN) {
1571 printk("io_thread - write failed, fd = %d, "
1572 "err = %d\n", kernel_fd, -n);
1573 }
1574 } 1566 }
1575 if (written < n) { 1567 if (written < n) {
1576 ubd_write_poll(-1); 1568 ubd_write_poll(-1);