2 * linux/fs/nfs/callback_proc.c
4 * Copyright (C) 2004 Trond Myklebust
6 * NFSv4 callback procedures
8 #include <linux/config.h>
9 #include <linux/nfs4.h>
10 #include <linux/nfs_fs.h>
13 #include "delegation.h"
15 #define NFSDBG_FACILITY NFSDBG_CALLBACK
17 unsigned nfs4_callback_getattr(struct cb_getattrargs
*args
, struct cb_getattrres
*res
)
19 struct nfs4_client
*clp
;
20 struct nfs_delegation
*delegation
;
21 struct nfs_inode
*nfsi
;
24 res
->bitmap
[0] = res
->bitmap
[1] = 0;
25 res
->status
= htonl(NFS4ERR_BADHANDLE
);
26 clp
= nfs4_find_client(&args
->addr
->sin_addr
);
29 inode
= nfs_delegation_find_inode(clp
, &args
->fh
);
33 down_read(&nfsi
->rwsem
);
34 delegation
= nfsi
->delegation
;
35 if (delegation
== NULL
|| (delegation
->type
& FMODE_WRITE
) == 0)
37 res
->size
= i_size_read(inode
);
38 res
->change_attr
= NFS_CHANGE_ATTR(inode
);
39 res
->ctime
= inode
->i_ctime
;
40 res
->mtime
= inode
->i_mtime
;
41 res
->bitmap
[0] = (FATTR4_WORD0_CHANGE
|FATTR4_WORD0_SIZE
) &
43 res
->bitmap
[1] = (FATTR4_WORD1_TIME_METADATA
|FATTR4_WORD1_TIME_MODIFY
) &
47 up_read(&nfsi
->rwsem
);
52 dprintk("%s: exit with status = %d\n", __FUNCTION__
, ntohl(res
->status
));
56 unsigned nfs4_callback_recall(struct cb_recallargs
*args
, void *dummy
)
58 struct nfs4_client
*clp
;
62 res
= htonl(NFS4ERR_BADHANDLE
);
63 clp
= nfs4_find_client(&args
->addr
->sin_addr
);
66 inode
= nfs_delegation_find_inode(clp
, &args
->fh
);
69 /* Set up a helper thread to actually return the delegation */
70 switch(nfs_async_inode_return_delegation(inode
, &args
->stateid
)) {
75 res
= htonl(NFS4ERR_BAD_STATEID
);
78 res
= htonl(NFS4ERR_RESOURCE
);
84 dprintk("%s: exit with status = %d\n", __FUNCTION__
, ntohl(res
));