NFS: Change cb_recallargs to pass "struct sockaddr *" instead of sockaddr_in
[deliverable/linux.git] / fs / nfs / callback_proc.c
1 /*
2 * linux/fs/nfs/callback_proc.c
3 *
4 * Copyright (C) 2004 Trond Myklebust
5 *
6 * NFSv4 callback procedures
7 */
8 #include <linux/nfs4.h>
9 #include <linux/nfs_fs.h>
10 #include "nfs4_fs.h"
11 #include "callback.h"
12 #include "delegation.h"
13 #include "internal.h"
14
15 #ifdef NFS_DEBUG
16 #define NFSDBG_FACILITY NFSDBG_CALLBACK
17 #endif
18
19 __be32 nfs4_callback_getattr(struct cb_getattrargs *args, struct cb_getattrres *res)
20 {
21 struct nfs_client *clp;
22 struct nfs_delegation *delegation;
23 struct nfs_inode *nfsi;
24 struct inode *inode;
25
26 res->bitmap[0] = res->bitmap[1] = 0;
27 res->status = htonl(NFS4ERR_BADHANDLE);
28 clp = nfs_find_client((struct sockaddr_in *)args->addr, 4);
29 if (clp == NULL)
30 goto out;
31
32 dprintk("NFS: GETATTR callback request from %s\n",
33 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
34
35 inode = nfs_delegation_find_inode(clp, &args->fh);
36 if (inode == NULL)
37 goto out_putclient;
38 nfsi = NFS_I(inode);
39 down_read(&nfsi->rwsem);
40 delegation = nfsi->delegation;
41 if (delegation == NULL || (delegation->type & FMODE_WRITE) == 0)
42 goto out_iput;
43 res->size = i_size_read(inode);
44 res->change_attr = delegation->change_attr;
45 if (nfsi->npages != 0)
46 res->change_attr++;
47 res->ctime = inode->i_ctime;
48 res->mtime = inode->i_mtime;
49 res->bitmap[0] = (FATTR4_WORD0_CHANGE|FATTR4_WORD0_SIZE) &
50 args->bitmap[0];
51 res->bitmap[1] = (FATTR4_WORD1_TIME_METADATA|FATTR4_WORD1_TIME_MODIFY) &
52 args->bitmap[1];
53 res->status = 0;
54 out_iput:
55 up_read(&nfsi->rwsem);
56 iput(inode);
57 out_putclient:
58 nfs_put_client(clp);
59 out:
60 dprintk("%s: exit with status = %d\n", __FUNCTION__, ntohl(res->status));
61 return res->status;
62 }
63
64 __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy)
65 {
66 struct nfs_client *clp;
67 struct inode *inode;
68 __be32 res;
69
70 res = htonl(NFS4ERR_BADHANDLE);
71 clp = nfs_find_client((struct sockaddr_in *)args->addr, 4);
72 if (clp == NULL)
73 goto out;
74
75 dprintk("NFS: RECALL callback request from %s\n",
76 rpc_peeraddr2str(clp->cl_rpcclient, RPC_DISPLAY_ADDR));
77
78 inode = nfs_delegation_find_inode(clp, &args->fh);
79 if (inode == NULL)
80 goto out_putclient;
81 /* Set up a helper thread to actually return the delegation */
82 switch(nfs_async_inode_return_delegation(inode, &args->stateid)) {
83 case 0:
84 res = 0;
85 break;
86 case -ENOENT:
87 res = htonl(NFS4ERR_BAD_STATEID);
88 break;
89 default:
90 res = htonl(NFS4ERR_RESOURCE);
91 }
92 iput(inode);
93 out_putclient:
94 nfs_put_client(clp);
95 out:
96 dprintk("%s: exit with status = %d\n", __FUNCTION__, ntohl(res));
97 return res;
98 }
This page took 0.035148 seconds and 5 git commands to generate.