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

[Xen-devel] !!!!!two pressing questions in the xen code notes(I'm dying!!!HELP!)



I'm doing some research on xen 4.1 platform.I have two question which I'm trying to make it convenient  for every expert to answer.
Question 1:
Here are some codes in the file xen-4.1.2/tools/ioemu-qemu-xen/block-raw-posix.c, 
....
 629 static BlockDriverAIOCB *raw_aio_read(BlockDriverState *bs,
 630         int64_t sector_num, uint8_t *buf, int nb_sectors,
 631         BlockDriverCompletionFunc *cb, void *opaque)
 632 { 
 633     RawAIOCB *acb;  
 634   
 635     /*
 636      * If O_DIRECT is used and the buffer is not aligned fall back
 637      * to synchronous IO.
 638      */
 639     BDRVRawState *s = bs->opaque;
 640 
 641     if (unlikely(s->aligned_buf != NULL && ((uintptr_t) buf % 512))) {
 642         QEMUBH *bh; 
 643         acb = qemu_aio_get(bs, cb, opaque);
 644         acb->ret = raw_pread(bs, 512 * sector_num, buf, 512 * nb_sectors);
 645         bh = qemu_bh_new(raw_aio_em_cb, acb);
 646         qemu_bh_schedule(bh);     
 647         return &acb->common;      
 648     }
 649                     
 650     acb = raw_aio_setup(bs, sector_num, buf, nb_sectors, cb, opaque);
 651     if (!acb)
 652         return NULL;
 653     if (qemu_paio_read(&acb->aiocb) < 0) {
 654         raw_aio_remove(acb);      
 655         return NULL;
 656     }
 657     return &acb->common;
 658 } 
......
In the notes between the codes , the sentence show that If O_DIRECT is used and the buffer is not aligned fall back  to synchronous IO. What does it mean?I just want to make these function returning with the exact data in its field which the parameter buf point to , that is to say, I want to make the asynchronous read into a synchronous one.I have make the  O_DIRECT used in file xenstore.c and the flags will be in effect along the way to this function above.

Question 2:
Here are some codes in /xen-4.1.2/tools/block-qcow.c
...
594 static void qcow_aio_read_cb(void *opaque, int ret)
595 {
596     QCowAIOCB *acb = opaque;
597     BlockDriverState *bs = acb->common.bs;
598     BDRVQcowState *s = bs->opaque;
599     int index_in_cluster;
600 
601     acb->hd_aiocb = NULL;
602     if (ret < 0) {   
603     fail:            
604         acb->common.cb(acb->common.opaque, ret);
605         qemu_aio_release(acb);    
606         return;      
607     }
.........................
642     if (!acb->cluster_offset) {
643         if (bs->backing_hd) {
644             /* read from the base image */
645             acb->hd_aiocb = bdrv_aio_read(bs->backing_hd,
646                 acb->sector_num, acb->buf, acb->n, qcow_aio_read_cb, acb);
647             if (acb->hd_aiocb == NULL)
648                 goto fail;
649         } else {
650             /* Note: in this case, no need to wait */
651             memset(acb->buf, 0, 512 * acb->n);
652             goto redo;
653         }
654     } else if (acb->cluster_offset & QCOW_OFLAG_COMPRESSED) {
655         /* add AIO support for compressed blocks ? */
656         if (decompress_cluster(s, acb->cluster_offset) < 0)
657             goto fail;
658         memcpy(acb->buf,
659                s->cluster_cache + index_in_cluster * 512, 512 * acb->n);
660         goto redo;
661     } else {
662         if ((acb->cluster_offset & 511) != 0) {
663             ret = -EIO;
664             goto fail;
665         }
666         acb->hd_aiocb = bdrv_aio_read(s->hd,
667                             (acb->cluster_offset >> 9) + index_in_cluster,
668                             acb->buf, acb->n, qcow_aio_read_cb, acb);
In the code note on the line 650, it says that  "in this case, no need to wait".
what does it mean? Here the code just would wait for what?

If I have some time ,I will learn the whole direction about how to ask a smart question which a expert send to me in a earlier mail.
Thanks.

A Newbie




_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.