Re: [PATCH v1 2/6] fs: use on-stack-bio if backing device has BDI_CAP_SYNC capability

From: Minchan Kim
Date: Thu Aug 10 2017 - 00:00:20 EST


On Wed, Aug 09, 2017 at 08:04:33PM -0700, Matthew Wilcox wrote:
> On Wed, Aug 09, 2017 at 11:41:50AM +0900, Minchan Kim wrote:
> > On Tue, Aug 08, 2017 at 07:31:22PM -0700, Matthew Wilcox wrote:
> > > On Wed, Aug 09, 2017 at 10:51:13AM +0900, Minchan Kim wrote:
> > > > On Tue, Aug 08, 2017 at 06:29:04AM -0700, Matthew Wilcox wrote:
> > > > > On Tue, Aug 08, 2017 at 05:49:59AM -0700, Matthew Wilcox wrote:
> > > > > > + struct bio sbio;
> > > > > > + struct bio_vec sbvec;
> > > > >
> > > > > ... this needs to be sbvec[nr_pages], of course.
> > > > >
> > > > > > - bio = mpage_alloc(bdev, blocks[0] << (blkbits - 9),
> > > > > > + if (bdi_cap_synchronous_io(inode_to_bdi(inode))) {
> > > > > > + bio = &sbio;
> > > > > > + bio_init(bio, &sbvec, nr_pages);
> > > > >
> > > > > ... and this needs to be 'sbvec', not '&sbvec'.
> > > >
> > > > I don't get it why we need sbvec[nr_pages].
> > > > On-stack-bio works with per-page.
> > > > May I miss something?
> > >
> > > The way I redid it, it will work with an arbitrary number of pages.
> >
> > IIUC, it would be good things with dynamic bio alloction with passing
> > allocated bio back and forth but on-stack bio cannot work like that.
> > It should be done in per-page so it is worth?
>
> I'm not passing the bio back and forth between do_mpage_readpage() and
> its callers. The version I sent allows for multiple pages in a single
> on-stack bio (when called from mpage_readpages()).

I'm confused. I want to confirm your thought before respinning.
Please correct me if I miss something.

The version you sent to me used on-stack bio within do_mpage_readpage
so that's why I said sbvec[nr_pages] would be pointless because it
works with per-page base unless if we use dynamic bio allocation.

But I guess now you suggest to use on-stack bio in mpage_readpages so
single on-stack bio in mpage_readpages's stack can batch multiple pages
in bvecs of a bio.

Right?