Skip to content

Commit 85004cc

Browse files
committed
Merge git://git.linux-nfs.org/pub/linux/nfs-2.6
* git://git.linux-nfs.org/pub/linux/nfs-2.6: (118 commits) NFSv4: Iterate through all nfs_clients when the server recalls a delegation NFSv4: Deal more correctly with duplicate delegations NFS: Fix a potential race between umount and nfs_access_cache_shrinker() NFS: Add an asynchronous delegreturn operation for use in nfs_clear_inode nfs: convert NFS_*(inode) helpers to static inline nfs: obliterate NFS_FLAGS macro NFS: Address memory leaks in the NFS client mount option parser nfs4: allow nfsv4 acls on non-regular-files NFS: Optimise away the sigmask code in aio/dio reads and writes SUNRPC: Don't bother changing the sigmask for asynchronous RPC calls SUNRPC: rpcb_getport_sync() passes incorrect address size to rpc_create() SUNRPC: Clean up block comment preceding rpcb_getport_sync() SUNRPC: Use appropriate argument types in rpcb client SUNRPC: rpcb_getport_sync() should use built-in hostname generator SUNRPC: Clean up functions that free address_strings array NFS: NFS version number is unsigned NLM: Fix a bogus 'return' in nlmclnt_rpc_release NLM: Introduce an arguments structure for nlmclnt_init() NLM/NFS: Use cached nlm_host when calling nlmclnt_proc() NFS: Invoke nlmclnt_init during NFS mount processing ...
2 parents 149a051 + 3fbd67a commit 85004cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+1910
-1293
lines changed

fs/lockd/clntlock.c

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,48 @@ struct nlm_wait {
4141

4242
static LIST_HEAD(nlm_blocked);
4343

44+
/**
45+
* nlmclnt_init - Set up per-NFS mount point lockd data structures
46+
* @nlm_init: pointer to arguments structure
47+
*
48+
* Returns pointer to an appropriate nlm_host struct,
49+
* or an ERR_PTR value.
50+
*/
51+
struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init)
52+
{
53+
struct nlm_host *host;
54+
u32 nlm_version = (nlm_init->nfs_version == 2) ? 1 : 4;
55+
int status;
56+
57+
status = lockd_up(nlm_init->protocol);
58+
if (status < 0)
59+
return ERR_PTR(status);
60+
61+
host = nlmclnt_lookup_host((struct sockaddr_in *)nlm_init->address,
62+
nlm_init->protocol, nlm_version,
63+
nlm_init->hostname,
64+
strlen(nlm_init->hostname));
65+
if (host == NULL) {
66+
lockd_down();
67+
return ERR_PTR(-ENOLCK);
68+
}
69+
70+
return host;
71+
}
72+
EXPORT_SYMBOL_GPL(nlmclnt_init);
73+
74+
/**
75+
* nlmclnt_done - Release resources allocated by nlmclnt_init()
76+
* @host: nlm_host structure reserved by nlmclnt_init()
77+
*
78+
*/
79+
void nlmclnt_done(struct nlm_host *host)
80+
{
81+
nlm_release_host(host);
82+
lockd_down();
83+
}
84+
EXPORT_SYMBOL_GPL(nlmclnt_done);
85+
4486
/*
4587
* Queue up a lock for blocking so that the GRANTED request can see it
4688
*/

fs/lockd/clntproc.c

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -145,34 +145,21 @@ static void nlmclnt_release_lockargs(struct nlm_rqst *req)
145145
BUG_ON(req->a_args.lock.fl.fl_ops != NULL);
146146
}
147147

148-
/*
149-
* This is the main entry point for the NLM client.
148+
/**
149+
* nlmclnt_proc - Perform a single client-side lock request
150+
* @host: address of a valid nlm_host context representing the NLM server
151+
* @cmd: fcntl-style file lock operation to perform
152+
* @fl: address of arguments for the lock operation
153+
*
150154
*/
151-
int
152-
nlmclnt_proc(struct inode *inode, int cmd, struct file_lock *fl)
155+
int nlmclnt_proc(struct nlm_host *host, int cmd, struct file_lock *fl)
153156
{
154-
struct rpc_clnt *client = NFS_CLIENT(inode);
155-
struct sockaddr_in addr;
156-
struct nfs_server *nfssrv = NFS_SERVER(inode);
157-
struct nlm_host *host;
158157
struct nlm_rqst *call;
159158
sigset_t oldset;
160159
unsigned long flags;
161-
int status, vers;
162-
163-
vers = (NFS_PROTO(inode)->version == 3) ? 4 : 1;
164-
if (NFS_PROTO(inode)->version > 3) {
165-
printk(KERN_NOTICE "NFSv4 file locking not implemented!\n");
166-
return -ENOLCK;
167-
}
168-
169-
rpc_peeraddr(client, (struct sockaddr *) &addr, sizeof(addr));
170-
host = nlmclnt_lookup_host(&addr, client->cl_xprt->prot, vers,
171-
nfssrv->nfs_client->cl_hostname,
172-
strlen(nfssrv->nfs_client->cl_hostname));
173-
if (host == NULL)
174-
return -ENOLCK;
160+
int status;
175161

162+
nlm_get_host(host);
176163
call = nlm_alloc_call(host);
177164
if (call == NULL)
178165
return -ENOMEM;
@@ -219,7 +206,7 @@ nlmclnt_proc(struct inode *inode, int cmd, struct file_lock *fl)
219206
dprintk("lockd: clnt proc returns %d\n", status);
220207
return status;
221208
}
222-
EXPORT_SYMBOL(nlmclnt_proc);
209+
EXPORT_SYMBOL_GPL(nlmclnt_proc);
223210

224211
/*
225212
* Allocate an NLM RPC call struct
@@ -257,7 +244,7 @@ void nlm_release_call(struct nlm_rqst *call)
257244

258245
static void nlmclnt_rpc_release(void *data)
259246
{
260-
return nlm_release_call(data);
247+
nlm_release_call(data);
261248
}
262249

263250
static int nlm_wait_on_grace(wait_queue_head_t *queue)

fs/lockd/xdr.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,8 +612,7 @@ const char *nlmdbg_cookie2a(const struct nlm_cookie *cookie)
612612
* called with BKL held.
613613
*/
614614
static char buf[2*NLM_MAXCOOKIELEN+1];
615-
int i;
616-
int len = sizeof(buf);
615+
unsigned int i, len = sizeof(buf);
617616
char *p = buf;
618617

619618
len--; /* allow for trailing \0 */

fs/nfs/callback.c

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,6 @@ static void nfs_callback_svc(struct svc_rqst *rqstp)
7373
complete(&nfs_callback_info.started);
7474

7575
for(;;) {
76-
char buf[RPC_MAX_ADDRBUFLEN];
77-
7876
if (signalled()) {
7977
if (nfs_callback_info.users == 0)
8078
break;
@@ -92,8 +90,6 @@ static void nfs_callback_svc(struct svc_rqst *rqstp)
9290
__FUNCTION__, -err);
9391
break;
9492
}
95-
dprintk("%s: request from %s\n", __FUNCTION__,
96-
svc_print_addr(rqstp, buf, sizeof(buf)));
9793
svc_process(rqstp);
9894
}
9995

@@ -168,12 +164,11 @@ void nfs_callback_down(void)
168164

169165
static int nfs_callback_authenticate(struct svc_rqst *rqstp)
170166
{
171-
struct sockaddr_in *addr = svc_addr_in(rqstp);
172167
struct nfs_client *clp;
173168
char buf[RPC_MAX_ADDRBUFLEN];
174169

175170
/* Don't talk to strangers */
176-
clp = nfs_find_client(addr, 4);
171+
clp = nfs_find_client(svc_addr(rqstp), 4);
177172
if (clp == NULL)
178173
return SVC_DROP;
179174

fs/nfs/callback.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ struct cb_compound_hdr_res {
3838
};
3939

4040
struct cb_getattrargs {
41-
struct sockaddr_in *addr;
41+
struct sockaddr *addr;
4242
struct nfs_fh fh;
4343
uint32_t bitmap[2];
4444
};
@@ -53,7 +53,7 @@ struct cb_getattrres {
5353
};
5454

5555
struct cb_recallargs {
56-
struct sockaddr_in *addr;
56+
struct sockaddr *addr;
5757
struct nfs_fh fh;
5858
nfs4_stateid stateid;
5959
uint32_t truncate;

fs/nfs/callback_proc.c

Lines changed: 33 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,26 @@
1212
#include "delegation.h"
1313
#include "internal.h"
1414

15+
#ifdef NFS_DEBUG
1516
#define NFSDBG_FACILITY NFSDBG_CALLBACK
17+
#endif
1618

1719
__be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres *res)
1820
{
1921
struct nfs_client *clp;
2022
struct nfs_delegation *delegation;
2123
struct nfs_inode *nfsi;
2224
struct inode *inode;
23-
25+
2426
res->bitmap[0] = res->bitmap[1] = 0;
2527
res->status = htonl(NFS4ERR_BADHANDLE);
2628
clp = nfs_find_client(args->addr, 4);
2729
if (clp == NULL)
2830
goto out;
31+
32+
dprintk("NFS: GETATTR callback request from %s\n",
33+
rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
34+
2935
inode = nfs_delegation_find_inode(clp, &args->fh);
3036
if (inode == NULL)
3137
goto out_putclient;
@@ -65,23 +71,32 @@ __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy)
6571
clp = nfs_find_client(args->addr, 4);
6672
if (clp == NULL)
6773
goto out;
68-
inode = nfs_delegation_find_inode(clp, &args->fh);
69-
if (inode == NULL)
70-
goto out_putclient;
71-
/* Set up a helper thread to actually return the delegation */
72-
switch(nfs_async_inode_return_delegation(inode, &args->stateid)) {
73-
case 0:
74-
res = 0;
75-
break;
76-
case -ENOENT:
77-
res = htonl(NFS4ERR_BAD_STATEID);
78-
break;
79-
default:
80-
res = htonl(NFS4ERR_RESOURCE);
81-
}
82-
iput(inode);
83-
out_putclient:
84-
nfs_put_client(clp);
74+
75+
dprintk("NFS: RECALL callback request from %s\n",
76+
rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
77+
78+
do {
79+
struct nfs_client *prev = clp;
80+
81+
inode = nfs_delegation_find_inode(clp, &args->fh);
82+
if (inode != NULL) {
83+
/* Set up a helper thread to actually return the delegation */
84+
switch(nfs_async_inode_return_delegation(inode, &args->stateid)) {
85+
case 0:
86+
res = 0;
87+
break;
88+
case -ENOENT:
89+
if (res != 0)
90+
res = htonl(NFS4ERR_BAD_STATEID);
91+
break;
92+
default:
93+
res = htonl(NFS4ERR_RESOURCE);
94+
}
95+
iput(inode);
96+
}
97+
clp = nfs_find_client_next(prev);
98+
nfs_put_client(prev);
99+
} while (clp != NULL);
85100
out:
86101
dprintk("%s: exit with status = %d\n", __FUNCTION__, ntohl(res));
87102
return res;

fs/nfs/callback_xdr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound
139139
if (unlikely(status != 0))
140140
return status;
141141
/* We do not like overly long tags! */
142-
if (hdr->taglen > CB_OP_TAGLEN_MAXSZ-12 || hdr->taglen < 0) {
142+
if (hdr->taglen > CB_OP_TAGLEN_MAXSZ - 12) {
143143
printk("NFSv4 CALLBACK %s: client sent tag of length %u\n",
144144
__FUNCTION__, hdr->taglen);
145145
return htonl(NFS4ERR_RESOURCE);
@@ -176,7 +176,7 @@ static __be32 decode_getattr_args(struct svc_rqst *rqstp, struct xdr_stream *xdr
176176
status = decode_fh(xdr, &args->fh);
177177
if (unlikely(status != 0))
178178
goto out;
179-
args->addr = svc_addr_in(rqstp);
179+
args->addr = svc_addr(rqstp);
180180
status = decode_bitmap(xdr, args->bitmap);
181181
out:
182182
dprintk("%s: exit with status = %d\n", __FUNCTION__, ntohl(status));
@@ -188,7 +188,7 @@ static __be32 decode_recall_args(struct svc_rqst *rqstp, struct xdr_stream *xdr,
188188
__be32 *p;
189189
__be32 status;
190190

191-
args->addr = svc_addr_in(rqstp);
191+
args->addr = svc_addr(rqstp);
192192
status = decode_stateid(xdr, &args->stateid);
193193
if (unlikely(status != 0))
194194
goto out;

0 commit comments

Comments
 (0)