[Devel] [PATCH RHEL7 COMMIT] fs/fuse kio_pcs: drop rpc connection close in pcs_rpc_engine_fini()

Konstantin Khorenko khorenko at virtuozzo.com
Thu Oct 4 16:23:31 MSK 2018


The commit is pushed to "branch-rh7-3.10.0-862.14.4.vz7.72.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-862.14.4.vz7.72.2
------>
commit f7db04e829254452207d885d15d755ea9e7c8a36
Author: Pavel Butsykin <pbutsykin at virtuozzo.com>
Date:   Wed Oct 3 17:08:56 2018 +0300

    fs/fuse kio_pcs: drop rpc connection close in pcs_rpc_engine_fini()
    
    In normal case the rpc connections closes as follows:
    pcs_csset_fini()
      pcs_cs_destroy()
        pcs_rpc_close()
    
    But if at this moment any request will keep a reference to the rpc connection,
    then pcs_rpc_engine_fini() will attempt to close the rpc connection the second
    time. RPC connection close should be in one place and this place is
    pcs_cs_destroy().
    
    Signed-off-by: Pavel Butsykin <pbutsykin at virtuozzo.com>
    Reviewed-by: Kirill Tkhai <ktkhai at virtuozzo.com>
    
    =======================================================
    Patchset description:
    
    RPC connection double close fixes
    
    https://pmc.acronis.com/browse/VSTOR-15378
    
    Pavel Butsykin (3):
      fs/fuse kio_pcs: fix race between req->end() and request_wait_answer()
      fs/fuse kio_pcs: remove fuse destroy request
      fs/fuse kio_pcs: drop rpc connection close in pcs_rpc_engine_fini()
---
 fs/fuse/kio/pcs/pcs_rpc.c | 29 +++++++++++++++++------------
 1 file changed, 17 insertions(+), 12 deletions(-)

diff --git a/fs/fuse/kio/pcs/pcs_rpc.c b/fs/fuse/kio/pcs/pcs_rpc.c
index fdbad982d8c0..27c32589313e 100644
--- a/fs/fuse/kio/pcs/pcs_rpc.c
+++ b/fs/fuse/kio/pcs/pcs_rpc.c
@@ -1257,23 +1257,28 @@ void pcs_rpc_engine_init(struct pcs_rpc_engine * eng, u8 role)
 
 }
 
-void pcs_rpc_engine_fini(struct pcs_rpc_engine * eng)
+static void pcs_rpc_fini_verify(struct hlist_head *rpc_list)
 {
-	unsigned int i;
-
-	for (i = 0; i < PCS_RPC_HASH_SIZE; i++) {
-		while (!hlist_empty(&eng->ht[i])) {
-			struct pcs_rpc * ep = hlist_entry(eng->ht[i].first, struct pcs_rpc, link);
+	while (!hlist_empty(rpc_list)) {
+		struct pcs_rpc * ep =
+			hlist_entry(rpc_list->first, struct pcs_rpc, link);
 
-			pcs_rpc_close(ep);
-		}
+		pr_warn("rpc connection isn't closed ep: %p (flags: %u, "
+			"state: %u, refcnt: %u)\n", ep, ep->flags, ep->state,
+			atomic_read(&ep->refcnt));
+		WARN_ON(!(ep->flags & PCS_RPC_F_DEAD));
+		WARN_ON(atomic_read(&ep->refcnt) <= 0);
 	}
+}
 
-	while (!hlist_empty(&eng->unhashed)) {
-		struct pcs_rpc * ep = hlist_entry(eng->unhashed.first, struct pcs_rpc, link);
+void pcs_rpc_engine_fini(struct pcs_rpc_engine * eng)
+{
+	unsigned int i;
 
-		pcs_rpc_close(ep);
-	}
+	for (i = 0; i < PCS_RPC_HASH_SIZE; i++)
+		pcs_rpc_fini_verify(&eng->ht[i]);
+
+	pcs_rpc_fini_verify(&eng->unhashed);
 
 	for (i = 0; i < RPC_GC_MAX_CLASS; i++) {
 		BUG_ON(list_lru_count(&eng->gc[i].lru));



More information about the Devel mailing list