30 #include <linux/types.h>
32 #include <linux/time.h>
34 #include <linux/errno.h>
35 #include <linux/string.h>
39 #include <linux/nfs.h>
41 #include <linux/nfs_fs.h>
47 #define NFSDBG_FACILITY NFSDBG_PROC
65 }
while (!fatal_signal_pending(
current));
69 #define rpc_call_sync(clnt, msg, flags) nfs_rpc_wrapper(clnt, msg, flags)
98 dprintk(
"%s: call getattr\n", __func__);
104 dprintk(
"%s: reply getattr: %d\n", __func__, status);
107 dprintk(
"%s: call statfs\n", __func__);
114 dprintk(
"%s: reply statfs: %d\n", __func__, status);
118 info->
rtpref = fsinfo.tsize;
119 info->
rtmult = fsinfo.bsize;
121 info->
wtpref = fsinfo.tsize;
122 info->
wtmult = fsinfo.bsize;
123 info->
dtpref = fsinfo.tsize;
146 dprintk(
"NFS reply getattr: %d\n", status);
176 dprintk(
"NFS reply setattr: %d\n", status);
181 nfs_proc_lookup(
struct inode *dir,
struct qstr *
name,
203 dprintk(
"NFS reply lookup: %d\n", status);
207 static int nfs_proc_readlink(
struct inode *inode,
struct page *
page,
208 unsigned int pgbase,
unsigned int pglen)
222 dprintk(
"NFS call readlink\n");
224 dprintk(
"NFS reply readlink: %d\n", status);
235 static struct nfs_createdata *nfs_alloc_createdata(
struct inode *dir,
236 struct dentry *dentry,
struct iattr *sattr)
243 data->
arg.fh = NFS_FH(dir);
246 data->
arg.sattr = sattr;
255 static void nfs_free_createdata(
const struct nfs_createdata *data)
261 nfs_proc_create(
struct inode *dir,
struct dentry *dentry,
struct iattr *sattr,
271 data = nfs_alloc_createdata(dir, dentry, sattr);
277 nfs_mark_for_revalidate(dir);
280 nfs_free_createdata(data);
282 dprintk(
"NFS reply create: %d\n", status);
290 nfs_proc_mknod(
struct inode *dir,
struct dentry *dentry,
struct iattr *sattr,
308 sattr->
ia_size = new_encode_dev(rdev);
311 data = nfs_alloc_createdata(dir, dentry, sattr);
318 nfs_mark_for_revalidate(dir);
327 nfs_free_createdata(data);
329 dprintk(
"NFS reply mknod: %d\n", status);
334 nfs_proc_remove(
struct inode *dir,
struct qstr *name)
348 nfs_mark_for_revalidate(dir);
350 dprintk(
"NFS reply remove: %d\n", status);
355 nfs_proc_unlink_setup(
struct rpc_message *msg,
struct inode *dir)
365 static int nfs_proc_unlink_done(
struct rpc_task *
task,
struct inode *dir)
367 if (nfs_async_handle_expired_key(task))
369 nfs_mark_for_revalidate(dir);
374 nfs_proc_rename_setup(
struct rpc_message *msg,
struct inode *dir)
385 nfs_proc_rename_done(
struct rpc_task *task,
struct inode *old_dir,
386 struct inode *new_dir)
388 if (nfs_async_handle_expired_key(task))
390 nfs_mark_for_revalidate(old_dir);
391 nfs_mark_for_revalidate(new_dir);
396 nfs_proc_rename(
struct inode *old_dir,
struct qstr *old_name,
397 struct inode *new_dir,
struct qstr *new_name)
400 .old_dir = NFS_FH(old_dir),
402 .new_dir = NFS_FH(new_dir),
413 nfs_mark_for_revalidate(old_dir);
414 nfs_mark_for_revalidate(new_dir);
415 dprintk(
"NFS reply rename: %d\n", status);
420 nfs_proc_link(
struct inode *inode,
struct inode *dir,
struct qstr *name)
423 .fromfh = NFS_FH(inode),
425 .toname = name->
name,
436 nfs_mark_for_revalidate(inode);
437 nfs_mark_for_revalidate(dir);
438 dprintk(
"NFS reply link: %d\n", status);
443 nfs_proc_symlink(
struct inode *dir,
struct dentry *dentry,
struct page *page,
444 unsigned int len,
struct iattr *sattr)
450 .fromname = dentry->
d_name.name,
451 .fromlen = dentry->
d_name.len,
474 nfs_mark_for_revalidate(dir);
485 nfs_free_fattr(fattr);
486 nfs_free_fhandle(fh);
488 dprintk(
"NFS reply symlink: %d\n", status);
493 nfs_proc_mkdir(
struct inode *dir,
struct dentry *dentry,
struct iattr *sattr)
502 data = nfs_alloc_createdata(dir, dentry, sattr);
509 nfs_mark_for_revalidate(dir);
512 nfs_free_createdata(data);
514 dprintk(
"NFS reply mkdir: %d\n", status);
519 nfs_proc_rmdir(
struct inode *dir,
struct qstr *name)
534 nfs_mark_for_revalidate(dir);
535 dprintk(
"NFS reply rmdir: %d\n", status);
547 nfs_proc_readdir(
struct dentry *dentry,
struct rpc_cred *
cred,
550 struct inode *dir = dentry->
d_inode;
564 dprintk(
"NFS call readdir %d\n", (
unsigned int)cookie);
569 dprintk(
"NFS reply readdir: %d\n", status);
588 dprintk(
"NFS reply statfs: %d\n", status);
591 stat->
tbytes = (
u64)fsinfo.blocks * fsinfo.bsize;
592 stat->
fbytes = (
u64)fsinfo.bfree * fsinfo.bsize;
593 stat->
abytes = (
u64)fsinfo.bavail * fsinfo.bsize;
616 dprintk(
"NFS reply fsinfo: %d\n", status);
620 info->
rtpref = fsinfo.tsize;
621 info->
rtmult = fsinfo.bsize;
623 info->
wtpref = fsinfo.tsize;
624 info->
wtmult = fsinfo.bsize;
625 info->
dtpref = fsinfo.tsize;
643 struct inode *inode = data->
header->inode;
645 if (nfs_async_handle_expired_key(task))
654 if (data->
args.offset + data->
res.count >= data->
res.fattr->size)
672 struct inode *inode = data->
header->inode;
674 if (nfs_async_handle_expired_key(task))
708 struct inode *inode = filp->
f_path.dentry->d_inode;
710 return nlmclnt_proc(NFS_SERVER(inode)->nlm_host, cmd, fl);
714 #define NFS_LOCK32_OFFSET_MAX ((__s32)0x7fffffffUL)
715 static int nfs_lock_check_bounds(
const struct file_lock *fl)
730 if (start < 0 || start > end)
737 static int nfs_have_delegation(
struct inode *inode,
fmode_t flags)
742 static int nfs_return_delegation(
struct inode *inode)
772 .dir_inode_ops = &nfs_dir_inode_operations,
773 .file_inode_ops = &nfs_file_inode_operations,
775 .getroot = nfs_proc_get_root,
778 .getattr = nfs_proc_getattr,
779 .setattr = nfs_proc_setattr,
780 .lookup = nfs_proc_lookup,
782 .readlink = nfs_proc_readlink,
783 .create = nfs_proc_create,
784 .remove = nfs_proc_remove,
785 .unlink_setup = nfs_proc_unlink_setup,
786 .unlink_rpc_prepare = nfs_proc_unlink_rpc_prepare,
787 .unlink_done = nfs_proc_unlink_done,
788 .rename = nfs_proc_rename,
789 .rename_setup = nfs_proc_rename_setup,
790 .rename_rpc_prepare = nfs_proc_rename_rpc_prepare,
791 .rename_done = nfs_proc_rename_done,
792 .link = nfs_proc_link,
793 .symlink = nfs_proc_symlink,
794 .mkdir = nfs_proc_mkdir,
795 .rmdir = nfs_proc_rmdir,
796 .readdir = nfs_proc_readdir,
797 .mknod = nfs_proc_mknod,
798 .statfs = nfs_proc_statfs,
799 .fsinfo = nfs_proc_fsinfo,
800 .pathconf = nfs_proc_pathconf,
802 .read_setup = nfs_proc_read_setup,
804 .read_rpc_prepare = nfs_proc_read_rpc_prepare,
805 .read_done = nfs_read_done,
806 .write_setup = nfs_proc_write_setup,
808 .write_rpc_prepare = nfs_proc_write_rpc_prepare,
809 .write_done = nfs_write_done,
810 .commit_setup = nfs_proc_commit_setup,
811 .commit_rpc_prepare = nfs_proc_commit_rpc_prepare,
812 .lock = nfs_proc_lock,
813 .lock_check_bounds = nfs_lock_check_bounds,
815 .have_delegation = nfs_have_delegation,
816 .return_delegation = nfs_return_delegation,