s390/dasd: fix data corruption
Subsystems (3)
Stefan Haberland
maintainercover s390/dasd: fix data corruption
Hi Jens,
please find following patch that fixes a likely data corruption when using devices with thin provisioning support.
As this is a severe issue I hope this will make it into RC6. If not, please let me know.
Regards,
Stefan
Stefan Haberland (1):
s390/dasd: fix data corruption for thin provisioned devices
drivers/s390/block/dasd.c | 27 +++++- drivers/s390/block/dasd_eckd.c | 163 +++++++++++++++++++++++++++++++-- drivers/s390/block/dasd_int.h | 15 ++- 3 files changed, 193 insertions(+), 12 deletions(-)
Signature · 1 line
2.17.1
Stefan Haberland
maintainerPATCH 1/1 s390/dasd: fix data corruption for thin provisioned devices
Devices are formatted in multiple of tracks.
For an Extent Space Efficient (ESE) volume we get errors when accessing unformatted tracks. In this case the driver either formats the track on the flight for write requests or returns zero data for read requests.
In case a request spans multiple tracks, the indication of an unformatted track presented for the first track is incorrectly applied to all tracks covered by the request. As a result, tracks containing data will be handled as empty, resulting in zero data being returned on read, or overwriting existing data with zero on write.
Fix by determining the track that gets the NRF error.
For write requests only format the track that is surely not formatted. For Read requests all tracks before have returned valid data and should not be touched.
All tracks after the unformatted track might be formatted or not. Those are returned to the blocklayer to build a new request.
When using alias devices there is a chance that multiple write requests trigger a format of the same track which might lead to data loss. Ensure that a track is formatted only once by maintaining a list of currently processed tracks.
--- drivers/s390/block/dasd.c | 27 +++++- drivers/s390/block/dasd_eckd.c | 163 +++++++++++++++++++++++++++++++-- drivers/s390/block/dasd_int.h | 15 ++- 3 files changed, 193 insertions(+), 12 deletions(-)
drivers/s390/block/dasd.c +24 -3
@@ -178,6 +178,8 @@ struct dasd_block *dasd_alloc_block(void) (unsigned long) block);INIT_LIST_HEAD (&block->ccw_queue);spin_lock_init (&block->queue_lock); +INIT_LIST_HEAD (&block->format_list); +spin_lock_init (&block->format_lock);timer_setup (&block->timer, dasd_block_timeout,0 );spin_lock_init (&block->profile.lock);
@@ -1779,20 +1781,26 @@ void dasd_int_handler(struct ccw_device *cdev, unsigned long intparm,if (dasd_ese_needs_format (cqr->block, irb)) {if (rq_data_dir ((struct request *)cqr->callback_data) ==READ ) { - device->discipline->ese_read (cqr); + device->discipline->ese_read (cqr, irb); cqr->status =DASD_CQR_SUCCESS ; cqr->stopclk = now;dasd_device_clear_timer (device);dasd_schedule_device_bh (device);return ; } - fcqr = device->discipline->ese_format (device, cqr); + fcqr = device->discipline->ese_format (device, cqr, irb);if (IS_ERR (fcqr)) { +if (PTR_ERR (fcqr) == -EINVAL ) { + cqr->status =DASD_CQR_ERROR ; +return ; + }/* * If we can't format now, let the request go * one extra round. Maybe we can format later. */ cqr->status =DASD_CQR_QUEUED ; +dasd_schedule_device_bh (device); +return ; }else { fcqr->status =DASD_CQR_QUEUED ; cqr->status =DASD_CQR_QUEUED ;
@@ -2748,11 +2756,13 @@ static void __dasd_cleanup_cqr(struct dasd_ccw_req *cqr) {struct request *req;blk_status_t error =BLK_STS_OK ; +unsigned int proc_bytes;int status; req = (struct request *) cqr->callback_data;dasd_profile_end (cqr->block, cqr, req); + proc_bytes = cqr->proc_bytes; status = cqr->block->base->discipline->free_cp (cqr, req);if (status <0 ) error =errno_to_blk_status (status);
@@ -2783,7 +2793,18 @@ static void __dasd_cleanup_cqr(struct dasd_ccw_req *cqr)blk_mq_end_request (req, error);blk_mq_run_hw_queues (req->q, true); }else { -blk_mq_complete_request (req); +/* +* Partial completed requests can happen with ESE devices. +* During read we might have gotten a NRF error and have to +* complete a request partially. +*/ +if (proc_bytes) { +blk_update_request (req,BLK_STS_OK , +blk_rq_bytes (req) - proc_bytes); +blk_mq_requeue_request (req, true); + }else { +blk_mq_complete_request (req); + } } }
drivers/s390/block/dasd_eckd.c +156 -7
241 lines not on this page · raw message
drivers/s390/block/dasd_int.h +13 -2
@@ -187,6 +187,7 @@ struct dasd_ccw_req {void (*callback)(struct dasd_ccw_req *,void *data);void *callback_data; +unsigned int proc_bytes;/* bytes for partial completion */ };/*
@@ -387,8 +388,9 @@ struct dasd_discipline {int (*ext_pool_warn_thrshld)(struct dasd_device *);int (*ext_pool_oos)(struct dasd_device *);int (*ext_pool_exhaust)(struct dasd_device *,struct dasd_ccw_req *); -struct dasd_ccw_req *(*ese_format)(struct dasd_device *,struct dasd_ccw_req *); -void (*ese_read)(struct dasd_ccw_req *); +struct dasd_ccw_req *(*ese_format)(struct dasd_device *, +struct dasd_ccw_req *,struct irb *); +int (*ese_read)(struct dasd_ccw_req *,struct irb *); };extern struct dasd_discipline *dasd_diag_discipline_pointer;
@@ -474,6 +476,11 @@ struct dasd_profile {spinlock_t lock; }; +struct dasd_format_entry { +struct list_head list; +sector_t track; +}; +struct dasd_device {/* Block device stuff. */ struct dasd_block *block;
@@ -539,6 +546,7 @@ struct dasd_device {struct dentry *debugfs_dentry;struct dentry *hosts_dentry;struct dasd_profile profile; +struct dasd_format_entry format_entry; };struct dasd_block {
@@ -564,6 +572,9 @@ struct dasd_block {struct dentry *debugfs_dentry;struct dasd_profile profile; + +struct list_head format_list; +spinlock_t format_lock; };struct dasd_attention_data {
Signature · 1 line
2.17.1
Jens Axboe
maintainerQuoted 6 lines · Stefan Haberland
Hi Jens,
please find following patch that fixes a likely data corruption when using devices with thin provisioning support.
As this is a severe issue I hope this will make it into RC6. If not, please let me know.
Applied for 5.6, thanks.
Signature · 1 line
Jens Axboe