Skip to contentSkip to conversation

Use MDS session for dual role MDS/DS

PATCH In review [email protected] 2 participants 6 messages May 12, 2010 – May 13, 2010 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Use MDS session for dual role MDS/DS

Plus some clean ups.

Use the MDS session for the data server traffic only if EXCHGID4_FLAG_USE_PNFS_DS is set as an MDS clientid pNFS role

0001-SQUASHME-pnfs_submit-use-MDS-session-for-dual-MDS-DS.patch 0002-SQUASHME-pnfs_submit-update-DS-nfs4_set_client.patch 0003-SQUASHME-pnfs_submit-cleanup-DS-exchange-flag-proces.patch

Testing:
CONFIG_NFS_V4_1 set:
pNFS, NFSv41, NFSv4 mount passes Connectathon tests.

CONFIG_NFS_V4_1 not set:
NFSv4 mount passes Connectathon tests.

-->Andy

#1 lore raw

PATCH 1/3 SQUASHME pnfs_submit: use MDS session for dual MDS/DS

From: Andy Adamson <[email protected]>

We currently only have one session per clientid. If the deviceid maps the MDS server as a data server, use the MDS session for the data server traffic only if EXCHGID4_FLAG_USE_PNFS_DS is set as an MDS clientid pNFS role.

Squash into "pnfs: filelayout: device ops"

---
 fs/nfs/client.c            |    3 ++-
 fs/nfs/internal.h          |    2 ++
 fs/nfs/nfs4filelayoutdev.c |   20 +++++++++++++++++++-
 3 files changed, 23 insertions(+), 2 deletions(-)
fs/nfs/client.c +2 -1
index 0337330..1979831 100644
@@ -348,7 +348,7 @@ static int nfs_sockaddr_match_ipaddr(const struct sockaddr *sa1,
  * Test if two socket addresses represent the same actual socket,
  * by comparing (only) relevant fields, including the port number.
  */
-static int nfs_sockaddr_cmp(const struct sockaddr *sa1,
+int nfs_sockaddr_cmp(const struct sockaddr *sa1,
 			    const struct sockaddr *sa2)
 {
 	if (sa1->sa_family != sa2->sa_family)
@@ -362,6 +362,7 @@ static int nfs_sockaddr_cmp(const struct sockaddr *sa1,
 	}
 	return 0;
 }
+EXPORT_SYMBOL(nfs_sockaddr_cmp);
 
 /*
  * Find a client by IP address and protocol version
fs/nfs/internal.h +2 -0
index 83f2953..92f3231 100644
@@ -139,6 +139,8 @@ extern struct nfs_server *nfs_clone_server(struct nfs_server *,
 					   struct nfs_fattr *);
 extern void nfs_mark_client_ready(struct nfs_client *clp, int state);
 extern int nfs4_check_client_ready(struct nfs_client *clp);
+extern int nfs_sockaddr_cmp(const struct sockaddr *sa1,
+		const struct sockaddr *sa2);
 extern int nfs4_set_client(struct nfs_server *server,
 		const char *hostname,
 		const struct sockaddr *addr,
fs/nfs/nfs4filelayoutdev.c +19 -1
index 462f6de..891c31d 100644
@@ -126,7 +126,8 @@ nfs4_pnfs_ds_create(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds)
 	};
 	struct sockaddr_in	sin;
 	struct rpc_clnt 	*mds_clnt = mds_srv->client;
-	struct nfs_client 	*clp;
+	struct nfs_client	*clp = mds_srv->nfs_client;
+	struct sockaddr		*mds_addr;
 	char			ip_addr[16];
 	int			addrlen;
 	int err = 0;
@@ -138,6 +139,23 @@ nfs4_pnfs_ds_create(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds)
 	sin.sin_addr.s_addr = ds->ds_ip_addr;
 	sin.sin_port = ds->ds_port;
 
+	/*
+	 * If this DS is also the MDS, use the MDS session only if the
+	 * MDS exchangeid flags show the EXCHGID4_FLAG_USE_PNFS_DS pNFS role.
+	 */
+	mds_addr = (struct sockaddr *)&clp->cl_addr;
+	if (nfs_sockaddr_cmp((struct sockaddr *)&sin, mds_addr)) {
+		if (!(clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_DS)) {
+			printk(KERN_INFO "ip:port %s is not a pNFS Data "
+				"Server\n", ds->r_addr);
+			err = -ENODEV;
+		} else {
+			atomic_inc(&clp->cl_count);
+			ds->ds_clp = clp;
+			dprintk("%s Using MDS Session for DS\n", __func__);
+		}
+		goto out;
+	}
 	/* Set timeout to the mds rpc clnt value.
 	 * XXX - find the correct authflavor....
 	 *
Signature · 1 line
1.6.6
#2 lore raw

PATCH 2/3 SQUASHME pnfs_submit: update DS nfs4_set_client

From: Andy Adamson <[email protected]>

Dont bother using the hostname, use the client ipaddr field from the MDS nfs_client for construction of the co_ownrid field the DS EXCHANGE_ID.

Clean up the comments.

Squash into "pnfs: filelayout: device ops"

---
 fs/nfs/nfs4filelayoutdev.c |   28 +++++-----------------------
 1 files changed, 5 insertions(+), 23 deletions(-)
fs/nfs/nfs4filelayoutdev.c +5 -23
index 891c31d..b41f437 100644
@@ -128,8 +128,6 @@ nfs4_pnfs_ds_create(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds)
 	struct rpc_clnt 	*mds_clnt = mds_srv->client;
 	struct nfs_client	*clp = mds_srv->nfs_client;
 	struct sockaddr		*mds_addr;
-	char			ip_addr[16];
-	int			addrlen;
 	int err = 0;
 
 	dprintk("--> %s ip:port %s au_flavor %d\n", __func__,
@@ -156,32 +154,16 @@ nfs4_pnfs_ds_create(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds)
 		}
 		goto out;
 	}
-	/* Set timeout to the mds rpc clnt value.
-	 * XXX - find the correct authflavor....
-	 *
-	 * Fake a client ipaddr (used for sessionid) with hostname
-	 * Use hostname since it might be more unique than ipaddr (which
-	 * could be set to the loopback 127.0.0/1.1
-	 *
-	 * XXX: Should sessions continue to use the cl_ipaddr field?
-	 */
-	addrlen = strnlen(utsname()->nodename, sizeof(utsname()->nodename));
-	if (addrlen > sizeof(ip_addr))
-		addrlen = sizeof(ip_addr);
-	memcpy(ip_addr, utsname()->nodename, addrlen);
-
-	/* XXX need a non-nfs_client struct interface to set up
-	 * data server sessions
-	 *
-	 * tmp: nfs4_set_client sets the nfs_server->nfs_client.
-	 *
-	 * We specify a retrans and timeout interval equual to MDS. ??
+	/*
+	 * Set a retrans, timeout interval, and authflavor equual to the MDS
+	 * values. Use the MDS nfs_client cl_ipaddr field so as to use the
+	 * same co_ownerid as the MDS.
 	 */
 	err = nfs4_set_client(&tmp,
 			      mds_srv->nfs_client->cl_hostname,
 			      (struct sockaddr *)&sin,
 			      sizeof(struct sockaddr),
-			      ip_addr,
+			      mds_srv->nfs_client->cl_ipaddr,
 			      mds_clnt->cl_auth->au_flavor,
 			      IPPROTO_TCP,
 			      mds_clnt->cl_xprt->timeout,
Signature · 1 line
1.6.6
#3 lore raw

PATCH 3/3 SQUASHME pnfs_submit: cleanup DS exchange flag processing

From: Andy Adamson <[email protected]>

Squash into "pnfs: filelayout: device ops"

---
 fs/nfs/nfs4filelayoutdev.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)
fs/nfs/nfs4filelayoutdev.c +8 -4
index b41f437..b04c9d9 100644
@@ -173,18 +173,16 @@ nfs4_pnfs_ds_create(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds)
 
 	clp = tmp.nfs_client;
 
-	/* Set exchange id and create session flags and setup session */
+	/* Ask for only the EXCHGID4_FLAG_USE_PNFS_DS pNFS role */
 	dprintk("%s EXCHANGE_ID for clp %p\n", __func__, clp);
 	clp->cl_exchange_flags = EXCHGID4_FLAG_USE_PNFS_DS;
+
 	err = nfs4_recover_expired_lease(clp);
 	if (!err)
 		err = nfs4_check_client_ready(clp);
 	if (err)
 		goto out_put;
 
-	/* mask out the server's MDS capability flag */
-	clp->cl_exchange_flags &= ~EXCHGID4_FLAG_USE_PNFS_MDS;
-
 	if (!(clp->cl_exchange_flags & EXCHGID4_FLAG_USE_PNFS_DS)) {
 		printk(KERN_INFO "ip:port %s is not a pNFS Data Server\n",
 			ds->r_addr);
@@ -193,6 +191,12 @@ nfs4_pnfs_ds_create(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds)
 	}
 
 	/*
+	 * Mask the (possibly) returned EXCHGID4_FLAG_USE_PNFS_MDS pNFS role
+	 * The is_ds_only_session depends on this.
+	 */
+	clp->cl_exchange_flags &= ~EXCHGID4_FLAG_USE_PNFS_MDS;
+
+	/*
 	 * Set DS lease equal to the MDS lease, renewal is scheduled in
 	 * create_session
 	 */
Signature · 1 line
1.6.6
#4 lore raw

RE: [PATCH 2/3] SQUASHME pnfs_submit: update DS nfs4_set_client

In reply to [email protected]
Quoted 81 lines

-----Original Message-----
From: Adamson, Andy
Sent: Wednesday, May 12, 2010 10:40 AM
To: [email protected]
Cc: [email protected]; Adamson, Andy
Subject: [PATCH 2/3] SQUASHME pnfs_submit: update DS nfs4_set_client

From: Andy Adamson <[email protected]>

Dont bother using the hostname, use the client ipaddr field from the MDS
nfs_client for construction of the co_ownrid field the DS EXCHANGE_ID.

Clean up the comments.

Squash into "pnfs: filelayout: device ops"

---
 fs/nfs/nfs4filelayoutdev.c |   28 +++++-----------------------
 1 files changed, 5 insertions(+), 23 deletions(-)
fs/nfs/nfs4filelayoutdev.c +0 -2
index 891c31d..b41f437 100644
@@ -128,8 +128,6 @@ nfs4_pnfs_ds_create(struct nfs_server *mds_srv,
 struct nfs4_pnfs_ds *ds)
 	struct rpc_clnt 	*mds_clnt = mds_srv->client;
 	struct nfs_client	*clp = mds_srv->nfs_client;
 	struct sockaddr		*mds_addr;
-	char			ip_addr[16];
-	int			addrlen;
 	int err = 0;
 
fs/nfs/nfs4filelayoutdev.c +2 -20
 	dprintk("--> %s ip:port %s au_flavor %d\n", __func__,
@@ -156,32 +154,16 @@ nfs4_pnfs_ds_create(struct nfs_server *mds_srv,
 struct nfs4_pnfs_ds *ds)
 		}
 		goto out;
 	}
-	/* Set timeout to the mds rpc clnt value.
-	 * XXX - find the correct authflavor....
-	 *
-	 * Fake a client ipaddr (used for sessionid) with hostname
-	 * Use hostname since it might be more unique than ipaddr (which
-	 * could be set to the loopback 127.0.0/1.1
-	 *
-	 * XXX: Should sessions continue to use the cl_ipaddr field?
-	 */
-	addrlen = strnlen(utsname()->nodename, sizeof(utsname()-
 >nodename));
-	if (addrlen > sizeof(ip_addr))
-		addrlen = sizeof(ip_addr);
-	memcpy(ip_addr, utsname()->nodename, addrlen);
-
-	/* XXX need a non-nfs_client struct interface to set up
-	 * data server sessions
-	 *
-	 * tmp: nfs4_set_client sets the nfs_server->nfs_client.
-	 *
-	 * We specify a retrans and timeout interval equual to MDS. ??
+	/*
+	 * Set a retrans, timeout interval, and authflavor equual to the

MDS

fs/nfs/nfs4filelayoutdev.c +1 -0
+	 * values. Use the MDS nfs_client cl_ipaddr field so as to use

the

fs/nfs/nfs4filelayoutdev.c +2 -2
+	 * same co_ownerid as the MDS.
 	 */
 	err = nfs4_set_client(&tmp,
 			      mds_srv->nfs_client->cl_hostname,
 			      (struct sockaddr *)&sin,
 			      sizeof(struct sockaddr),
-			      ip_addr,
+			      mds_srv->nfs_client->cl_ipaddr,
 			      mds_clnt->cl_auth->au_flavor,
 			      IPPROTO_TCP,
 			      mds_clnt->cl_xprt->timeout,
--
Quoted 1 line

1.6.6

Hi Andy,

Is there a way to avoid creating a new nfs_client altogether and just re-use the existing one along with its session ?

-a

Quoted 3 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs"

in

Quoted 2 lines

the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

A message that is not in the archive (sent off-list or not yet received): B9364369CA66BF45806C2CD86EAB8BA60607E6A4-hX7t0kiaRRqx3DEm5hsDiAK/[email protected]

#6 lore raw

RE: [PATCH 2/3] SQUASHME pnfs_submit: update DS nfs4_set_client

Quoted 48 lines

-----Original Message-----
From: Batsakis, Alexandros
Sent: Thursday, May 13, 2010 12:14 PM
To: Adamson, Andy; [email protected]
Cc: [email protected]
Subject: RE: [PATCH 2/3] SQUASHME pnfs_submit: update DS nfs4_set_client

Quoted 7 lines

-----Original Message-----
From: Adamson, Andy
Sent: Wednesday, May 12, 2010 10:40 AM
To: [email protected]
Cc: [email protected]; Adamson, Andy
Subject: [PATCH 2/3] SQUASHME pnfs_submit: update DS nfs4_set_client

Quoted 5 lines

From: Andy Adamson <[email protected]>

Dont bother using the hostname, use the client ipaddr field from the MDS
nfs_client for construction of the co_ownrid field the DS

EXCHANGE_ID.

Quoted 23 lines

Clean up the comments.

Squash into "pnfs: filelayout: device ops"

---
 fs/nfs/nfs4filelayoutdev.c |   28 +++++-----------------------
 1 files changed, 5 insertions(+), 23 deletions(-)
fs/nfs/nfs4filelayoutdev.c +0 -2
index 891c31d..b41f437 100644
@@ -128,8 +128,6 @@ nfs4_pnfs_ds_create(struct nfs_server *mds_srv,
 struct nfs4_pnfs_ds *ds)
 	struct rpc_clnt 	*mds_clnt = mds_srv->client;
 	struct nfs_client	*clp = mds_srv->nfs_client;
 	struct sockaddr		*mds_addr;
-	char			ip_addr[16];
-	int			addrlen;
 	int err = 0;
 
Quoted 2 lines

fs/nfs/nfs4filelayoutdev.c nfs4_pnfs_ds_create(struct nfs_server

Quoted 2 lines
fs/nfs/nfs4filelayoutdev.c +0 -0
 	dprintk("--> %s ip:port %s au_flavor %d\n", __func__,
@@ -156,32 +154,16 @@ nfs4_pnfs_ds_create(struct nfs_server

*mds_srv,

Quoted 46 lines
Quoted 42 lines
fs/nfs/nfs4filelayoutdev.c +2 -20
 struct nfs4_pnfs_ds *ds)
 		}
 		goto out;
 	}
-	/* Set timeout to the mds rpc clnt value.
-	 * XXX - find the correct authflavor....
-	 *
-	 * Fake a client ipaddr (used for sessionid) with hostname
-	 * Use hostname since it might be more unique than ipaddr (which
-	 * could be set to the loopback 127.0.0/1.1
-	 *
-	 * XXX: Should sessions continue to use the cl_ipaddr field?
-	 */
-	addrlen = strnlen(utsname()->nodename, sizeof(utsname()-
 >nodename));
-	if (addrlen > sizeof(ip_addr))
-		addrlen = sizeof(ip_addr);
-	memcpy(ip_addr, utsname()->nodename, addrlen);
-
-	/* XXX need a non-nfs_client struct interface to set up
-	 * data server sessions
-	 *
-	 * tmp: nfs4_set_client sets the nfs_server->nfs_client.
-	 *
-	 * We specify a retrans and timeout interval equual to MDS. ??
+	/*
+	 * Set a retrans, timeout interval, and authflavor equual to the

MDS

fs/nfs/nfs4filelayoutdev.c +1 -0
+	 * values. Use the MDS nfs_client cl_ipaddr field so as to use

the

fs/nfs/nfs4filelayoutdev.c +2 -2
+	 * same co_ownerid as the MDS.
 	 */
 	err = nfs4_set_client(&tmp,
 			      mds_srv->nfs_client->cl_hostname,
 			      (struct sockaddr *)&sin,
 			      sizeof(struct sockaddr),
-			      ip_addr,
+			      mds_srv->nfs_client->cl_ipaddr,
 			      mds_clnt->cl_auth->au_flavor,
 			      IPPROTO_TCP,
 			      mds_clnt->cl_xprt->timeout,
--
Quoted 1 line

1.6.6

Hi Andy,

Quoted 5 lines

Is there a way to avoid creating a new nfs_client altogether and just re-use the existing one along with its session ?

-a

Nevermind. I should have read patch 1/3 as well :)

-a

Quoted 8 lines
Quoted 3 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs"

in

Quoted 2 lines

the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

--
To unsubscribe from this list: send the line "unsubscribe linux-nfs"

in

Quoted 2 lines

the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html