All of lore.kernel.org
 help / color / mirror / Atom feed
* a problem from blktap?
@ 2009-07-07  9:19 房海峰
  2009-07-07  9:47 ` 房海峰
  2009-07-07 16:49 ` jake wires
  0 siblings, 2 replies; 3+ messages in thread
From: 房海峰 @ 2009-07-07  9:19 UTC (permalink / raw)
  To: xen-devel; +Cc: fanghaifeng


[-- Attachment #1.1: Type: text/plain, Size: 11229 bytes --]

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 



房海峰 

[-- Attachment #1.2: Type: text/html, Size: 50868 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: a problem from blktap?
  2009-07-07  9:19 a problem from blktap? 房海峰
@ 2009-07-07  9:47 ` 房海峰
  2009-07-07 16:49 ` jake wires
  1 sibling, 0 replies; 3+ messages in thread
From: 房海峰 @ 2009-07-07  9:47 UTC (permalink / raw)
  To: 房海峰; +Cc: xen-devel


[-- Attachment #1.1: Type: text/plain, Size: 11486 bytes --]

when i open the large file by the mode of O_DIRECT, Can the malloc() be used?


2009-07-07 



房海峰 



发件人: 房海峰 
发送时间: 2009-07-07  17:20:01 
收件人: xen-devel 
抄送: fanghaifeng 
主题: [Xen-devel] a problem from blktap? 
 
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 



房海峰 

[-- Attachment #1.2: Type: text/html, Size: 53359 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: a problem from blktap?
  2009-07-07  9:19 a problem from blktap? 房海峰
  2009-07-07  9:47 ` 房海峰
@ 2009-07-07 16:49 ` jake wires
  1 sibling, 0 replies; 3+ messages in thread
From: jake wires @ 2009-07-07 16:49 UTC (permalink / raw)
  To: 房海峰; +Cc: xen-devel, fanghaifeng


[-- Attachment #1.1: Type: text/plain, Size: 5257 bytes --]

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@126.com>

>  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@lists.xensource.com
> http://lists.xensource.com/xen-devel
>
>

[-- Attachment #1.2: Type: text/html, Size: 51445 bytes --]

[-- Attachment #2: Type: text/plain, Size: 138 bytes --]

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2009-07-07 16:49 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-07  9:19 a problem from blktap? 房海峰
2009-07-07  9:47 ` 房海峰
2009-07-07 16:49 ` jake wires

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.