kernelnewbies.kernelnewbies.org archive mirror
 help / color / mirror / Atom feed
* block request execution failing on RHEL6.0 (2.6.32-71.el6.x86_64)
@ 2011-04-20 12:36 ajit jain
  2011-04-26 17:12 ` ajit jain
  0 siblings, 1 reply; 3+ messages in thread
From: ajit jain @ 2011-04-20 12:36 UTC (permalink / raw)
  To: kernelnewbies

Hi All,

I have written a func to send a CDB on a scsi device from the kernel. For
that I am getting a request and queueing for execution.
But blk_execute_rq() func is setting errors field of request to 65536 and
sense length is set but all the fields in sense header is
0.

I dont know what I am missing, any suggestion would be great help.


snippet of the code
===========================
    rq = blk_get_request(q, rw, __GFP_WAIT);
    if(!rq){
         goto out;
    }
    if (buflen &&  blk_rq_map_kern(q, rq, buf, buflen, __GFP_WAIT)){
         goto out;
    }
    rq->cmd_len = cmdlen;
    memcpy(rq->cmd, cmd, cmdlen);
    memset(sense, 0, sizeof(sense));
    rq->sense_len = 0;
    rq->sense = sense;
    rq->cmd_type |= REQ_TYPE_BLOCK_PC;
    rq->cmd_type |= REQ_NOMERGE;
    rq->timeout = WRITE_SCSI_TIMEOUT;              //WRITE_SCSI_TIMEOUT is
set to 60 sec
    blk_execute_rq(q, bd_disk, rq, 0);
    error = rq->errors;
    if( error ){
        dbg("error in blk_execute_rq error %d",error);
    }
    if(rq->sense_len){
            process_sense_info(rq->sense);
    } else {
            info("no sense available");
     }
==========================================


thanks,
ajit

PS:We can not use sg_ioctl interface because code expects user space
application only to invoke sg_ioctl that the reason it does a copyin.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110420/9b6934ee/attachment.html 

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

* block request execution failing on RHEL6.0 (2.6.32-71.el6.x86_64)
  2011-04-20 12:36 block request execution failing on RHEL6.0 (2.6.32-71.el6.x86_64) ajit jain
@ 2011-04-26 17:12 ` ajit jain
  2011-04-26 17:22   ` Mulyadi Santosa
  0 siblings, 1 reply; 3+ messages in thread
From: ajit jain @ 2011-04-26 17:12 UTC (permalink / raw)
  To: kernelnewbies

Hi All,

I have found the issue.

in kernel prior to RHEL 6.0 blk_pc_request(rq) is define as:
#define blk_pc_request(rq)      ((rq)->flags & REQ_BLOCK_PC)
while in RHEL 6.0 it is define as:
#define blk_pc_request(rq)      ((rq)->cmd_type == REQ_TYPE_BLOCK_PC)

So, the issue was adding I was REQ_NOMERGE flag in cmd_type field of the
request. This was making blk_pc_request(rq) to return false and thats why
IOs were not going to scsi layer.

thanks,
ajit

On Wed, Apr 20, 2011 at 6:06 PM, ajit jain <ajit4mail@gmail.com> wrote:

> Hi All,
>
> I have written a func to send a CDB on a scsi device from the kernel. For
> that I am getting a request and queueing for execution.
> But blk_execute_rq() func is setting errors field of request to 65536 and
> sense length is set but all the fields in sense header is
> 0.
>
> I dont know what I am missing, any suggestion would be great help.
>
>
> snippet of the code
> ===========================
>     rq = blk_get_request(q, rw, __GFP_WAIT);
>     if(!rq){
>          goto out;
>     }
>     if (buflen &&  blk_rq_map_kern(q, rq, buf, buflen, __GFP_WAIT)){
>          goto out;
>     }
>     rq->cmd_len = cmdlen;
>     memcpy(rq->cmd, cmd, cmdlen);
>     memset(sense, 0, sizeof(sense));
>     rq->sense_len = 0;
>     rq->sense = sense;
>     rq->cmd_type |= REQ_TYPE_BLOCK_PC;
>     rq->cmd_type |= REQ_NOMERGE;
>     rq->timeout = WRITE_SCSI_TIMEOUT;              //WRITE_SCSI_TIMEOUT is
> set to 60 sec
>     blk_execute_rq(q, bd_disk, rq, 0);
>     error = rq->errors;
>     if( error ){
>         dbg("error in blk_execute_rq error %d",error);
>     }
>     if(rq->sense_len){
>             process_sense_info(rq->sense);
>     } else {
>             info("no sense available");
>      }
> ==========================================
>
>
> thanks,
> ajit
>
> PS:We can not use sg_ioctl interface because code expects user space
> application only to invoke sg_ioctl that the reason it does a copyin.
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.kernelnewbies.org/pipermail/kernelnewbies/attachments/20110426/59f57cfe/attachment.html 

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

* block request execution failing on RHEL6.0 (2.6.32-71.el6.x86_64)
  2011-04-26 17:12 ` ajit jain
@ 2011-04-26 17:22   ` Mulyadi Santosa
  0 siblings, 0 replies; 3+ messages in thread
From: Mulyadi Santosa @ 2011-04-26 17:22 UTC (permalink / raw)
  To: kernelnewbies

On Wed, Apr 27, 2011 at 00:12, ajit jain <ajit4mail@gmail.com> wrote:
> Hi All,
>
> I have found the issue.
>
> in kernel prior to RHEL 6.0 blk_pc_request(rq) is define as:
> #define blk_pc_request(rq)????? ((rq)->flags & REQ_BLOCK_PC)
> while in RHEL 6.0 it is define as:
> #define blk_pc_request(rq)????? ((rq)->cmd_type == REQ_TYPE_BLOCK_PC)
>
> So, the issue was adding I was REQ_NOMERGE flag in cmd_type field of the
> request. This was making blk_pc_request(rq) to return false and thats why
> IOs were not going to scsi layer.

Wow, great research! May I suggest something? I think you need to
inform this bug to RHEL kernel team.... quite likely it's a serious
regression.
-- 
regards,

Mulyadi Santosa
Freelance Linux trainer and consultant

blog: the-hydra.blogspot.com
training: mulyaditraining.blogspot.com

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

end of thread, other threads:[~2011-04-26 17:22 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-20 12:36 block request execution failing on RHEL6.0 (2.6.32-71.el6.x86_64) ajit jain
2011-04-26 17:12 ` ajit jain
2011-04-26 17:22   ` Mulyadi Santosa

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).