Skip to content

Commit c9e4558

Browse files
DaveWysochanskiRHkergon
authored andcommitted
dm mpath: add retry pg init
This patch allows a failed path group initialisation command to be retried. It adds a generic MP_RETRY flag and a "pg_init_retries" feature to device-mapper multipath which limits the number of retries. 1. A hw handler sends a path initialization command to the storage and the command completes with an error code indicating the command should be retried. 2. The hardware handler calls dm_pg_init_complete() with MP_RETRY set in err_flags to ask the dm multipath core to retry. 3. If the retry limit has not been exceeded, pg_init() is retried. Otherwise fail_path() is called. If you are using the userspace multipath-tools or device-mapper-multipath package, you can set pg_init_retries in the 'device' section of your /etc/multipath.conf file. For example: features "2 pg_init_retries 7" The number of PG retries attempted is reported in the 'dmsetup status' output. Signed-off-by: Dave Wysochanski <dwysocha@redhat.com> Acked-by: Mike Christie <michaelc@cs.wisc.edu> Acked-by: Chandra Seetharaman <sekharan@us.ibm.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com>
1 parent 636d578 commit c9e4558

2 files changed

Lines changed: 68 additions & 14 deletions

File tree

‎drivers/md/dm-hw-handler.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,6 @@ unsigned dm_scsi_err_handler(struct hw_handler *hwh, struct bio *bio);
5858
#define MP_FAIL_PATH 1
5959
#define MP_BYPASS_PG 2
6060
#define MP_ERROR_IO 4 /* Don't retry this I/O */
61+
#define MP_RETRY 8
6162

6263
#endif

‎drivers/md/dm-mpath.c‎

Lines changed: 67 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ struct multipath {
7575
unsigned queue_io; /* Must we queue all I/O? */
7676
unsigned queue_if_no_path; /* Queue I/O if last path fails? */
7777
unsigned saved_queue_if_no_path;/* Saved state during suspension */
78+
unsigned pg_init_retries; /* Number of times to retry pg_init */
79+
unsigned pg_init_count; /* Number of times pg_init called */
7880

7981
struct work_struct process_queued_ios;
8082
struct bio_list queued_ios;
@@ -225,6 +227,8 @@ static void __switch_pg(struct multipath *m, struct pgpath *pgpath)
225227
m->pg_init_required = 0;
226228
m->queue_io = 0;
227229
}
230+
231+
m->pg_init_count = 0;
228232
}
229233

230234
static int __choose_path_in_pg(struct multipath *m, struct priority_group *pg)
@@ -424,6 +428,7 @@ static void process_queued_ios(struct work_struct *work)
424428
must_queue = 0;
425429

426430
if (m->pg_init_required && !m->pg_init_in_progress) {
431+
m->pg_init_count++;
427432
m->pg_init_required = 0;
428433
m->pg_init_in_progress = 1;
429434
init_required = 1;
@@ -689,9 +694,11 @@ static int parse_features(struct arg_set *as, struct multipath *m)
689694
int r;
690695
unsigned argc;
691696
struct dm_target *ti = m->ti;
697+
const char *param_name;
692698

693699
static struct param _params[] = {
694-
{0, 1, "invalid number of feature args"},
700+
{0, 3, "invalid number of feature args"},
701+
{1, 50, "pg_init_retries must be between 1 and 50"},
695702
};
696703

697704
r = read_param(_params, shift(as), &argc, &ti->error);
@@ -701,12 +708,28 @@ static int parse_features(struct arg_set *as, struct multipath *m)
701708
if (!argc)
702709
return 0;
703710

704-
if (!strnicmp(shift(as), MESG_STR("queue_if_no_path")))
705-
return queue_if_no_path(m, 1, 0);
706-
else {
711+
do {
712+
param_name = shift(as);
713+
argc--;
714+
715+
if (!strnicmp(param_name, MESG_STR("queue_if_no_path"))) {
716+
r = queue_if_no_path(m, 1, 0);
717+
continue;
718+
}
719+
720+
if (!strnicmp(param_name, MESG_STR("pg_init_retries")) &&
721+
(argc >= 1)) {
722+
r = read_param(_params + 1, shift(as),
723+
&m->pg_init_retries, &ti->error);
724+
argc--;
725+
continue;
726+
}
727+
707728
ti->error = "Unrecognised multipath feature request";
708-
return -EINVAL;
709-
}
729+
r = -EINVAL;
730+
} while (argc && !r);
731+
732+
return r;
710733
}
711734

712735
static int multipath_ctr(struct dm_target *ti, unsigned int argc,
@@ -975,6 +998,26 @@ static int bypass_pg_num(struct multipath *m, const char *pgstr, int bypassed)
975998
return 0;
976999
}
9771000

1001+
/*
1002+
* Should we retry pg_init immediately?
1003+
*/
1004+
static int pg_init_limit_reached(struct multipath *m, struct pgpath *pgpath)
1005+
{
1006+
unsigned long flags;
1007+
int limit_reached = 0;
1008+
1009+
spin_lock_irqsave(&m->lock, flags);
1010+
1011+
if (m->pg_init_count <= m->pg_init_retries)
1012+
m->pg_init_required = 1;
1013+
else
1014+
limit_reached = 1;
1015+
1016+
spin_unlock_irqrestore(&m->lock, flags);
1017+
1018+
return limit_reached;
1019+
}
1020+
9781021
/*
9791022
* pg_init must call this when it has completed its initialisation
9801023
*/
@@ -985,8 +1028,14 @@ void dm_pg_init_complete(struct dm_path *path, unsigned err_flags)
9851028
struct multipath *m = pg->m;
9861029
unsigned long flags;
9871030

988-
/* We insist on failing the path if the PG is already bypassed. */
989-
if (err_flags && pg->bypassed)
1031+
/*
1032+
* If requested, retry pg_init until maximum number of retries exceeded.
1033+
* If retry not requested and PG already bypassed, always fail the path.
1034+
*/
1035+
if (err_flags & MP_RETRY) {
1036+
if (pg_init_limit_reached(m, pgpath))
1037+
err_flags |= MP_FAIL_PATH;
1038+
} else if (err_flags && pg->bypassed)
9901039
err_flags |= MP_FAIL_PATH;
9911040

9921041
if (err_flags & MP_FAIL_PATH)
@@ -996,7 +1045,7 @@ void dm_pg_init_complete(struct dm_path *path, unsigned err_flags)
9961045
bypass_pg(m, pg, 1);
9971046

9981047
spin_lock_irqsave(&m->lock, flags);
999-
if (err_flags) {
1048+
if (err_flags & ~MP_RETRY) {
10001049
m->current_pgpath = NULL;
10011050
m->current_pg = NULL;
10021051
} else if (!m->pg_init_required)
@@ -1148,11 +1197,15 @@ static int multipath_status(struct dm_target *ti, status_type_t type,
11481197

11491198
/* Features */
11501199
if (type == STATUSTYPE_INFO)
1151-
DMEMIT("1 %u ", m->queue_size);
1152-
else if (m->queue_if_no_path)
1153-
DMEMIT("1 queue_if_no_path ");
1154-
else
1155-
DMEMIT("0 ");
1200+
DMEMIT("2 %u %u ", m->queue_size, m->pg_init_count);
1201+
else {
1202+
DMEMIT("%u ", m->queue_if_no_path +
1203+
(m->pg_init_retries > 0) * 2);
1204+
if (m->queue_if_no_path)
1205+
DMEMIT("queue_if_no_path ");
1206+
if (m->pg_init_retries)
1207+
DMEMIT("pg_init_retries %u ", m->pg_init_retries);
1208+
}
11561209

11571210
if (hwh->type && hwh->type->status)
11581211
sz += hwh->type->status(hwh, type, result + sz, maxlen - sz);

0 commit comments

Comments
 (0)