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

Re: [Xen-devel] a problem from blktap?


  • To: 房海峰 <fhf25@xxxxxxx>
  • From: jake wires <jake.wires@xxxxxxxxx>
  • Date: Tue, 7 Jul 2009 09:49:08 -0700
  • Cc: xen-devel <xen-devel@xxxxxxxxxxxxxxxxxxx>, fanghaifeng <fanghaifeng@xxxxxxxxxx>
  • Delivery-date: Tue, 07 Jul 2009 09:49:41 -0700
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; b=PSoo9oOQXIUPdEmEHMexgswNcYYu2OJJJAI/ZbUTyMQtWV14zS89+QpmSw9Q1IUvoM 4ODeBxNXht+0UXt0sdMOmcyz6dh20SWMIZ/LXgD6OqHjs6koF286p51Gw01mzgy41vD8 jFj0pJJ2uJBRvHL+sVEMS/AEr7Db4XN6i6dQM=
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

hi,

when you use O_DIRECT, buffers passed to read/write calls must be sector-aligned.  posix_memalign() will give you what you want.

jake

2009/7/7 房海峰 <fhf25@xxxxxxx>
hi all,
 
currently, i am debuging the code derived from block-sync.c, the detail as follow:
 
=================================================================
        struct socket_message_header *msg_hdr;                                                                                                               
        struct socketmsg_sync_read * msg_body;                                                                                                               
                                                                                                                                                             
        int msglen, size;                                                                                                                                    
        char * msgbuf = msg;                                                                                                                                 
        int ret = 0;                                                                                                                                         
        uint64_t offset;                                                                                                                                     
                                                                                                                                                             
        char * iobuf = NULL;                                                                                                                                 
                                                                                                                                                             
        msg_hdr = (struct socket_message_header *)msgbuf;                                                                                                    
        msg_body = (struct socketmsg_sync_read *)(msgbuf + sizeof(struct socket_message_header));                                                            
        msglen = msg_hdr->len;                                                                                                                               
                                                                                                                                                             
        size    = msg_body->nb_sectors * msg_body-sector_size;
        offset  = msg_body->sector * (uint64_t)msg_body->sector_size;                         
                                                                                                                                                             
        MY_DPRINTF("READ: nb_sectors = %d, sector_size = %d, start_sector = %llu",                                                                           
                msg_body->nb_sectors,                                                                                                                        
                msg_body->sector_size,                                                                                                                       
                msg_body->sector);                                                                                                                           
                                                                                                                                                             
        //iobuf = calloc(size, sizeof(char));                                                                                                                
        iobuf = malloc(size);                                                                                                                                
        if (!iobuf)                                                                                                                                          
                goto failure;                                                                                                                                
        MY_DPRINTF("IO Buffer memory calloc is ok!");                                                                                                        
                                                                                                                                                             
        ret = lseek(image_fd, offset, SEEK_SET);                                                                                                             
        if (ret != (off_t)-1) {                                                                                                                              
                                                                                                                                                             
                MY_DPRINTF("after lseek, the position is at %lu", (unsigned long) ret);                                                                      
                MY_DPRINTF("image_fd = %d, iobuf = %p, size = %d", image_fd, iobuf, size);                                                                   
                                                                                                                                                             
                ret = readn(image_fd, (void*)iobuf, (size_t)size);                                                                                           
                if (ret < 0) {                                                                                                                               
                        MY_DPRINTF("readn(%s) is error!", strerror(errno));                                                                                  
                        goto failure;                                                                                                                        
                }                                                                                                                                            
                else                                                                                                                                         
                        {                                                                                                                                    
                                MY_DPRINTF("readn() is end, and has read [%d] data!", ret);                                                                  
                        }                                                                                                                                    
        } else                                                                                                                                               
        {                                                                                                                                                    
                MY_DPRINTF("lseek is error(%s)", strerror(errno));                                                                                           
                goto failure;                                                                                                                                
        }                                                                                                                                                    
        MY_DPRINTF("Seek and Read image is ok!");                                      
 
===================================================================================
the debuging output, which cut from /var/log/message, are as follow:
 
Jul  7 16:45:07 domain0 remote-blktapctrl[3963]: [hook_new_tapdisk(712)] loop for select(4)............                                                      
Jul  7 16:45:11 domain0 remote-blktapctrl[3963]: [hook_new_tapdisk(715)] select() is end, and ret = 1                                                        
Jul  7 16:45:11 domain0 remote-blktapctrl[3963]: [hook_new_tapdisk(720)] enter hook_read_message().                                                          
Jul  7 16:45:11 domain0 remote-blktapctrl[3963]: [hook_read_message(632)] read() is end, and msglen=32                                                       
Jul  7 16:45:11 domain0 remote-blktapctrl[3963]: [hook_read_message(651)] receive SOCK_MSG_READ message.                                                     
Jul  7 16:45:11 domain0 remote-blktapctrl[3963]: [hook_do_read(502)] READ: nb_sectors = 2, sector_size = 512, start_sector = 2                               
Jul  7 16:45:11 domain0 remote-blktapctrl[3963]: [hook_do_read(508)] IO Buffer memory calloc is ok!                                                          
Jul  7 16:45:11 domain0 remote-blktapctrl[3963]: [hook_do_read(513)] after lseek, the position is at 1024                                                    
Jul  7 16:45:11 domain0 remote-blktapctrl[3963]: [hook_do_read(514)] image_fd = 6, iobuf = 0x804f388, size = 1024                                            
Jul  7 16:45:11 domain0 remote-blktapctrl[3963]: [readn(66)] call readn(fd[6], ptr[0x804f388], n[1024])                                                      
Jul  7 16:45:11 domain0 remote-blktapctrl[3963]: [readn(70)] call read(fd[6], ptr[0x804f388], nleft[1024])                                                   
Jul  7 16:45:11 domain0 remote-blktapctrl[3963]: [readn(73)] read is error (Invalid argument)                                                                
Jul  7 16:45:11 domain0 remote-blktapctrl[3963]: [readn(74)] nread = -1, nleft = 1024, n = 1024                                                              
Jul  7 16:45:11 domain0 remote-blktapctrl[3963]: [hook_do_read(518)] readn(Invalid argument) is error!                                                       
Jul  7 16:45:11 domain0 remote-blktapctrl[3963]: [hook_read_message(653)] hook_do_read() is end, and ret = -1                                                
Jul  7 16:45:11 domain0 remote-blktapctrl[3963]: [hook_read_message(670)] do with message is error!                                                          
Jul  7 16:45:11 domain0 remote-blktapctrl[3963]: [hook_new_tapdisk(722)] out of hook_read_message().                                                         
Jul  7 16:45:11 domain0 remote-blktapctrl[3963]: [hook_new_tapdisk(712)] loop for select(5)............                                                      
Jul  7 16:45:21 domain0 remote-blktapctrl[3963]: [hook_new_tapdisk(715)] select() is end, and ret = 0     
 
among the list above, you can find the error message about the "readn" function. to resovle this problem, i have try some methods, BUT all is failure.
 
varify the mode of opening the file, that is O_RDWR | O_DIRECT | O_LARGEFILE
 
So, who can help me to do with this problem?
 
read is error (Invalid argument) ?
 
 
thanks a lot!
 
 
2009-07-07

房海峰

_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel


_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

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