aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_super.c
diff options
context:
space:
mode:
authorCarlos Maiolino <cmaiolino@redhat.com>2012-09-20 09:32:38 -0400
committerBen Myers <bpm@sgi.com>2012-09-26 16:56:33 -0400
commit2d2194f61fddab3a9731b6e7a7ae3a4a19dd810c (patch)
treeaea773af614c823aad15ecd832b9061343a589bd /fs/xfs/xfs_super.c
parent08bf540412ed82a15cb9068249ad49b410a7b082 (diff)
xfs: reduce code duplication handling inode32/64 options
Add xfs_set_inode32() to be used to enable inode32 allocation mode. this will reduce the amount of duplicated code needed to mount/remount a filesystem with inode32 option. This patch also changes xfs_set_inode64() to return the maximum AG number that inodes can be allocated instead of set mp->m_maxagi by itself, so that the behaviour is the same as xfs_set_inode32(). This simplifies code that calls these functions and needs to know the maximum AG that inodes can be allocated in. Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_super.c')
-rw-r--r--fs/xfs/xfs_super.c89
1 files changed, 65 insertions, 24 deletions
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 996257d36fd1..d6619d685531 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -599,6 +599,71 @@ xfs_max_file_offset(
599 return (((__uint64_t)pagefactor) << bitshift) - 1; 599 return (((__uint64_t)pagefactor) << bitshift) - 1;
600} 600}
601 601
602xfs_agnumber_t
603xfs_set_inode32(struct xfs_mount *mp)
604{
605 xfs_agnumber_t index = 0;
606 xfs_sb_t *sbp = &mp->m_sb;
607 xfs_agnumber_t max_metadata;
608 xfs_agino_t agino = XFS_OFFBNO_TO_AGINO(mp, sbp->sb_agblocks -1, 0);
609 xfs_ino_t ino = XFS_AGINO_TO_INO(mp, sbp->sb_agcount -1, agino);
610 xfs_perag_t *pag;
611
612 /* Calculate how much should be reserved for inodes to meet
613 * the max inode percentage.
614 */
615 if (mp->m_maxicount) {
616 __uint64_t icount;
617
618 icount = sbp->sb_dblocks * sbp->sb_imax_pct;
619 do_div(icount, 100);
620 icount += sbp->sb_agblocks - 1;
621 do_div(icount, sbp->sb_agblocks);
622 max_metadata = icount;
623 } else {
624 max_metadata = sbp->sb_agcount;
625 }
626
627 for (index = 0; index < sbp->sb_agcount; index++) {
628 ino = XFS_AGINO_TO_INO(mp, index, agino);
629 if (ino > XFS_MAXINUMBER_32) {
630 index++;
631 break;
632 }
633
634 pag = xfs_perag_get(mp, index);
635 pag->pagi_inodeok = 1;
636 if (index < max_metadata)
637 pag->pagf_metadata = 1;
638 xfs_perag_put(pag);
639 }
640 return index;
641}
642
643xfs_agnumber_t
644xfs_set_inode64(struct xfs_mount *mp)
645{
646 xfs_agnumber_t index = 0;
647
648 for (index = 0; index < mp->m_sb.sb_agcount; index++) {
649 struct xfs_perag *pag;
650
651 pag = xfs_perag_get(mp, index);
652 pag->pagi_inodeok = 1;
653 pag->pagf_metadata = 0;
654 xfs_perag_put(pag);
655 }
656
657 /* There is no need for lock protection on m_flags,
658 * the rw_semaphore of the VFS superblock is locked
659 * during mount/umount/remount operations, so this is
660 * enough to avoid concurency on the m_flags field
661 */
662 mp->m_flags &= ~(XFS_MOUNT_32BITINODES |
663 XFS_MOUNT_SMALL_INUMS);
664 return index;
665}
666
602STATIC int 667STATIC int
603xfs_blkdev_get( 668xfs_blkdev_get(
604 xfs_mount_t *mp, 669 xfs_mount_t *mp,
@@ -1039,30 +1104,6 @@ xfs_restore_resvblks(struct xfs_mount *mp)
1039 xfs_reserve_blocks(mp, &resblks, NULL); 1104 xfs_reserve_blocks(mp, &resblks, NULL);
1040} 1105}
1041 1106
1042STATIC void
1043xfs_set_inode64(struct xfs_mount *mp)
1044{
1045 int i = 0;
1046
1047 for (i = 0; i < mp->m_sb.sb_agcount; i++) {
1048 struct xfs_perag *pag;
1049
1050 pag = xfs_perag_get(mp, i);
1051 pag->pagi_inodeok = 1;
1052 pag->pagf_metadata = 0;
1053 xfs_perag_put(pag);
1054 }
1055
1056 /* There is no need for lock protection on m_flags,
1057 * the rw_semaphore of the VFS superblock is locked
1058 * during mount/umount/remount operations, so this is
1059 * enough to avoid concurency on the m_flags field
1060 */
1061 mp->m_flags &= ~(XFS_MOUNT_32BITINODES |
1062 XFS_MOUNT_SMALL_INUMS);
1063 mp->m_maxagi = i;
1064}
1065
1066STATIC int 1107STATIC int
1067xfs_fs_remount( 1108xfs_fs_remount(
1068 struct super_block *sb, 1109 struct super_block *sb,