fs/fuse kio: reset write_iter for canceled msg

Submitted by Pavel Butsykin on June 25, 2019, 2:40 p.m.

Details

Message ID 20190625144025.1867-1-pbutsykin@virtuozzo.com
State New
Series "fs/fuse kio: reset write_iter for canceled msg"
Headers show

Commit Message

Pavel Butsykin June 25, 2019, 2:40 p.m.
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.

#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;