Port-xen archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

XEN_BSIZE vs DEV_BSIZE in xbd(4) and xbdback(4)



Hi list,

What was the reason behind the XEN_BSIZE/VBD_BSIZE vs DEV_BSIZE split (in current state, they are identical, eg. 9 bits/512 bytes)

The byte counts and nbytes are either calculated using DEV_BSIZE or XEN_BSIZE, and IIRC, disk(9) with physical blocks != 512 bytes should be implemented via disk_blocksize() and dk_blkshift elements.

FWIW:

--- xen/xbd_xenbus.c    2011-03-30 02:13:28.000000000 +0200
+++ xen/xbd_xenbus.c      2011-05-03 11:20:35.000000000 +0200
@@ -73,9 +73,6 @@ __KERNEL_RCSID(0, "$NetBSD: xbd_xenbus.c

 #define XBD_RING_SIZE __RING_SIZE((blkif_sring_t *)0, PAGE_SIZE)

-#define XEN_BSHIFT      9               /* log2(XEN_BSIZE) */
-#define XEN_BSIZE       (1 << XEN_BSHIFT)
-
 struct xbd_req {
        SLIST_ENTRY(xbd_req) req_next;
        uint16_t req_id; /* ID passed to backend */
@@ -888,7 +885,7 @@ xbdstart(struct dk_softc *dksc, struct b

        xbdreq->req_bp = bp;
        xbdreq->req_data = bp->b_data;
-       if ((vaddr_t)bp->b_data & (XEN_BSIZE - 1)) {
+       if ((vaddr_t)bp->b_data & (DEV_BSIZE - 1)) {
                if (__predict_false(xbd_map_align(xbdreq) != 0)) {
                        ret = -1;
                        goto out;
@@ -914,14 +911,14 @@ xbdstart(struct dk_softc *dksc, struct b
        }
        for (seg = 0, bcount = bp->b_bcount; bcount > 0;) {
                pmap_extract_ma(pmap_kernel(), va, &ma);
-               KASSERT((ma & (XEN_BSIZE - 1)) == 0);
+               KASSERT((ma & (DEV_BSIZE - 1)) == 0);
                if (bcount > PAGE_SIZE - off)
                        nbytes = PAGE_SIZE - off;
                else
                        nbytes = bcount;
-               nsects = nbytes >> XEN_BSHIFT;
-               req->seg[seg].first_sect = off >> XEN_BSHIFT;
- req->seg[seg].last_sect = (off >> XEN_BSHIFT) + nsects - 1;
+               nsects = nbytes >> DEV_BSHIFT;
+               req->seg[seg].first_sect = off >> DEV_BSHIFT;
+ req->seg[seg].last_sect = (off >> DEV_BSHIFT) + nsects - 1; KASSERT(req->seg[seg].first_sect <= req->seg[seg].last_sect);
                KASSERT(req->seg[seg].last_sect < 8);
                if (__predict_false(xengnt_grant_access(
--- sys/arch/xen/xen/xbdback_xenbus.c 29 Apr 2011 22:58:46 -0000 1.34
+++ sys/arch/xen/xen/xbdback_xenbus.c   3 May 2011 09:40:05 -0000
@@ -66,8 +66,7 @@ __KERNEL_RCSID(0, "$NetBSD: xbdback_xenb
#define BLKIF_MAX_PAGES_PER_REQUEST (BLKIF_MAX_SEGMENTS_PER_REQUEST + 1)

 /* Values are expressed in 512-byte sectors */
-#define VBD_BSIZE 512
-#define VBD_MAXSECT ((PAGE_SIZE / VBD_BSIZE) - 1)
+#define VBD_MAXSECT ((PAGE_SIZE / DEV_BSIZE) - 1)

 struct xbdback_request;
 struct xbdback_io;
@@ -1190,7 +1189,7 @@ xbdback_co_io_gotio(struct xbdback_insta
        xbd_io->xio_mapped = 0;
        xbd_io->xio_operation = xbdi->xbdi_xen_req.operation;

-       start_offset = xbdi->xbdi_this_fs * VBD_BSIZE;
+       start_offset = xbdi->xbdi_this_fs * DEV_BSIZE;

        if (xbdi->xbdi_xen_req.operation == BLKIF_OP_WRITE) {
                buf_flags = B_WRITE;
@@ -1272,7 +1271,7 @@ xbdback_co_io_gotfrag2(struct xbdback_in
xbd_io->xio_gref[xbd_io->xio_nrma++] = xbdi->xbdi_thisgrt;
        }

-       xbd_io->xio_buf.b_bcount += (daddr_t)(seg_size * VBD_BSIZE);
+       xbd_io->xio_buf.b_bcount += (daddr_t)(seg_size * DEV_BSIZE);
        XENPRINTF(("xbdback_io domain %d: start sect %d size %d\n",
            xbdi->xbdi_domid, (int)xbdi->xbdi_next_sector, seg_size));


--
Jean-Yves Migeon
jeanyves.migeon%free.fr@localhost


Home | Main Index | Thread Index | Old Index