RE: Possible bug in scsi_lib.c:scsi_req_map_sg()

2007-03-04 Thread James Bottomley
On Sun, 2007-03-04 at 00:36 -0700, Dachepalli, Sudhir wrote: Our driver gets called in with the following fashion through the queuecommand. scsi_request_fn() - scsi_dispatch_cmd() - rtn = host-hostt-queuecommand(cmd, scsi_done); We are using the cmd ( scsi_cmnd) as a pass through with out

Re: Possible bug in scsi_lib.c:scsi_req_map_sg()

2007-03-04 Thread James Bottomley
On Sun, 2007-03-04 at 09:43 -0600, Mike Christie wrote: There are trying to do a scsi level multipath driver for RDAC support. And they are trying to do something similar to request based multipath (route requests instead of bios but in their case they are routing scsi_cmnds instead of

Re: Possible bug in scsi_lib.c:scsi_req_map_sg()

2007-03-04 Thread Mike Christie
James Bottomley wrote: On Sun, 2007-03-04 at 10:21 -0600, Mike Christie wrote: I think they get around this and other request settings that need resetting by using scsi_execute_async. They will take the command, data direction and buffer fields from the original scsi_cmnd, then pass those on

Re: Possible bug in scsi_lib.c:scsi_req_map_sg()

2007-03-04 Thread Mike Christie
Mike Christie wrote: James Bottomley wrote: On Sun, 2007-03-04 at 10:21 -0600, Mike Christie wrote: I think they get around this and other request settings that need resetting by using scsi_execute_async. They will take the command, data direction and buffer fields from the original

RE: Possible bug in scsi_lib.c:scsi_req_map_sg()

2007-03-04 Thread Dachepalli, Sudhir
Do you think the following could work If I used blk layer functions instead of scsi_execute_async: Blk_get_request() Req-flags |= REQ_DONTPREP Blk_rq_map_kern() Blk_execute_req_nowait() Blk_put_request() Regards, Sudhir -Original Message- From: Mike Christie [mailto:[EMAIL PROTECTED]

RE: Possible bug in scsi_lib.c:scsi_req_map_sg()

2007-03-04 Thread James Bottomley
On Sun, 2007-03-04 at 11:00 -0700, Dachepalli, Sudhir wrote: Do you think the following could work If I used blk layer functions instead of scsi_execute_async: Blk_get_request() Req-flags |= REQ_DONTPREP There's additional complexity here: if the request isn't prepared, no command is

convert sg to block layer helpers - v5

2007-03-04 Thread michaelc
There is no big changes between v4 and v5. I was able to fix things in scsi tgt, so I could remove the weird arguements the block helpers were taking for it. I also tried to break up the patchset for easier viewing. The final patch also takes care of the access_ok regression. These patches were

[PATCH 1/7] rm bio hacks in scsi tgt

2007-03-04 Thread michaelc
From: Mike Christie [EMAIL PROTECTED] scsi tgt breaks up a command into multple scatterlists if we cannot fit all the data in one. This was because the block rq helpers did not support large requests and because we can get a command of any old size so it is hard to preallocate pages for

[PATCH 2/7] rm block device arg from bio map user

2007-03-04 Thread michaelc
From: Mike Christie [EMAIL PROTECTED] Everyone is passing in NULL, so let's just make it a little more simple and drop the block device argument from the bio mapping functions. Signed-off-by: Mike Christie [EMAIL PROTECTED] --- block/ll_rw_blk.c |4 ++-- fs/bio.c| 17

[PATCH 5/7] Add sg io mmap helper

2007-03-04 Thread michaelc
From: Mike Christie [EMAIL PROTECTED] sg.c supports mmap, so this patch just move the code to the block layer for others to share and converts it to the bio reserved buffer. The helpers are: - blk_rq_mmap - does some checks to makre sure the reserved buf is large enough. - blk_rq_vma_nopage -

[PATCH 4/7] Add reserve buffer for sg io

2007-03-04 Thread michaelc
From: Mike Christie [EMAIL PROTECTED] sg and st use a reserve buffer so that they can always gaurantee that they can execute IO of a certain size which is larger than the worst case guess. This patch adds a bio_reserved_buf structure, which holds mutlple segments that can be mapped into BIOs.

[PATCH 3/7] Support large sg io segments

2007-03-04 Thread michaelc
From: Mike Christie [EMAIL PROTECTED] sg.c and st allocate large chunks of clustered pages to try and make really large requests. The block layer sg io code only allocates a page at a time, so we can end up with lots of unclustered pages and smaller requests. This patch modifies the block layer

[PATCH 7/7] mv user buffer copy access_ok test to block helper

2007-03-04 Thread michaelc
From: Mike Christie [EMAIL PROTECTED] sg.c does a access_ok test on the user buffer when doing indirect IO. bsg and scsi_ioctl.c did not, but it seems like it would be ok to be common. This patch moves that test to the block layer helpers. Signed-off-by: Mike Christie [EMAIL PROTECTED] ---

[PATCH 6/7] Convert sg to block layer helpers

2007-03-04 Thread michaelc
From: Mike Christie [EMAIL PROTECTED] Convert sg to block layer helpers. I have tested with sg3_utils and sg_utils. I have tested the mmap, iovec, dio and indirect IO paths, by running those tools and the example programs against software iscsi which does not support clustering, scsi_debug which

RE: Possible bug in scsi_lib.c:scsi_req_map_sg()

2007-03-04 Thread Dachepalli, Sudhir
James, How about the following: 1. Cmd= Scsi_get_command( on physical device ) 2. Clone the scsi_cmnd fields of the virtual cmnd( command received by failover driver) to physical cmnd (the command allocated by scsi_get_command ) 3. blk_get_request() 4. fill the request fields, req-special =

Re: convert sg to block layer helpers - v5

2007-03-04 Thread Douglas Gilbert
[EMAIL PROTECTED] wrote: There is no big changes between v4 and v5. I was able to fix things in scsi tgt, so I could remove the weird arguements the block helpers were taking for it. I also tried to break up the patchset for easier viewing. The final patch also takes care of the access_ok

Re: convert sg to block layer helpers - v5

2007-03-04 Thread Mike Christie
Douglas Gilbert wrote: Mike, I see you are removing the scatter_elem_sz parameter. What decides the scatter gather element size? Can it be greater than PAGE_SIZE? Oh yeah, sorry I should have documented that. I just made the code try to allocate as large a element as possible. So the code

Re: convert sg to block layer helpers - v5

2007-03-04 Thread Douglas Gilbert
Mike Christie wrote: Douglas Gilbert wrote: Mike, I see you are removing the scatter_elem_sz parameter. What decides the scatter gather element size? Can it be greater than PAGE_SIZE? Oh yeah, sorry I should have documented that. I just made the code try to allocate as large a element

Re: [PATCH 7/7] mv user buffer copy access_ok test to block helper

2007-03-04 Thread Mike Christie
[EMAIL PROTECTED] wrote: + if (!access_ok(read ? +VERIFY_WRITE : VERIFY_READ, +p, iov_len)) + return -EFAULT; }

Re: [PATCH 3/3] tgt: fix scsi command leak

2007-03-04 Thread FUJITA Tomonori
From: Douglas Gilbert [EMAIL PROTECTED] Subject: Re: [PATCH 3/3] tgt: fix scsi command leak Date: Sat, 03 Mar 2007 11:58:19 -0500 FUJITA Tomonori wrote: The failure to map user-space pages leads to scsi command leak. It can happens mostly because of user-space daemon bugs (or OOM). This