Skip to contentSkip to conversation

Device mapper and dm-mpath fixes

PATCH In review Bart Van Assche 4 participants 17 messages Aug 9, 2017 – Aug 10, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Device mapper and dm-mpath fixes

Hello Mike,

The patches in this series are what I came up with while analyzing the soft and hard lockups reported by Laurence Oberman. Please consider these patches for kernel v4.14.

Thank you,

Bart.

Bart Van Assche (7):
dm: Fix the second dec_pending() argument in __split_and_process_bio()
dm: Fix printk() rate limiting code
dm-mpath: Do not lock up a CPU with requeuing activity
dm-mpath: Avoid that building with W=1 causes gcc 7 to complain about
fall-through
dm-mpath: Complain about unsupported __multipath_map_bio() return
values
dm-mpath: Retry BLK_STS_RESOURCE errors
dm-mpath: Make the dm-sq requeuing behavior consistent with the dm-mq
behavior

 drivers/md/dm-mpath.c         |  8 ++++++--
 drivers/md/dm-rq.c            |  9 +++++----
 drivers/md/dm.c               | 12 +-----------
 include/linux/device-mapper.h | 41 ++++++++++++-----------------------------
 4 files changed, 24 insertions(+), 46 deletions(-)
Signature · 1 line
2.13.3
#1 lore raw

PATCH 1/7 dm: Fix the second dec_pending() argument in __split_and_process_bio()

Detected by sparse.

Fixes commit 4e4cbee93d56 ("block: switch bios to blk_status_t")
Cc Christoph Hellwig <[email protected]>
Cc Laurence Oberman <[email protected]>
---
 drivers/md/dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm.c +1 -1
index 2edbcc2d7d3f..8298670757e9 100644
@@ -1523,7 +1523,7 @@ static void __split_and_process_bio(struct mapped_device *md,
 	}
 
 	/* drop the extra reference count */
-	dec_pending(ci.io, error);
+	dec_pending(ci.io, errno_to_blk_status(error));
 }
 /*-----------------------------------------------------------------
  * CRUD END
Signature · 1 line
2.13.3
Tested-by on v1 1/7
#3 lore raw

Re: [PATCH 1/7] dm: Fix the second dec_pending() argument in __split_and_process_bio()

In reply to Bart Van Assche
Quoted 21 lines · Bart Van Assche

Detected by sparse.

Fixes commit 4e4cbee93d56 ("block: switch bios to blk_status_t")
Cc Christoph Hellwig <[email protected]>
Cc Laurence Oberman <[email protected]>

---
 drivers/md/dm.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm.c +0 -0
index 2edbcc2d7d3f..8298670757e9 100644
@@ -1523,7 +1523,7 @@ static void __split_and_process_bio(struct
 mapped_device *md,
  	}


  /* drop the extra reference count */

drivers/md/dm.c +1 -1
-	dec_pending(ci.io, error);
+	dec_pending(ci.io, errno_to_blk_status(error));
Quoted 3 lines

 } /*-----------------------------------------------------------------
  * CRUD END

Hello Bart

I applied and tested all patches except patch 2/7 (as discussed) I also still have the prior patch in place you sent me.

I built a new kernel on 4.13-rc3

The soft lockups are gone for me with 10 parallel writes. I also have not seen a hard lockup so far.

What is important to note is that if I use the [none] scheduler I am
still stable but I will sporadically get the ******
"[38071.773471] device-mapper: multipath: blk_get_request() returned -11 - requeuing
"

However that is not unexpected I guess.

The ( requeuing messages) do NOT show up with [mq-deadline] which is all I was testing with last night and yesterday. So when I said they are gone, that was specifically for [mq-deadline]

Patches look good and are helping. I will circle back and patch and test on Ming's kernel.

For the series except PATCH2/7 and including

[PATCH] block: Make blk_mq_delay_kick_requeue_list() rerun the queue at a quiet time

Thanks
Laurence

--
dm-devel mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/dm-devel

#4 lore raw

Re: [PATCH 1/7] dm: Fix the second dec_pending() argument in __split_and_process_bio()

Quoted 2 lines · Laurence Oberman

The soft lockups are gone for me with 10 parallel writes. I also have not seen a hard lockup so far.

That's great news!

Quoted 6 lines

What is important to note is that if I use the [none] scheduler I am
still stable but I will sporadically get the ******
"[38071.773471] device-mapper: multipath: blk_get_request() returned -11 - requeuing"

However that is not unexpected I guess.

Yes, this is expected.

Quoted 6 lines

For the series except PATCH2/7 and including

[PATCH] block: Make blk_mq_delay_kick_requeue_list() rerun the queue at a quiet time

Thanks for the testing!

Bart.

#5 lore raw

PATCH 2/7 dm: Fix printk() rate limiting code

In reply to Bart Van Assche

Using the same rate limiting state for different kinds of messages is wrong because this can cause a high frequency message to suppress a report of a low frequency message. Hence use a unique rate limiting state per message type.

Fixes commit 71a16736a15e ("dm: use local printk ratelimit")
Cc Namhyung Kim <[email protected]>
Cc Alasdair G Kergon <[email protected]>
Cc Laurence Oberman <[email protected]>
---
 drivers/md/dm.c               | 10 ----------
 include/linux/device-mapper.h | 41 ++++++++++++-----------------------------
 2 files changed, 12 insertions(+), 39 deletions(-)
drivers/md/dm.c +0 -10
index 8298670757e9..d669fddd9290 100644
@@ -27,16 +27,6 @@
 
 #define DM_MSG_PREFIX "core"
 
-#ifdef CONFIG_PRINTK
-/*
- * ratelimit state to be used in DMXXX_LIMIT().
- */
-DEFINE_RATELIMIT_STATE(dm_ratelimit_state,
-		       DEFAULT_RATELIMIT_INTERVAL,
-		       DEFAULT_RATELIMIT_BURST);
-EXPORT_SYMBOL(dm_ratelimit_state);
-#endif
-
 /*
  * Cookies are numeric values sent with CHANGE and REMOVE
  * uevents while resuming, removing or renaming the device.
include/linux/device-mapper.h +12 -29

58 lines not on this page · raw message

Signature · 1 line
2.13.3
#6 lore raw

PATCH 3/7 dm-mpath: Do not lock up a CPU with requeuing activity

In reply to Bart Van Assche

When using the block layer in single queue mode, get_request() returns ERR_PTR(-EAGAIN) if the queue is dying and the REQ_NOWAIT flag has been passed to get_request(). Avoid that the kernel reports soft lockup complaints in this case due to continuous requeuing activity.

---
 drivers/md/dm-mpath.c | 1 -
 1 file changed, 1 deletion(-)
drivers/md/dm-mpath.c +0 -1
index 0e8ab5bb3575..0baa461eccaa 100644
@@ -504,7 +504,6 @@ static int multipath_clone_and_map(struct dm_target *ti, struct request *rq,
 		if (queue_dying) {
 			atomic_inc(&m->pg_init_in_progress);
 			activate_or_offline_path(pgpath);
-			return DM_MAPIO_REQUEUE;
 		}
 		return DM_MAPIO_DELAY_REQUEUE;
 	}
Signature · 1 line
2.13.3
Reviewed-by on v1 3/7
#7 lore raw

Re: [PATCH 3/7] dm-mpath: Do not lock up a CPU with requeuing activity

Quoted 5 lines · Bart Van Assche

When using the block layer in single queue mode, get_request() returns ERR_PTR(-EAGAIN) if the queue is dying and the REQ_NOWAIT flag has been passed to get_request(). Avoid that the kernel reports soft lockup complaints in this case due to continuous requeuing activity.

Looks good,

#8 lore raw

PATCH 4/7 dm-mpath: Avoid that building with W=1 causes gcc 7 to complain about fall-through

In reply to Bart Van Assche
Cc Laurence Oberman <[email protected]>
---
 drivers/md/dm-mpath.c | 1 +
 1 file changed, 1 insertion(+)
drivers/md/dm-mpath.c +1 -0
index 0baa461eccaa..6e20deac4add 100644
@@ -1379,6 +1379,7 @@ static void pg_init_done(void *data, int errors)
 	case SCSI_DH_RETRY:
 		/* Wait before retrying. */
 		delay_retry = 1;
+		/* fall through */
 	case SCSI_DH_IMM_RETRY:
 	case SCSI_DH_RES_TEMP_UNAVAIL:
 		if (pg_init_limit_reached(m, pgpath))
Signature · 1 line
2.13.3
Reviewed-by on v1 4/7
#9 lore raw

Re: [PATCH 4/7] dm-mpath: Avoid that building with W=1 causes gcc 7 to complain about fall-through

Quoted 11 lines · Bart Van Assche
Cc Laurence Oberman <[email protected]>
---
 drivers/md/dm-mpath.c | 1 +
 1 file changed, 1 insertion(+)
drivers/md/dm-mpath.c +0 -0
index 0baa461eccaa..6e20deac4add 100644

drivers/md/dm-mpath.c static void pg_init_done(void *data, int errors) · line 1385

Quoted 7 lines
drivers/md/dm-mpath.c +1 -0
@@ -1379,6 +1379,7 @@ static void pg_init_done(void *data, int errors)
 	case SCSI_DH_RETRY:
 		/* Wait before retrying. */
 		delay_retry = 1;
+		/* fall through */
 	case SCSI_DH_IMM_RETRY:
 	case SCSI_DH_RES_TEMP_UNAVAIL:
 		if (pg_init_limit_reached(m, pgpath))

I prefer /*FALLTHRU*/ over the less shouty lower case version, but either way this looks okay:

#10 lore raw

PATCH 5/7 dm-mpath: Complain about unsupported __multipath_map_bio() return values

In reply to Bart Van Assche

The only behavior change introduced by this patch is that WARN_ON_ONCE() is called if __multipath_map_bio() would return an unsupported return value.

Cc Christoph Hellwig <[email protected]>
Cc Laurence Oberman <[email protected]>
---
 drivers/md/dm-mpath.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/md/dm-mpath.c +5 -0
index 6e20deac4add..f2ffa20c69b9 100644
@@ -632,6 +632,11 @@ static void process_queued_bios(struct work_struct *work)
 		case DM_MAPIO_REMAPPED:
 			generic_make_request(bio);
 			break;
+		case 0:
+			break;
+		default:
+			WARN_ONCE(true, "__multipath_map_bio() returned %d\n",
+				  r);
 		}
 	}
 	blk_finish_plug(&plug);
Signature · 1 line
2.13.3
Reviewed-by on v1 5/7
#11 lore raw

Re: [PATCH 5/7] dm-mpath: Complain about unsupported __multipath_map_bio() return values

Quoted 3 lines · Bart Van Assche

The only behavior change introduced by this patch is that WARN_ON_ONCE() is called if __multipath_map_bio() would return an unsupported return value.

Looks good,

#12 lore raw

PATCH 6/7 dm-mpath: Retry BLK_STS_RESOURCE errors

In reply to Bart Van Assche

Retry requests instead of failing these if an out-of-memory error occurs or the block driver below dm-mpath is busy. This restores the v4.12 behavior of noretry_error(), namely that -ENOMEM results in a retry.

Fixes commit 2a842acab109 ("block: introduce new block status code type")
Cc Christoph Hellwig <[email protected]>
Cc Laurence Oberman <[email protected]>
---
 drivers/md/dm-mpath.c | 1 -
 1 file changed, 1 deletion(-)
drivers/md/dm-mpath.c +0 -1
index f2ffa20c69b9..3c1f8a89b10f 100644
@@ -1463,7 +1463,6 @@ static int noretry_error(blk_status_t error)
 	case BLK_STS_TARGET:
 	case BLK_STS_NEXUS:
 	case BLK_STS_MEDIUM:
-	case BLK_STS_RESOURCE:
 		return 1;
 	}
 
Signature · 1 line
2.13.3
Reviewed-by on v1 6/7
#13 lore raw

Re: [PATCH 6/7] dm-mpath: Retry BLK_STS_RESOURCE errors

Quoted 4 lines · Bart Van Assche

Retry requests instead of failing these if an out-of-memory error occurs or the block driver below dm-mpath is busy. This restores the v4.12 behavior of noretry_error(), namely that -ENOMEM results in a retry.

Thanks,

not idea how the resource one leaked in.

#14 lore raw

PATCH 7/7 dm-mpath: Make the dm-sq requeuing behavior consistent with the dm-mq behavior

In reply to Bart Van Assche

DM_MAPIO_DELAY_REQUEUE causes dm-mq to requeue after a delay but causes dm-sq to requeue immediately. Make the behavior of dm-sq consistent with that of dm-mq.

Cc Laurence Oberman <[email protected]>
---
 drivers/md/dm-rq.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/md/dm-rq.c +5 -4
index c6ebc5b1e00e..cbee09054d1e 100644
@@ -237,14 +237,14 @@ static void dm_end_request(struct request *clone, blk_status_t error)
 /*
  * Requeue the original request of a clone.
  */
-static void dm_old_requeue_request(struct request *rq)
+static void dm_old_requeue_request(struct request *rq, unsigned long delay_ms)
 {
 	struct request_queue *q = rq->q;
 	unsigned long flags;
 
 	spin_lock_irqsave(q->queue_lock, flags);
 	blk_requeue_request(q, rq);
-	blk_run_queue_async(q);
+	blk_delay_queue(q, delay_ms);
 	spin_unlock_irqrestore(q->queue_lock, flags);
 }
 
@@ -270,6 +270,7 @@ static void dm_requeue_original_request(struct dm_rq_target_io *tio, bool delay_
 	struct mapped_device *md = tio->md;
 	struct request *rq = tio->orig;
 	int rw = rq_data_dir(rq);
+	unsigned long delay_ms = delay_requeue ? 100 : 0;
 
 	rq_end_stats(md, rq);
 	if (tio->clone) {
@@ -278,9 +279,9 @@ static void dm_requeue_original_request(struct dm_rq_target_io *tio, bool delay_
 	}
 
 	if (!rq->q->mq_ops)
-		dm_old_requeue_request(rq);
+		dm_old_requeue_request(rq, delay_ms);
 	else
-		dm_mq_delay_requeue_request(rq, delay_requeue ? 100/*ms*/ : 0);
+		dm_mq_delay_requeue_request(rq, delay_ms);
 
 	rq_completed(md, rw, false);
 }
Signature · 1 line
2.13.3
#16 lore raw
In reply to Bart Van Assche
Quoted 22 lines · Bart Van Assche

Hello Mike,

The patches in this series are what I came up with while analyzing the soft and hard lockups reported by Laurence Oberman. Please consider these patches for kernel v4.14.

Thank you,

Bart.

Bart Van Assche (7):
dm: Fix the second dec_pending() argument in __split_and_process_bio()
dm: Fix printk() rate limiting code
dm-mpath: Do not lock up a CPU with requeuing activity
dm-mpath: Avoid that building with W=1 causes gcc 7 to complain about
fall-through
dm-mpath: Complain about unsupported __multipath_map_bio() return
values
dm-mpath: Retry BLK_STS_RESOURCE errors
dm-mpath: Make the dm-sq requeuing behavior consistent with the dm-mq
behavior

Quoted 5 lines
 drivers/md/dm-mpath.c         |  8 ++++++--
 drivers/md/dm-rq.c            |  9 +++++----
 drivers/md/dm.c               | 12 +-----------
 include/linux/device-mapper.h | 41 ++++++++++++-----------------------------
 4 files changed, 24 insertions(+), 46 deletions(-)

Hey Bart,

Thanks for the patches. I'm currently on a leave of absence to recover from a nasty fall I had (broke my sacrum and dislocated my left thumb at the wrist)... so: I won't be getting to these patches for a couple weeks.

Mike