[RHEL7,COMMIT] fuse kio: support unix socket for local CSes

Submitted by Konstantin Khorenko on June 25, 2018, 4:15 p.m.

Details

Message ID 201806251615.w5PGFLQ6011435@finist_ce7.work
State New
Series "fuse kio: support unix socket for local CSes"
Headers show

Commit Message

Konstantin Khorenko June 25, 2018, 4:15 p.m.
The commit is pushed to "branch-rh7-3.10.0-693.21.1.vz7.50.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-693.21.1.vz7.50.15
------>
commit 04f07ce15ef44bdeb639e42b9a0ae5ec1297b4a6
Author: Alexey Kuznetsov <kuznet@virtuozzo.com>
Date:   Mon Jun 25 19:15:21 2018 +0300

    fuse kio: support unix socket for local CSes
    
    A little bit ugly, it encodes request for AF_UNIX socket as address type
    PCS_ADDRTYPE_UNIX. This way we do not have to extent pcs_api_csconnreq_t.
    But we do not have flexibility to select connection type any moment at our
    will. But user space still can suppress unix sockets while doing getmap, so
    that it is functionally complete.
    
    Affects: https://pmc.acronis.com/browse/VSTOR-9817
    
    Signed-off-by: Alexey Kuznetsov <kuznet@virtuozzo.com>
    Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 fs/fuse/kio/pcs/pcs_cs.c           | 11 ++++++++---
 fs/fuse/kio/pcs/pcs_fuse_kdirect.c |  3 +++
 fs/fuse/kio/pcs/pcs_rpc.c          | 12 +++---------
 3 files changed, 14 insertions(+), 12 deletions(-)

Patch hide | download patch | download mbox

diff --git a/fs/fuse/kio/pcs/pcs_cs.c b/fs/fuse/kio/pcs/pcs_cs.c
index 251f75c8abf7..71b7d686dfdc 100644
--- a/fs/fuse/kio/pcs/pcs_cs.c
+++ b/fs/fuse/kio/pcs/pcs_cs.c
@@ -203,7 +203,10 @@  struct pcs_cs *pcs_cs_find_create(struct pcs_cs_set *csset, PCS_NODE_ID_T *id, P
 				}
 			}
 		}
-		/* TODO: (flags & PCS_RPC_F_LOCAL) should be checker here */
+		if (flags & CS_FL_LOCAL_SOCK)
+			cs->rpc->flags |= PCS_RPC_F_LOCAL;
+		else
+			cs->rpc->flags &= ~PCS_RPC_F_LOCAL;
 		return cs;
 	}
 	BUG_ON(addr == NULL);
@@ -220,8 +223,10 @@  struct pcs_cs *pcs_cs_find_create(struct pcs_cs_set *csset, PCS_NODE_ID_T *id, P
 	pcs_rpc_set_peer_id(cs->rpc, id, PCS_NODE_ROLE_CS);
 	pcs_rpc_set_address(cs->rpc, addr);
 
-
-	/* TODO: Init PCS_RPC_F_LOCAL if available here */
+	if (flags & CS_FL_LOCAL_SOCK)
+		cs->rpc->flags |= PCS_RPC_F_LOCAL;
+	else
+		cs->rpc->flags &= ~PCS_RPC_F_LOCAL;
 
 	spin_lock(&cs->lock);
 	spin_lock(&csset->lock);
diff --git a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
index af82b043f786..6bc68e718d07 100644
--- a/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
+++ b/fs/fuse/kio/pcs/pcs_fuse_kdirect.c
@@ -559,6 +559,9 @@  int fuse_pcs_csconn_send(struct fuse_conn *fc, struct pcs_rpc *ep, int flags)
 	memcpy(&csconn->address, &ep->addr, sizeof(ep->addr));
 	csconn->flags = flags;
 
+	if (ep->flags & PCS_RPC_F_LOCAL)
+		csconn->address.type = PCS_ADDRTYPE_UNIX;
+
 	req->in.h.opcode = FUSE_IOCTL;
 	req->in.numargs = 2;
 	req->in.args[0].size = sizeof(*inarg);
diff --git a/fs/fuse/kio/pcs/pcs_rpc.c b/fs/fuse/kio/pcs/pcs_rpc.c
index 04711ccee5fd..71c8461bc740 100644
--- a/fs/fuse/kio/pcs/pcs_rpc.c
+++ b/fs/fuse/kio/pcs/pcs_rpc.c
@@ -558,16 +558,10 @@  void pcs_rpc_connect(struct pcs_rpc * ep)
 	if (ep->state != PCS_RPC_UNCONN)
 		return;
 
-	if (ep->flags & PCS_RPC_F_LOCAL) {
-		/* TODO, local path is temprorally disabled */
-		BUG_ON(1);
-	} else {
-		TRACE("Connecting to node " NODE_FMT "\n", NODE_ARGS(ep->peer_id));
+	TRACE("Connecting to node " NODE_FMT "\n", NODE_ARGS(ep->peer_id));
 
-
-		BUG_ON(!ep->ops->connect);
-		ep->ops->connect(ep);
-	}
+	BUG_ON(!ep->ops->connect);
+	ep->ops->connect(ep);
 }
 
 /* Send notification, which does not require waiting for response from peer.