Message ID | alpine.LRH.2.02.1711071641090.1339@file01.intranet.prod.int.rdu2.redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Tue, Nov 07, 2017 at 04:45:17PM -0500, Mikulas Patocka wrote: > Hi > > I need the function bio_kmap_irq in the driver that I am developing, but > it doesn't return the size of the mapped data. I've made this patch to fix > it. To be honest I think we should just remove bio_kmap_irq. It is currently unused and assumes there is only a single bvec to map. I think you're much better off using a proper bvec iterator in your caller and then call bvec_kmap_irq/bvec_kunmap_irq manually.
On Wed, 8 Nov 2017, Christoph Hellwig wrote: > On Tue, Nov 07, 2017 at 04:45:17PM -0500, Mikulas Patocka wrote: > > Hi > > > > I need the function bio_kmap_irq in the driver that I am developing, but > > it doesn't return the size of the mapped data. I've made this patch to fix > > it. > > To be honest I think we should just remove bio_kmap_irq. It is currently > unused and assumes there is only a single bvec to map. It could be removed from include/linux/bio.h and moved to my driver. But if we leave it in bio.h, it could be used by others as well. bio_kmap_irq can iterate over the whole bio if we use bio_advance on the bio. > I think you're much better off using a proper bvec iterator in your > caller and then call bvec_kmap_irq/bvec_kunmap_irq manually. Mikulas
On Wed, Nov 08, 2017 at 07:38:44AM -0500, Mikulas Patocka wrote: > > To be honest I think we should just remove bio_kmap_irq. It is currently > > unused and assumes there is only a single bvec to map. > > It could be removed from include/linux/bio.h and moved to my driver. But > if we leave it in bio.h, it could be used by others as well. > > bio_kmap_irq can iterate over the whole bio if we use bio_advance on the > bio. The bio_kmap_irq name implies it maps the whole bio, but it only maps the current segment. Now if there were plenty of users and it was non-trivial we could say we should fix the name and documentation. But given how trivial it is I'd rather have you open code it to clearly document what you are doing.
Index: linux-2.6/include/linux/bio.h =================================================================== --- linux-2.6.orig/include/linux/bio.h +++ linux-2.6/include/linux/bio.h @@ -576,14 +576,16 @@ static inline void bvec_kunmap_irq(char #endif static inline char *__bio_kmap_irq(struct bio *bio, struct bvec_iter iter, - unsigned long *flags) + unsigned long *flags, unsigned *size) { - return bvec_kmap_irq(&bio_iter_iovec(bio, iter), flags); + struct bio_vec bv = bio_iter_iovec(bio, iter); + *size = bv.bv_len; + return bvec_kmap_irq(&bv, flags); } #define __bio_kunmap_irq(buf, flags) bvec_kunmap_irq(buf, flags) -#define bio_kmap_irq(bio, flags) \ - __bio_kmap_irq((bio), (bio)->bi_iter, (flags)) +#define bio_kmap_irq(bio, flags, size) \ + __bio_kmap_irq((bio), (bio)->bi_iter, (flags), (size)) #define bio_kunmap_irq(buf,flags) __bio_kunmap_irq(buf, flags) /*