aboutsummaryrefslogtreecommitdiffstats
path: root/fs/nfs/dir.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/nfs/dir.c')
-rw-r--r--fs/nfs/dir.c107
1 files changed, 17 insertions, 90 deletions
diff --git a/fs/nfs/dir.c b/fs/nfs/dir.c
index a6b1c7fb8232..d49f1b9cd3fd 100644
--- a/fs/nfs/dir.c
+++ b/fs/nfs/dir.c
@@ -46,16 +46,6 @@
46static int nfs_opendir(struct inode *, struct file *); 46static int nfs_opendir(struct inode *, struct file *);
47static int nfs_closedir(struct inode *, struct file *); 47static int nfs_closedir(struct inode *, struct file *);
48static int nfs_readdir(struct file *, void *, filldir_t); 48static int nfs_readdir(struct file *, void *, filldir_t);
49static struct dentry *nfs_lookup(struct inode *, struct dentry *, unsigned int);
50static int nfs_create(struct inode *, struct dentry *, umode_t, bool);
51static int nfs_mkdir(struct inode *, struct dentry *, umode_t);
52static int nfs_rmdir(struct inode *, struct dentry *);
53static int nfs_unlink(struct inode *, struct dentry *);
54static int nfs_symlink(struct inode *, struct dentry *, const char *);
55static int nfs_link(struct dentry *, struct inode *, struct dentry *);
56static int nfs_mknod(struct inode *, struct dentry *, umode_t, dev_t);
57static int nfs_rename(struct inode *, struct dentry *,
58 struct inode *, struct dentry *);
59static int nfs_fsync_dir(struct file *, loff_t, loff_t, int); 49static int nfs_fsync_dir(struct file *, loff_t, loff_t, int);
60static loff_t nfs_llseek_dir(struct file *, loff_t, int); 50static loff_t nfs_llseek_dir(struct file *, loff_t, int);
61static void nfs_readdir_clear_array(struct page*); 51static void nfs_readdir_clear_array(struct page*);
@@ -69,73 +59,10 @@ const struct file_operations nfs_dir_operations = {
69 .fsync = nfs_fsync_dir, 59 .fsync = nfs_fsync_dir,
70}; 60};
71 61
72const struct inode_operations nfs_dir_inode_operations = {
73 .create = nfs_create,
74 .lookup = nfs_lookup,
75 .link = nfs_link,
76 .unlink = nfs_unlink,
77 .symlink = nfs_symlink,
78 .mkdir = nfs_mkdir,
79 .rmdir = nfs_rmdir,
80 .mknod = nfs_mknod,
81 .rename = nfs_rename,
82 .permission = nfs_permission,
83 .getattr = nfs_getattr,
84 .setattr = nfs_setattr,
85};
86
87const struct address_space_operations nfs_dir_aops = { 62const struct address_space_operations nfs_dir_aops = {
88 .freepage = nfs_readdir_clear_array, 63 .freepage = nfs_readdir_clear_array,
89}; 64};
90 65
91#ifdef CONFIG_NFS_V3
92const struct inode_operations nfs3_dir_inode_operations = {
93 .create = nfs_create,
94 .lookup = nfs_lookup,
95 .link = nfs_link,
96 .unlink = nfs_unlink,
97 .symlink = nfs_symlink,
98 .mkdir = nfs_mkdir,
99 .rmdir = nfs_rmdir,
100 .mknod = nfs_mknod,
101 .rename = nfs_rename,
102 .permission = nfs_permission,
103 .getattr = nfs_getattr,
104 .setattr = nfs_setattr,
105 .listxattr = nfs3_listxattr,
106 .getxattr = nfs3_getxattr,
107 .setxattr = nfs3_setxattr,
108 .removexattr = nfs3_removexattr,
109};
110#endif /* CONFIG_NFS_V3 */
111
112#ifdef CONFIG_NFS_V4
113
114static int nfs_atomic_open(struct inode *, struct dentry *,
115 struct file *, unsigned, umode_t,
116 int *);
117const struct inode_operations nfs4_dir_inode_operations = {
118 .create = nfs_create,
119 .lookup = nfs_lookup,
120 .atomic_open = nfs_atomic_open,
121 .link = nfs_link,
122 .unlink = nfs_unlink,
123 .symlink = nfs_symlink,
124 .mkdir = nfs_mkdir,
125 .rmdir = nfs_rmdir,
126 .mknod = nfs_mknod,
127 .rename = nfs_rename,
128 .permission = nfs_permission,
129 .getattr = nfs_getattr,
130 .setattr = nfs_setattr,
131 .getxattr = generic_getxattr,
132 .setxattr = generic_setxattr,
133 .listxattr = generic_listxattr,
134 .removexattr = generic_removexattr,
135};
136
137#endif /* CONFIG_NFS_V4 */
138
139static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode *dir, struct rpc_cred *cred) 66static struct nfs_open_dir_context *alloc_nfs_open_dir_context(struct inode *dir, struct rpc_cred *cred)
140{ 67{
141 struct nfs_open_dir_context *ctx; 68 struct nfs_open_dir_context *ctx;
@@ -1128,7 +1055,7 @@ static int nfs_lookup_revalidate(struct dentry *dentry, unsigned int flags)
1128 goto out_bad; 1055 goto out_bad;
1129 } 1056 }
1130 1057
1131 if (nfs_have_delegation(inode, FMODE_READ)) 1058 if (NFS_PROTO(dir)->have_delegation(inode, FMODE_READ))
1132 goto out_set_verifier; 1059 goto out_set_verifier;
1133 1060
1134 /* Force a full look up iff the parent directory has changed */ 1061 /* Force a full look up iff the parent directory has changed */
@@ -1270,7 +1197,7 @@ const struct dentry_operations nfs_dentry_operations = {
1270 .d_release = nfs_d_release, 1197 .d_release = nfs_d_release,
1271}; 1198};
1272 1199
1273static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned int flags) 1200struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, unsigned int flags)
1274{ 1201{
1275 struct dentry *res; 1202 struct dentry *res;
1276 struct dentry *parent; 1203 struct dentry *parent;
@@ -1398,9 +1325,9 @@ out:
1398 return err; 1325 return err;
1399} 1326}
1400 1327
1401static int nfs_atomic_open(struct inode *dir, struct dentry *dentry, 1328int nfs_atomic_open(struct inode *dir, struct dentry *dentry,
1402 struct file *file, unsigned open_flags, 1329 struct file *file, unsigned open_flags,
1403 umode_t mode, int *opened) 1330 umode_t mode, int *opened)
1404{ 1331{
1405 struct nfs_open_context *ctx; 1332 struct nfs_open_context *ctx;
1406 struct dentry *res; 1333 struct dentry *res;
@@ -1588,7 +1515,7 @@ out_error:
1588 * that the operation succeeded on the server, but an error in the 1515 * that the operation succeeded on the server, but an error in the
1589 * reply path made it appear to have failed. 1516 * reply path made it appear to have failed.
1590 */ 1517 */
1591static int nfs_create(struct inode *dir, struct dentry *dentry, 1518int nfs_create(struct inode *dir, struct dentry *dentry,
1592 umode_t mode, bool excl) 1519 umode_t mode, bool excl)
1593{ 1520{
1594 struct iattr attr; 1521 struct iattr attr;
@@ -1613,7 +1540,7 @@ out_err:
1613/* 1540/*
1614 * See comments for nfs_proc_create regarding failed operations. 1541 * See comments for nfs_proc_create regarding failed operations.
1615 */ 1542 */
1616static int 1543int
1617nfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev) 1544nfs_mknod(struct inode *dir, struct dentry *dentry, umode_t mode, dev_t rdev)
1618{ 1545{
1619 struct iattr attr; 1546 struct iattr attr;
@@ -1640,7 +1567,7 @@ out_err:
1640/* 1567/*
1641 * See comments for nfs_proc_create regarding failed operations. 1568 * See comments for nfs_proc_create regarding failed operations.
1642 */ 1569 */
1643static int nfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode) 1570int nfs_mkdir(struct inode *dir, struct dentry *dentry, umode_t mode)
1644{ 1571{
1645 struct iattr attr; 1572 struct iattr attr;
1646 int error; 1573 int error;
@@ -1666,7 +1593,7 @@ static void nfs_dentry_handle_enoent(struct dentry *dentry)
1666 d_delete(dentry); 1593 d_delete(dentry);
1667} 1594}
1668 1595
1669static int nfs_rmdir(struct inode *dir, struct dentry *dentry) 1596int nfs_rmdir(struct inode *dir, struct dentry *dentry)
1670{ 1597{
1671 int error; 1598 int error;
1672 1599
@@ -1706,7 +1633,7 @@ static int nfs_safe_remove(struct dentry *dentry)
1706 } 1633 }
1707 1634
1708 if (inode != NULL) { 1635 if (inode != NULL) {
1709 nfs_inode_return_delegation(inode); 1636 NFS_PROTO(inode)->return_delegation(inode);
1710 error = NFS_PROTO(dir)->remove(dir, &dentry->d_name); 1637 error = NFS_PROTO(dir)->remove(dir, &dentry->d_name);
1711 /* The VFS may want to delete this inode */ 1638 /* The VFS may want to delete this inode */
1712 if (error == 0) 1639 if (error == 0)
@@ -1725,7 +1652,7 @@ out:
1725 * 1652 *
1726 * If sillyrename() returns 0, we do nothing, otherwise we unlink. 1653 * If sillyrename() returns 0, we do nothing, otherwise we unlink.
1727 */ 1654 */
1728static int nfs_unlink(struct inode *dir, struct dentry *dentry) 1655int nfs_unlink(struct inode *dir, struct dentry *dentry)
1729{ 1656{
1730 int error; 1657 int error;
1731 int need_rehash = 0; 1658 int need_rehash = 0;
@@ -1769,7 +1696,7 @@ static int nfs_unlink(struct inode *dir, struct dentry *dentry)
1769 * now have a new file handle and can instantiate an in-core NFS inode 1696 * now have a new file handle and can instantiate an in-core NFS inode
1770 * and move the raw page into its mapping. 1697 * and move the raw page into its mapping.
1771 */ 1698 */
1772static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname) 1699int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *symname)
1773{ 1700{
1774 struct pagevec lru_pvec; 1701 struct pagevec lru_pvec;
1775 struct page *page; 1702 struct page *page;
@@ -1824,7 +1751,7 @@ static int nfs_symlink(struct inode *dir, struct dentry *dentry, const char *sym
1824 return 0; 1751 return 0;
1825} 1752}
1826 1753
1827static int 1754int
1828nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry) 1755nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
1829{ 1756{
1830 struct inode *inode = old_dentry->d_inode; 1757 struct inode *inode = old_dentry->d_inode;
@@ -1834,7 +1761,7 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
1834 old_dentry->d_parent->d_name.name, old_dentry->d_name.name, 1761 old_dentry->d_parent->d_name.name, old_dentry->d_name.name,
1835 dentry->d_parent->d_name.name, dentry->d_name.name); 1762 dentry->d_parent->d_name.name, dentry->d_name.name);
1836 1763
1837 nfs_inode_return_delegation(inode); 1764 NFS_PROTO(inode)->return_delegation(inode);
1838 1765
1839 d_drop(dentry); 1766 d_drop(dentry);
1840 error = NFS_PROTO(dir)->link(inode, dir, &dentry->d_name); 1767 error = NFS_PROTO(dir)->link(inode, dir, &dentry->d_name);
@@ -1869,7 +1796,7 @@ nfs_link(struct dentry *old_dentry, struct inode *dir, struct dentry *dentry)
1869 * If these conditions are met, we can drop the dentries before doing 1796 * If these conditions are met, we can drop the dentries before doing
1870 * the rename. 1797 * the rename.
1871 */ 1798 */
1872static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry, 1799int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1873 struct inode *new_dir, struct dentry *new_dentry) 1800 struct inode *new_dir, struct dentry *new_dentry)
1874{ 1801{
1875 struct inode *old_inode = old_dentry->d_inode; 1802 struct inode *old_inode = old_dentry->d_inode;
@@ -1918,9 +1845,9 @@ static int nfs_rename(struct inode *old_dir, struct dentry *old_dentry,
1918 } 1845 }
1919 } 1846 }
1920 1847
1921 nfs_inode_return_delegation(old_inode); 1848 NFS_PROTO(old_inode)->return_delegation(old_inode);
1922 if (new_inode != NULL) 1849 if (new_inode != NULL)
1923 nfs_inode_return_delegation(new_inode); 1850 NFS_PROTO(new_inode)->return_delegation(new_inode);
1924 1851
1925 error = NFS_PROTO(old_dir)->rename(old_dir, &old_dentry->d_name, 1852 error = NFS_PROTO(old_dir)->rename(old_dir, &old_dentry->d_name,
1926 new_dir, &new_dentry->d_name); 1853 new_dir, &new_dentry->d_name);