diff options
Diffstat (limited to 'fs/nfs/nfs4filelayoutdev.c')
-rw-r--r-- | fs/nfs/nfs4filelayoutdev.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/fs/nfs/nfs4filelayoutdev.c b/fs/nfs/nfs4filelayoutdev.c index b73c34375f60..8bc91fb8b6fa 100644 --- a/fs/nfs/nfs4filelayoutdev.c +++ b/fs/nfs/nfs4filelayoutdev.c | |||
@@ -104,6 +104,67 @@ _data_server_lookup_locked(u32 ip_addr, u32 port) | |||
104 | return NULL; | 104 | return NULL; |
105 | } | 105 | } |
106 | 106 | ||
107 | /* | ||
108 | * Create an rpc connection to the nfs4_pnfs_ds data server | ||
109 | * Currently only support IPv4 | ||
110 | */ | ||
111 | static int | ||
112 | nfs4_ds_connect(struct nfs_server *mds_srv, struct nfs4_pnfs_ds *ds) | ||
113 | { | ||
114 | struct nfs_client *clp; | ||
115 | struct sockaddr_in sin; | ||
116 | int status = 0; | ||
117 | |||
118 | dprintk("--> %s ip:port %x:%hu au_flavor %d\n", __func__, | ||
119 | ntohl(ds->ds_ip_addr), ntohs(ds->ds_port), | ||
120 | mds_srv->nfs_client->cl_rpcclient->cl_auth->au_flavor); | ||
121 | |||
122 | sin.sin_family = AF_INET; | ||
123 | sin.sin_addr.s_addr = ds->ds_ip_addr; | ||
124 | sin.sin_port = ds->ds_port; | ||
125 | |||
126 | clp = nfs4_set_ds_client(mds_srv->nfs_client, (struct sockaddr *)&sin, | ||
127 | sizeof(sin), IPPROTO_TCP); | ||
128 | if (IS_ERR(clp)) { | ||
129 | status = PTR_ERR(clp); | ||
130 | goto out; | ||
131 | } | ||
132 | |||
133 | if ((clp->cl_exchange_flags & EXCHGID4_FLAG_MASK_PNFS) != 0) { | ||
134 | if (!is_ds_client(clp)) { | ||
135 | status = -ENODEV; | ||
136 | goto out_put; | ||
137 | } | ||
138 | ds->ds_clp = clp; | ||
139 | dprintk("%s [existing] ip=%x, port=%hu\n", __func__, | ||
140 | ntohl(ds->ds_ip_addr), ntohs(ds->ds_port)); | ||
141 | goto out; | ||
142 | } | ||
143 | |||
144 | /* | ||
145 | * Do not set NFS_CS_CHECK_LEASE_TIME instead set the DS lease to | ||
146 | * be equal to the MDS lease. Renewal is scheduled in create_session. | ||
147 | */ | ||
148 | spin_lock(&mds_srv->nfs_client->cl_lock); | ||
149 | clp->cl_lease_time = mds_srv->nfs_client->cl_lease_time; | ||
150 | spin_unlock(&mds_srv->nfs_client->cl_lock); | ||
151 | clp->cl_last_renewal = jiffies; | ||
152 | |||
153 | /* New nfs_client */ | ||
154 | status = nfs4_init_ds_session(clp); | ||
155 | if (status) | ||
156 | goto out_put; | ||
157 | |||
158 | ds->ds_clp = clp; | ||
159 | dprintk("%s [new] ip=%x, port=%hu\n", __func__, ntohl(ds->ds_ip_addr), | ||
160 | ntohs(ds->ds_port)); | ||
161 | out: | ||
162 | return status; | ||
163 | out_put: | ||
164 | nfs_put_client(clp); | ||
165 | goto out; | ||
166 | } | ||
167 | |||
107 | static void | 168 | static void |
108 | destroy_ds(struct nfs4_pnfs_ds *ds) | 169 | destroy_ds(struct nfs4_pnfs_ds *ds) |
109 | { | 170 | { |