Skip to content

Commit 0df01a7

Browse files
snitmgregkh
authored andcommitted
dm mpath: disable WRITE SAME if it fails
commit f84cb8a upstream. Workaround the SCSI layer's problematic WRITE SAME heuristics by disabling WRITE SAME in the DM multipath device's queue_limits if an underlying device disabled it. The WRITE SAME heuristics, with both the original commit 5db4486 ("[SCSI] sd: Implement support for WRITE SAME") and the updated commit 66c28f9 ("[SCSI] sd: Update WRITE SAME heuristics"), default to enabling WRITE SAME(10) even without successfully determining it is supported. After the first failed WRITE SAME the SCSI layer will disable WRITE SAME for the device (by setting sdkp->device->no_write_same which results in 'max_write_same_sectors' in device's queue_limits to be set to 0). When a device is stacked ontop of such a SCSI device any changes to that SCSI device's queue_limits do not automatically propagate up the stack. As such, a DM multipath device will not have its WRITE SAME support disabled. This causes the block layer to continue to issue WRITE SAME requests to the mpath device which causes paths to fail and (if mpath IO isn't configured to queue when no paths are available) it will result in actual IO errors to the upper layers. This fix doesn't help configurations that have additional devices stacked ontop of the mpath device (e.g. LVM created linear DM devices ontop). A proper fix that restacks all the queue_limits from the bottom of the device stack up will need to be explored if SCSI will continue to use this model of optimistically allowing op codes and then disabling them after they fail for the first time. Before this patch: EXT4-fs (dm-6): mounted filesystem with ordered data mode. Opts: (null) device-mapper: multipath: XXX snitm debugging: got -EREMOTEIO (-121) device-mapper: multipath: XXX snitm debugging: failing WRITE SAME IO with error=-121 end_request: critical target error, dev dm-6, sector 528 dm-6: WRITE SAME failed. Manually zeroing. device-mapper: multipath: Failing path 8:112. end_request: I/O error, dev dm-6, sector 4616 dm-6: WRITE SAME failed. Manually zeroing. end_request: I/O error, dev dm-6, sector 4616 end_request: I/O error, dev dm-6, sector 5640 end_request: I/O error, dev dm-6, sector 6664 end_request: I/O error, dev dm-6, sector 7688 end_request: I/O error, dev dm-6, sector 524288 Buffer I/O error on device dm-6, logical block 65536 lost page write due to I/O error on dm-6 JBD2: Error -5 detected when updating journal superblock for dm-6-8. end_request: I/O error, dev dm-6, sector 524296 Aborting journal on device dm-6-8. end_request: I/O error, dev dm-6, sector 524288 Buffer I/O error on device dm-6, logical block 65536 lost page write due to I/O error on dm-6 JBD2: Error -5 detected when updating journal superblock for dm-6-8. # cat /sys/block/sdh/queue/write_same_max_bytes 0 # cat /sys/block/dm-6/queue/write_same_max_bytes 33553920 After this patch: EXT4-fs (dm-6): mounted filesystem with ordered data mode. Opts: (null) device-mapper: multipath: XXX snitm debugging: got -EREMOTEIO (-121) device-mapper: multipath: XXX snitm debugging: WRITE SAME I/O failed with error=-121 end_request: critical target error, dev dm-6, sector 528 dm-6: WRITE SAME failed. Manually zeroing. # cat /sys/block/sdh/queue/write_same_max_bytes 0 # cat /sys/block/dm-6/queue/write_same_max_bytes 0 It should be noted that WRITE SAME support wasn't enabled in DM multipath until v3.10. Signed-off-by: Mike Snitzer <snitzer@redhat.com> Cc: Martin K. Petersen <martin.petersen@oracle.com> Cc: Hannes Reinecke <hare@suse.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4db0b84 commit 0df01a7

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

‎drivers/md/dm-mpath.c‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1284,8 +1284,17 @@ static int do_end_io(struct multipath *m, struct request *clone,
12841284
if (!error && !clone->errors)
12851285
return 0; /* I/O complete */
12861286

1287-
if (error == -EOPNOTSUPP || error == -EREMOTEIO || error == -EILSEQ)
1287+
if (error == -EOPNOTSUPP || error == -EREMOTEIO || error == -EILSEQ) {
1288+
if ((clone->cmd_flags & REQ_WRITE_SAME) &&
1289+
!clone->q->limits.max_write_same_sectors) {
1290+
struct queue_limits *limits;
1291+
1292+
/* device doesn't really support WRITE SAME, disable it */
1293+
limits = dm_get_queue_limits(dm_table_get_md(m->ti->table));
1294+
limits->max_write_same_sectors = 0;
1295+
}
12881296
return error;
1297+
}
12891298

12901299
if (mpio->pgpath)
12911300
fail_path(mpio->pgpath);

‎drivers/md/dm.c‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2249,6 +2249,17 @@ struct target_type *dm_get_immutable_target_type(struct mapped_device *md)
22492249
return md->immutable_target_type;
22502250
}
22512251

2252+
/*
2253+
* The queue_limits are only valid as long as you have a reference
2254+
* count on 'md'.
2255+
*/
2256+
struct queue_limits *dm_get_queue_limits(struct mapped_device *md)
2257+
{
2258+
BUG_ON(!atomic_read(&md->holders));
2259+
return &md->queue->limits;
2260+
}
2261+
EXPORT_SYMBOL_GPL(dm_get_queue_limits);
2262+
22522263
/*
22532264
* Fully initialize a request-based queue (->elevator, ->request_fn, etc).
22542265
*/

‎include/linux/device-mapper.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,13 +405,14 @@ int dm_noflush_suspending(struct dm_target *ti);
405405
union map_info *dm_get_mapinfo(struct bio *bio);
406406
union map_info *dm_get_rq_mapinfo(struct request *rq);
407407

408+
struct queue_limits *dm_get_queue_limits(struct mapped_device *md);
409+
408410
/*
409411
* Geometry functions.
410412
*/
411413
int dm_get_geometry(struct mapped_device *md, struct hd_geometry *geo);
412414
int dm_set_geometry(struct mapped_device *md, struct hd_geometry *geo);
413415

414-
415416
/*-----------------------------------------------------------------
416417
* Functions for manipulating device-mapper tables.
417418
*---------------------------------------------------------------*/

0 commit comments

Comments
 (0)