Do it with already existing generation id. kreq stores genid
of connection at time of enqueue, and if it races with reconnect,
it is rejected.

Signed-off-by: Alexey Kuznetsov <kuz...@virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_krpc.c | 5 ++++-
 fs/fuse/kio/pcs/pcs_krpc.h | 1 +
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/fs/fuse/kio/pcs/pcs_krpc.c b/fs/fuse/kio/pcs/pcs_krpc.c
index a0e0799..786cef2 100644
--- a/fs/fuse/kio/pcs/pcs_krpc.c
+++ b/fs/fuse/kio/pcs/pcs_krpc.c
@@ -581,7 +581,8 @@ static int kreq_make_sendmsg(struct krpc_req *kreq)
        msg->get_iter = krpc_msg_get_data;
 
        spin_lock(&krpc->lock);
-       if (krpc->state != PCS_KRPC_STATE_CONNECTED) {
+       if (krpc->state != PCS_KRPC_STATE_CONNECTED ||
+           krpc->gen != kreq->gen) {
                spin_unlock(&krpc->lock);
                res = -ECONNABORTED;
                goto err_free_data_chunk;
@@ -826,6 +827,8 @@ static long pcs_krpc_ioctl(struct file *file, unsigned int 
cmd, unsigned long ar
                if (!kreq)
                        return -ENOMEM;
 
+               kreq->gen = ctx->gen;
+
                if (copy_from_user(&kreq->iocmsg, (void __user *)arg, 
sizeof(kreq->iocmsg))) {
                        krpc_req_free(kreq);
                        return -EFAULT;
diff --git a/fs/fuse/kio/pcs/pcs_krpc.h b/fs/fuse/kio/pcs/pcs_krpc.h
index 8021b02..15d9f77 100644
--- a/fs/fuse/kio/pcs/pcs_krpc.h
+++ b/fs/fuse/kio/pcs/pcs_krpc.h
@@ -130,6 +130,7 @@ struct krpc_req {
 
        struct krpc_completion completion;
 
+       u32                         gen;
        struct llist_node           llist_link;
        struct pcs_krpc_ioc_sendmsg iocmsg;
 };
-- 
1.8.3.1

_______________________________________________
Devel mailing list
Devel@openvz.org
https://lists.openvz.org/mailman/listinfo/devel

Reply via email to