Subject: linux-next: manual merge of the md tree with the block tree

From: Stephen Rothwell <[email-masked]>
Date: Thu, 31 May 2018 14:34:36 +1000

Hi all,

Today's linux-next merge of the md tree got a conflict in:

  drivers/md/md.c

between commit:

  afeee514ce7f ("md: convert to bioset_init()/mempool_init()")

from the block tree and commit:

  5a409b4f56d5 ("MD: fix lock contention for flush bios")

from the md tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/md/md.c
index fc692b7128bb,6b4e2f29fe4e..000000000000
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@@ -5498,16 -5518,34 +5519,32 @@@ int md_run(struct mddev *mddev
  		sysfs_notify_dirent_safe(rdev->sysfs_state);
  	}
  
 -	if (mddev->bio_set == NULL) {
 -		mddev->bio_set = bioset_create(BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS);
 -		if (!mddev->bio_set)
 -			return -ENOMEM;
 +	if (!bioset_initialized(&mddev->bio_set)) {
 +		err = bioset_init(&mddev->bio_set, BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS);
 +		if (err)
 +			return err;
  	}
 -	if (mddev->sync_set == NULL) {
 -		mddev->sync_set = bioset_create(BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS);
 -		if (!mddev->sync_set) {
 -			err = -ENOMEM;
 +	if (!bioset_initialized(&mddev->sync_set)) {
 +		err = bioset_init(&mddev->sync_set, BIO_POOL_SIZE, 0, BIOSET_NEED_BVECS);
 +		if (err)
  			goto abort;
 -		}
  	}
+ 	if (mddev->flush_pool == NULL) {
+ 		mddev->flush_pool = mempool_create(NR_FLUSH_INFOS, flush_info_alloc,
+ 						flush_info_free, mddev);
+ 		if (!mddev->flush_pool) {
+ 			err = -ENOMEM;
+ 			goto abort;
+ 		}
+ 	}
+ 	if (mddev->flush_bio_pool == NULL) {
+ 		mddev->flush_bio_pool = mempool_create(NR_FLUSH_BIOS, flush_bio_alloc,
+ 						flush_bio_free, mddev);
+ 		if (!mddev->flush_bio_pool) {
+ 			err = -ENOMEM;
+ 			goto abort;
+ 		}
+ 	}
  
  	spin_lock(&pers_lock);
  	pers = find_pers(mddev->level, mddev->clevel);
@@@ -5667,8 -5705,22 +5704,16 @@@
  	return 0;
  
  abort:
+ 	if (mddev->flush_bio_pool) {
+ 		mempool_destroy(mddev->flush_bio_pool);
+ 		mddev->flush_bio_pool = NULL;
+ 	}
+ 	if (mddev->flush_pool){
+ 		mempool_destroy(mddev->flush_pool);
+ 		mddev->flush_pool = NULL;
+ 	}
 -	if (mddev->bio_set) {
 -		bioset_free(mddev->bio_set);
 -		mddev->bio_set = NULL;
 -	}
 -	if (mddev->sync_set) {
 -		bioset_free(mddev->sync_set);
 -		mddev->sync_set = NULL;
 -	}
 +	bioset_exit(&mddev->bio_set);
 +	bioset_exit(&mddev->sync_set);
  
  	return err;
  }
@@@ -5881,8 -5933,22 +5926,16 @@@ void md_stop(struct mddev *mddev
  	 * This is called from dm-raid
  	 */
  	__md_stop(mddev);
+ 	if (mddev->flush_bio_pool) {
+ 		mempool_destroy(mddev->flush_bio_pool);
+ 		mddev->flush_bio_pool = NULL;
+ 	}
+ 	if (mddev->flush_pool) {
+ 		mempool_destroy(mddev->flush_pool);
+ 		mddev->flush_pool = NULL;
+ 	}
 -	if (mddev->bio_set) {
 -		bioset_free(mddev->bio_set);
 -		mddev->bio_set = NULL;
 -	}
 -	if (mddev->sync_set) {
 -		bioset_free(mddev->sync_set);
 -		mddev->sync_set = NULL;
 -	}
 +	bioset_exit(&mddev->bio_set);
 +	bioset_exit(&mddev->sync_set);
  }
  
  EXPORT_SYMBOL_GPL(md_stop);