[Sheepdog] [PATCH 6/8] sheepdog: remove sd_read_done

MORITA Kazutaka morita.kazutaka at lab.ntt.co.jp
Tue Apr 27 08:33:52 CEST 2010


The name `sd_read_done' is a bit confusing because it is called before
we send a read request to the server. Moreover, it has a lot in common
with its caller `sd_readv_bh_cb', so we should remove this.

Signed-off-by: MORITA Kazutaka <morita.kazutaka at lab.ntt.co.jp>
---
 block/sheepdog.c |   53 +++++++++++------------------------------------------
 1 files changed, 11 insertions(+), 42 deletions(-)

diff --git a/block/sheepdog.c b/block/sheepdog.c
index 410c8b2..bfccd63 100644
--- a/block/sheepdog.c
+++ b/block/sheepdog.c
@@ -1346,23 +1346,27 @@ static BlockDriverAIOCB *sd_aio_writev(BlockDriverState *bs,
 	return &acb->common;
 }
 
-static void sd_read_done(struct sd_aiocb *acb)
+static void sd_readv_bh_cb(void *p)
 {
+	struct sd_aiocb *acb = p;
+	int ret = 0;
 	unsigned long len, done = 0, total = acb->nb_sectors * 512;
 	unsigned long idx = acb->sector_num * 512 / CHUNK_SIZE;
-	uint64_t oid, offset = (acb->sector_num * 512) % CHUNK_SIZE;
+	uint64_t oid;
+	uint64_t offset = (acb->sector_num * 512) % CHUNK_SIZE;
 	struct bdrv_sd_state *s = acb->common.bs->opaque;
-	int ret, i;
+
+	qemu_bh_delete(acb->bh);
+	acb->bh = NULL;
 
 	acb->aiocb_type = AIOCB_READ_UDATA;
 	acb->aio_done_func = sd_finish_aiocb;
 
-	i = 0;
 	while (done != total) {
-		len = min_t(unsigned long, total - done, CHUNK_SIZE - offset);
-
 		oid = s->inode.data_oid[idx];
 
+		len = min_t(unsigned long, total - done, CHUNK_SIZE - offset);
+
 		if (oid) {
 			ret = add_aio_request(s, acb, oid, NULL, 0, len, offset,
 					      0, 0, 0, 0, done);
@@ -1375,48 +1379,13 @@ static void sd_read_done(struct sd_aiocb *acb)
 		idx++;
 		offset = 0;
 		done += len;
-		i++;
 	}
+
 out:
 	if (QLIST_EMPTY(&acb->aioreq_head))
 		sd_finish_aiocb(acb);
 }
 
-static void sd_readv_bh_cb(void *p)
-{
-	struct sd_aiocb *acb = p;
-	int ret = 0, read_data = 0;
-	unsigned long len, done = 0, total = acb->nb_sectors * 512;
-	unsigned long idx = acb->sector_num * 512 / CHUNK_SIZE;
-	uint64_t oid;
-	uint64_t offset = (acb->sector_num * 512) % CHUNK_SIZE;
-	struct bdrv_sd_state *s = acb->common.bs->opaque;
-
-	qemu_bh_delete(acb->bh);
-	acb->bh = NULL;
-
-	while (done != total) {
-		oid = s->inode.data_oid[idx];
-
-		len = min_t(unsigned long, total - done, CHUNK_SIZE - offset);
-
-		if (oid)
-			read_data++;
-
-		idx++;
-		done += len;
-	}
-
-	if (read_data) {
-		sd_read_done(acb);
-		return;
-	}
-
-	acb->ret = ret;
-	sd_finish_aiocb(acb);
-	return;
-}
-
 static BlockDriverAIOCB *sd_aio_readv(BlockDriverState *bs,
 				      int64_t sector_num,
 				      QEMUIOVector *qiov,
-- 
1.5.6.5




More information about the sheepdog mailing list