aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2008-08-13 02:23:13 -0400
committerLachlan McIlroy <lachlan@redback.melbourne.sgi.com>2008-08-13 02:23:13 -0400
commit41be8bed1f3168f34386f3a15d63682cfd586b8e (patch)
tree8cddec00890168b807853e5b6761625a3e194f3e /fs
parent5ec7f8c7d14a3ea6bf920b3350f5c5d3527cb837 (diff)
[XFS] sanitize xfs_initialize_vnode
Sanitize setting up the Linux indode. Setting up the xfs_inode <-> inode link is opencoded in xfs_iget_core now because that's the only place it needs to be done, xfs_initialize_vnode is renamed to xfs_setup_inode and loses all superflous paramaters. The check for I_NEW is removed because it always is true and the di_mode check moves into xfs_iget_core because it's only needed there. xfs_set_inodeops and xfs_revalidate_inode are merged into xfs_setup_inode and the whole things is moved into xfs_iops.c where it belongs. SGI-PV: 981498 SGI-Modid: xfs-linux-melb:xfs-kern:31782a Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Niv Sardi <xaiki@sgi.com> Signed-off-by: Lachlan McIlroy <lachlan@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.c103
-rw-r--r--fs/xfs/linux-2.6/xfs_iops.h8
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c110
-rw-r--r--fs/xfs/linux-2.6/xfs_super.h3
-rw-r--r--fs/xfs/xfs_iget.c9
-rw-r--r--fs/xfs/xfs_inode.c4
6 files changed, 111 insertions, 126 deletions
diff --git a/fs/xfs/linux-2.6/xfs_iops.c b/fs/xfs/linux-2.6/xfs_iops.c
index cc0f21af48fe..ace56bd3a5fb 100644
--- a/fs/xfs/linux-2.6/xfs_iops.c
+++ b/fs/xfs/linux-2.6/xfs_iops.c
@@ -710,7 +710,7 @@ out_error:
710 return error; 710 return error;
711} 711}
712 712
713const struct inode_operations xfs_inode_operations = { 713static const struct inode_operations xfs_inode_operations = {
714 .permission = xfs_vn_permission, 714 .permission = xfs_vn_permission,
715 .truncate = xfs_vn_truncate, 715 .truncate = xfs_vn_truncate,
716 .getattr = xfs_vn_getattr, 716 .getattr = xfs_vn_getattr,
@@ -722,7 +722,7 @@ const struct inode_operations xfs_inode_operations = {
722 .fallocate = xfs_vn_fallocate, 722 .fallocate = xfs_vn_fallocate,
723}; 723};
724 724
725const struct inode_operations xfs_dir_inode_operations = { 725static const struct inode_operations xfs_dir_inode_operations = {
726 .create = xfs_vn_create, 726 .create = xfs_vn_create,
727 .lookup = xfs_vn_lookup, 727 .lookup = xfs_vn_lookup,
728 .link = xfs_vn_link, 728 .link = xfs_vn_link,
@@ -747,7 +747,7 @@ const struct inode_operations xfs_dir_inode_operations = {
747 .listxattr = xfs_vn_listxattr, 747 .listxattr = xfs_vn_listxattr,
748}; 748};
749 749
750const struct inode_operations xfs_dir_ci_inode_operations = { 750static const struct inode_operations xfs_dir_ci_inode_operations = {
751 .create = xfs_vn_create, 751 .create = xfs_vn_create,
752 .lookup = xfs_vn_ci_lookup, 752 .lookup = xfs_vn_ci_lookup,
753 .link = xfs_vn_link, 753 .link = xfs_vn_link,
@@ -772,7 +772,7 @@ const struct inode_operations xfs_dir_ci_inode_operations = {
772 .listxattr = xfs_vn_listxattr, 772 .listxattr = xfs_vn_listxattr,
773}; 773};
774 774
775const struct inode_operations xfs_symlink_inode_operations = { 775static const struct inode_operations xfs_symlink_inode_operations = {
776 .readlink = generic_readlink, 776 .readlink = generic_readlink,
777 .follow_link = xfs_vn_follow_link, 777 .follow_link = xfs_vn_follow_link,
778 .put_link = xfs_vn_put_link, 778 .put_link = xfs_vn_put_link,
@@ -784,3 +784,98 @@ const struct inode_operations xfs_symlink_inode_operations = {
784 .removexattr = generic_removexattr, 784 .removexattr = generic_removexattr,
785 .listxattr = xfs_vn_listxattr, 785 .listxattr = xfs_vn_listxattr,
786}; 786};
787
788STATIC void
789xfs_diflags_to_iflags(
790 struct inode *inode,
791 struct xfs_inode *ip)
792{
793 if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
794 inode->i_flags |= S_IMMUTABLE;
795 else
796 inode->i_flags &= ~S_IMMUTABLE;
797 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
798 inode->i_flags |= S_APPEND;
799 else
800 inode->i_flags &= ~S_APPEND;
801 if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
802 inode->i_flags |= S_SYNC;
803 else
804 inode->i_flags &= ~S_SYNC;
805 if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
806 inode->i_flags |= S_NOATIME;
807 else
808 inode->i_flags &= ~S_NOATIME;
809}
810
811/*
812 * Initialize the Linux inode, set up the operation vectors and
813 * unlock the inode.
814 *
815 * When reading existing inodes from disk this is called directly
816 * from xfs_iget, when creating a new inode it is called from
817 * xfs_ialloc after setting up the inode.
818 */
819void
820xfs_setup_inode(
821 struct xfs_inode *ip)
822{
823 struct inode *inode = ip->i_vnode;
824
825 inode->i_mode = ip->i_d.di_mode;
826 inode->i_nlink = ip->i_d.di_nlink;
827 inode->i_uid = ip->i_d.di_uid;
828 inode->i_gid = ip->i_d.di_gid;
829
830 switch (inode->i_mode & S_IFMT) {
831 case S_IFBLK:
832 case S_IFCHR:
833 inode->i_rdev =
834 MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
835 sysv_minor(ip->i_df.if_u2.if_rdev));
836 break;
837 default:
838 inode->i_rdev = 0;
839 break;
840 }
841
842 inode->i_generation = ip->i_d.di_gen;
843 i_size_write(inode, ip->i_d.di_size);
844 inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec;
845 inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec;
846 inode->i_mtime.tv_sec = ip->i_d.di_mtime.t_sec;
847 inode->i_mtime.tv_nsec = ip->i_d.di_mtime.t_nsec;
848 inode->i_ctime.tv_sec = ip->i_d.di_ctime.t_sec;
849 inode->i_ctime.tv_nsec = ip->i_d.di_ctime.t_nsec;
850 xfs_diflags_to_iflags(inode, ip);
851 xfs_iflags_clear(ip, XFS_IMODIFIED);
852
853 switch (inode->i_mode & S_IFMT) {
854 case S_IFREG:
855 inode->i_op = &xfs_inode_operations;
856 inode->i_fop = &xfs_file_operations;
857 inode->i_mapping->a_ops = &xfs_address_space_operations;
858 break;
859 case S_IFDIR:
860 if (xfs_sb_version_hasasciici(&XFS_M(inode->i_sb)->m_sb))
861 inode->i_op = &xfs_dir_ci_inode_operations;
862 else
863 inode->i_op = &xfs_dir_inode_operations;
864 inode->i_fop = &xfs_dir_file_operations;
865 break;
866 case S_IFLNK:
867 inode->i_op = &xfs_symlink_inode_operations;
868 if (!(ip->i_df.if_flags & XFS_IFINLINE))
869 inode->i_mapping->a_ops = &xfs_address_space_operations;
870 break;
871 default:
872 inode->i_op = &xfs_inode_operations;
873 init_special_inode(inode, inode->i_mode, inode->i_rdev);
874 break;
875 }
876
877 xfs_iflags_clear(ip, XFS_INEW);
878 barrier();
879
880 unlock_new_inode(inode);
881}
diff --git a/fs/xfs/linux-2.6/xfs_iops.h b/fs/xfs/linux-2.6/xfs_iops.h
index fdda404bc343..2204f466dee0 100644
--- a/fs/xfs/linux-2.6/xfs_iops.h
+++ b/fs/xfs/linux-2.6/xfs_iops.h
@@ -18,10 +18,7 @@
18#ifndef __XFS_IOPS_H__ 18#ifndef __XFS_IOPS_H__
19#define __XFS_IOPS_H__ 19#define __XFS_IOPS_H__
20 20
21extern const struct inode_operations xfs_inode_operations; 21struct xfs_inode;
22extern const struct inode_operations xfs_dir_inode_operations;
23extern const struct inode_operations xfs_dir_ci_inode_operations;
24extern const struct inode_operations xfs_symlink_inode_operations;
25 22
26extern const struct file_operations xfs_file_operations; 23extern const struct file_operations xfs_file_operations;
27extern const struct file_operations xfs_dir_file_operations; 24extern const struct file_operations xfs_dir_file_operations;
@@ -29,8 +26,9 @@ extern const struct file_operations xfs_invis_file_operations;
29 26
30extern ssize_t xfs_vn_listxattr(struct dentry *, char *data, size_t size); 27extern ssize_t xfs_vn_listxattr(struct dentry *, char *data, size_t size);
31 28
32struct xfs_inode;
33extern void xfs_ichgtime(struct xfs_inode *, int); 29extern void xfs_ichgtime(struct xfs_inode *, int);
34extern void xfs_ichgtime_fast(struct xfs_inode *, struct inode *, int); 30extern void xfs_ichgtime_fast(struct xfs_inode *, struct inode *, int);
35 31
32extern void xfs_setup_inode(struct xfs_inode *);
33
36#endif /* __XFS_IOPS_H__ */ 34#endif /* __XFS_IOPS_H__ */
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 7605b071dc88..0eaad84a6803 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -581,116 +581,6 @@ xfs_max_file_offset(
581 return (((__uint64_t)pagefactor) << bitshift) - 1; 581 return (((__uint64_t)pagefactor) << bitshift) - 1;
582} 582}
583 583
584STATIC_INLINE void
585xfs_set_inodeops(
586 struct inode *inode)
587{
588 switch (inode->i_mode & S_IFMT) {
589 case S_IFREG:
590 inode->i_op = &xfs_inode_operations;
591 inode->i_fop = &xfs_file_operations;
592 inode->i_mapping->a_ops = &xfs_address_space_operations;
593 break;
594 case S_IFDIR:
595 if (xfs_sb_version_hasasciici(&XFS_M(inode->i_sb)->m_sb))
596 inode->i_op = &xfs_dir_ci_inode_operations;
597 else
598 inode->i_op = &xfs_dir_inode_operations;
599 inode->i_fop = &xfs_dir_file_operations;
600 break;
601 case S_IFLNK:
602 inode->i_op = &xfs_symlink_inode_operations;
603 if (!(XFS_I(inode)->i_df.if_flags & XFS_IFINLINE))
604 inode->i_mapping->a_ops = &xfs_address_space_operations;
605 break;
606 default:
607 inode->i_op = &xfs_inode_operations;
608 init_special_inode(inode, inode->i_mode, inode->i_rdev);
609 break;
610 }
611}
612
613STATIC_INLINE void
614xfs_revalidate_inode(
615 xfs_mount_t *mp,
616 struct inode *inode,
617 xfs_inode_t *ip)
618{
619
620 inode->i_mode = ip->i_d.di_mode;
621 inode->i_nlink = ip->i_d.di_nlink;
622 inode->i_uid = ip->i_d.di_uid;
623 inode->i_gid = ip->i_d.di_gid;
624
625 switch (inode->i_mode & S_IFMT) {
626 case S_IFBLK:
627 case S_IFCHR:
628 inode->i_rdev =
629 MKDEV(sysv_major(ip->i_df.if_u2.if_rdev) & 0x1ff,
630 sysv_minor(ip->i_df.if_u2.if_rdev));
631 break;
632 default:
633 inode->i_rdev = 0;
634 break;
635 }
636
637 inode->i_generation = ip->i_d.di_gen;
638 i_size_write(inode, ip->i_d.di_size);
639 inode->i_atime.tv_sec = ip->i_d.di_atime.t_sec;
640 inode->i_atime.tv_nsec = ip->i_d.di_atime.t_nsec;
641 inode->i_mtime.tv_sec = ip->i_d.di_mtime.t_sec;
642 inode->i_mtime.tv_nsec = ip->i_d.di_mtime.t_nsec;
643 inode->i_ctime.tv_sec = ip->i_d.di_ctime.t_sec;
644 inode->i_ctime.tv_nsec = ip->i_d.di_ctime.t_nsec;
645 if (ip->i_d.di_flags & XFS_DIFLAG_IMMUTABLE)
646 inode->i_flags |= S_IMMUTABLE;
647 else
648 inode->i_flags &= ~S_IMMUTABLE;
649 if (ip->i_d.di_flags & XFS_DIFLAG_APPEND)
650 inode->i_flags |= S_APPEND;
651 else
652 inode->i_flags &= ~S_APPEND;
653 if (ip->i_d.di_flags & XFS_DIFLAG_SYNC)
654 inode->i_flags |= S_SYNC;
655 else
656 inode->i_flags &= ~S_SYNC;
657 if (ip->i_d.di_flags & XFS_DIFLAG_NOATIME)
658 inode->i_flags |= S_NOATIME;
659 else
660 inode->i_flags &= ~S_NOATIME;
661 xfs_iflags_clear(ip, XFS_IMODIFIED);
662}
663
664void
665xfs_initialize_vnode(
666 struct xfs_mount *mp,
667 struct inode *inode,
668 struct xfs_inode *ip)
669{
670
671 if (!ip->i_vnode) {
672 ip->i_vnode = inode;
673 inode->i_private = ip;
674 }
675
676 /*
677 * We need to set the ops vectors, and unlock the inode, but if
678 * we have been called during the new inode create process, it is
679 * too early to fill in the Linux inode. We will get called a
680 * second time once the inode is properly set up, and then we can
681 * finish our work.
682 */
683 if (ip->i_d.di_mode != 0 && (inode->i_state & I_NEW)) {
684 xfs_revalidate_inode(mp, inode, ip);
685 xfs_set_inodeops(inode);
686
687 xfs_iflags_clear(ip, XFS_INEW);
688 barrier();
689
690 unlock_new_inode(inode);
691 }
692}
693
694int 584int
695xfs_blkdev_get( 585xfs_blkdev_get(
696 xfs_mount_t *mp, 586 xfs_mount_t *mp,
diff --git a/fs/xfs/linux-2.6/xfs_super.h b/fs/xfs/linux-2.6/xfs_super.h
index 57145fff3850..fe2ef4e6a0f9 100644
--- a/fs/xfs/linux-2.6/xfs_super.h
+++ b/fs/xfs/linux-2.6/xfs_super.h
@@ -101,9 +101,6 @@ struct block_device;
101 101
102extern __uint64_t xfs_max_file_offset(unsigned int); 102extern __uint64_t xfs_max_file_offset(unsigned int);
103 103
104extern void xfs_initialize_vnode(struct xfs_mount *mp, struct inode *vp,
105 struct xfs_inode *ip);
106
107extern void xfs_flush_inode(struct xfs_inode *); 104extern void xfs_flush_inode(struct xfs_inode *);
108extern void xfs_flush_device(struct xfs_inode *); 105extern void xfs_flush_device(struct xfs_inode *);
109 106
diff --git a/fs/xfs/xfs_iget.c b/fs/xfs/xfs_iget.c
index d44342640ca3..539c2dd8eae8 100644
--- a/fs/xfs/xfs_iget.c
+++ b/fs/xfs/xfs_iget.c
@@ -288,10 +288,17 @@ finish_inode:
288 *ipp = ip; 288 *ipp = ip;
289 289
290 /* 290 /*
291 * Set up the Linux with the Linux inode.
292 */
293 ip->i_vnode = inode;
294 inode->i_private = ip;
295
296 /*
291 * If we have a real type for an on-disk inode, we can set ops(&unlock) 297 * If we have a real type for an on-disk inode, we can set ops(&unlock)
292 * now. If it's a new inode being created, xfs_ialloc will handle it. 298 * now. If it's a new inode being created, xfs_ialloc will handle it.
293 */ 299 */
294 xfs_initialize_vnode(mp, inode, ip); 300 if (ip->i_d.di_mode != 0)
301 xfs_setup_inode(ip);
295 return 0; 302 return 0;
296} 303}
297 304
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 19e7a7b82703..5bb638b445e8 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -1046,7 +1046,6 @@ xfs_ialloc(
1046{ 1046{
1047 xfs_ino_t ino; 1047 xfs_ino_t ino;
1048 xfs_inode_t *ip; 1048 xfs_inode_t *ip;
1049 struct inode *vp;
1050 uint flags; 1049 uint flags;
1051 int error; 1050 int error;
1052 1051
@@ -1077,7 +1076,6 @@ xfs_ialloc(
1077 } 1076 }
1078 ASSERT(ip != NULL); 1077 ASSERT(ip != NULL);
1079 1078
1080 vp = VFS_I(ip);
1081 ip->i_d.di_mode = (__uint16_t)mode; 1079 ip->i_d.di_mode = (__uint16_t)mode;
1082 ip->i_d.di_onlink = 0; 1080 ip->i_d.di_onlink = 0;
1083 ip->i_d.di_nlink = nlink; 1081 ip->i_d.di_nlink = nlink;
@@ -1220,7 +1218,7 @@ xfs_ialloc(
1220 xfs_trans_log_inode(tp, ip, flags); 1218 xfs_trans_log_inode(tp, ip, flags);
1221 1219
1222 /* now that we have an i_mode we can setup inode ops and unlock */ 1220 /* now that we have an i_mode we can setup inode ops and unlock */
1223 xfs_initialize_vnode(tp->t_mountp, vp, ip); 1221 xfs_setup_inode(ip);
1224 1222
1225 *ipp = ip; 1223 *ipp = ip;
1226 return 0; 1224 return 0;