Re: [PATCH v9 21/25] block/rnbd: server: functionality for IO submission to file or block dev

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

 



On Mon, Mar 2, 2020 at 11:06 AM Danil Kipnis
<danil.kipnis@xxxxxxxxxxxxxxx> wrote:
>
> On Sun, Mar 1, 2020 at 4:09 AM Bart Van Assche <bvanassche@xxxxxxx> wrote:
> >
> > On 2020-02-21 02:47, Jack Wang wrote:
> > > +static struct bio *rnbd_bio_map_kern(struct request_queue *q, void *data,
> > > +                                   struct bio_set *bs,
> > > +                                   unsigned int len, gfp_t gfp_mask)
> > > +{
> > > +     unsigned long kaddr = (unsigned long)data;
> > > +     unsigned long end = (kaddr + len + PAGE_SIZE - 1) >> PAGE_SHIFT;
> > > +     unsigned long start = kaddr >> PAGE_SHIFT;
> > > +     const int nr_pages = end - start;
> > > +     int offset, i;
> > > +     struct bio *bio;
> > > +
> > > +     bio = bio_alloc_bioset(gfp_mask, nr_pages, bs);
> > > +     if (!bio)
> > > +             return ERR_PTR(-ENOMEM);
> > > +
> > > +     offset = offset_in_page(kaddr);
> > > +     for (i = 0; i < nr_pages; i++) {
> > > +             unsigned int bytes = PAGE_SIZE - offset;
> > > +
> > > +             if (len <= 0)
> > > +                     break;
> > > +
> > > +             if (bytes > len)
> > > +                     bytes = len;
> > > +
> > > +             if (bio_add_pc_page(q, bio, virt_to_page(data), bytes,
> > > +                                 offset) < bytes) {
> > > +                     /* we don't support partial mappings */
> > > +                     bio_put(bio);
> > > +                     return ERR_PTR(-EINVAL);
> > > +             }
> > > +
> > > +             data += bytes;
> > > +             len -= bytes;
> > > +             offset = 0;
> > > +     }
> > > +
> > > +     bio->bi_end_io = bio_put;
> > > +     return bio;
> > > +}
> >
> > The above function is almost identical to bio_map_kern(). Please find a
> > way to prevent such code duplication.
>
> Hi Bart,
>
> We prealloc bio_set in order to avoid allocation in io path done by
> bio_map_kern() (call to bio_kmalloc). Instead we use
> bio_alloc_bioset() with a preallocated bio_set. Will test whether
> performance advantage is measurable and if not will switch to
> bio_map_kern.
Hi Bart,

We tried the above approach and just noticed the bio_map_kern was no
longer exported since 5.4 kernel.
We checked target_core_iblock.c and nvme io-cmd-bdev.c, they are open
coding similar function.

I guess re-export bio_map_kern will not be accepted?
Do you have suggestion how should we handle it?

Thanks!



[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux