diff options
Diffstat (limited to 'fs')
-rw-r--r-- | fs/gfs2/incore.h | 7 | ||||
-rw-r--r-- | fs/gfs2/inode.c | 143 | ||||
-rw-r--r-- | fs/gfs2/ops_fstype.c | 45 | ||||
-rw-r--r-- | fs/gfs2/rgrp.c | 2 | ||||
-rw-r--r-- | fs/gfs2/super.c | 3 |
5 files changed, 10 insertions, 190 deletions
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 1d11e6e0373e..52436abc3b4d 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h | |||
@@ -548,18 +548,12 @@ struct gfs2_sbd { | |||
548 | struct dentry *sd_root_dir; | 548 | struct dentry *sd_root_dir; |
549 | 549 | ||
550 | struct inode *sd_jindex; | 550 | struct inode *sd_jindex; |
551 | struct inode *sd_inum_inode; | ||
552 | struct inode *sd_statfs_inode; | 551 | struct inode *sd_statfs_inode; |
553 | struct inode *sd_ir_inode; | ||
554 | struct inode *sd_sc_inode; | 552 | struct inode *sd_sc_inode; |
555 | struct inode *sd_qc_inode; | 553 | struct inode *sd_qc_inode; |
556 | struct inode *sd_rindex; | 554 | struct inode *sd_rindex; |
557 | struct inode *sd_quota_inode; | 555 | struct inode *sd_quota_inode; |
558 | 556 | ||
559 | /* Inum stuff */ | ||
560 | |||
561 | struct mutex sd_inum_mutex; | ||
562 | |||
563 | /* StatFS stuff */ | 557 | /* StatFS stuff */ |
564 | 558 | ||
565 | spinlock_t sd_statfs_spin; | 559 | spinlock_t sd_statfs_spin; |
@@ -587,7 +581,6 @@ struct gfs2_sbd { | |||
587 | struct gfs2_holder sd_journal_gh; | 581 | struct gfs2_holder sd_journal_gh; |
588 | struct gfs2_holder sd_jinode_gh; | 582 | struct gfs2_holder sd_jinode_gh; |
589 | 583 | ||
590 | struct gfs2_holder sd_ir_gh; | ||
591 | struct gfs2_holder sd_sc_gh; | 584 | struct gfs2_holder sd_sc_gh; |
592 | struct gfs2_holder sd_qc_gh; | 585 | struct gfs2_holder sd_qc_gh; |
593 | 586 | ||
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 4f5e442d60d8..fb15d3b1f409 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
@@ -519,139 +519,6 @@ out: | |||
519 | return inode ? inode : ERR_PTR(error); | 519 | return inode ? inode : ERR_PTR(error); |
520 | } | 520 | } |
521 | 521 | ||
522 | static void gfs2_inum_range_in(struct gfs2_inum_range_host *ir, const void *buf) | ||
523 | { | ||
524 | const struct gfs2_inum_range *str = buf; | ||
525 | |||
526 | ir->ir_start = be64_to_cpu(str->ir_start); | ||
527 | ir->ir_length = be64_to_cpu(str->ir_length); | ||
528 | } | ||
529 | |||
530 | static void gfs2_inum_range_out(const struct gfs2_inum_range_host *ir, void *buf) | ||
531 | { | ||
532 | struct gfs2_inum_range *str = buf; | ||
533 | |||
534 | str->ir_start = cpu_to_be64(ir->ir_start); | ||
535 | str->ir_length = cpu_to_be64(ir->ir_length); | ||
536 | } | ||
537 | |||
538 | static int pick_formal_ino_1(struct gfs2_sbd *sdp, u64 *formal_ino) | ||
539 | { | ||
540 | struct gfs2_inode *ip = GFS2_I(sdp->sd_ir_inode); | ||
541 | struct buffer_head *bh; | ||
542 | struct gfs2_inum_range_host ir; | ||
543 | int error; | ||
544 | |||
545 | error = gfs2_trans_begin(sdp, RES_DINODE, 0); | ||
546 | if (error) | ||
547 | return error; | ||
548 | mutex_lock(&sdp->sd_inum_mutex); | ||
549 | |||
550 | error = gfs2_meta_inode_buffer(ip, &bh); | ||
551 | if (error) { | ||
552 | mutex_unlock(&sdp->sd_inum_mutex); | ||
553 | gfs2_trans_end(sdp); | ||
554 | return error; | ||
555 | } | ||
556 | |||
557 | gfs2_inum_range_in(&ir, bh->b_data + sizeof(struct gfs2_dinode)); | ||
558 | |||
559 | if (ir.ir_length) { | ||
560 | *formal_ino = ir.ir_start++; | ||
561 | ir.ir_length--; | ||
562 | gfs2_trans_add_bh(ip->i_gl, bh, 1); | ||
563 | gfs2_inum_range_out(&ir, | ||
564 | bh->b_data + sizeof(struct gfs2_dinode)); | ||
565 | brelse(bh); | ||
566 | mutex_unlock(&sdp->sd_inum_mutex); | ||
567 | gfs2_trans_end(sdp); | ||
568 | return 0; | ||
569 | } | ||
570 | |||
571 | brelse(bh); | ||
572 | |||
573 | mutex_unlock(&sdp->sd_inum_mutex); | ||
574 | gfs2_trans_end(sdp); | ||
575 | |||
576 | return 1; | ||
577 | } | ||
578 | |||
579 | static int pick_formal_ino_2(struct gfs2_sbd *sdp, u64 *formal_ino) | ||
580 | { | ||
581 | struct gfs2_inode *ip = GFS2_I(sdp->sd_ir_inode); | ||
582 | struct gfs2_inode *m_ip = GFS2_I(sdp->sd_inum_inode); | ||
583 | struct gfs2_holder gh; | ||
584 | struct buffer_head *bh; | ||
585 | struct gfs2_inum_range_host ir; | ||
586 | int error; | ||
587 | |||
588 | error = gfs2_glock_nq_init(m_ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh); | ||
589 | if (error) | ||
590 | return error; | ||
591 | |||
592 | error = gfs2_trans_begin(sdp, 2 * RES_DINODE, 0); | ||
593 | if (error) | ||
594 | goto out; | ||
595 | mutex_lock(&sdp->sd_inum_mutex); | ||
596 | |||
597 | error = gfs2_meta_inode_buffer(ip, &bh); | ||
598 | if (error) | ||
599 | goto out_end_trans; | ||
600 | |||
601 | gfs2_inum_range_in(&ir, bh->b_data + sizeof(struct gfs2_dinode)); | ||
602 | |||
603 | if (!ir.ir_length) { | ||
604 | struct buffer_head *m_bh; | ||
605 | u64 x, y; | ||
606 | __be64 z; | ||
607 | |||
608 | error = gfs2_meta_inode_buffer(m_ip, &m_bh); | ||
609 | if (error) | ||
610 | goto out_brelse; | ||
611 | |||
612 | z = *(__be64 *)(m_bh->b_data + sizeof(struct gfs2_dinode)); | ||
613 | x = y = be64_to_cpu(z); | ||
614 | ir.ir_start = x; | ||
615 | ir.ir_length = GFS2_INUM_QUANTUM; | ||
616 | x += GFS2_INUM_QUANTUM; | ||
617 | if (x < y) | ||
618 | gfs2_consist_inode(m_ip); | ||
619 | z = cpu_to_be64(x); | ||
620 | gfs2_trans_add_bh(m_ip->i_gl, m_bh, 1); | ||
621 | *(__be64 *)(m_bh->b_data + sizeof(struct gfs2_dinode)) = z; | ||
622 | |||
623 | brelse(m_bh); | ||
624 | } | ||
625 | |||
626 | *formal_ino = ir.ir_start++; | ||
627 | ir.ir_length--; | ||
628 | |||
629 | gfs2_trans_add_bh(ip->i_gl, bh, 1); | ||
630 | gfs2_inum_range_out(&ir, bh->b_data + sizeof(struct gfs2_dinode)); | ||
631 | |||
632 | out_brelse: | ||
633 | brelse(bh); | ||
634 | out_end_trans: | ||
635 | mutex_unlock(&sdp->sd_inum_mutex); | ||
636 | gfs2_trans_end(sdp); | ||
637 | out: | ||
638 | gfs2_glock_dq_uninit(&gh); | ||
639 | return error; | ||
640 | } | ||
641 | |||
642 | static int pick_formal_ino(struct gfs2_sbd *sdp, u64 *inum) | ||
643 | { | ||
644 | int error; | ||
645 | |||
646 | error = pick_formal_ino_1(sdp, inum); | ||
647 | if (error <= 0) | ||
648 | return error; | ||
649 | |||
650 | error = pick_formal_ino_2(sdp, inum); | ||
651 | |||
652 | return error; | ||
653 | } | ||
654 | |||
655 | /** | 522 | /** |
656 | * create_ok - OK to create a new on-disk inode here? | 523 | * create_ok - OK to create a new on-disk inode here? |
657 | * @dip: Directory in which dinode is to be created | 524 | * @dip: Directory in which dinode is to be created |
@@ -981,13 +848,10 @@ struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, | |||
981 | if (error) | 848 | if (error) |
982 | goto fail_gunlock; | 849 | goto fail_gunlock; |
983 | 850 | ||
984 | error = pick_formal_ino(sdp, &inum.no_formal_ino); | ||
985 | if (error) | ||
986 | goto fail_gunlock; | ||
987 | |||
988 | error = alloc_dinode(dip, &inum.no_addr, &generation); | 851 | error = alloc_dinode(dip, &inum.no_addr, &generation); |
989 | if (error) | 852 | if (error) |
990 | goto fail_gunlock; | 853 | goto fail_gunlock; |
854 | inum.no_formal_ino = generation; | ||
991 | 855 | ||
992 | error = gfs2_glock_nq_num(sdp, inum.no_addr, &gfs2_inode_glops, | 856 | error = gfs2_glock_nq_num(sdp, inum.no_addr, &gfs2_inode_glops, |
993 | LM_ST_EXCLUSIVE, GL_SKIP, ghs + 1); | 857 | LM_ST_EXCLUSIVE, GL_SKIP, ghs + 1); |
@@ -998,9 +862,8 @@ struct inode *gfs2_createi(struct gfs2_holder *ghs, const struct qstr *name, | |||
998 | if (error) | 862 | if (error) |
999 | goto fail_gunlock2; | 863 | goto fail_gunlock2; |
1000 | 864 | ||
1001 | inode = gfs2_inode_lookup(dir->i_sb, IF2DT(mode), | 865 | inode = gfs2_inode_lookup(dir->i_sb, IF2DT(mode), inum.no_addr, |
1002 | inum.no_addr, | 866 | inum.no_formal_ino, 0); |
1003 | inum.no_formal_ino, 0); | ||
1004 | if (IS_ERR(inode)) | 867 | if (IS_ERR(inode)) |
1005 | goto fail_gunlock2; | 868 | goto fail_gunlock2; |
1006 | 869 | ||
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 1ec69e63c694..8e3f00e1430d 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c | |||
@@ -84,7 +84,6 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb) | |||
84 | 84 | ||
85 | gfs2_tune_init(&sdp->sd_tune); | 85 | gfs2_tune_init(&sdp->sd_tune); |
86 | 86 | ||
87 | mutex_init(&sdp->sd_inum_mutex); | ||
88 | spin_lock_init(&sdp->sd_statfs_spin); | 87 | spin_lock_init(&sdp->sd_statfs_spin); |
89 | 88 | ||
90 | spin_lock_init(&sdp->sd_rindex_spin); | 89 | spin_lock_init(&sdp->sd_rindex_spin); |
@@ -833,21 +832,12 @@ static int init_inodes(struct gfs2_sbd *sdp, int undo) | |||
833 | if (error) | 832 | if (error) |
834 | goto fail; | 833 | goto fail; |
835 | 834 | ||
836 | /* Read in the master inode number inode */ | ||
837 | sdp->sd_inum_inode = gfs2_lookup_simple(master, "inum"); | ||
838 | if (IS_ERR(sdp->sd_inum_inode)) { | ||
839 | error = PTR_ERR(sdp->sd_inum_inode); | ||
840 | fs_err(sdp, "can't read in inum inode: %d\n", error); | ||
841 | goto fail_journal; | ||
842 | } | ||
843 | |||
844 | |||
845 | /* Read in the master statfs inode */ | 835 | /* Read in the master statfs inode */ |
846 | sdp->sd_statfs_inode = gfs2_lookup_simple(master, "statfs"); | 836 | sdp->sd_statfs_inode = gfs2_lookup_simple(master, "statfs"); |
847 | if (IS_ERR(sdp->sd_statfs_inode)) { | 837 | if (IS_ERR(sdp->sd_statfs_inode)) { |
848 | error = PTR_ERR(sdp->sd_statfs_inode); | 838 | error = PTR_ERR(sdp->sd_statfs_inode); |
849 | fs_err(sdp, "can't read in statfs inode: %d\n", error); | 839 | fs_err(sdp, "can't read in statfs inode: %d\n", error); |
850 | goto fail_inum; | 840 | goto fail_journal; |
851 | } | 841 | } |
852 | 842 | ||
853 | /* Read in the resource index inode */ | 843 | /* Read in the resource index inode */ |
@@ -876,8 +866,6 @@ fail_rindex: | |||
876 | iput(sdp->sd_rindex); | 866 | iput(sdp->sd_rindex); |
877 | fail_statfs: | 867 | fail_statfs: |
878 | iput(sdp->sd_statfs_inode); | 868 | iput(sdp->sd_statfs_inode); |
879 | fail_inum: | ||
880 | iput(sdp->sd_inum_inode); | ||
881 | fail_journal: | 869 | fail_journal: |
882 | init_journal(sdp, UNDO); | 870 | init_journal(sdp, UNDO); |
883 | fail: | 871 | fail: |
@@ -905,20 +893,12 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) | |||
905 | return error; | 893 | return error; |
906 | } | 894 | } |
907 | 895 | ||
908 | sprintf(buf, "inum_range%u", sdp->sd_jdesc->jd_jid); | ||
909 | sdp->sd_ir_inode = gfs2_lookup_simple(pn, buf); | ||
910 | if (IS_ERR(sdp->sd_ir_inode)) { | ||
911 | error = PTR_ERR(sdp->sd_ir_inode); | ||
912 | fs_err(sdp, "can't find local \"ir\" file: %d\n", error); | ||
913 | goto fail; | ||
914 | } | ||
915 | |||
916 | sprintf(buf, "statfs_change%u", sdp->sd_jdesc->jd_jid); | 896 | sprintf(buf, "statfs_change%u", sdp->sd_jdesc->jd_jid); |
917 | sdp->sd_sc_inode = gfs2_lookup_simple(pn, buf); | 897 | sdp->sd_sc_inode = gfs2_lookup_simple(pn, buf); |
918 | if (IS_ERR(sdp->sd_sc_inode)) { | 898 | if (IS_ERR(sdp->sd_sc_inode)) { |
919 | error = PTR_ERR(sdp->sd_sc_inode); | 899 | error = PTR_ERR(sdp->sd_sc_inode); |
920 | fs_err(sdp, "can't find local \"sc\" file: %d\n", error); | 900 | fs_err(sdp, "can't find local \"sc\" file: %d\n", error); |
921 | goto fail_ir_i; | 901 | goto fail; |
922 | } | 902 | } |
923 | 903 | ||
924 | sprintf(buf, "quota_change%u", sdp->sd_jdesc->jd_jid); | 904 | sprintf(buf, "quota_change%u", sdp->sd_jdesc->jd_jid); |
@@ -932,27 +912,16 @@ static int init_per_node(struct gfs2_sbd *sdp, int undo) | |||
932 | iput(pn); | 912 | iput(pn); |
933 | pn = NULL; | 913 | pn = NULL; |
934 | 914 | ||
935 | ip = GFS2_I(sdp->sd_ir_inode); | ||
936 | error = gfs2_glock_nq_init(ip->i_gl, | ||
937 | LM_ST_EXCLUSIVE, 0, | ||
938 | &sdp->sd_ir_gh); | ||
939 | if (error) { | ||
940 | fs_err(sdp, "can't lock local \"ir\" file: %d\n", error); | ||
941 | goto fail_qc_i; | ||
942 | } | ||
943 | |||
944 | ip = GFS2_I(sdp->sd_sc_inode); | 915 | ip = GFS2_I(sdp->sd_sc_inode); |
945 | error = gfs2_glock_nq_init(ip->i_gl, | 916 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, |
946 | LM_ST_EXCLUSIVE, 0, | ||
947 | &sdp->sd_sc_gh); | 917 | &sdp->sd_sc_gh); |
948 | if (error) { | 918 | if (error) { |
949 | fs_err(sdp, "can't lock local \"sc\" file: %d\n", error); | 919 | fs_err(sdp, "can't lock local \"sc\" file: %d\n", error); |
950 | goto fail_ir_gh; | 920 | goto fail_qc_i; |
951 | } | 921 | } |
952 | 922 | ||
953 | ip = GFS2_I(sdp->sd_qc_inode); | 923 | ip = GFS2_I(sdp->sd_qc_inode); |
954 | error = gfs2_glock_nq_init(ip->i_gl, | 924 | error = gfs2_glock_nq_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, |
955 | LM_ST_EXCLUSIVE, 0, | ||
956 | &sdp->sd_qc_gh); | 925 | &sdp->sd_qc_gh); |
957 | if (error) { | 926 | if (error) { |
958 | fs_err(sdp, "can't lock local \"qc\" file: %d\n", error); | 927 | fs_err(sdp, "can't lock local \"qc\" file: %d\n", error); |
@@ -965,14 +934,10 @@ fail_qc_gh: | |||
965 | gfs2_glock_dq_uninit(&sdp->sd_qc_gh); | 934 | gfs2_glock_dq_uninit(&sdp->sd_qc_gh); |
966 | fail_ut_gh: | 935 | fail_ut_gh: |
967 | gfs2_glock_dq_uninit(&sdp->sd_sc_gh); | 936 | gfs2_glock_dq_uninit(&sdp->sd_sc_gh); |
968 | fail_ir_gh: | ||
969 | gfs2_glock_dq_uninit(&sdp->sd_ir_gh); | ||
970 | fail_qc_i: | 937 | fail_qc_i: |
971 | iput(sdp->sd_qc_inode); | 938 | iput(sdp->sd_qc_inode); |
972 | fail_ut_i: | 939 | fail_ut_i: |
973 | iput(sdp->sd_sc_inode); | 940 | iput(sdp->sd_sc_inode); |
974 | fail_ir_i: | ||
975 | iput(sdp->sd_ir_inode); | ||
976 | fail: | 941 | fail: |
977 | if (pn) | 942 | if (pn) |
978 | iput(pn); | 943 | iput(pn); |
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index c681c54fbd60..388a61d12fc8 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
@@ -1567,6 +1567,8 @@ int gfs2_alloc_di(struct gfs2_inode *dip, u64 *bn, u64 *generation) | |||
1567 | rgd->rd_free--; | 1567 | rgd->rd_free--; |
1568 | rgd->rd_dinodes++; | 1568 | rgd->rd_dinodes++; |
1569 | *generation = rgd->rd_igeneration++; | 1569 | *generation = rgd->rd_igeneration++; |
1570 | if (*generation == 0) | ||
1571 | *generation = rgd->rd_igeneration++; | ||
1570 | gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); | 1572 | gfs2_trans_add_bh(rgd->rd_gl, rgd->rd_bits[0].bi_bh, 1); |
1571 | gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); | 1573 | gfs2_rgrp_out(rgd, rgd->rd_bits[0].bi_bh->b_data); |
1572 | 1574 | ||
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 2e78a3f68a76..d95cf777d244 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
@@ -788,7 +788,6 @@ restart: | |||
788 | /* Release stuff */ | 788 | /* Release stuff */ |
789 | 789 | ||
790 | iput(sdp->sd_jindex); | 790 | iput(sdp->sd_jindex); |
791 | iput(sdp->sd_inum_inode); | ||
792 | iput(sdp->sd_statfs_inode); | 791 | iput(sdp->sd_statfs_inode); |
793 | iput(sdp->sd_rindex); | 792 | iput(sdp->sd_rindex); |
794 | iput(sdp->sd_quota_inode); | 793 | iput(sdp->sd_quota_inode); |
@@ -799,10 +798,8 @@ restart: | |||
799 | if (!sdp->sd_args.ar_spectator) { | 798 | if (!sdp->sd_args.ar_spectator) { |
800 | gfs2_glock_dq_uninit(&sdp->sd_journal_gh); | 799 | gfs2_glock_dq_uninit(&sdp->sd_journal_gh); |
801 | gfs2_glock_dq_uninit(&sdp->sd_jinode_gh); | 800 | gfs2_glock_dq_uninit(&sdp->sd_jinode_gh); |
802 | gfs2_glock_dq_uninit(&sdp->sd_ir_gh); | ||
803 | gfs2_glock_dq_uninit(&sdp->sd_sc_gh); | 801 | gfs2_glock_dq_uninit(&sdp->sd_sc_gh); |
804 | gfs2_glock_dq_uninit(&sdp->sd_qc_gh); | 802 | gfs2_glock_dq_uninit(&sdp->sd_qc_gh); |
805 | iput(sdp->sd_ir_inode); | ||
806 | iput(sdp->sd_sc_inode); | 803 | iput(sdp->sd_sc_inode); |
807 | iput(sdp->sd_qc_inode); | 804 | iput(sdp->sd_qc_inode); |
808 | } | 805 | } |