]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blobdiff - fs/nfs/inode.c
NFS: Convert v2 into a module
[mirror_ubuntu-jammy-kernel.git] / fs / nfs / inode.c
index e605d695dbcb7b746d633f37e5ceb509deb7b790..f358b976e9e683167dd51855ed28d090f1238a95 100644 (file)
@@ -32,7 +32,6 @@
 #include <linux/lockd/bind.h>
 #include <linux/seq_file.h>
 #include <linux/mount.h>
-#include <linux/nfs_idmap.h>
 #include <linux/vfs.h>
 #include <linux/inet.h>
 #include <linux/nfs_xdr.h>
@@ -51,6 +50,7 @@
 #include "fscache.h"
 #include "dns_resolve.h"
 #include "pnfs.h"
+#include "nfs.h"
 #include "netns.h"
 
 #define NFSDBG_FACILITY                NFSDBG_VFS
@@ -106,7 +106,7 @@ u64 nfs_compat_user_ino64(u64 fileid)
        return ino;
 }
 
-static void nfs_clear_inode(struct inode *inode)
+void nfs_clear_inode(struct inode *inode)
 {
        /*
         * The following should never happen...
@@ -193,6 +193,7 @@ void nfs_invalidate_atime(struct inode *inode)
        NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME;
        spin_unlock(&inode->i_lock);
 }
+EXPORT_SYMBOL_GPL(nfs_invalidate_atime);
 
 /*
  * Invalidate, but do not unhash, the inode.
@@ -430,7 +431,7 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
         * Return any delegations if we're going to change ACLs
         */
        if ((attr->ia_valid & (ATTR_MODE|ATTR_UID|ATTR_GID)) != 0)
-               nfs_inode_return_delegation(inode);
+               NFS_PROTO(inode)->return_delegation(inode);
        error = NFS_PROTO(inode)->setattr(dentry, fattr, attr);
        if (error == 0)
                nfs_refresh_inode(inode, fattr);
@@ -438,6 +439,7 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
 out:
        return error;
 }
+EXPORT_SYMBOL_GPL(nfs_setattr);
 
 /**
  * nfs_vmtruncate - unmap mappings "freed" by truncate() syscall
@@ -496,6 +498,7 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr)
                nfs_vmtruncate(inode, attr->ia_size);
        }
 }
+EXPORT_SYMBOL_GPL(nfs_setattr_update_inode);
 
 int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
 {
@@ -535,6 +538,7 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
 out:
        return err;
 }
+EXPORT_SYMBOL_GPL(nfs_getattr);
 
 static void nfs_init_lock_context(struct nfs_lock_context *l_ctx)
 {
@@ -623,6 +627,7 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync)
                return;
        nfs_revalidate_inode(server, inode);
 }
+EXPORT_SYMBOL_GPL(nfs_close_context);
 
 struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f_mode)
 {
@@ -1028,6 +1033,7 @@ void nfs_fattr_init(struct nfs_fattr *fattr)
        fattr->owner_name = NULL;
        fattr->group_name = NULL;
 }
+EXPORT_SYMBOL_GPL(nfs_fattr_init);
 
 struct nfs_fattr *nfs_alloc_fattr(void)
 {
@@ -1038,6 +1044,7 @@ struct nfs_fattr *nfs_alloc_fattr(void)
                nfs_fattr_init(fattr);
        return fattr;
 }
+EXPORT_SYMBOL_GPL(nfs_alloc_fattr);
 
 struct nfs_fh *nfs_alloc_fhandle(void)
 {
@@ -1048,6 +1055,7 @@ struct nfs_fh *nfs_alloc_fhandle(void)
                fh->size = 0;
        return fh;
 }
+EXPORT_SYMBOL_GPL(nfs_alloc_fhandle);
 
 #ifdef NFS_DEBUG
 /*
@@ -1168,6 +1176,7 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
 
        return status;
 }
+EXPORT_SYMBOL_GPL(nfs_refresh_inode);
 
 static int nfs_post_op_update_inode_locked(struct inode *inode, struct nfs_fattr *fattr)
 {
@@ -1255,6 +1264,7 @@ out_noforce:
        spin_unlock(&inode->i_lock);
        return status;
 }
+EXPORT_SYMBOL_GPL(nfs_post_op_update_inode_force_wcc);
 
 /*
  * Many nfs protocol calls return the new file attributes after
@@ -1457,7 +1467,7 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
        if (!(S_ISREG(inode->i_mode) || S_ISDIR(inode->i_mode)
                                || S_ISLNK(inode->i_mode)))
                invalid &= ~NFS_INO_INVALID_DATA;
-       if (!nfs_have_delegation(inode, FMODE_READ) ||
+       if (!NFS_PROTO(inode)->have_delegation(inode, FMODE_READ) ||
                        (save_cache_validity & NFS_INO_REVAL_FORCED))
                nfsi->cache_validity |= invalid;
 
@@ -1472,27 +1482,6 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr)
        return -ESTALE;
 }
 
-
-#ifdef CONFIG_NFS_V4
-
-/*
- * Clean out any remaining NFSv4 state that might be left over due
- * to open() calls that passed nfs_atomic_lookup, but failed to call
- * nfs_open().
- */
-void nfs4_evict_inode(struct inode *inode)
-{
-       truncate_inode_pages(&inode->i_data, 0);
-       clear_inode(inode);
-       pnfs_return_layout(inode);
-       pnfs_destroy_layout(NFS_I(inode));
-       /* If we are holding a delegation, return it! */
-       nfs_inode_return_delegation_noreclaim(inode);
-       /* First call standard NFS clear_inode() code */
-       nfs_clear_inode(inode);
-}
-#endif
-
 struct inode *nfs_alloc_inode(struct super_block *sb)
 {
        struct nfs_inode *nfsi;
@@ -1530,7 +1519,6 @@ static inline void nfs4_init_once(struct nfs_inode *nfsi)
        nfsi->delegation_state = 0;
        init_rwsem(&nfsi->rwsem);
        nfsi->layout = NULL;
-       atomic_set(&nfsi->commit_info.rpcs_out, 0);
 #endif
 }
 
@@ -1545,6 +1533,7 @@ static void init_once(void *foo)
        INIT_LIST_HEAD(&nfsi->commit_info.list);
        nfsi->npages = 0;
        nfsi->commit_info.ncommit = 0;
+       atomic_set(&nfsi->commit_info.rpcs_out, 0);
        atomic_set(&nfsi->silly_count, 1);
        INIT_HLIST_HEAD(&nfsi->silly_list);
        init_waitqueue_head(&nfsi->waitqueue);
@@ -1628,87 +1617,92 @@ static int __init init_nfs_fs(void)
 {
        int err;
 
-       err = nfs_idmap_init();
-       if (err < 0)
-               goto out10;
-
        err = nfs_dns_resolver_init();
        if (err < 0)
-               goto out9;
+               goto out11;
 
        err = register_pernet_subsys(&nfs_net_ops);
        if (err < 0)
-               goto out8;
+               goto out10;
 
        err = nfs_fscache_register();
        if (err < 0)
-               goto out7;
+               goto out9;
 
        err = nfsiod_start();
        if (err)
-               goto out6;
+               goto out8;
 
        err = nfs_fs_proc_init();
        if (err)
-               goto out5;
+               goto out7;
 
        err = nfs_init_nfspagecache();
        if (err)
-               goto out4;
+               goto out6;
 
        err = nfs_init_inodecache();
        if (err)
-               goto out3;
+               goto out5;
 
        err = nfs_init_readpagecache();
        if (err)
-               goto out2;
+               goto out4;
 
        err = nfs_init_writepagecache();
        if (err)
-               goto out1;
+               goto out3;
 
        err = nfs_init_directcache();
        if (err)
-               goto out0;
+               goto out2;
 
 #ifdef CONFIG_PROC_FS
        rpc_proc_register(&init_net, &nfs_rpcstat);
 #endif
+
+       err = nfs_register_versions();
+       if (err)
+               goto out1;
+
        if ((err = register_nfs_fs()) != 0)
-               goto out;
+               goto out0;
+
        return 0;
-out:
+out0:
+       nfs_unregister_versions();
+out1:
 #ifdef CONFIG_PROC_FS
        rpc_proc_unregister(&init_net, "nfs");
 #endif
        nfs_destroy_directcache();
-out0:
-       nfs_destroy_writepagecache();
-out1:
-       nfs_destroy_readpagecache();
 out2:
-       nfs_destroy_inodecache();
+       nfs_destroy_writepagecache();
 out3:
-       nfs_destroy_nfspagecache();
+       nfs_destroy_readpagecache();
 out4:
-       nfs_fs_proc_exit();
+       nfs_destroy_inodecache();
 out5:
-       nfsiod_stop();
+       nfs_destroy_nfspagecache();
 out6:
-       nfs_fscache_unregister();
+       nfs_fs_proc_exit();
 out7:
-       unregister_pernet_subsys(&nfs_net_ops);
+       nfsiod_stop();
 out8:
-       nfs_dns_resolver_destroy();
+       nfs_fscache_unregister();
 out9:
-       nfs_idmap_quit();
+       unregister_pernet_subsys(&nfs_net_ops);
 out10:
+       nfs_dns_resolver_destroy();
+out11:
        return err;
 }
 
 static void __exit exit_nfs_fs(void)
 {
+#ifdef CONFIG_NFS_V4
+       exit_nfs_v4();
+#endif
        nfs_destroy_directcache();
        nfs_destroy_writepagecache();
        nfs_destroy_readpagecache();
@@ -1717,7 +1711,6 @@ static void __exit exit_nfs_fs(void)
        nfs_fscache_unregister();
        unregister_pernet_subsys(&nfs_net_ops);
        nfs_dns_resolver_destroy();
-       nfs_idmap_quit();
 #ifdef CONFIG_PROC_FS
        rpc_proc_unregister(&init_net, "nfs");
 #endif