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

From: Stephen Rothwell <[email-masked]>
Date: Thu, 28 Jul 2022 13:14:59 +1000

Hi all,

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

  drivers/md/dm.c

between commit:

  1be3479b8533 ("block: move ->bio_split to the gendisk")

from the block tree and commit:

  8b211aaccb91 ("dm: add two stage requeue mechanism")

from the device-mapper 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/dm.c
index b7458f2dd3e4,47bcc5081b2b..000000000000
--- a/drivers/md/dm.c
+++ b/drivers/md/dm.c
@@@ -962,6 -1001,58 +1001,58 @@@ static void __dm_io_complete(struct dm_
  	}
  }
  
+ static void dm_wq_requeue_work(struct work_struct *work)
+ {
+ 	struct mapped_device *md = container_of(work, struct mapped_device,
+ 						requeue_work);
+ 	unsigned long flags;
+ 	struct dm_io *io;
+ 
+ 	/* reuse deferred lock to simplify dm_handle_requeue */
+ 	spin_lock_irqsave(&md->deferred_lock, flags);
+ 	io = md->requeue_list;
+ 	md->requeue_list = NULL;
+ 	spin_unlock_irqrestore(&md->deferred_lock, flags);
+ 
+ 	while (io) {
+ 		struct dm_io *next = io->next;
+ 
 -		dm_io_rewind(io, &md->queue->bio_split);
++		dm_io_rewind(io, &md->disk->bio_split);
+ 
+ 		io->next = NULL;
+ 		__dm_io_complete(io, false);
+ 		io = next;
+ 	}
+ }
+ 
+ /*
+  * Two staged requeue:
+  *
+  * 1) io->orig_bio points to the real original bio, and the part mapped to
+  *    this io must be requeued, instead of other parts of the original bio.
+  *
+  * 2) io->orig_bio points to new cloned bio which matches the requeued dm_io.
+  */
+ static void dm_io_complete(struct dm_io *io)
+ {
+ 	bool first_requeue;
+ 
+ 	/*
+ 	 * Only dm_io that has been split needs two stage requeue, otherwise
+ 	 * we may run into long bio clone chain during suspend and OOM could
+ 	 * be triggered.
+ 	 *
+ 	 * Also flush data dm_io won't be marked as DM_IO_WAS_SPLIT, so they
+ 	 * also aren't handled via the first stage requeue.
+ 	 */
+ 	if (dm_io_flagged(io, DM_IO_WAS_SPLIT))
+ 		first_requeue = true;
+ 	else
+ 		first_requeue = false;
+ 
+ 	__dm_io_complete(io, first_requeue);
+ }
+ 
  /*
   * Decrements the number of outstanding ios that a bio has been
   * cloned into, completing the original io if necc.