aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2007-10-11 04:09:40 -0400
committerLachlan McIlroy <lachlan@redback.melbourne.sgi.com>2008-02-07 00:53:27 -0500
commit4ca488eb45692520f745f96abc00ea4e268a87d4 (patch)
tree525662017ca7cfdc45b9d62f01e045d1da999e4a
parentc43f408795c3210c9f5c925e4a49dbb93d41bb57 (diff)
[XFS] Kill off xfs_statvfs.
We were already filling the Linux struct statfs anyway, and doing this trivial task directly in xfs_fs_statfs makes the code quite a bit cleaner. While I was at it I also moved copying attributes that don't change over the lifetime of the filesystem outside the superblock lock. xfs_fs_fill_super used to get the magic number and blocksize through xfs_statvfs, but assigning them directly is a lot cleaner and will save some stack space during mount. SGI-PV: 971186 SGI-Modid: xfs-linux-melb:xfs-kern:29802a Signed-off-by: Christoph Hellwig <hch@infradead.org> Signed-off-by: Tim Shimmin <tes@sgi.com>
-rw-r--r--fs/xfs/linux-2.6/xfs_linux.h4
-rw-r--r--fs/xfs/linux-2.6/xfs_super.c51
-rw-r--r--fs/xfs/xfs_vfsops.c53
-rw-r--r--fs/xfs/xfs_vfsops.h2
4 files changed, 41 insertions, 69 deletions
diff --git a/fs/xfs/linux-2.6/xfs_linux.h b/fs/xfs/linux-2.6/xfs_linux.h
index ec51ecd13877..9bf4f7e965c7 100644
--- a/fs/xfs/linux-2.6/xfs_linux.h
+++ b/fs/xfs/linux-2.6/xfs_linux.h
@@ -207,10 +207,6 @@
207#define xfs_stack_trace() dump_stack() 207#define xfs_stack_trace() dump_stack()
208#define xfs_itruncate_data(ip, off) \ 208#define xfs_itruncate_data(ip, off) \
209 (-vmtruncate(vn_to_inode(XFS_ITOV(ip)), (off))) 209 (-vmtruncate(vn_to_inode(XFS_ITOV(ip)), (off)))
210#define xfs_statvfs_fsid(statp, mp) \
211 ({ u64 id = huge_encode_dev((mp)->m_ddev_targp->bt_dev); \
212 __kernel_fsid_t *fsid = &(statp)->f_fsid; \
213 (fsid->val[0] = (u32)id, fsid->val[1] = (u32)(id >> 32)); })
214 210
215 211
216/* Move the kernel do_div definition off to one side */ 212/* Move the kernel do_div definition off to one side */
diff --git a/fs/xfs/linux-2.6/xfs_super.c b/fs/xfs/linux-2.6/xfs_super.c
index 400ed2f20717..c0549737f7ea 100644
--- a/fs/xfs/linux-2.6/xfs_super.c
+++ b/fs/xfs/linux-2.6/xfs_super.c
@@ -681,8 +681,44 @@ xfs_fs_statfs(
681 struct dentry *dentry, 681 struct dentry *dentry,
682 struct kstatfs *statp) 682 struct kstatfs *statp)
683{ 683{
684 return -xfs_statvfs(XFS_M(dentry->d_sb), statp, 684 struct xfs_mount *mp = XFS_M(dentry->d_sb);
685 vn_from_inode(dentry->d_inode)); 685 xfs_sb_t *sbp = &mp->m_sb;
686 __uint64_t fakeinos, id;
687 xfs_extlen_t lsize;
688
689 statp->f_type = XFS_SB_MAGIC;
690 statp->f_namelen = MAXNAMELEN - 1;
691
692 id = huge_encode_dev(mp->m_ddev_targp->bt_dev);
693 statp->f_fsid.val[0] = (u32)id;
694 statp->f_fsid.val[1] = (u32)(id >> 32);
695
696 xfs_icsb_sync_counters_flags(mp, XFS_ICSB_LAZY_COUNT);
697
698 spin_lock(&mp->m_sb_lock);
699 statp->f_bsize = sbp->sb_blocksize;
700 lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
701 statp->f_blocks = sbp->sb_dblocks - lsize;
702 statp->f_bfree = statp->f_bavail =
703 sbp->sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp);
704 fakeinos = statp->f_bfree << sbp->sb_inopblog;
705#if XFS_BIG_INUMS
706 fakeinos += mp->m_inoadd;
707#endif
708 statp->f_files =
709 MIN(sbp->sb_icount + fakeinos, (__uint64_t)XFS_MAXINUMBER);
710 if (mp->m_maxicount)
711#if XFS_BIG_INUMS
712 if (!mp->m_inoadd)
713#endif
714 statp->f_files = min_t(typeof(statp->f_files),
715 statp->f_files,
716 mp->m_maxicount);
717 statp->f_ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree);
718 spin_unlock(&mp->m_sb_lock);
719
720 XFS_QM_DQSTATVFS(XFS_I(dentry->d_inode), statp);
721 return 0;
686} 722}
687 723
688STATIC int 724STATIC int
@@ -777,7 +813,6 @@ xfs_fs_fill_super(
777 struct inode *rootvp; 813 struct inode *rootvp;
778 struct xfs_mount *mp = NULL; 814 struct xfs_mount *mp = NULL;
779 struct xfs_mount_args *args = xfs_args_allocate(sb, silent); 815 struct xfs_mount_args *args = xfs_args_allocate(sb, silent);
780 struct kstatfs statvfs;
781 int error; 816 int error;
782 817
783 mp = xfs_mount_init(); 818 mp = xfs_mount_init();
@@ -805,14 +840,10 @@ xfs_fs_fill_super(
805 if (error) 840 if (error)
806 goto fail_vfsop; 841 goto fail_vfsop;
807 842
808 error = xfs_statvfs(mp, &statvfs, NULL);
809 if (error)
810 goto fail_unmount;
811
812 sb->s_dirt = 1; 843 sb->s_dirt = 1;
813 sb->s_magic = statvfs.f_type; 844 sb->s_magic = XFS_SB_MAGIC;
814 sb->s_blocksize = statvfs.f_bsize; 845 sb->s_blocksize = mp->m_sb.sb_blocksize;
815 sb->s_blocksize_bits = ffs(statvfs.f_bsize) - 1; 846 sb->s_blocksize_bits = ffs(sb->s_blocksize) - 1;
816 sb->s_maxbytes = xfs_max_file_offset(sb->s_blocksize_bits); 847 sb->s_maxbytes = xfs_max_file_offset(sb->s_blocksize_bits);
817 sb->s_time_gran = 1; 848 sb->s_time_gran = 1;
818 set_posix_acl_flag(sb); 849 set_posix_acl_flag(sb);
diff --git a/fs/xfs/xfs_vfsops.c b/fs/xfs/xfs_vfsops.c
index f5844678d45e..1249548aa12e 100644
--- a/fs/xfs/xfs_vfsops.c
+++ b/fs/xfs/xfs_vfsops.c
@@ -839,59 +839,6 @@ xfs_root(
839} 839}
840 840
841/* 841/*
842 * xfs_statvfs
843 *
844 * Fill in the statvfs structure for the given file system. We use
845 * the superblock lock in the mount structure to ensure a consistent
846 * snapshot of the counters returned.
847 */
848int
849xfs_statvfs(
850 xfs_mount_t *mp,
851 bhv_statvfs_t *statp,
852 bhv_vnode_t *vp)
853{
854 __uint64_t fakeinos;
855 xfs_extlen_t lsize;
856 xfs_sb_t *sbp;
857
858 sbp = &(mp->m_sb);
859
860 statp->f_type = XFS_SB_MAGIC;
861
862 xfs_icsb_sync_counters_flags(mp, XFS_ICSB_LAZY_COUNT);
863 spin_lock(&mp->m_sb_lock);
864 statp->f_bsize = sbp->sb_blocksize;
865 lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
866 statp->f_blocks = sbp->sb_dblocks - lsize;
867 statp->f_bfree = statp->f_bavail =
868 sbp->sb_fdblocks - XFS_ALLOC_SET_ASIDE(mp);
869 fakeinos = statp->f_bfree << sbp->sb_inopblog;
870#if XFS_BIG_INUMS
871 fakeinos += mp->m_inoadd;
872#endif
873 statp->f_files =
874 MIN(sbp->sb_icount + fakeinos, (__uint64_t)XFS_MAXINUMBER);
875 if (mp->m_maxicount)
876#if XFS_BIG_INUMS
877 if (!mp->m_inoadd)
878#endif
879 statp->f_files = min_t(typeof(statp->f_files),
880 statp->f_files,
881 mp->m_maxicount);
882 statp->f_ffree = statp->f_files - (sbp->sb_icount - sbp->sb_ifree);
883 spin_unlock(&mp->m_sb_lock);
884
885 xfs_statvfs_fsid(statp, mp);
886 statp->f_namelen = MAXNAMELEN - 1;
887
888 if (vp)
889 XFS_QM_DQSTATVFS(xfs_vtoi(vp), statp);
890 return 0;
891}
892
893
894/*
895 * xfs_sync flushes any pending I/O to file system vfsp. 842 * xfs_sync flushes any pending I/O to file system vfsp.
896 * 843 *
897 * This routine is called by vfs_sync() to make sure that things make it 844 * This routine is called by vfs_sync() to make sure that things make it
diff --git a/fs/xfs/xfs_vfsops.h b/fs/xfs/xfs_vfsops.h
index a592fe02a339..ce3eb9454de4 100644
--- a/fs/xfs/xfs_vfsops.h
+++ b/fs/xfs/xfs_vfsops.h
@@ -14,8 +14,6 @@ int xfs_unmount(struct xfs_mount *mp, int flags, struct cred *credp);
14int xfs_mntupdate(struct xfs_mount *mp, int *flags, 14int xfs_mntupdate(struct xfs_mount *mp, int *flags,
15 struct xfs_mount_args *args); 15 struct xfs_mount_args *args);
16int xfs_root(struct xfs_mount *mp, bhv_vnode_t **vpp); 16int xfs_root(struct xfs_mount *mp, bhv_vnode_t **vpp);
17int xfs_statvfs(struct xfs_mount *mp, struct kstatfs *statp,
18 bhv_vnode_t *vp);
19int xfs_sync(struct xfs_mount *mp, int flags); 17int xfs_sync(struct xfs_mount *mp, int flags);
20int xfs_vget(struct xfs_mount *mp, bhv_vnode_t **vpp, struct xfs_fid *xfid); 18int xfs_vget(struct xfs_mount *mp, bhv_vnode_t **vpp, struct xfs_fid *xfid);
21int xfs_parseargs(struct xfs_mount *mp, char *options, 19int xfs_parseargs(struct xfs_mount *mp, char *options,