All of lore.kernel.org
 help / color / mirror / Atom feed
From: 房海峰 <fhf25@126.com>
To: 房海峰 <fhf25@126.com>
Cc: xen-devel <xen-devel@lists.xensource.com>
Subject: Re: a problem from blktap?
Date: Tue, 7 Jul 2009 17:47:38 +0800	[thread overview]
Message-ID: <200907071747377228985@126.com> (raw)
In-Reply-To: 200907071719004656785@126.com


[-- 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

  reply	other threads:[~2009-07-07  9:47 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-07-07  9:19 a problem from blktap? 房海峰
2009-07-07  9:47 ` 房海峰 [this message]
2009-07-07 16:49 ` jake wires

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200907071747377228985@126.com \
    --to=fhf25@126.com \
    --cc=xen-devel@lists.xensource.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.