From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.openvz.org (unknown [69.168.225.77]) by lore.virtuozzo.com (Postfix) with ESMTPS id 5695380024 for ; Thu, 27 Aug 2026 12:38:47 +0000 (UTC) Received: from mail.openvz.org (localhost [127.0.0.1]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 67RCbQdq000393; Thu, 27 Aug 2026 15:37:27 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 67RCbQdq000393 Authentication-Results: mail.openvz.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=virtuozzo.com header.i=@virtuozzo.com header.b="OWBKM0g2" Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) by mail.openvz.org (8.14.4/8.14.4) with ESMTP id 67RCbP4N000389 (version=TLSv1/SSLv3 cipher=AES128-GCM-SHA256 bits=128 verify=FAIL) for ; Thu, 27 Aug 2026 15:37:25 +0300 DKIM-Filter: OpenDKIM Filter v2.11.0 mail.openvz.org 67RCbP4N000389 Received: by mail-wr1-f71.google.com with SMTP id ffacd0b85a97d-47f81362fb1so411180f8f.1 for ; Thu, 27 Aug 2026 05:37:25 -0700 (PDT) X-Gm-Message-State: AFuF++lu+2ZFGuXnm3Do43Ig0xlTDj1vIkBzrUWWlabpOALi1dzyFqK/ W/zFSham6vr0Vx2V5nUBKknGKlh3EeWYidRZc/BK/uo6dqs0QExmu1QV8hMThcV9KKcCWSIn6Jo CHyc9CTAt/m6fCC4nsQTwuNVKULnsv/XDnyxDuetFpWVcW+61wO22mw== X-Gm-Gg: AR+sD12J1HWC66k3b+y0wgMaB2RtTnMOelxkA21z2iIxNkFDaxS8BiH5BqAue9EPQYq Q33LVojdhtgbVKEBTx8TM7DWAj415BGsSXcp12ufEJrzKFPoUvPUe31/m725qgPabkTKp5SYPfd bSyDvn2QZMfL0lzGMtp2w7Lo6uoipSXG53OEfkfV21zurNN1Qn3zDTYJiEthW+bxbS5n9kAT3pW JfSwKzX3WqZ4vdQn2jzjWmDkuKxANIar4/c37cy+FExjBtDPjd2rlrICWERCX0uqUixO5+oT1uH esfoc4NvoydYUXn8iqcnmjotQoelIhAuZ5TzM7uvdkp7KKGps3/yadyN/ev9zeIQX9UgeUcex5D M2XVSHFA9/0FS0SIy X-Received: by 2002:a05:6000:41c2:b0:482:e4bc:51a8 with SMTP id ffacd0b85a97d-482e4bc53camr16735550f8f.7.1787834244802; Thu, 27 Aug 2026 05:37:24 -0700 (PDT) X-Received: by 2002:a05:6000:41c2:b0:482:e4bc:51a8 with SMTP id ffacd0b85a97d-482e4bc53camr16735455f8f.7.1787834244333; Thu, 27 Aug 2026 05:37:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1787834244; cv=none; d=google.com; s=arc-20260327; b=Mt+EqC2mSXkozSysuNp8RKC1uu/pGs6EUcI1zqI2az3BbLVkMIX+VZND1dTJj11lZa fNt3ZSSXUOHthXz1ZOaZFbsAwF0trdIQ4L3XuLImdic+bH1DnhRUu97zOAjk6MNDyNhW JcZObJV7tES2PLs+j5Ll5rLGre8N7PUg7AGRFP0cFIPsCjFu7zWrJ+gJieMAAVIxQrX+ 9V2dy3tmBQu9AXQ10+DcFuu3D7pDU2maCnjayBcC6ww6unKV0OAZa0/hNiRPO0qPi2Se DPysP1sTKP2pg3WI3M08UUhsOG1w9wyJsCThCl9517bQcr+Uz3L3Re/fiwnc48uuD1Fq K+gQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20260327; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=FBz9UqAKx/mhkqJZLWx0AV3mLhOqomFj10FA3Qn/bKo=; fh=CyEa5k0km+zUBGOSzDGfbole2hTjTZicm1CHqnc8J2I=; b=bm+2jXj1w9/BguHI3j0ek747BVukR2heMWM8KW7XGgcQDZ9LnVvEGvXm5ZcloVH5ci Zc/suWqlnSMJIeP/6wwY1hHLDI7EYfTBxnoNWb7btAdWubMYJdnRjg+mL7Z2CMROtGbu VgvMtD6sKPG1fCMXxsrN86yt0yfMwU5yFVwGreKXm8rBgzjnf9X+DgmyHUDK5nzoLRYo ofEqv6qLo72W3RdpNdQRyIpe53DqZFtgSsh6lFnW99D/04K/bbbR4l4gTFvdxGymQdhz 5dJbckWMkar/37bhQ/CH84XCGuqnahYhuWbv2HjeSA7pNb9o4jgj3Unw9GgrxJk5dS8H t6Sg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=OWBKM0g2; spf=pass (google.com: domain of kui.liu@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=kui.liu@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com Received: from relay.virtuozzo.com (relay.virtuozzo.com. [130.117.225.111]) by mx.google.com with ESMTPS id ffacd0b85a97d-482e2787c77si7285801f8f.85.2026.08.27.05.37.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Aug 2026 05:37:24 -0700 (PDT) Received-SPF: pass (google.com: domain of kui.liu@virtuozzo.com designates 130.117.225.111 as permitted sender) client-ip=130.117.225.111; Authentication-Results: mx.google.com; dkim=pass header.i=@virtuozzo.com header.s=relay header.b=OWBKM0g2; spf=pass (google.com: domain of kui.liu@virtuozzo.com designates 130.117.225.111 as permitted sender) smtp.mailfrom=kui.liu@virtuozzo.com; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=virtuozzo.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=FBz9UqAKx/mhkqJZLWx0AV3mLhOqomFj10FA3Qn/bKo=; b=OWBKM0g2YpyS EJv2a48NYUcIcV13zeprIeBHaowDWtxX/gClW0jJcyLsTQtSa/A/80ZtoaFzArE0Myj1pQdD5qMaT Ah35MOiFFjw34Iz3qQ1u8EZSyVSh4Dg0G8Mb8m9pmqcqFamHPfFi5fhI42ETknkiSnyb1myxu6kdu L31l7miu6K/MDdJHS72LU8Nc1W3Me5byfcWNHyEPBJRHdBuehUj+LIlpJVhjhMX0jTH/qsxkgmyon h5dRJR1rHMZQEZxE6SmECLuS0SxBOgcRt0LlCtOkbTlwkUP8+jMNL3ZN3MnnDbUDLj72d24IScpfj V5VnBTSRy4d1Rv/sSN4CQw==; Received: from ch-vpn.virtuozzo.com ([130.117.225.6] helo=localhost.localdomain) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1wzZJv-00BDf6-1v; Thu, 27 Aug 2026 14:37:21 +0200 From: Liu Kui To: devel@openvz.org Date: Thu, 27 Aug 2026 20:37:12 +0800 Message-ID: <20260827123712.84476-1-kui.liu@virtuozzo.com> X-Mailer: git-send-email 2.50.1 MIME-Version: 1.0 X-OZ-Fwd: true Cc: azaitsev@virtuozzo.com, Liu Kui Subject: [Devel] [PATCH VZ10] fs/fuse kio: track pending kRPC connect via state machine only X-BeenThere: devel@openvz.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: OpenVZ development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: devel-bounces@openvz.org Errors-To: devel-bounces@openvz.org Rework the previous fix ("fs/fuse kio: fix kRPC connect issues") to not require the new struct pcs_krpc member "connect_req", so the fix can be shipped as a livepatch. Both things connect_req was tracking are already derivable from the existing state machine once PCS_KRPC_STATE_CONNECT is made to mean exactly "a connect req is in flight": - krpc_connect_done() settles a failed connect back to UNCONN instead of leaving the state in CONNECT forever; - pcs_krpc_abort() no longer resets CONNECT to UNCONN: the req is still in flight, and only its completion settles the state; - pcs_krpc_connect() proceeds only from UNCONN or ABORTED, refusing new connects (-EPERM) while a req is in flight - at most one connect req exists at a time, same as with the connect_req check; - pcs_krpc_poll() reports EPOLLERR on UNCONN: poll bails out earlier unless ctx->gen == krpc->gen, and the current session can only be in UNCONN if its connect failed or was aborted, which is what the (CONNECT && !connect_req) test used to detect. gen only advances in pcs_krpc_connect(), which is blocked during CONNECT, so within that state the in-flight req always carries the current gen and krpc_connect_done()'s existing staleness check is sufficient. Related to: https://virtuozzo.atlassian.net/browse/VSTOR-135626 Signed-off-by: Liu Kui --- fs/fuse/kio/pcs/pcs_krpc.c | 39 ++++++++++++++++++++++++++++---------- fs/fuse/kio/pcs/pcs_krpc.h | 2 -- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/fs/fuse/kio/pcs/pcs_krpc.c b/fs/fuse/kio/pcs/pcs_krpc.c index b55c093c13d0..bcfbfc6d9304 100644 --- a/fs/fuse/kio/pcs/pcs_krpc.c +++ b/fs/fuse/kio/pcs/pcs_krpc.c @@ -738,8 +738,12 @@ static int pcs_krpc_abort(struct pcs_krpc *krpc) spin_lock(&krpc->lock); if (krpc->state != PCS_KRPC_STATE_CONNECTED) { - if (krpc->state == PCS_KRPC_STATE_CONNECT) - krpc->state = PCS_KRPC_STATE_UNCONN; + /* + * A pending connect stays in CONNECT state: its connect req + * is still in flight and krpc_connect_done() will settle the + * state to UNCONN when it completes. Until then new connects + * are refused, so at most one connect req exists at a time. + */ spin_unlock(&krpc->lock); return 0; } @@ -907,8 +911,13 @@ static __poll_t pcs_krpc_poll(struct file *file, poll_table *wait) spin_lock(&krpc->lock); + /* + * ctx->gen == krpc->gen (checked above) means this is the current + * session, so UNCONN here can only mean its connect attempt has + * failed (see krpc_connect_done()) or the session was aborted. + */ if (krpc->state == PCS_KRPC_STATE_ABORTED || - (krpc->state == PCS_KRPC_STATE_CONNECT && !krpc->connect_req)) { + krpc->state == PCS_KRPC_STATE_UNCONN) { pollflags |= EPOLLERR; } else if (krpc->state == PCS_KRPC_STATE_CONNECTED) { pollflags |= EPOLLOUT; @@ -999,7 +1008,6 @@ int pcs_krpc_create(struct pcs_krpc_set *krpcs, PCS_NODE_ID_T *id, krpc->gen = 0; krpc->state = PCS_KRPC_STATE_UNCONN; krpc->cs = NULL; - krpc->connect_req = NULL; krpc->rpc = pcs_rpc_clnt_create(&cc_from_krpcset(krpcs)->eng, id, addr, cs_flags); if (!krpc->rpc) { @@ -1051,8 +1059,6 @@ static void krpc_connect_done(struct pcs_msg *msg) } spin_lock(&krpc->lock); - if (krpc->connect_req == req) - krpc->connect_req = NULL; /* from a stale session, do nothing */ if (req->gen != krpc->gen || krpc->state != PCS_KRPC_STATE_CONNECT) { spin_unlock(&krpc->lock); @@ -1062,6 +1068,14 @@ static void krpc_connect_done(struct pcs_msg *msg) if (!pcs_if_error(&msg->error)) { krpc->state = PCS_KRPC_STATE_CONNECTED; pollflags = EPOLLOUT; + } else { + /* + * Connect failed: settle back to UNCONN so that a new connect + * is allowed again, and report the failure to poll(). Since + * gen is unchanged, the current session's poll sees UNCONN + * and returns EPOLLERR. + */ + krpc->state = PCS_KRPC_STATE_UNCONN; } spin_unlock(&krpc->lock); @@ -1119,9 +1133,15 @@ int pcs_krpc_connect(struct pcs_krpc_set *krpcs, PCS_NODE_ID_T *id) } spin_lock(&krpc->lock); - if (krpc->state == PCS_KRPC_STATE_CONNECTED || - krpc->state == PCS_KRPC_STATE_DESTROYED || - krpc->connect_req) { + /* + * A connect is allowed only when there is neither an established + * session nor a connect req in flight (CONNECT state, see + * krpc_connect_done()). This limits connect reqs to one at a time: + * if userspace gave up on a connect and retries, the new connect + * fails immediately until the old req completes. + */ + if (krpc->state != PCS_KRPC_STATE_UNCONN && + krpc->state != PCS_KRPC_STATE_ABORTED) { spin_unlock(&krpc->lock); err = -EPERM; /* fput() drops ctx and its krpc reference via pcs_krpc_release() */ @@ -1133,7 +1153,6 @@ int pcs_krpc_connect(struct pcs_krpc_set *krpcs, PCS_NODE_ID_T *id) connect_req->gen = krpc->gen; connect_req->krpc = pcs_krpc_get(krpc); krpc->state = PCS_KRPC_STATE_CONNECT; - krpc->connect_req = connect_req; spin_unlock(&krpc->lock); /* publish the fd only after the connect is committed */ diff --git a/fs/fuse/kio/pcs/pcs_krpc.h b/fs/fuse/kio/pcs/pcs_krpc.h index 3db9e9712019..6a090ef66185 100644 --- a/fs/fuse/kio/pcs/pcs_krpc.h +++ b/fs/fuse/kio/pcs/pcs_krpc.h @@ -82,8 +82,6 @@ struct pcs_krpc { /** Wait queue head for poll */ wait_queue_head_t poll_wait; struct pcs_cs *cs; - - struct krpc_connect_req *connect_req; }; struct pcs_krpc_context { -- 2.50.1 (Apple Git-155) _______________________________________________ Devel mailing list Devel@openvz.org https://lists.openvz.org/mailman/listinfo/devel