[RHEL7,COMMIT] fs/fuse kio_pcs: handle old map in pcs_cs_submit()

Submitted by Konstantin Khorenko on June 27, 2018, 3:49 p.m.

Details

Message ID 201806271549.w5RFnJqd016914@finist_ce7.work
State New
Series "fs/fuse kio_pcs: handle old map in pcs_cs_submit()"
Headers show

Commit Message

Konstantin Khorenko June 27, 2018, 3:49 p.m.
The commit is pushed to "branch-rh7-3.10.0-862.3.2.vz7.61.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.3.2.vz7.61.5
------>
commit 24003095f3d9a60bd0c5e3155217b18ac2084bc0
Author: Pavel Butsykin <pbutsykin@virtuozzo.com>
Date:   Wed Jun 27 18:49:19 2018 +0300

    fs/fuse kio_pcs: handle old map in pcs_cs_submit()
    
    The map may be dead or updated at the time of sending cs request. We can
    immediately complete such request with PCS_ERR_CSD_STALE_MAP, there is no need
    to send this request and wait for a response with an error.
    
    https://pmc.acronis.com/browse/VSTOR-11315
    
    Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai@virtuozzo.com>
    Acked-by: Alexey Kuznetsov <kuznet@virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_cs.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/kio/pcs/pcs_cs.c b/fs/fuse/kio/pcs/pcs_cs.c
index 71b7d686dfdc..6efa54f0056f 100644
--- a/fs/fuse/kio/pcs/pcs_cs.c
+++ b/fs/fuse/kio/pcs/pcs_cs.c
@@ -491,6 +491,7 @@  void pcs_cs_submit(struct pcs_cs *cs, struct pcs_int_request *ireq)
 	struct pcs_msg *msg = &ireq->iochunk.msg;
 	struct pcs_cs_iohdr *ioh;
 	struct pcs_cs_list *csl = ireq->iochunk.csl;
+	struct pcs_map_entry *map = ireq->iochunk.map; /* ireq keeps reference to map */
 
 	msg->private = cs;
 
@@ -535,12 +536,14 @@  void pcs_cs_submit(struct pcs_cs *cs, struct pcs_int_request *ireq)
 	msg->done = cs_sent;
 	msg->get_iter = cs_get_data;
 
-	/* TODO
-	 * Theoretically at this moment this map may already becomes dead
-	 * what should I do then?
-	 * This may happens only in case of aio/dio vs	truncate race
-	 */
-	BUG_ON(ireq->iochunk.map->state & PCS_MAP_DEAD);
+	if ((map->state & PCS_MAP_DEAD) || (map->cs_list != csl)) {
+		ireq->error.value = PCS_ERR_CSD_STALE_MAP;
+		ireq->error.remote = 1;
+		ireq->error.offender = csl->cs[0].info.id;
+		ireq_complete(ireq);
+		return;
+	}
+
 	ioh->map_version = csl->version;
 	if (pcs_req_direction(ireq->iochunk.cmd))
 		msg->timeout = csl->write_timeout;