From: Keir Fraser Date: Tue, 26 May 2009 08:49:19 +0000 (+0100) Subject: minios: Fix blkfront driver when sector_size != 512 X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=7f723d73815e4e45c4d234eb304d9ef49ceb32f5;p=people%2Fliuw%2Flibxenctrl-split%2Fmini-os.git minios: Fix blkfront driver when sector_size != 512 The first and last sector as well as the sector number of the request is expressed in 512 bytes units, independently from the real sector size. Signed-off-by: Stefano Stabellini --- diff --git a/blkfront.c b/blkfront.c index d869715..6fc2c96 100644 --- a/blkfront.c +++ b/blkfront.c @@ -310,14 +310,14 @@ void blkfront_aio(struct blkfront_aiocb *aiocbp, int write) req->nr_segments = n; req->handle = dev->handle; req->id = (uintptr_t) aiocbp; - req->sector_number = aiocbp->aio_offset / dev->info.sector_size; + req->sector_number = aiocbp->aio_offset / 512; for (j = 0; j < n; j++) { req->seg[j].first_sect = 0; - req->seg[j].last_sect = PAGE_SIZE / dev->info.sector_size - 1; + req->seg[j].last_sect = PAGE_SIZE / 512 - 1; } - req->seg[0].first_sect = ((uintptr_t)aiocbp->aio_buf & ~PAGE_MASK) / dev->info.sector_size; - req->seg[n-1].last_sect = (((uintptr_t)aiocbp->aio_buf + aiocbp->aio_nbytes - 1) & ~PAGE_MASK) / dev->info.sector_size; + req->seg[0].first_sect = ((uintptr_t)aiocbp->aio_buf & ~PAGE_MASK) / 512; + req->seg[n-1].last_sect = (((uintptr_t)aiocbp->aio_buf + aiocbp->aio_nbytes - 1) & ~PAGE_MASK) / 512; for (j = 0; j < n; j++) { uintptr_t data = start + j * PAGE_SIZE; if (!write) {