Re: Understanding kmap/kunmap

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

 



Correction. The problem occurs when 8 bios of size 512 with 1 bvec each 
all share the same page. I made a bad assumption previously.

-Kai Meyer

On 12/01/2011 10:49 AM, Kai Meyer wrote:
> I want to be able to copy data into a struct bio *, so I use
> bio_for_each_segment to loop through each bvec, like so:
>
> void some_function(struct bio *bio, char *some_data) {
>       struct bio_vec *bvec;
>       int i;
>       unsigned int bio_so_far = 0;
>       bio_for_each_segment(bvec, bio, i) {
>           char *bio_buffer = __bio_kmap_atomic(bio, i, KM_USER0);
>           memcpy(bio_buffer, some_data + bio_so_far, bvec->bv_len);
>           __bio_kunmap_atomic(bio, KM_USER0);
>           bio_so_far += bvec->bv_len;
>       }
> }
>
> There's lots more to the function, but this is basically the distilled
> version with out any extra stuff.
>
> What I'm finding is that when the bio has multiple bvecs that share the
> same page, only the first bvec's data actually gets copied back up to
> user-space, the rest is garbage or null (meaning, what was there
> already). For instance, I see a lot of bios from vfat that are 4096
> bytes long but are comprised of 8 bvecs that are 512 bytes long that all
> have an offset to the same page.
>
> I've tried doing just one kmap_atomic on the page by keeping track of
> what the last page I kmap'ed was, but that didn't fix the problem either.
>
> Any documentation or high level explanation of kmap/kunmap or other
> ideas to try are welcome.
>
> -Kai Meyer
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies@xxxxxxxxxxxxxxxxx
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies

_______________________________________________
Kernelnewbies mailing list
Kernelnewbies@xxxxxxxxxxxxxxxxx
http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies


[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