diff options
Diffstat (limited to 'fs/gfs2/quota.c')
-rw-r--r-- | fs/gfs2/quota.c | 74 |
1 files changed, 34 insertions, 40 deletions
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index a08dabd6ce90..56aaf915c59a 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
@@ -94,7 +94,7 @@ static int qd_alloc(struct gfs2_sbd *sdp, int user, u32 id, | |||
94 | struct gfs2_quota_data *qd; | 94 | struct gfs2_quota_data *qd; |
95 | int error; | 95 | int error; |
96 | 96 | ||
97 | qd = kzalloc(sizeof(struct gfs2_quota_data), GFP_KERNEL); | 97 | qd = kzalloc(sizeof(struct gfs2_quota_data), GFP_NOFS); |
98 | if (!qd) | 98 | if (!qd) |
99 | return -ENOMEM; | 99 | return -ENOMEM; |
100 | 100 | ||
@@ -616,16 +616,9 @@ static int gfs2_adjust_quota(struct gfs2_inode *ip, loff_t loc, | |||
616 | s64 value; | 616 | s64 value; |
617 | int err = -EIO; | 617 | int err = -EIO; |
618 | 618 | ||
619 | if (gfs2_is_stuffed(ip)) { | 619 | if (gfs2_is_stuffed(ip)) |
620 | struct gfs2_alloc *al = NULL; | ||
621 | al = gfs2_alloc_get(ip); | ||
622 | /* just request 1 blk */ | ||
623 | al->al_requested = 1; | ||
624 | gfs2_inplace_reserve(ip); | ||
625 | gfs2_unstuff_dinode(ip, NULL); | 620 | gfs2_unstuff_dinode(ip, NULL); |
626 | gfs2_inplace_release(ip); | 621 | |
627 | gfs2_alloc_put(ip); | ||
628 | } | ||
629 | page = grab_cache_page(mapping, index); | 622 | page = grab_cache_page(mapping, index); |
630 | if (!page) | 623 | if (!page) |
631 | return -ENOMEM; | 624 | return -ENOMEM; |
@@ -690,14 +683,14 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda) | |||
690 | unsigned int qx, x; | 683 | unsigned int qx, x; |
691 | struct gfs2_quota_data *qd; | 684 | struct gfs2_quota_data *qd; |
692 | loff_t offset; | 685 | loff_t offset; |
693 | unsigned int nalloc = 0; | 686 | unsigned int nalloc = 0, blocks; |
694 | struct gfs2_alloc *al = NULL; | 687 | struct gfs2_alloc *al = NULL; |
695 | int error; | 688 | int error; |
696 | 689 | ||
697 | gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota), | 690 | gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota), |
698 | &data_blocks, &ind_blocks); | 691 | &data_blocks, &ind_blocks); |
699 | 692 | ||
700 | ghs = kcalloc(num_qd, sizeof(struct gfs2_holder), GFP_KERNEL); | 693 | ghs = kcalloc(num_qd, sizeof(struct gfs2_holder), GFP_NOFS); |
701 | if (!ghs) | 694 | if (!ghs) |
702 | return -ENOMEM; | 695 | return -ENOMEM; |
703 | 696 | ||
@@ -727,30 +720,33 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda) | |||
727 | nalloc++; | 720 | nalloc++; |
728 | } | 721 | } |
729 | 722 | ||
730 | if (nalloc) { | 723 | al = gfs2_alloc_get(ip); |
731 | al = gfs2_alloc_get(ip); | 724 | if (!al) { |
725 | error = -ENOMEM; | ||
726 | goto out_gunlock; | ||
727 | } | ||
728 | /* | ||
729 | * 1 blk for unstuffing inode if stuffed. We add this extra | ||
730 | * block to the reservation unconditionally. If the inode | ||
731 | * doesn't need unstuffing, the block will be released to the | ||
732 | * rgrp since it won't be allocated during the transaction | ||
733 | */ | ||
734 | al->al_requested = 1; | ||
735 | /* +1 in the end for block requested above for unstuffing */ | ||
736 | blocks = num_qd * data_blocks + RES_DINODE + num_qd + 1; | ||
732 | 737 | ||
733 | al->al_requested = nalloc * (data_blocks + ind_blocks); | 738 | if (nalloc) |
739 | al->al_requested += nalloc * (data_blocks + ind_blocks); | ||
740 | error = gfs2_inplace_reserve(ip); | ||
741 | if (error) | ||
742 | goto out_alloc; | ||
734 | 743 | ||
735 | error = gfs2_inplace_reserve(ip); | 744 | if (nalloc) |
736 | if (error) | 745 | blocks += al->al_rgd->rd_length + nalloc * ind_blocks + RES_STATFS; |
737 | goto out_alloc; | 746 | |
738 | 747 | error = gfs2_trans_begin(sdp, blocks, 0); | |
739 | error = gfs2_trans_begin(sdp, | 748 | if (error) |
740 | al->al_rgd->rd_length + | 749 | goto out_ipres; |
741 | num_qd * data_blocks + | ||
742 | nalloc * ind_blocks + | ||
743 | RES_DINODE + num_qd + | ||
744 | RES_STATFS, 0); | ||
745 | if (error) | ||
746 | goto out_ipres; | ||
747 | } else { | ||
748 | error = gfs2_trans_begin(sdp, | ||
749 | num_qd * data_blocks + | ||
750 | RES_DINODE + num_qd, 0); | ||
751 | if (error) | ||
752 | goto out_gunlock; | ||
753 | } | ||
754 | 750 | ||
755 | for (x = 0; x < num_qd; x++) { | 751 | for (x = 0; x < num_qd; x++) { |
756 | qd = qda[x]; | 752 | qd = qda[x]; |
@@ -769,11 +765,9 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda) | |||
769 | out_end_trans: | 765 | out_end_trans: |
770 | gfs2_trans_end(sdp); | 766 | gfs2_trans_end(sdp); |
771 | out_ipres: | 767 | out_ipres: |
772 | if (nalloc) | 768 | gfs2_inplace_release(ip); |
773 | gfs2_inplace_release(ip); | ||
774 | out_alloc: | 769 | out_alloc: |
775 | if (nalloc) | 770 | gfs2_alloc_put(ip); |
776 | gfs2_alloc_put(ip); | ||
777 | out_gunlock: | 771 | out_gunlock: |
778 | gfs2_glock_dq_uninit(&i_gh); | 772 | gfs2_glock_dq_uninit(&i_gh); |
779 | out: | 773 | out: |
@@ -1124,12 +1118,12 @@ int gfs2_quota_init(struct gfs2_sbd *sdp) | |||
1124 | error = -ENOMEM; | 1118 | error = -ENOMEM; |
1125 | 1119 | ||
1126 | sdp->sd_quota_bitmap = kcalloc(sdp->sd_quota_chunks, | 1120 | sdp->sd_quota_bitmap = kcalloc(sdp->sd_quota_chunks, |
1127 | sizeof(unsigned char *), GFP_KERNEL); | 1121 | sizeof(unsigned char *), GFP_NOFS); |
1128 | if (!sdp->sd_quota_bitmap) | 1122 | if (!sdp->sd_quota_bitmap) |
1129 | return error; | 1123 | return error; |
1130 | 1124 | ||
1131 | for (x = 0; x < sdp->sd_quota_chunks; x++) { | 1125 | for (x = 0; x < sdp->sd_quota_chunks; x++) { |
1132 | sdp->sd_quota_bitmap[x] = kzalloc(PAGE_SIZE, GFP_KERNEL); | 1126 | sdp->sd_quota_bitmap[x] = kzalloc(PAGE_SIZE, GFP_NOFS); |
1133 | if (!sdp->sd_quota_bitmap[x]) | 1127 | if (!sdp->sd_quota_bitmap[x]) |
1134 | goto fail; | 1128 | goto fail; |
1135 | } | 1129 | } |