[RHEL7,COMMIT] fs/fuse kio: reset write_iter for canceled msg

Submitted by Konstantin Khorenko on June 26, 2019, 12:41 p.m.

Details

Message ID 201906261241.x5QCfrpB005521@finist-ce7.sw.ru
State New
Series "fs/fuse kio: reset write_iter for canceled msg"
Headers show

Commit Message

Konstantin Khorenko June 26, 2019, 12:41 p.m.
The commit is pushed to "branch-rh7-3.10.0-957.12.2.vz7.96.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-957.12.2.vz7.96.19
------>
commit ffd0e7d40241ce44efee525e97b9010391c29446
Author: Pavel Butsykin <pbutsykin@virtuozzo.com>
Date:   Wed Jun 26 15:41:53 2019 +0300

    fs/fuse kio: reset write_iter for canceled msg
    
    Each message initializes its own iterator before sending message and resets it
    after sending. If the message is canceled by timeout in calendar_work(), but
    the iterator of this message isn't cleared, then sending the next message will
    fail. To fix this, let's reset sio->write_iter in pcs_sock_cancel_msg() if the
    message is currently being processed but sio->write_offset is still zero.
    
    https://pmc.acronis.com/browse/VSTOR-21044
    
    Signed-off-by: Pavel Butsykin <pbutsykin@virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_sock_io.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/kio/pcs/pcs_sock_io.c b/fs/fuse/kio/pcs/pcs_sock_io.c
index e0699f57a007..bae7610af826 100644
--- a/fs/fuse/kio/pcs/pcs_sock_io.c
+++ b/fs/fuse/kio/pcs/pcs_sock_io.c
@@ -449,9 +449,12 @@  int pcs_sock_cancel_msg(struct pcs_msg * msg)
 
 	BUG_ON(msg->sio == NULL);
 
-	if (sio->write_offset && sio->write_queue.next == &msg->list)
-		return -EBUSY;
-
+	if (sio->write_queue.next == &msg->list) {
+		if (sio->write_offset)
+			return -EBUSY;
+		else
+			iov_iter_init_bad(&sio->write_iter);
+	}
 	list_del_init(&msg->list);
 	sio->write_queue_len -= msg->size;
 	msg->stage = PCS_MSG_STAGE_SENT;