[RH7] ploop: Handle map_index error in ploop_index_wb_proceed()

Submitted by Kirill Tkhai on June 2, 2020, 9:50 a.m.

Details

Message ID 159109141916.212720.8359182838240170723.stgit@localhost.localdomain
State New
Series "ploop: Handle map_index error in ploop_index_wb_proceed()"
Headers show

Commit Message

Kirill Tkhai June 2, 2020, 9:50 a.m.
->map_index can fail (though, the probability is very low).
Handle this.

https://jira.sw.ru/browse/PSBM-104572

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 drivers/block/ploop/map.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/block/ploop/map.c b/drivers/block/ploop/map.c
index 6276fb9ec414..460fa4f37a23 100644
--- a/drivers/block/ploop/map.c
+++ b/drivers/block/ploop/map.c
@@ -855,14 +855,19 @@  void ploop_index_wb_proceed(struct ploop_request * preq)
 	struct page * page = preq->sinfo.wi.tpage;
 	unsigned long rw = preq->req_index_update_rw;
 	sector_t sec;
+	int ret;
 
 	preq->eng_state = PLOOP_E_INDEX_WB;
 
-	top_delta->ops->map_index(top_delta, m->mn_start, &sec);
+	ret = top_delta->ops->map_index(top_delta, m->mn_start, &sec);
+	if (ret == 0) {
+		PLOOP_FAIL_REQUEST(preq, -EINVAL);
+		goto out;
+	}
 
 	__TRACE("wbi-proceed %p %u %p\n", preq, preq->req_cluster, m);
 	top_delta->io.ops->write_page(&top_delta->io, preq, page, sec, rw);
-
+out:
 	put_page(page);
 }