Re: new patchset to eliminate DM's use of BIOSET_NEED_RESCUER

Mike Snitzer
2017-11-22T18:49:31Z

On Wed, Nov 22 2017 at 1:24pm -0500,
Mikulas Patocka <mpatocka@redhat.com> wrote:

> Another problem is this:
>
> struct bio *b = bio_clone_bioset(bio, GFP_NOIO, md->queue->bio_split);
> bio_advance(b, (bio_sectors(b) - ci.sector_count) << 9);
> bio_chain(b, bio);
>
> What if it blocks because the bioset is exhausted?
>
> The code basically builds a chain of bios of unlimited length (suppose for
> example a case when we are splitting on every sector boundary, so there
> will be one bio for every sector in the original bio), it could exhaust
> the bioset easily.
>
> It would be better to use mechanism from md-raid that chains all the
> sub-bios to the same master bio and doesn't create long chains of bios:
>
> if (max_sectors < bio_sectors(bio)) {
> struct bio *split = bio_split(bio, max_sectors,
> gfp, conf->bio_split);
> bio_chain(split, bio);
> generic_make_request(bio);
> bio = split;
> r1_bio->master_bio = bio;
> r1_bio->sectors = max_sectors;
> }

I'd be happy to take an incremental patch that improves on this commit:
https://git.kernel.org/pub/scm/linux/kernel/git/device-mapper/linux-dm.git/commit/?h=dm-4.16&id=b46d6a08f1ae7bf53e4cde28e0ccdf91567d432e

But short of that I'll have to come back to this.

Thanks,
Mike