WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

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

To: 房海峰 <fhf25@xxxxxxx>
Subject: Re: [Xen-devel] a problem from blktap?
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
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type; bh=WTkFuOt9/v820NaTt6srgzaT4VtoVtiics++OSQHAZ8=; b=qBE0lG9ffPiBpkQ1Sh0cRWOolJ7dJimHOxwODKNnGtZjYZdQjbdWUoN0JbfUv44WOb FlGwcQNnhakoCYwBo3nk/0tA/pZHLxhANopk+RYKnRMSgAfVjNilIrD3YvcqoZ0R0Gj+ 29bSiYcxXJwU4531CACLROleuudfhYgdGSA6s=
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=
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
In-reply-to: <200907071719004656785@xxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <200907071719004656785@xxxxxxx>
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
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
<Prev in Thread] Current Thread [Next in Thread>