diff options
Diffstat (limited to 'fs/nfs/inode.c')
-rw-r--r-- | fs/nfs/inode.c | 105 |
1 files changed, 47 insertions, 58 deletions
diff --git a/fs/nfs/inode.c b/fs/nfs/inode.c index 35f7e4bc680e..2ed6138f32ad 100644 --- a/fs/nfs/inode.c +++ b/fs/nfs/inode.c | |||
@@ -50,6 +50,7 @@ | |||
50 | #include "fscache.h" | 50 | #include "fscache.h" |
51 | #include "dns_resolve.h" | 51 | #include "dns_resolve.h" |
52 | #include "pnfs.h" | 52 | #include "pnfs.h" |
53 | #include "nfs.h" | ||
53 | #include "netns.h" | 54 | #include "netns.h" |
54 | 55 | ||
55 | #define NFSDBG_FACILITY NFSDBG_VFS | 56 | #define NFSDBG_FACILITY NFSDBG_VFS |
@@ -81,6 +82,7 @@ int nfs_wait_bit_killable(void *word) | |||
81 | freezable_schedule(); | 82 | freezable_schedule(); |
82 | return 0; | 83 | return 0; |
83 | } | 84 | } |
85 | EXPORT_SYMBOL_GPL(nfs_wait_bit_killable); | ||
84 | 86 | ||
85 | /** | 87 | /** |
86 | * nfs_compat_user_ino64 - returns the user-visible inode number | 88 | * nfs_compat_user_ino64 - returns the user-visible inode number |
@@ -105,7 +107,7 @@ u64 nfs_compat_user_ino64(u64 fileid) | |||
105 | return ino; | 107 | return ino; |
106 | } | 108 | } |
107 | 109 | ||
108 | static void nfs_clear_inode(struct inode *inode) | 110 | void nfs_clear_inode(struct inode *inode) |
109 | { | 111 | { |
110 | /* | 112 | /* |
111 | * The following should never happen... | 113 | * The following should never happen... |
@@ -116,6 +118,7 @@ static void nfs_clear_inode(struct inode *inode) | |||
116 | nfs_access_zap_cache(inode); | 118 | nfs_access_zap_cache(inode); |
117 | nfs_fscache_release_inode_cookie(inode); | 119 | nfs_fscache_release_inode_cookie(inode); |
118 | } | 120 | } |
121 | EXPORT_SYMBOL_GPL(nfs_clear_inode); | ||
119 | 122 | ||
120 | void nfs_evict_inode(struct inode *inode) | 123 | void nfs_evict_inode(struct inode *inode) |
121 | { | 124 | { |
@@ -185,6 +188,7 @@ void nfs_zap_acl_cache(struct inode *inode) | |||
185 | NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_ACL; | 188 | NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_ACL; |
186 | spin_unlock(&inode->i_lock); | 189 | spin_unlock(&inode->i_lock); |
187 | } | 190 | } |
191 | EXPORT_SYMBOL_GPL(nfs_zap_acl_cache); | ||
188 | 192 | ||
189 | void nfs_invalidate_atime(struct inode *inode) | 193 | void nfs_invalidate_atime(struct inode *inode) |
190 | { | 194 | { |
@@ -192,6 +196,7 @@ void nfs_invalidate_atime(struct inode *inode) | |||
192 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME; | 196 | NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME; |
193 | spin_unlock(&inode->i_lock); | 197 | spin_unlock(&inode->i_lock); |
194 | } | 198 | } |
199 | EXPORT_SYMBOL_GPL(nfs_invalidate_atime); | ||
195 | 200 | ||
196 | /* | 201 | /* |
197 | * Invalidate, but do not unhash, the inode. | 202 | * Invalidate, but do not unhash, the inode. |
@@ -390,6 +395,7 @@ out_no_inode: | |||
390 | dprintk("nfs_fhget: iget failed with error %ld\n", PTR_ERR(inode)); | 395 | dprintk("nfs_fhget: iget failed with error %ld\n", PTR_ERR(inode)); |
391 | goto out; | 396 | goto out; |
392 | } | 397 | } |
398 | EXPORT_SYMBOL_GPL(nfs_fhget); | ||
393 | 399 | ||
394 | #define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET|ATTR_FILE|ATTR_OPEN) | 400 | #define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET|ATTR_FILE|ATTR_OPEN) |
395 | 401 | ||
@@ -437,6 +443,7 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr) | |||
437 | out: | 443 | out: |
438 | return error; | 444 | return error; |
439 | } | 445 | } |
446 | EXPORT_SYMBOL_GPL(nfs_setattr); | ||
440 | 447 | ||
441 | /** | 448 | /** |
442 | * nfs_vmtruncate - unmap mappings "freed" by truncate() syscall | 449 | * nfs_vmtruncate - unmap mappings "freed" by truncate() syscall |
@@ -495,6 +502,7 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr) | |||
495 | nfs_vmtruncate(inode, attr->ia_size); | 502 | nfs_vmtruncate(inode, attr->ia_size); |
496 | } | 503 | } |
497 | } | 504 | } |
505 | EXPORT_SYMBOL_GPL(nfs_setattr_update_inode); | ||
498 | 506 | ||
499 | int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) | 507 | int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) |
500 | { | 508 | { |
@@ -534,6 +542,7 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat) | |||
534 | out: | 542 | out: |
535 | return err; | 543 | return err; |
536 | } | 544 | } |
545 | EXPORT_SYMBOL_GPL(nfs_getattr); | ||
537 | 546 | ||
538 | static void nfs_init_lock_context(struct nfs_lock_context *l_ctx) | 547 | static void nfs_init_lock_context(struct nfs_lock_context *l_ctx) |
539 | { | 548 | { |
@@ -622,6 +631,7 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync) | |||
622 | return; | 631 | return; |
623 | nfs_revalidate_inode(server, inode); | 632 | nfs_revalidate_inode(server, inode); |
624 | } | 633 | } |
634 | EXPORT_SYMBOL_GPL(nfs_close_context); | ||
625 | 635 | ||
626 | struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f_mode) | 636 | struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f_mode) |
627 | { | 637 | { |
@@ -648,6 +658,7 @@ struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f | |||
648 | ctx->mdsthreshold = NULL; | 658 | ctx->mdsthreshold = NULL; |
649 | return ctx; | 659 | return ctx; |
650 | } | 660 | } |
661 | EXPORT_SYMBOL_GPL(alloc_nfs_open_context); | ||
651 | 662 | ||
652 | struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx) | 663 | struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx) |
653 | { | 664 | { |
@@ -655,6 +666,7 @@ struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx) | |||
655 | atomic_inc(&ctx->lock_context.count); | 666 | atomic_inc(&ctx->lock_context.count); |
656 | return ctx; | 667 | return ctx; |
657 | } | 668 | } |
669 | EXPORT_SYMBOL_GPL(get_nfs_open_context); | ||
658 | 670 | ||
659 | static void __put_nfs_open_context(struct nfs_open_context *ctx, int is_sync) | 671 | static void __put_nfs_open_context(struct nfs_open_context *ctx, int is_sync) |
660 | { | 672 | { |
@@ -682,6 +694,7 @@ void put_nfs_open_context(struct nfs_open_context *ctx) | |||
682 | { | 694 | { |
683 | __put_nfs_open_context(ctx, 0); | 695 | __put_nfs_open_context(ctx, 0); |
684 | } | 696 | } |
697 | EXPORT_SYMBOL_GPL(put_nfs_open_context); | ||
685 | 698 | ||
686 | /* | 699 | /* |
687 | * Ensure that mmap has a recent RPC credential for use when writing out | 700 | * Ensure that mmap has a recent RPC credential for use when writing out |
@@ -697,6 +710,7 @@ void nfs_file_set_open_context(struct file *filp, struct nfs_open_context *ctx) | |||
697 | list_add(&ctx->list, &nfsi->open_files); | 710 | list_add(&ctx->list, &nfsi->open_files); |
698 | spin_unlock(&inode->i_lock); | 711 | spin_unlock(&inode->i_lock); |
699 | } | 712 | } |
713 | EXPORT_SYMBOL_GPL(nfs_file_set_open_context); | ||
700 | 714 | ||
701 | /* | 715 | /* |
702 | * Given an inode, search for an open context with the desired characteristics | 716 | * Given an inode, search for an open context with the desired characteristics |
@@ -841,6 +855,7 @@ int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode) | |||
841 | return NFS_STALE(inode) ? -ESTALE : 0; | 855 | return NFS_STALE(inode) ? -ESTALE : 0; |
842 | return __nfs_revalidate_inode(server, inode); | 856 | return __nfs_revalidate_inode(server, inode); |
843 | } | 857 | } |
858 | EXPORT_SYMBOL_GPL(nfs_revalidate_inode); | ||
844 | 859 | ||
845 | static int nfs_invalidate_mapping(struct inode *inode, struct address_space *mapping) | 860 | static int nfs_invalidate_mapping(struct inode *inode, struct address_space *mapping) |
846 | { | 861 | { |
@@ -1027,6 +1042,7 @@ void nfs_fattr_init(struct nfs_fattr *fattr) | |||
1027 | fattr->owner_name = NULL; | 1042 | fattr->owner_name = NULL; |
1028 | fattr->group_name = NULL; | 1043 | fattr->group_name = NULL; |
1029 | } | 1044 | } |
1045 | EXPORT_SYMBOL_GPL(nfs_fattr_init); | ||
1030 | 1046 | ||
1031 | struct nfs_fattr *nfs_alloc_fattr(void) | 1047 | struct nfs_fattr *nfs_alloc_fattr(void) |
1032 | { | 1048 | { |
@@ -1037,6 +1053,7 @@ struct nfs_fattr *nfs_alloc_fattr(void) | |||
1037 | nfs_fattr_init(fattr); | 1053 | nfs_fattr_init(fattr); |
1038 | return fattr; | 1054 | return fattr; |
1039 | } | 1055 | } |
1056 | EXPORT_SYMBOL_GPL(nfs_alloc_fattr); | ||
1040 | 1057 | ||
1041 | struct nfs_fh *nfs_alloc_fhandle(void) | 1058 | struct nfs_fh *nfs_alloc_fhandle(void) |
1042 | { | 1059 | { |
@@ -1047,6 +1064,7 @@ struct nfs_fh *nfs_alloc_fhandle(void) | |||
1047 | fh->size = 0; | 1064 | fh->size = 0; |
1048 | return fh; | 1065 | return fh; |
1049 | } | 1066 | } |
1067 | EXPORT_SYMBOL_GPL(nfs_alloc_fhandle); | ||
1050 | 1068 | ||
1051 | #ifdef NFS_DEBUG | 1069 | #ifdef NFS_DEBUG |
1052 | /* | 1070 | /* |
@@ -1167,6 +1185,7 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1167 | 1185 | ||
1168 | return status; | 1186 | return status; |
1169 | } | 1187 | } |
1188 | EXPORT_SYMBOL_GPL(nfs_refresh_inode); | ||
1170 | 1189 | ||
1171 | static int nfs_post_op_update_inode_locked(struct inode *inode, struct nfs_fattr *fattr) | 1190 | static int nfs_post_op_update_inode_locked(struct inode *inode, struct nfs_fattr *fattr) |
1172 | { | 1191 | { |
@@ -1203,6 +1222,7 @@ int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1203 | spin_unlock(&inode->i_lock); | 1222 | spin_unlock(&inode->i_lock); |
1204 | return status; | 1223 | return status; |
1205 | } | 1224 | } |
1225 | EXPORT_SYMBOL_GPL(nfs_post_op_update_inode); | ||
1206 | 1226 | ||
1207 | /** | 1227 | /** |
1208 | * nfs_post_op_update_inode_force_wcc - try to update the inode attribute cache | 1228 | * nfs_post_op_update_inode_force_wcc - try to update the inode attribute cache |
@@ -1254,6 +1274,7 @@ out_noforce: | |||
1254 | spin_unlock(&inode->i_lock); | 1274 | spin_unlock(&inode->i_lock); |
1255 | return status; | 1275 | return status; |
1256 | } | 1276 | } |
1277 | EXPORT_SYMBOL_GPL(nfs_post_op_update_inode_force_wcc); | ||
1257 | 1278 | ||
1258 | /* | 1279 | /* |
1259 | * Many nfs protocol calls return the new file attributes after | 1280 | * Many nfs protocol calls return the new file attributes after |
@@ -1471,27 +1492,6 @@ static int nfs_update_inode(struct inode *inode, struct nfs_fattr *fattr) | |||
1471 | return -ESTALE; | 1492 | return -ESTALE; |
1472 | } | 1493 | } |
1473 | 1494 | ||
1474 | |||
1475 | #ifdef CONFIG_NFS_V4 | ||
1476 | |||
1477 | /* | ||
1478 | * Clean out any remaining NFSv4 state that might be left over due | ||
1479 | * to open() calls that passed nfs_atomic_lookup, but failed to call | ||
1480 | * nfs_open(). | ||
1481 | */ | ||
1482 | void nfs4_evict_inode(struct inode *inode) | ||
1483 | { | ||
1484 | truncate_inode_pages(&inode->i_data, 0); | ||
1485 | clear_inode(inode); | ||
1486 | pnfs_return_layout(inode); | ||
1487 | pnfs_destroy_layout(NFS_I(inode)); | ||
1488 | /* If we are holding a delegation, return it! */ | ||
1489 | nfs_inode_return_delegation_noreclaim(inode); | ||
1490 | /* First call standard NFS clear_inode() code */ | ||
1491 | nfs_clear_inode(inode); | ||
1492 | } | ||
1493 | #endif | ||
1494 | |||
1495 | struct inode *nfs_alloc_inode(struct super_block *sb) | 1495 | struct inode *nfs_alloc_inode(struct super_block *sb) |
1496 | { | 1496 | { |
1497 | struct nfs_inode *nfsi; | 1497 | struct nfs_inode *nfsi; |
@@ -1504,11 +1504,12 @@ struct inode *nfs_alloc_inode(struct super_block *sb) | |||
1504 | nfsi->acl_access = ERR_PTR(-EAGAIN); | 1504 | nfsi->acl_access = ERR_PTR(-EAGAIN); |
1505 | nfsi->acl_default = ERR_PTR(-EAGAIN); | 1505 | nfsi->acl_default = ERR_PTR(-EAGAIN); |
1506 | #endif | 1506 | #endif |
1507 | #ifdef CONFIG_NFS_V4 | 1507 | #if IS_ENABLED(CONFIG_NFS_V4) |
1508 | nfsi->nfs4_acl = NULL; | 1508 | nfsi->nfs4_acl = NULL; |
1509 | #endif /* CONFIG_NFS_V4 */ | 1509 | #endif /* CONFIG_NFS_V4 */ |
1510 | return &nfsi->vfs_inode; | 1510 | return &nfsi->vfs_inode; |
1511 | } | 1511 | } |
1512 | EXPORT_SYMBOL_GPL(nfs_alloc_inode); | ||
1512 | 1513 | ||
1513 | static void nfs_i_callback(struct rcu_head *head) | 1514 | static void nfs_i_callback(struct rcu_head *head) |
1514 | { | 1515 | { |
@@ -1520,10 +1521,11 @@ void nfs_destroy_inode(struct inode *inode) | |||
1520 | { | 1521 | { |
1521 | call_rcu(&inode->i_rcu, nfs_i_callback); | 1522 | call_rcu(&inode->i_rcu, nfs_i_callback); |
1522 | } | 1523 | } |
1524 | EXPORT_SYMBOL_GPL(nfs_destroy_inode); | ||
1523 | 1525 | ||
1524 | static inline void nfs4_init_once(struct nfs_inode *nfsi) | 1526 | static inline void nfs4_init_once(struct nfs_inode *nfsi) |
1525 | { | 1527 | { |
1526 | #ifdef CONFIG_NFS_V4 | 1528 | #if IS_ENABLED(CONFIG_NFS_V4) |
1527 | INIT_LIST_HEAD(&nfsi->open_states); | 1529 | INIT_LIST_HEAD(&nfsi->open_states); |
1528 | nfsi->delegation = NULL; | 1530 | nfsi->delegation = NULL; |
1529 | nfsi->delegation_state = 0; | 1531 | nfsi->delegation_state = 0; |
@@ -1569,6 +1571,7 @@ static void nfs_destroy_inodecache(void) | |||
1569 | } | 1571 | } |
1570 | 1572 | ||
1571 | struct workqueue_struct *nfsiod_workqueue; | 1573 | struct workqueue_struct *nfsiod_workqueue; |
1574 | EXPORT_SYMBOL_GPL(nfsiod_workqueue); | ||
1572 | 1575 | ||
1573 | /* | 1576 | /* |
1574 | * start up the nfsiod workqueue | 1577 | * start up the nfsiod workqueue |
@@ -1629,94 +1632,80 @@ static int __init init_nfs_fs(void) | |||
1629 | 1632 | ||
1630 | err = nfs_dns_resolver_init(); | 1633 | err = nfs_dns_resolver_init(); |
1631 | if (err < 0) | 1634 | if (err < 0) |
1632 | goto out11; | 1635 | goto out10;; |
1633 | 1636 | ||
1634 | err = register_pernet_subsys(&nfs_net_ops); | 1637 | err = register_pernet_subsys(&nfs_net_ops); |
1635 | if (err < 0) | 1638 | if (err < 0) |
1636 | goto out10; | 1639 | goto out9; |
1637 | 1640 | ||
1638 | err = nfs_fscache_register(); | 1641 | err = nfs_fscache_register(); |
1639 | if (err < 0) | 1642 | if (err < 0) |
1640 | goto out9; | 1643 | goto out8; |
1641 | 1644 | ||
1642 | err = nfsiod_start(); | 1645 | err = nfsiod_start(); |
1643 | if (err) | 1646 | if (err) |
1644 | goto out8; | 1647 | goto out7; |
1645 | 1648 | ||
1646 | err = nfs_fs_proc_init(); | 1649 | err = nfs_fs_proc_init(); |
1647 | if (err) | 1650 | if (err) |
1648 | goto out7; | 1651 | goto out6; |
1649 | 1652 | ||
1650 | err = nfs_init_nfspagecache(); | 1653 | err = nfs_init_nfspagecache(); |
1651 | if (err) | 1654 | if (err) |
1652 | goto out6; | 1655 | goto out5; |
1653 | 1656 | ||
1654 | err = nfs_init_inodecache(); | 1657 | err = nfs_init_inodecache(); |
1655 | if (err) | 1658 | if (err) |
1656 | goto out5; | 1659 | goto out4; |
1657 | 1660 | ||
1658 | err = nfs_init_readpagecache(); | 1661 | err = nfs_init_readpagecache(); |
1659 | if (err) | 1662 | if (err) |
1660 | goto out4; | 1663 | goto out3; |
1661 | 1664 | ||
1662 | err = nfs_init_writepagecache(); | 1665 | err = nfs_init_writepagecache(); |
1663 | if (err) | 1666 | if (err) |
1664 | goto out3; | 1667 | goto out2; |
1665 | 1668 | ||
1666 | err = nfs_init_directcache(); | 1669 | err = nfs_init_directcache(); |
1667 | if (err) | 1670 | if (err) |
1668 | goto out2; | 1671 | goto out1; |
1669 | 1672 | ||
1670 | #ifdef CONFIG_PROC_FS | 1673 | #ifdef CONFIG_PROC_FS |
1671 | rpc_proc_register(&init_net, &nfs_rpcstat); | 1674 | rpc_proc_register(&init_net, &nfs_rpcstat); |
1672 | #endif | 1675 | #endif |
1673 | |||
1674 | #ifdef CONFIG_NFS_V4 | ||
1675 | err = init_nfs_v4(); | ||
1676 | if (err) | ||
1677 | goto out1; | ||
1678 | #endif | ||
1679 | |||
1680 | if ((err = register_nfs_fs()) != 0) | 1676 | if ((err = register_nfs_fs()) != 0) |
1681 | goto out0; | 1677 | goto out0; |
1682 | 1678 | ||
1683 | return 0; | 1679 | return 0; |
1684 | out0: | 1680 | out0: |
1685 | #ifdef CONFIG_NFS_V4 | ||
1686 | exit_nfs_v4(); | ||
1687 | out1: | ||
1688 | #endif | ||
1689 | #ifdef CONFIG_PROC_FS | 1681 | #ifdef CONFIG_PROC_FS |
1690 | rpc_proc_unregister(&init_net, "nfs"); | 1682 | rpc_proc_unregister(&init_net, "nfs"); |
1691 | #endif | 1683 | #endif |
1692 | nfs_destroy_directcache(); | 1684 | nfs_destroy_directcache(); |
1693 | out2: | 1685 | out1: |
1694 | nfs_destroy_writepagecache(); | 1686 | nfs_destroy_writepagecache(); |
1695 | out3: | 1687 | out2: |
1696 | nfs_destroy_readpagecache(); | 1688 | nfs_destroy_readpagecache(); |
1697 | out4: | 1689 | out3: |
1698 | nfs_destroy_inodecache(); | 1690 | nfs_destroy_inodecache(); |
1699 | out5: | 1691 | out4: |
1700 | nfs_destroy_nfspagecache(); | 1692 | nfs_destroy_nfspagecache(); |
1701 | out6: | 1693 | out5: |
1702 | nfs_fs_proc_exit(); | 1694 | nfs_fs_proc_exit(); |
1703 | out7: | 1695 | out6: |
1704 | nfsiod_stop(); | 1696 | nfsiod_stop(); |
1705 | out8: | 1697 | out7: |
1706 | nfs_fscache_unregister(); | 1698 | nfs_fscache_unregister(); |
1707 | out9: | 1699 | out8: |
1708 | unregister_pernet_subsys(&nfs_net_ops); | 1700 | unregister_pernet_subsys(&nfs_net_ops); |
1709 | out10: | 1701 | out9: |
1710 | nfs_dns_resolver_destroy(); | 1702 | nfs_dns_resolver_destroy(); |
1711 | out11: | 1703 | out10: |
1712 | return err; | 1704 | return err; |
1713 | } | 1705 | } |
1714 | 1706 | ||
1715 | static void __exit exit_nfs_fs(void) | 1707 | static void __exit exit_nfs_fs(void) |
1716 | { | 1708 | { |
1717 | #ifdef CONFIG_NFS_V4 | ||
1718 | exit_nfs_v4(); | ||
1719 | #endif | ||
1720 | nfs_destroy_directcache(); | 1709 | nfs_destroy_directcache(); |
1721 | nfs_destroy_writepagecache(); | 1710 | nfs_destroy_writepagecache(); |
1722 | nfs_destroy_readpagecache(); | 1711 | nfs_destroy_readpagecache(); |