problem in understanding direct IO and bio submission

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi All,

I am working on a filesystem in which supports direct IO using get_user_pages
functions. The scenario is <please bear with me, this is a little long>: 

1. I have read in LDD3 that get_user_pages doesn't support unaligned user space
address. Infact, I tried giving it and it simply started copying from the next
aligned address (and removing trailing bytes of requested data).

2. In this filesystem, I create multiple bio's, each with multiple pages. These
pages are either get_user_pages mapped pages or a in kernel buffer which I
copy_to_user/copy_from_user. This way data is being copied to-and-from the
user-space buffer for requested bytes.

3. A bio can have multiple pages which are fetched using get_user_pages (I am
not using bio_map_user, but essentially doing the same thing). Hence, a bio may
have more than one vector.

4. These devices on which IO is performed (which contain the filesystem) are
connected using a SCSI adapter to a switch and through a FC channel to the
device (SAN).

I have tried this setup on 2.6.5 kernel as well as 2.6.16 kernel (for which this
is targetted). The problem which came up recently was:

1. The IO is being performed successfully for direct IO as required in normal
circumstances.
2. In case I set /sys/block/<device name>/device/online to 0 (making the device
offline) error is returned to user space.
2a. the driver is designed to capture the error in bi_end_io pointed function
(fs_bio_endio) which has a similar code snippet (copied from other drivers using
submit_bio/end_bio interface).

<code>
if(bio->bi_size > 0)
  return 1;

else{
  if ((uptodate == 0) || (error<0)){
      /* convey error through a tasklet */
  }else{
      /* perform accounting of bio */
  }
}
</code>

THE Problem is:

As soon as I disconnect the disk from the switch port (using switch software),
end_bio is being called (as expected), but everytime the bi_size field is set to
positive (but error and uptodate set) and hence the control doesn't enter the
function. The userspace IO process gets suspended (Disk Sleep) and machine is
still usable except unmount the busy partition. No call to end_bio is done which
contains utodate and error but NOT bi_size > 0.

This starts to work perfectly when I fit one page per bio (pages which are user
space mapped), and after the normal SCSI timeout, I get a call to end_bio with
bi_size==0 and uptodate and error set (-5).

Is there any such restriction as to having multiple pages per bio for user-space
mapped pages? Or am I missing something which is needed to be done such cases?

I have gone through the biodoc.txt in Documentation and it states:
----
Note: Right now the only user of bios with more than one page is ll_rw_kio,
which in turn means that only raw I/O uses it (direct i/o may not work right
now).                                          
---

Any help would be really appreciated.

Regards
Shreyansh




--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux