aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_mount.c43
-rw-r--r--fs/xfs/xfs_super.c89
-rw-r--r--fs/xfs/xfs_super.h2
3 files changed, 72 insertions, 62 deletions
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 29c2f83d4147..b2bd3a0e6376 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -440,7 +440,7 @@ xfs_initialize_perag(
440 xfs_agnumber_t agcount, 440 xfs_agnumber_t agcount,
441 xfs_agnumber_t *maxagi) 441 xfs_agnumber_t *maxagi)
442{ 442{
443 xfs_agnumber_t index, max_metadata; 443 xfs_agnumber_t index;
444 xfs_agnumber_t first_initialised = 0; 444 xfs_agnumber_t first_initialised = 0;
445 xfs_perag_t *pag; 445 xfs_perag_t *pag;
446 xfs_agino_t agino; 446 xfs_agino_t agino;
@@ -500,43 +500,10 @@ xfs_initialize_perag(
500 else 500 else
501 mp->m_flags &= ~XFS_MOUNT_32BITINODES; 501 mp->m_flags &= ~XFS_MOUNT_32BITINODES;
502 502
503 if (mp->m_flags & XFS_MOUNT_32BITINODES) { 503 if (mp->m_flags & XFS_MOUNT_32BITINODES)
504 /* 504 index = xfs_set_inode32(mp);
505 * Calculate how much should be reserved for inodes to meet 505 else
506 * the max inode percentage. 506 index = xfs_set_inode64(mp);
507 */
508 if (mp->m_maxicount) {
509 __uint64_t icount;
510
511 icount = sbp->sb_dblocks * sbp->sb_imax_pct;
512 do_div(icount, 100);
513 icount += sbp->sb_agblocks - 1;
514 do_div(icount, sbp->sb_agblocks);
515 max_metadata = icount;
516 } else {
517 max_metadata = agcount;
518 }
519
520 for (index = 0; index < agcount; index++) {
521 ino = XFS_AGINO_TO_INO(mp, index, agino);
522 if (ino > XFS_MAXINUMBER_32) {
523 index++;
524 break;
525 }
526
527 pag = xfs_perag_get(mp, index);
528 pag->pagi_inodeok = 1;
529 if (index < max_metadata)
530 pag->pagf_metadata = 1;
531 xfs_perag_put(pag);
532 }
533 } else {
534 for (index = 0; index < agcount; index++) {
535 pag = xfs_perag_get(mp, index);
536 pag->pagi_inodeok = 1;
537 xfs_perag_put(pag);
538 }
539 }
540 507
541 if (maxagi) 508 if (maxagi)
542 *maxagi = index; 509 *maxagi = index;
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,
diff --git a/fs/xfs/xfs_super.h b/fs/xfs/xfs_super.h
index 09b0c26b2245..9de4a920ba05 100644
--- a/fs/xfs/xfs_super.h
+++ b/fs/xfs/xfs_super.h
@@ -75,6 +75,8 @@ struct block_device;
75extern __uint64_t xfs_max_file_offset(unsigned int); 75extern __uint64_t xfs_max_file_offset(unsigned int);
76 76
77extern void xfs_blkdev_issue_flush(struct xfs_buftarg *); 77extern void xfs_blkdev_issue_flush(struct xfs_buftarg *);
78extern xfs_agnumber_t xfs_set_inode32(struct xfs_mount *);
79extern xfs_agnumber_t xfs_set_inode64(struct xfs_mount *);
78 80
79extern const struct export_operations xfs_export_operations; 81extern const struct export_operations xfs_export_operations;
80extern const struct xattr_handler *xfs_xattr_handlers[]; 82extern const struct xattr_handler *xfs_xattr_handlers[];