The current ubd implementation doesn't support write
barriers (blk_queue_ordered etc.), and the reccomendation
is to use synchronous IO to ensure data integrity. In
principle, adding barrier request support ought to get
around this problem, allowing writes without O_SYNC with
occasional calls to fdatasync on the underlying data (the
motivation for write barrier support was safety of
journalling filesystems on disks with write caches, an
analogous problem).

ext3 and reiserfs support the write barrier stuff if
mounted with appropriate options (barrier=1 and
barrier=flush respectively).

Implementing this ought to give performance somewhere
between ubdXs and ubdX, but with adequate guarantees of
data integrity for use with modern filesystems. That said,
I haven't measured this yet.

A patch for this is pretty simple (see below). Has there
been discussion of this before? I couldn't find any in the
list archives....

--- ubd_kern.c.orig     2005-10-04 10:17:50.000000000 +0100
+++ ubd_kern.c  2005-10-04 10:22:59.000000000 +0100
@@ -68,6 +68,7 @@
        unsigned long long cow_offset;
        unsigned long bitmap_words[2];
        int error;
+        int barrier;
 };
 
 extern int open_ubd_file(char *file, struct openflags *openflags,
@@ -825,6 +826,8 @@
                unregister_blkdev(MAJOR_NR, "ubd");
                return -1;
        }
+
+        blk_queue_ordered(ubd_queue, QUEUE_ORDERED_TAG);
 
        if (fake_major != MAJOR_NR) {
                char name[sizeof("ubd_nnn\0")];
@@ -1003,6 +1006,8 @@
        io_req->buffer = req->buffer;
        io_req->sectorsize = 1 << 9;
 
+        io_req->barrier = blk_barrier_rq(req);
+
        if(dev->cow.file != NULL)
                cowify_req(io_req, dev->cow.bitmap, dev->cow.bitmap_offset,
                           dev->cow.bitmap_len);
@@ -1334,6 +1339,8 @@
                start = end;
        } while(start < nsectors);
 
+        if (req->barrier) fdatasync(req->fds[bit]); /* XXX also sync before 
this write? */
+
        req->error = update_bitmap(req);
 }
 


-- 
``Is there no beginning to your talents?''
  (Clive Anderson, to Jeffrey Archer)


-------------------------------------------------------
This SF.Net email is sponsored by:
Power Architecture Resource Center: Free content, downloads, discussions,
and more. http://solutions.newsforge.com/ibmarch.tmpl
_______________________________________________
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