Skip to content

Commit

Permalink
Merge git://git.linux-nfs.org/pub/linux/nfs-2.6
Browse files Browse the repository at this point in the history
* 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
  ...
  • Loading branch information
Linus Torvalds committed Jan 30, 2008
2 parents 149a051 + 3fbd67a commit 85004cc
Show file tree
Hide file tree
Showing 55 changed files with 1,910 additions and 1,293 deletions.
42 changes: 42 additions & 0 deletions fs/lockd/clntlock.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,48 @@ struct nlm_wait {

static LIST_HEAD(nlm_blocked);

/**
* nlmclnt_init - Set up per-NFS mount point lockd data structures
* @nlm_init: pointer to arguments structure
*
* Returns pointer to an appropriate nlm_host struct,
* or an ERR_PTR value.
*/
struct nlm_host *nlmclnt_init(const struct nlmclnt_initdata *nlm_init)
{
struct nlm_host *host;
u32 nlm_version = (nlm_init->nfs_version == 2) ? 1 : 4;
int status;

status = lockd_up(nlm_init->protocol);
if (status < 0)
return ERR_PTR(status);

host = nlmclnt_lookup_host((struct sockaddr_in *)nlm_init->address,
nlm_init->protocol, nlm_version,
nlm_init->hostname,
strlen(nlm_init->hostname));
if (host == NULL) {
lockd_down();
return ERR_PTR(-ENOLCK);
}

return host;
}
EXPORT_SYMBOL_GPL(nlmclnt_init);

/**
* nlmclnt_done - Release resources allocated by nlmclnt_init()
* @host: nlm_host structure reserved by nlmclnt_init()
*
*/
void nlmclnt_done(struct nlm_host *host)
{
nlm_release_host(host);
lockd_down();
}
EXPORT_SYMBOL_GPL(nlmclnt_done);

/*
* Queue up a lock for blocking so that the GRANTED request can see it
*/
Expand Down
35 changes: 11 additions & 24 deletions fs/lockd/clntproc.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,34 +145,21 @@ static void nlmclnt_release_lockargs(struct nlm_rqst *req)
BUG_ON(req->a_args.lock.fl.fl_ops != NULL);
}

/*
* This is the main entry point for the NLM client.
/**
* nlmclnt_proc - Perform a single client-side lock request
* @host: address of a valid nlm_host context representing the NLM server
* @cmd: fcntl-style file lock operation to perform
* @fl: address of arguments for the lock operation
*
*/
int
nlmclnt_proc(struct inode *inode, int cmd, struct file_lock *fl)
int nlmclnt_proc(struct nlm_host *host, int cmd, struct file_lock *fl)
{
struct rpc_clnt *client = NFS_CLIENT(inode);
struct sockaddr_in addr;
struct nfs_server *nfssrv = NFS_SERVER(inode);
struct nlm_host *host;
struct nlm_rqst *call;
sigset_t oldset;
unsigned long flags;
int status, vers;

vers = (NFS_PROTO(inode)->version == 3) ? 4 : 1;
if (NFS_PROTO(inode)->version > 3) {
printk(KERN_NOTICE "NFSv4 file locking not implemented!\n");
return -ENOLCK;
}

rpc_peeraddr(client, (struct sockaddr *) &addr, sizeof(addr));
host = nlmclnt_lookup_host(&addr, client->cl_xprt->prot, vers,
nfssrv->nfs_client->cl_hostname,
strlen(nfssrv->nfs_client->cl_hostname));
if (host == NULL)
return -ENOLCK;
int status;

nlm_get_host(host);
call = nlm_alloc_call(host);
if (call == NULL)
return -ENOMEM;
Expand Down Expand Up @@ -219,7 +206,7 @@ nlmclnt_proc(struct inode *inode, int cmd, struct file_lock *fl)
dprintk("lockd: clnt proc returns %d\n", status);
return status;
}
EXPORT_SYMBOL(nlmclnt_proc);
EXPORT_SYMBOL_GPL(nlmclnt_proc);

/*
* Allocate an NLM RPC call struct
Expand Down Expand Up @@ -257,7 +244,7 @@ void nlm_release_call(struct nlm_rqst *call)

static void nlmclnt_rpc_release(void *data)
{
return nlm_release_call(data);
nlm_release_call(data);
}

static int nlm_wait_on_grace(wait_queue_head_t *queue)
Expand Down
3 changes: 1 addition & 2 deletions fs/lockd/xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -612,8 +612,7 @@ const char *nlmdbg_cookie2a(const struct nlm_cookie *cookie)
* called with BKL held.
*/
static char buf[2*NLM_MAXCOOKIELEN+1];
int i;
int len = sizeof(buf);
unsigned int i, len = sizeof(buf);
char *p = buf;

len--; /* allow for trailing \0 */
Expand Down
7 changes: 1 addition & 6 deletions fs/nfs/callback.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,6 @@ static void nfs_callback_svc(struct svc_rqst *rqstp)
complete(&nfs_callback_info.started);

for(;;) {
char buf[RPC_MAX_ADDRBUFLEN];

if (signalled()) {
if (nfs_callback_info.users == 0)
break;
Expand All @@ -92,8 +90,6 @@ static void nfs_callback_svc(struct svc_rqst *rqstp)
__FUNCTION__, -err);
break;
}
dprintk("%s: request from %s\n", __FUNCTION__,
svc_print_addr(rqstp, buf, sizeof(buf)));
svc_process(rqstp);
}

Expand Down Expand Up @@ -168,12 +164,11 @@ void nfs_callback_down(void)

static int nfs_callback_authenticate(struct svc_rqst *rqstp)
{
struct sockaddr_in *addr = svc_addr_in(rqstp);
struct nfs_client *clp;
char buf[RPC_MAX_ADDRBUFLEN];

/* Don't talk to strangers */
clp = nfs_find_client(addr, 4);
clp = nfs_find_client(svc_addr(rqstp), 4);
if (clp == NULL)
return SVC_DROP;

Expand Down
4 changes: 2 additions & 2 deletions fs/nfs/callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ struct cb_compound_hdr_res {
};

struct cb_getattrargs {
struct sockaddr_in *addr;
struct sockaddr *addr;
struct nfs_fh fh;
uint32_t bitmap[2];
};
Expand All @@ -53,7 +53,7 @@ struct cb_getattrres {
};

struct cb_recallargs {
struct sockaddr_in *addr;
struct sockaddr *addr;
struct nfs_fh fh;
nfs4_stateid stateid;
uint32_t truncate;
Expand Down
51 changes: 33 additions & 18 deletions fs/nfs/callback_proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,26 @@
#include "delegation.h"
#include "internal.h"

#ifdef NFS_DEBUG
#define NFSDBG_FACILITY NFSDBG_CALLBACK
#endif

__be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres *res)
{
struct nfs_client *clp;
struct nfs_delegation *delegation;
struct nfs_inode *nfsi;
struct inode *inode;

res->bitmap[0] = res->bitmap[1] = 0;
res->status = htonl(NFS4ERR_BADHANDLE);
clp = nfs_find_client(args->addr, 4);
if (clp == NULL)
goto out;

dprintk("NFS: GETATTR callback request from %s\n",
rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));

inode = nfs_delegation_find_inode(clp, &args->fh);
if (inode == NULL)
goto out_putclient;
Expand Down Expand Up @@ -65,23 +71,32 @@ __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy)
clp = nfs_find_client(args->addr, 4);
if (clp == NULL)
goto out;
inode = nfs_delegation_find_inode(clp, &args->fh);
if (inode == NULL)
goto out_putclient;
/* Set up a helper thread to actually return the delegation */
switch(nfs_async_inode_return_delegation(inode, &args->stateid)) {
case 0:
res = 0;
break;
case -ENOENT:
res = htonl(NFS4ERR_BAD_STATEID);
break;
default:
res = htonl(NFS4ERR_RESOURCE);
}
iput(inode);
out_putclient:
nfs_put_client(clp);

dprintk("NFS: RECALL callback request from %s\n",
rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));

do {
struct nfs_client *prev = clp;

inode = nfs_delegation_find_inode(clp, &args->fh);
if (inode != NULL) {
/* Set up a helper thread to actually return the delegation */
switch(nfs_async_inode_return_delegation(inode, &args->stateid)) {
case 0:
res = 0;
break;
case -ENOENT:
if (res != 0)
res = htonl(NFS4ERR_BAD_STATEID);
break;
default:
res = htonl(NFS4ERR_RESOURCE);
}
iput(inode);
}
clp = nfs_find_client_next(prev);
nfs_put_client(prev);
} while (clp != NULL);
out:
dprintk("%s: exit with status = %d\n", __FUNCTION__, ntohl(res));
return res;
Expand Down
6 changes: 3 additions & 3 deletions fs/nfs/callback_xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static __be32 decode_compound_hdr_arg(struct xdr_stream *xdr, struct cb_compound
if (unlikely(status != 0))
return status;
/* We do not like overly long tags! */
if (hdr->taglen > CB_OP_TAGLEN_MAXSZ-12 || hdr->taglen < 0) {
if (hdr->taglen > CB_OP_TAGLEN_MAXSZ - 12) {
printk("NFSv4 CALLBACK %s: client sent tag of length %u\n",
__FUNCTION__, hdr->taglen);
return htonl(NFS4ERR_RESOURCE);
Expand Down Expand Up @@ -176,7 +176,7 @@ static __be32 decode_getattr_args(struct svc_rqst *rqstp, struct xdr_stream *xdr
status = decode_fh(xdr, &args->fh);
if (unlikely(status != 0))
goto out;
args->addr = svc_addr_in(rqstp);
args->addr = svc_addr(rqstp);
status = decode_bitmap(xdr, args->bitmap);
out:
dprintk("%s: exit with status = %d\n", __FUNCTION__, ntohl(status));
Expand All @@ -188,7 +188,7 @@ static __be32 decode_recall_args(struct svc_rqst *rqstp, struct xdr_stream *xdr,
__be32 *p;
__be32 status;

args->addr = svc_addr_in(rqstp);
args->addr = svc_addr(rqstp);
status = decode_stateid(xdr, &args->stateid);
if (unlikely(status != 0))
goto out;
Expand Down
Loading

0 comments on commit 85004cc

Please sign in to comment.