diff options
| author | Bob Peterson <rpeterso@redhat.com> | 2011-11-21 13:36:17 -0500 |
|---|---|---|
| committer | Steven Whitehouse <swhiteho@redhat.com> | 2011-11-22 05:25:21 -0500 |
| commit | 564e12b1157215171e7f3af5b70611ec7154327c (patch) | |
| tree | f2a6e3394e59209f8e43a36f10f67bf1372c966c | |
| parent | b3e47ca0c2427ec72a74e36c6408784b6098f2b5 (diff) | |
GFS2: decouple quota allocations from block allocations
This patch separates the code pertaining to allocations into two
parts: quota-related information and block reservations.
This patch also moves all the block reservation structure allocations to
function gfs2_inplace_reserve to simplify the code, and moves
the frees to function gfs2_inplace_release.
Signed-off-by: Bob Peterson <rpeterso@redhat.com>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
| -rw-r--r-- | fs/gfs2/aops.c | 18 | ||||
| -rw-r--r-- | fs/gfs2/bmap.c | 19 | ||||
| -rw-r--r-- | fs/gfs2/dir.c | 4 | ||||
| -rw-r--r-- | fs/gfs2/file.c | 25 | ||||
| -rw-r--r-- | fs/gfs2/incore.h | 19 | ||||
| -rw-r--r-- | fs/gfs2/inode.c | 58 | ||||
| -rw-r--r-- | fs/gfs2/main.c | 3 | ||||
| -rw-r--r-- | fs/gfs2/quota.c | 85 | ||||
| -rw-r--r-- | fs/gfs2/rgrp.c | 71 | ||||
| -rw-r--r-- | fs/gfs2/rgrp.h | 12 | ||||
| -rw-r--r-- | fs/gfs2/super.c | 14 | ||||
| -rw-r--r-- | fs/gfs2/trans.h | 6 | ||||
| -rw-r--r-- | fs/gfs2/xattr.c | 35 |
13 files changed, 188 insertions, 181 deletions
diff --git a/fs/gfs2/aops.c b/fs/gfs2/aops.c index 4858e1fed8b1..501e5cba09b3 100644 --- a/fs/gfs2/aops.c +++ b/fs/gfs2/aops.c | |||
| @@ -615,7 +615,7 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping, | |||
| 615 | unsigned int data_blocks = 0, ind_blocks = 0, rblocks; | 615 | unsigned int data_blocks = 0, ind_blocks = 0, rblocks; |
| 616 | int alloc_required; | 616 | int alloc_required; |
| 617 | int error = 0; | 617 | int error = 0; |
| 618 | struct gfs2_alloc *al = NULL; | 618 | struct gfs2_qadata *qa = NULL; |
| 619 | pgoff_t index = pos >> PAGE_CACHE_SHIFT; | 619 | pgoff_t index = pos >> PAGE_CACHE_SHIFT; |
| 620 | unsigned from = pos & (PAGE_CACHE_SIZE - 1); | 620 | unsigned from = pos & (PAGE_CACHE_SIZE - 1); |
| 621 | struct page *page; | 621 | struct page *page; |
| @@ -639,8 +639,8 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping, | |||
| 639 | gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks); | 639 | gfs2_write_calc_reserv(ip, len, &data_blocks, &ind_blocks); |
| 640 | 640 | ||
| 641 | if (alloc_required) { | 641 | if (alloc_required) { |
| 642 | al = gfs2_alloc_get(ip); | 642 | qa = gfs2_qadata_get(ip); |
| 643 | if (!al) { | 643 | if (!qa) { |
| 644 | error = -ENOMEM; | 644 | error = -ENOMEM; |
| 645 | goto out_unlock; | 645 | goto out_unlock; |
| 646 | } | 646 | } |
| @@ -649,8 +649,7 @@ static int gfs2_write_begin(struct file *file, struct address_space *mapping, | |||
| 649 | if (error) | 649 | if (error) |
| 650 | goto out_alloc_put; | 650 | goto out_alloc_put; |
| 651 | 651 | ||
| 652 | al->al_requested = data_blocks + ind_blocks; | 652 | error = gfs2_inplace_reserve(ip, data_blocks + ind_blocks); |
| 653 | error = gfs2_inplace_reserve(ip); | ||
| 654 | if (error) | 653 | if (error) |
| 655 | goto out_qunlock; | 654 | goto out_qunlock; |
| 656 | } | 655 | } |
| @@ -711,7 +710,7 @@ out_trans_fail: | |||
| 711 | out_qunlock: | 710 | out_qunlock: |
| 712 | gfs2_quota_unlock(ip); | 711 | gfs2_quota_unlock(ip); |
| 713 | out_alloc_put: | 712 | out_alloc_put: |
| 714 | gfs2_alloc_put(ip); | 713 | gfs2_qadata_put(ip); |
| 715 | } | 714 | } |
| 716 | out_unlock: | 715 | out_unlock: |
| 717 | if (&ip->i_inode == sdp->sd_rindex) { | 716 | if (&ip->i_inode == sdp->sd_rindex) { |
| @@ -848,7 +847,7 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping, | |||
| 848 | struct gfs2_sbd *sdp = GFS2_SB(inode); | 847 | struct gfs2_sbd *sdp = GFS2_SB(inode); |
| 849 | struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); | 848 | struct gfs2_inode *m_ip = GFS2_I(sdp->sd_statfs_inode); |
| 850 | struct buffer_head *dibh; | 849 | struct buffer_head *dibh; |
| 851 | struct gfs2_alloc *al = ip->i_alloc; | 850 | struct gfs2_qadata *qa = ip->i_qadata; |
| 852 | unsigned int from = pos & (PAGE_CACHE_SIZE - 1); | 851 | unsigned int from = pos & (PAGE_CACHE_SIZE - 1); |
| 853 | unsigned int to = from + len; | 852 | unsigned int to = from + len; |
| 854 | int ret; | 853 | int ret; |
| @@ -880,10 +879,11 @@ static int gfs2_write_end(struct file *file, struct address_space *mapping, | |||
| 880 | brelse(dibh); | 879 | brelse(dibh); |
| 881 | failed: | 880 | failed: |
| 882 | gfs2_trans_end(sdp); | 881 | gfs2_trans_end(sdp); |
| 883 | if (al) { | 882 | if (ip->i_res) |
| 884 | gfs2_inplace_release(ip); | 883 | gfs2_inplace_release(ip); |
| 884 | if (qa) { | ||
| 885 | gfs2_quota_unlock(ip); | 885 | gfs2_quota_unlock(ip); |
| 886 | gfs2_alloc_put(ip); | 886 | gfs2_qadata_put(ip); |
| 887 | } | 887 | } |
| 888 | if (inode == sdp->sd_rindex) { | 888 | if (inode == sdp->sd_rindex) { |
| 889 | gfs2_glock_dq(&m_ip->i_gh); | 889 | gfs2_glock_dq(&m_ip->i_gh); |
diff --git a/fs/gfs2/bmap.c b/fs/gfs2/bmap.c index cb74312eb270..14a704015970 100644 --- a/fs/gfs2/bmap.c +++ b/fs/gfs2/bmap.c | |||
| @@ -1041,7 +1041,7 @@ static int trunc_dealloc(struct gfs2_inode *ip, u64 size) | |||
| 1041 | lblock = (size - 1) >> sdp->sd_sb.sb_bsize_shift; | 1041 | lblock = (size - 1) >> sdp->sd_sb.sb_bsize_shift; |
| 1042 | 1042 | ||
| 1043 | find_metapath(sdp, lblock, &mp, ip->i_height); | 1043 | find_metapath(sdp, lblock, &mp, ip->i_height); |
| 1044 | if (!gfs2_alloc_get(ip)) | 1044 | if (!gfs2_qadata_get(ip)) |
| 1045 | return -ENOMEM; | 1045 | return -ENOMEM; |
| 1046 | 1046 | ||
| 1047 | error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); | 1047 | error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); |
| @@ -1061,7 +1061,7 @@ static int trunc_dealloc(struct gfs2_inode *ip, u64 size) | |||
| 1061 | gfs2_quota_unhold(ip); | 1061 | gfs2_quota_unhold(ip); |
| 1062 | 1062 | ||
| 1063 | out: | 1063 | out: |
| 1064 | gfs2_alloc_put(ip); | 1064 | gfs2_qadata_put(ip); |
| 1065 | return error; | 1065 | return error; |
| 1066 | } | 1066 | } |
| 1067 | 1067 | ||
| @@ -1163,21 +1163,20 @@ static int do_grow(struct inode *inode, u64 size) | |||
| 1163 | struct gfs2_inode *ip = GFS2_I(inode); | 1163 | struct gfs2_inode *ip = GFS2_I(inode); |
| 1164 | struct gfs2_sbd *sdp = GFS2_SB(inode); | 1164 | struct gfs2_sbd *sdp = GFS2_SB(inode); |
| 1165 | struct buffer_head *dibh; | 1165 | struct buffer_head *dibh; |
| 1166 | struct gfs2_alloc *al = NULL; | 1166 | struct gfs2_qadata *qa = NULL; |
| 1167 | int error; | 1167 | int error; |
| 1168 | 1168 | ||
| 1169 | if (gfs2_is_stuffed(ip) && | 1169 | if (gfs2_is_stuffed(ip) && |
| 1170 | (size > (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)))) { | 1170 | (size > (sdp->sd_sb.sb_bsize - sizeof(struct gfs2_dinode)))) { |
| 1171 | al = gfs2_alloc_get(ip); | 1171 | qa = gfs2_qadata_get(ip); |
| 1172 | if (al == NULL) | 1172 | if (qa == NULL) |
| 1173 | return -ENOMEM; | 1173 | return -ENOMEM; |
| 1174 | 1174 | ||
| 1175 | error = gfs2_quota_lock_check(ip); | 1175 | error = gfs2_quota_lock_check(ip); |
| 1176 | if (error) | 1176 | if (error) |
| 1177 | goto do_grow_alloc_put; | 1177 | goto do_grow_alloc_put; |
| 1178 | 1178 | ||
| 1179 | al->al_requested = 1; | 1179 | error = gfs2_inplace_reserve(ip, 1); |
| 1180 | error = gfs2_inplace_reserve(ip); | ||
| 1181 | if (error) | 1180 | if (error) |
| 1182 | goto do_grow_qunlock; | 1181 | goto do_grow_qunlock; |
| 1183 | } | 1182 | } |
| @@ -1186,7 +1185,7 @@ static int do_grow(struct inode *inode, u64 size) | |||
| 1186 | if (error) | 1185 | if (error) |
| 1187 | goto do_grow_release; | 1186 | goto do_grow_release; |
| 1188 | 1187 | ||
| 1189 | if (al) { | 1188 | if (qa) { |
| 1190 | error = gfs2_unstuff_dinode(ip, NULL); | 1189 | error = gfs2_unstuff_dinode(ip, NULL); |
| 1191 | if (error) | 1190 | if (error) |
| 1192 | goto do_end_trans; | 1191 | goto do_end_trans; |
| @@ -1205,12 +1204,12 @@ static int do_grow(struct inode *inode, u64 size) | |||
| 1205 | do_end_trans: | 1204 | do_end_trans: |
| 1206 | gfs2_trans_end(sdp); | 1205 | gfs2_trans_end(sdp); |
| 1207 | do_grow_release: | 1206 | do_grow_release: |
| 1208 | if (al) { | 1207 | if (qa) { |
| 1209 | gfs2_inplace_release(ip); | 1208 | gfs2_inplace_release(ip); |
| 1210 | do_grow_qunlock: | 1209 | do_grow_qunlock: |
| 1211 | gfs2_quota_unlock(ip); | 1210 | gfs2_quota_unlock(ip); |
| 1212 | do_grow_alloc_put: | 1211 | do_grow_alloc_put: |
| 1213 | gfs2_alloc_put(ip); | 1212 | gfs2_qadata_put(ip); |
| 1214 | } | 1213 | } |
| 1215 | return error; | 1214 | return error; |
| 1216 | } | 1215 | } |
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index f8485da3b853..c35573abd371 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c | |||
| @@ -1850,7 +1850,7 @@ static int leaf_dealloc(struct gfs2_inode *dip, u32 index, u32 len, | |||
| 1850 | if (!ht) | 1850 | if (!ht) |
| 1851 | return -ENOMEM; | 1851 | return -ENOMEM; |
| 1852 | 1852 | ||
| 1853 | if (!gfs2_alloc_get(dip)) { | 1853 | if (!gfs2_qadata_get(dip)) { |
| 1854 | error = -ENOMEM; | 1854 | error = -ENOMEM; |
| 1855 | goto out; | 1855 | goto out; |
| 1856 | } | 1856 | } |
| @@ -1939,7 +1939,7 @@ out_rlist: | |||
| 1939 | gfs2_rlist_free(&rlist); | 1939 | gfs2_rlist_free(&rlist); |
| 1940 | gfs2_quota_unhold(dip); | 1940 | gfs2_quota_unhold(dip); |
| 1941 | out_put: | 1941 | out_put: |
| 1942 | gfs2_alloc_put(dip); | 1942 | gfs2_qadata_put(dip); |
| 1943 | out: | 1943 | out: |
| 1944 | kfree(ht); | 1944 | kfree(ht); |
| 1945 | return error; | 1945 | return error; |
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index 9b6c6ac351a8..42ceb23651e5 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c | |||
| @@ -365,7 +365,7 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
| 365 | u64 pos = page->index << PAGE_CACHE_SHIFT; | 365 | u64 pos = page->index << PAGE_CACHE_SHIFT; |
| 366 | unsigned int data_blocks, ind_blocks, rblocks; | 366 | unsigned int data_blocks, ind_blocks, rblocks; |
| 367 | struct gfs2_holder gh; | 367 | struct gfs2_holder gh; |
| 368 | struct gfs2_alloc *al; | 368 | struct gfs2_qadata *qa; |
| 369 | loff_t size; | 369 | loff_t size; |
| 370 | int ret; | 370 | int ret; |
| 371 | 371 | ||
| @@ -393,16 +393,15 @@ static int gfs2_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf) | |||
| 393 | } | 393 | } |
| 394 | 394 | ||
| 395 | ret = -ENOMEM; | 395 | ret = -ENOMEM; |
| 396 | al = gfs2_alloc_get(ip); | 396 | qa = gfs2_qadata_get(ip); |
| 397 | if (al == NULL) | 397 | if (qa == NULL) |
| 398 | goto out_unlock; | 398 | goto out_unlock; |
| 399 | 399 | ||
| 400 | ret = gfs2_quota_lock_check(ip); | 400 | ret = gfs2_quota_lock_check(ip); |
| 401 | if (ret) | 401 | if (ret) |
| 402 | goto out_alloc_put; | 402 | goto out_alloc_put; |
| 403 | gfs2_write_calc_reserv(ip, PAGE_CACHE_SIZE, &data_blocks, &ind_blocks); | 403 | gfs2_write_calc_reserv(ip, PAGE_CACHE_SIZE, &data_blocks, &ind_blocks); |
| 404 | al->al_requested = data_blocks + ind_blocks; | 404 | ret = gfs2_inplace_reserve(ip, data_blocks + ind_blocks); |
| 405 | ret = gfs2_inplace_reserve(ip); | ||
| 406 | if (ret) | 405 | if (ret) |
| 407 | goto out_quota_unlock; | 406 | goto out_quota_unlock; |
| 408 | 407 | ||
| @@ -448,7 +447,7 @@ out_trans_fail: | |||
| 448 | out_quota_unlock: | 447 | out_quota_unlock: |
| 449 | gfs2_quota_unlock(ip); | 448 | gfs2_quota_unlock(ip); |
| 450 | out_alloc_put: | 449 | out_alloc_put: |
| 451 | gfs2_alloc_put(ip); | 450 | gfs2_qadata_put(ip); |
| 452 | out_unlock: | 451 | out_unlock: |
| 453 | gfs2_glock_dq(&gh); | 452 | gfs2_glock_dq(&gh); |
| 454 | out: | 453 | out: |
| @@ -750,7 +749,7 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, | |||
| 750 | struct gfs2_inode *ip = GFS2_I(inode); | 749 | struct gfs2_inode *ip = GFS2_I(inode); |
| 751 | unsigned int data_blocks = 0, ind_blocks = 0, rblocks; | 750 | unsigned int data_blocks = 0, ind_blocks = 0, rblocks; |
| 752 | loff_t bytes, max_bytes; | 751 | loff_t bytes, max_bytes; |
| 753 | struct gfs2_alloc *al; | 752 | struct gfs2_qadata *qa; |
| 754 | int error; | 753 | int error; |
| 755 | const loff_t pos = offset; | 754 | const loff_t pos = offset; |
| 756 | const loff_t count = len; | 755 | const loff_t count = len; |
| @@ -784,8 +783,8 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, | |||
| 784 | while (len > 0) { | 783 | while (len > 0) { |
| 785 | if (len < bytes) | 784 | if (len < bytes) |
| 786 | bytes = len; | 785 | bytes = len; |
| 787 | al = gfs2_alloc_get(ip); | 786 | qa = gfs2_qadata_get(ip); |
| 788 | if (!al) { | 787 | if (!qa) { |
| 789 | error = -ENOMEM; | 788 | error = -ENOMEM; |
| 790 | goto out_unlock; | 789 | goto out_unlock; |
| 791 | } | 790 | } |
| @@ -797,8 +796,7 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, | |||
| 797 | retry: | 796 | retry: |
| 798 | gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks); | 797 | gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks); |
| 799 | 798 | ||
| 800 | al->al_requested = data_blocks + ind_blocks; | 799 | error = gfs2_inplace_reserve(ip, data_blocks + ind_blocks); |
| 801 | error = gfs2_inplace_reserve(ip); | ||
| 802 | if (error) { | 800 | if (error) { |
| 803 | if (error == -ENOSPC && bytes > sdp->sd_sb.sb_bsize) { | 801 | if (error == -ENOSPC && bytes > sdp->sd_sb.sb_bsize) { |
| 804 | bytes >>= 1; | 802 | bytes >>= 1; |
| @@ -812,7 +810,6 @@ retry: | |||
| 812 | max_bytes = bytes; | 810 | max_bytes = bytes; |
| 813 | calc_max_reserv(ip, (len > max_chunk_size)? max_chunk_size: len, | 811 | calc_max_reserv(ip, (len > max_chunk_size)? max_chunk_size: len, |
| 814 | &max_bytes, &data_blocks, &ind_blocks); | 812 | &max_bytes, &data_blocks, &ind_blocks); |
| 815 | al->al_requested = data_blocks + ind_blocks; | ||
| 816 | 813 | ||
| 817 | rblocks = RES_DINODE + ind_blocks + RES_STATFS + RES_QUOTA + | 814 | rblocks = RES_DINODE + ind_blocks + RES_STATFS + RES_QUOTA + |
| 818 | RES_RG_HDR + gfs2_rg_blocks(ip); | 815 | RES_RG_HDR + gfs2_rg_blocks(ip); |
| @@ -834,7 +831,7 @@ retry: | |||
| 834 | offset += max_bytes; | 831 | offset += max_bytes; |
| 835 | gfs2_inplace_release(ip); | 832 | gfs2_inplace_release(ip); |
| 836 | gfs2_quota_unlock(ip); | 833 | gfs2_quota_unlock(ip); |
| 837 | gfs2_alloc_put(ip); | 834 | gfs2_qadata_put(ip); |
| 838 | } | 835 | } |
| 839 | 836 | ||
| 840 | if (error == 0) | 837 | if (error == 0) |
| @@ -846,7 +843,7 @@ out_trans_fail: | |||
| 846 | out_qunlock: | 843 | out_qunlock: |
| 847 | gfs2_quota_unlock(ip); | 844 | gfs2_quota_unlock(ip); |
| 848 | out_alloc_put: | 845 | out_alloc_put: |
| 849 | gfs2_alloc_put(ip); | 846 | gfs2_qadata_put(ip); |
| 850 | out_unlock: | 847 | out_unlock: |
| 851 | gfs2_glock_dq(&ip->i_gh); | 848 | gfs2_glock_dq(&ip->i_gh); |
| 852 | out_uninit: | 849 | out_uninit: |
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 32f5beccb74b..e1d3bb59945c 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h | |||
| @@ -244,16 +244,16 @@ struct gfs2_glock { | |||
| 244 | 244 | ||
| 245 | #define GFS2_MIN_LVB_SIZE 32 /* Min size of LVB that gfs2 supports */ | 245 | #define GFS2_MIN_LVB_SIZE 32 /* Min size of LVB that gfs2 supports */ |
| 246 | 246 | ||
| 247 | struct gfs2_alloc { | 247 | struct gfs2_qadata { /* quota allocation data */ |
| 248 | /* Quota stuff */ | 248 | /* Quota stuff */ |
| 249 | struct gfs2_quota_data *al_qd[2*MAXQUOTAS]; | 249 | struct gfs2_quota_data *qa_qd[2*MAXQUOTAS]; |
| 250 | struct gfs2_holder al_qd_ghs[2*MAXQUOTAS]; | 250 | struct gfs2_holder qa_qd_ghs[2*MAXQUOTAS]; |
| 251 | unsigned int al_qd_num; | 251 | unsigned int qa_qd_num; |
| 252 | 252 | }; | |
| 253 | u32 al_requested; /* Filled in by caller of gfs2_inplace_reserve() */ | ||
| 254 | 253 | ||
| 255 | /* Filled in by gfs2_inplace_reserve() */ | 254 | struct gfs2_blkreserv { |
| 256 | struct gfs2_holder al_rgd_gh; | 255 | u32 rs_requested; /* Filled in by caller of gfs2_inplace_reserve() */ |
| 256 | struct gfs2_holder rs_rgd_gh; /* Filled in by gfs2_inplace_reserve() */ | ||
| 257 | }; | 257 | }; |
| 258 | 258 | ||
| 259 | enum { | 259 | enum { |
| @@ -274,7 +274,8 @@ struct gfs2_inode { | |||
| 274 | struct gfs2_glock *i_gl; /* Move into i_gh? */ | 274 | struct gfs2_glock *i_gl; /* Move into i_gh? */ |
| 275 | struct gfs2_holder i_iopen_gh; | 275 | struct gfs2_holder i_iopen_gh; |
| 276 | struct gfs2_holder i_gh; /* for prepare/commit_write only */ | 276 | struct gfs2_holder i_gh; /* for prepare/commit_write only */ |
| 277 | struct gfs2_alloc *i_alloc; | 277 | struct gfs2_qadata *i_qadata; /* quota allocation data */ |
| 278 | struct gfs2_blkreserv *i_res; /* resource group block reservation */ | ||
| 278 | struct gfs2_rgrpd *i_rgd; | 279 | struct gfs2_rgrpd *i_rgd; |
| 279 | u64 i_goal; /* goal block for allocations */ | 280 | u64 i_goal; /* goal block for allocations */ |
| 280 | struct rw_semaphore i_rw_mutex; | 281 | struct rw_semaphore i_rw_mutex; |
diff --git a/fs/gfs2/inode.c b/fs/gfs2/inode.c index 3ab192bac7d3..ab8c429880a5 100644 --- a/fs/gfs2/inode.c +++ b/fs/gfs2/inode.c | |||
| @@ -391,11 +391,11 @@ static int alloc_dinode(struct gfs2_inode *dip, u64 *no_addr, u64 *generation) | |||
| 391 | int error; | 391 | int error; |
| 392 | int dblocks = 0; | 392 | int dblocks = 0; |
| 393 | 393 | ||
| 394 | if (gfs2_alloc_get(dip) == NULL) | 394 | error = gfs2_rindex_update(sdp); |
| 395 | return -ENOMEM; | 395 | if (error) |
| 396 | fs_warn(sdp, "rindex update returns %d\n", error); | ||
| 396 | 397 | ||
| 397 | dip->i_alloc->al_requested = RES_DINODE; | 398 | error = gfs2_inplace_reserve(dip, RES_DINODE); |
| 398 | error = gfs2_inplace_reserve(dip); | ||
| 399 | if (error) | 399 | if (error) |
| 400 | goto out; | 400 | goto out; |
| 401 | 401 | ||
| @@ -410,7 +410,6 @@ static int alloc_dinode(struct gfs2_inode *dip, u64 *no_addr, u64 *generation) | |||
| 410 | out_ipreserv: | 410 | out_ipreserv: |
| 411 | gfs2_inplace_release(dip); | 411 | gfs2_inplace_release(dip); |
| 412 | out: | 412 | out: |
| 413 | gfs2_alloc_put(dip); | ||
| 414 | return error; | 413 | return error; |
| 415 | } | 414 | } |
| 416 | 415 | ||
| @@ -526,7 +525,7 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, | |||
| 526 | int error; | 525 | int error; |
| 527 | 526 | ||
| 528 | munge_mode_uid_gid(dip, &mode, &uid, &gid); | 527 | munge_mode_uid_gid(dip, &mode, &uid, &gid); |
| 529 | if (!gfs2_alloc_get(dip)) | 528 | if (!gfs2_qadata_get(dip)) |
| 530 | return -ENOMEM; | 529 | return -ENOMEM; |
| 531 | 530 | ||
| 532 | error = gfs2_quota_lock(dip, uid, gid); | 531 | error = gfs2_quota_lock(dip, uid, gid); |
| @@ -548,7 +547,7 @@ static int make_dinode(struct gfs2_inode *dip, struct gfs2_glock *gl, | |||
| 548 | out_quota: | 547 | out_quota: |
| 549 | gfs2_quota_unlock(dip); | 548 | gfs2_quota_unlock(dip); |
| 550 | out: | 549 | out: |
| 551 | gfs2_alloc_put(dip); | 550 | gfs2_qadata_put(dip); |
| 552 | return error; | 551 | return error; |
| 553 | } | 552 | } |
| 554 | 553 | ||
| @@ -556,13 +555,13 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name, | |||
| 556 | struct gfs2_inode *ip) | 555 | struct gfs2_inode *ip) |
| 557 | { | 556 | { |
| 558 | struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); | 557 | struct gfs2_sbd *sdp = GFS2_SB(&dip->i_inode); |
| 559 | struct gfs2_alloc *al; | 558 | struct gfs2_qadata *qa; |
| 560 | int alloc_required; | 559 | int alloc_required; |
| 561 | struct buffer_head *dibh; | 560 | struct buffer_head *dibh; |
| 562 | int error; | 561 | int error; |
| 563 | 562 | ||
| 564 | al = gfs2_alloc_get(dip); | 563 | qa = gfs2_qadata_get(dip); |
| 565 | if (!al) | 564 | if (!qa) |
| 566 | return -ENOMEM; | 565 | return -ENOMEM; |
| 567 | 566 | ||
| 568 | error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); | 567 | error = gfs2_quota_lock(dip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); |
| @@ -577,9 +576,7 @@ static int link_dinode(struct gfs2_inode *dip, const struct qstr *name, | |||
| 577 | if (error) | 576 | if (error) |
| 578 | goto fail_quota_locks; | 577 | goto fail_quota_locks; |
| 579 | 578 | ||
| 580 | al->al_requested = sdp->sd_max_dirres; | 579 | error = gfs2_inplace_reserve(dip, sdp->sd_max_dirres); |
| 581 | |||
| 582 | error = gfs2_inplace_reserve(dip); | ||
| 583 | if (error) | 580 | if (error) |
| 584 | goto fail_quota_locks; | 581 | goto fail_quota_locks; |
| 585 | 582 | ||
| @@ -620,7 +617,7 @@ fail_quota_locks: | |||
| 620 | gfs2_quota_unlock(dip); | 617 | gfs2_quota_unlock(dip); |
| 621 | 618 | ||
| 622 | fail: | 619 | fail: |
| 623 | gfs2_alloc_put(dip); | 620 | gfs2_qadata_put(dip); |
| 624 | return error; | 621 | return error; |
| 625 | } | 622 | } |
| 626 | 623 | ||
| @@ -729,9 +726,12 @@ static int gfs2_create_inode(struct inode *dir, struct dentry *dentry, | |||
| 729 | brelse(bh); | 726 | brelse(bh); |
| 730 | 727 | ||
| 731 | gfs2_trans_end(sdp); | 728 | gfs2_trans_end(sdp); |
| 732 | gfs2_inplace_release(dip); | 729 | /* Check if we reserved space in the rgrp. Function link_dinode may |
| 730 | not, depending on whether alloc is required. */ | ||
| 731 | if (dip->i_res) | ||
| 732 | gfs2_inplace_release(dip); | ||
| 733 | gfs2_quota_unlock(dip); | 733 | gfs2_quota_unlock(dip); |
| 734 | gfs2_alloc_put(dip); | 734 | gfs2_qadata_put(dip); |
| 735 | mark_inode_dirty(inode); | 735 | mark_inode_dirty(inode); |
| 736 | gfs2_glock_dq_uninit_m(2, ghs); | 736 | gfs2_glock_dq_uninit_m(2, ghs); |
| 737 | d_instantiate(dentry, inode); | 737 | d_instantiate(dentry, inode); |
| @@ -876,8 +876,9 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, | |||
| 876 | error = 0; | 876 | error = 0; |
| 877 | 877 | ||
| 878 | if (alloc_required) { | 878 | if (alloc_required) { |
| 879 | struct gfs2_alloc *al = gfs2_alloc_get(dip); | 879 | struct gfs2_qadata *qa = gfs2_qadata_get(dip); |
| 880 | if (!al) { | 880 | |
| 881 | if (!qa) { | ||
| 881 | error = -ENOMEM; | 882 | error = -ENOMEM; |
| 882 | goto out_gunlock; | 883 | goto out_gunlock; |
| 883 | } | 884 | } |
| @@ -886,9 +887,7 @@ static int gfs2_link(struct dentry *old_dentry, struct inode *dir, | |||
| 886 | if (error) | 887 | if (error) |
| 887 | goto out_alloc; | 888 | goto out_alloc; |
| 888 | 889 | ||
| 889 | al->al_requested = sdp->sd_max_dirres; | 890 | error = gfs2_inplace_reserve(dip, sdp->sd_max_dirres); |
| 890 | |||
| 891 | error = gfs2_inplace_reserve(dip); | ||
| 892 | if (error) | 891 | if (error) |
| 893 | goto out_gunlock_q; | 892 | goto out_gunlock_q; |
| 894 | 893 | ||
| @@ -931,7 +930,7 @@ out_gunlock_q: | |||
| 931 | gfs2_quota_unlock(dip); | 930 | gfs2_quota_unlock(dip); |
| 932 | out_alloc: | 931 | out_alloc: |
| 933 | if (alloc_required) | 932 | if (alloc_required) |
| 934 | gfs2_alloc_put(dip); | 933 | gfs2_qadata_put(dip); |
| 935 | out_gunlock: | 934 | out_gunlock: |
| 936 | gfs2_glock_dq(ghs + 1); | 935 | gfs2_glock_dq(ghs + 1); |
| 937 | out_child: | 936 | out_child: |
| @@ -1354,8 +1353,9 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, | |||
| 1354 | error = 0; | 1353 | error = 0; |
| 1355 | 1354 | ||
| 1356 | if (alloc_required) { | 1355 | if (alloc_required) { |
| 1357 | struct gfs2_alloc *al = gfs2_alloc_get(ndip); | 1356 | struct gfs2_qadata *qa = gfs2_qadata_get(ndip); |
| 1358 | if (!al) { | 1357 | |
| 1358 | if (!qa) { | ||
| 1359 | error = -ENOMEM; | 1359 | error = -ENOMEM; |
| 1360 | goto out_gunlock; | 1360 | goto out_gunlock; |
| 1361 | } | 1361 | } |
| @@ -1364,9 +1364,7 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry, | |||
| 1364 | if (error) | 1364 | if (error) |
| 1365 | goto out_alloc; | 1365 | goto out_alloc; |
| 1366 | 1366 | ||
| 1367 | al->al_requested = sdp->sd_max_dirres; | 1367 | error = gfs2_inplace_reserve(ndip, sdp->sd_max_dirres); |
| 1368 | |||
| 1369 | error = gfs2_inplace_reserve(ndip); | ||
| 1370 | if (error) | 1368 | if (error) |
| 1371 | goto out_gunlock_q; | 1369 | goto out_gunlock_q; |
| 1372 | 1370 | ||
| @@ -1427,7 +1425,7 @@ out_gunlock_q: | |||
| 1427 | gfs2_quota_unlock(ndip); | 1425 | gfs2_quota_unlock(ndip); |
| 1428 | out_alloc: | 1426 | out_alloc: |
| 1429 | if (alloc_required) | 1427 | if (alloc_required) |
| 1430 | gfs2_alloc_put(ndip); | 1428 | gfs2_qadata_put(ndip); |
| 1431 | out_gunlock: | 1429 | out_gunlock: |
| 1432 | while (x--) { | 1430 | while (x--) { |
| 1433 | gfs2_glock_dq(ghs + x); | 1431 | gfs2_glock_dq(ghs + x); |
| @@ -1588,7 +1586,7 @@ static int setattr_chown(struct inode *inode, struct iattr *attr) | |||
| 1588 | if (!(attr->ia_valid & ATTR_GID) || ogid == ngid) | 1586 | if (!(attr->ia_valid & ATTR_GID) || ogid == ngid) |
| 1589 | ogid = ngid = NO_QUOTA_CHANGE; | 1587 | ogid = ngid = NO_QUOTA_CHANGE; |
| 1590 | 1588 | ||
| 1591 | if (!gfs2_alloc_get(ip)) | 1589 | if (!gfs2_qadata_get(ip)) |
| 1592 | return -ENOMEM; | 1590 | return -ENOMEM; |
| 1593 | 1591 | ||
| 1594 | error = gfs2_quota_lock(ip, nuid, ngid); | 1592 | error = gfs2_quota_lock(ip, nuid, ngid); |
| @@ -1620,7 +1618,7 @@ out_end_trans: | |||
| 1620 | out_gunlock_q: | 1618 | out_gunlock_q: |
| 1621 | gfs2_quota_unlock(ip); | 1619 | gfs2_quota_unlock(ip); |
| 1622 | out_alloc: | 1620 | out_alloc: |
| 1623 | gfs2_alloc_put(ip); | 1621 | gfs2_qadata_put(ip); |
| 1624 | return error; | 1622 | return error; |
| 1625 | } | 1623 | } |
| 1626 | 1624 | ||
diff --git a/fs/gfs2/main.c b/fs/gfs2/main.c index 8a139ff1919f..c150298e2d8e 100644 --- a/fs/gfs2/main.c +++ b/fs/gfs2/main.c | |||
| @@ -40,7 +40,8 @@ static void gfs2_init_inode_once(void *foo) | |||
| 40 | inode_init_once(&ip->i_inode); | 40 | inode_init_once(&ip->i_inode); |
| 41 | init_rwsem(&ip->i_rw_mutex); | 41 | init_rwsem(&ip->i_rw_mutex); |
| 42 | INIT_LIST_HEAD(&ip->i_trunc_list); | 42 | INIT_LIST_HEAD(&ip->i_trunc_list); |
| 43 | ip->i_alloc = NULL; | 43 | ip->i_qadata = NULL; |
| 44 | ip->i_res = NULL; | ||
| 44 | ip->i_hash_cache = NULL; | 45 | ip->i_hash_cache = NULL; |
| 45 | } | 46 | } |
| 46 | 47 | ||
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index d1962b2f67f9..98a01db1f6dc 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
| @@ -494,11 +494,11 @@ static void qdsb_put(struct gfs2_quota_data *qd) | |||
| 494 | int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid) | 494 | int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid) |
| 495 | { | 495 | { |
| 496 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 496 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
| 497 | struct gfs2_alloc *al = ip->i_alloc; | 497 | struct gfs2_qadata *qa = ip->i_qadata; |
| 498 | struct gfs2_quota_data **qd = al->al_qd; | 498 | struct gfs2_quota_data **qd = qa->qa_qd; |
| 499 | int error; | 499 | int error; |
| 500 | 500 | ||
| 501 | if (gfs2_assert_warn(sdp, !al->al_qd_num) || | 501 | if (gfs2_assert_warn(sdp, !qa->qa_qd_num) || |
| 502 | gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags))) | 502 | gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags))) |
| 503 | return -EIO; | 503 | return -EIO; |
| 504 | 504 | ||
| @@ -508,20 +508,20 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid) | |||
| 508 | error = qdsb_get(sdp, QUOTA_USER, ip->i_inode.i_uid, qd); | 508 | error = qdsb_get(sdp, QUOTA_USER, ip->i_inode.i_uid, qd); |
| 509 | if (error) | 509 | if (error) |
| 510 | goto out; | 510 | goto out; |
| 511 | al->al_qd_num++; | 511 | qa->qa_qd_num++; |
| 512 | qd++; | 512 | qd++; |
| 513 | 513 | ||
| 514 | error = qdsb_get(sdp, QUOTA_GROUP, ip->i_inode.i_gid, qd); | 514 | error = qdsb_get(sdp, QUOTA_GROUP, ip->i_inode.i_gid, qd); |
| 515 | if (error) | 515 | if (error) |
| 516 | goto out; | 516 | goto out; |
| 517 | al->al_qd_num++; | 517 | qa->qa_qd_num++; |
| 518 | qd++; | 518 | qd++; |
| 519 | 519 | ||
| 520 | if (uid != NO_QUOTA_CHANGE && uid != ip->i_inode.i_uid) { | 520 | if (uid != NO_QUOTA_CHANGE && uid != ip->i_inode.i_uid) { |
| 521 | error = qdsb_get(sdp, QUOTA_USER, uid, qd); | 521 | error = qdsb_get(sdp, QUOTA_USER, uid, qd); |
| 522 | if (error) | 522 | if (error) |
| 523 | goto out; | 523 | goto out; |
| 524 | al->al_qd_num++; | 524 | qa->qa_qd_num++; |
| 525 | qd++; | 525 | qd++; |
| 526 | } | 526 | } |
| 527 | 527 | ||
| @@ -529,7 +529,7 @@ int gfs2_quota_hold(struct gfs2_inode *ip, u32 uid, u32 gid) | |||
| 529 | error = qdsb_get(sdp, QUOTA_GROUP, gid, qd); | 529 | error = qdsb_get(sdp, QUOTA_GROUP, gid, qd); |
| 530 | if (error) | 530 | if (error) |
| 531 | goto out; | 531 | goto out; |
| 532 | al->al_qd_num++; | 532 | qa->qa_qd_num++; |
| 533 | qd++; | 533 | qd++; |
| 534 | } | 534 | } |
| 535 | 535 | ||
| @@ -542,16 +542,16 @@ out: | |||
| 542 | void gfs2_quota_unhold(struct gfs2_inode *ip) | 542 | void gfs2_quota_unhold(struct gfs2_inode *ip) |
| 543 | { | 543 | { |
| 544 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 544 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
| 545 | struct gfs2_alloc *al = ip->i_alloc; | 545 | struct gfs2_qadata *qa = ip->i_qadata; |
| 546 | unsigned int x; | 546 | unsigned int x; |
| 547 | 547 | ||
| 548 | gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags)); | 548 | gfs2_assert_warn(sdp, !test_bit(GIF_QD_LOCKED, &ip->i_flags)); |
| 549 | 549 | ||
| 550 | for (x = 0; x < al->al_qd_num; x++) { | 550 | for (x = 0; x < qa->qa_qd_num; x++) { |
| 551 | qdsb_put(al->al_qd[x]); | 551 | qdsb_put(qa->qa_qd[x]); |
| 552 | al->al_qd[x] = NULL; | 552 | qa->qa_qd[x] = NULL; |
| 553 | } | 553 | } |
| 554 | al->al_qd_num = 0; | 554 | qa->qa_qd_num = 0; |
| 555 | } | 555 | } |
| 556 | 556 | ||
| 557 | static int sort_qd(const void *a, const void *b) | 557 | static int sort_qd(const void *a, const void *b) |
| @@ -762,7 +762,6 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda) | |||
| 762 | struct gfs2_quota_data *qd; | 762 | struct gfs2_quota_data *qd; |
| 763 | loff_t offset; | 763 | loff_t offset; |
| 764 | unsigned int nalloc = 0, blocks; | 764 | unsigned int nalloc = 0, blocks; |
| 765 | struct gfs2_alloc *al = NULL; | ||
| 766 | int error; | 765 | int error; |
| 767 | 766 | ||
| 768 | gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota), | 767 | gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota), |
| @@ -792,26 +791,19 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda) | |||
| 792 | nalloc++; | 791 | nalloc++; |
| 793 | } | 792 | } |
| 794 | 793 | ||
| 795 | al = gfs2_alloc_get(ip); | ||
| 796 | if (!al) { | ||
| 797 | error = -ENOMEM; | ||
| 798 | goto out_gunlock; | ||
| 799 | } | ||
| 800 | /* | 794 | /* |
| 801 | * 1 blk for unstuffing inode if stuffed. We add this extra | 795 | * 1 blk for unstuffing inode if stuffed. We add this extra |
| 802 | * block to the reservation unconditionally. If the inode | 796 | * block to the reservation unconditionally. If the inode |
| 803 | * doesn't need unstuffing, the block will be released to the | 797 | * doesn't need unstuffing, the block will be released to the |
| 804 | * rgrp since it won't be allocated during the transaction | 798 | * rgrp since it won't be allocated during the transaction |
| 805 | */ | 799 | */ |
| 806 | al->al_requested = 1; | ||
| 807 | /* +3 in the end for unstuffing block, inode size update block | 800 | /* +3 in the end for unstuffing block, inode size update block |
| 808 | * and another block in case quota straddles page boundary and | 801 | * and another block in case quota straddles page boundary and |
| 809 | * two blocks need to be updated instead of 1 */ | 802 | * two blocks need to be updated instead of 1 */ |
| 810 | blocks = num_qd * data_blocks + RES_DINODE + num_qd + 3; | 803 | blocks = num_qd * data_blocks + RES_DINODE + num_qd + 3; |
| 811 | 804 | ||
| 812 | if (nalloc) | 805 | error = gfs2_inplace_reserve(ip, 1 + |
| 813 | al->al_requested += nalloc * (data_blocks + ind_blocks); | 806 | (nalloc * (data_blocks + ind_blocks))); |
| 814 | error = gfs2_inplace_reserve(ip); | ||
| 815 | if (error) | 807 | if (error) |
| 816 | goto out_alloc; | 808 | goto out_alloc; |
| 817 | 809 | ||
| @@ -840,8 +832,6 @@ out_end_trans: | |||
| 840 | out_ipres: | 832 | out_ipres: |
| 841 | gfs2_inplace_release(ip); | 833 | gfs2_inplace_release(ip); |
| 842 | out_alloc: | 834 | out_alloc: |
| 843 | gfs2_alloc_put(ip); | ||
| 844 | out_gunlock: | ||
| 845 | gfs2_glock_dq_uninit(&i_gh); | 835 | gfs2_glock_dq_uninit(&i_gh); |
| 846 | out: | 836 | out: |
| 847 | while (qx--) | 837 | while (qx--) |
| @@ -925,7 +915,7 @@ fail: | |||
| 925 | int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid) | 915 | int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid) |
| 926 | { | 916 | { |
| 927 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 917 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
| 928 | struct gfs2_alloc *al = ip->i_alloc; | 918 | struct gfs2_qadata *qa = ip->i_qadata; |
| 929 | struct gfs2_quota_data *qd; | 919 | struct gfs2_quota_data *qd; |
| 930 | unsigned int x; | 920 | unsigned int x; |
| 931 | int error = 0; | 921 | int error = 0; |
| @@ -938,15 +928,15 @@ int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid) | |||
| 938 | sdp->sd_args.ar_quota != GFS2_QUOTA_ON) | 928 | sdp->sd_args.ar_quota != GFS2_QUOTA_ON) |
| 939 | return 0; | 929 | return 0; |
| 940 | 930 | ||
| 941 | sort(al->al_qd, al->al_qd_num, sizeof(struct gfs2_quota_data *), | 931 | sort(qa->qa_qd, qa->qa_qd_num, sizeof(struct gfs2_quota_data *), |
| 942 | sort_qd, NULL); | 932 | sort_qd, NULL); |
| 943 | 933 | ||
| 944 | for (x = 0; x < al->al_qd_num; x++) { | 934 | for (x = 0; x < qa->qa_qd_num; x++) { |
| 945 | int force = NO_FORCE; | 935 | int force = NO_FORCE; |
| 946 | qd = al->al_qd[x]; | 936 | qd = qa->qa_qd[x]; |
| 947 | if (test_and_clear_bit(QDF_REFRESH, &qd->qd_flags)) | 937 | if (test_and_clear_bit(QDF_REFRESH, &qd->qd_flags)) |
| 948 | force = FORCE; | 938 | force = FORCE; |
| 949 | error = do_glock(qd, force, &al->al_qd_ghs[x]); | 939 | error = do_glock(qd, force, &qa->qa_qd_ghs[x]); |
| 950 | if (error) | 940 | if (error) |
| 951 | break; | 941 | break; |
| 952 | } | 942 | } |
| @@ -955,7 +945,7 @@ int gfs2_quota_lock(struct gfs2_inode *ip, u32 uid, u32 gid) | |||
| 955 | set_bit(GIF_QD_LOCKED, &ip->i_flags); | 945 | set_bit(GIF_QD_LOCKED, &ip->i_flags); |
| 956 | else { | 946 | else { |
| 957 | while (x--) | 947 | while (x--) |
| 958 | gfs2_glock_dq_uninit(&al->al_qd_ghs[x]); | 948 | gfs2_glock_dq_uninit(&qa->qa_qd_ghs[x]); |
| 959 | gfs2_quota_unhold(ip); | 949 | gfs2_quota_unhold(ip); |
| 960 | } | 950 | } |
| 961 | 951 | ||
| @@ -1000,7 +990,7 @@ static int need_sync(struct gfs2_quota_data *qd) | |||
| 1000 | 990 | ||
| 1001 | void gfs2_quota_unlock(struct gfs2_inode *ip) | 991 | void gfs2_quota_unlock(struct gfs2_inode *ip) |
| 1002 | { | 992 | { |
| 1003 | struct gfs2_alloc *al = ip->i_alloc; | 993 | struct gfs2_qadata *qa = ip->i_qadata; |
| 1004 | struct gfs2_quota_data *qda[4]; | 994 | struct gfs2_quota_data *qda[4]; |
| 1005 | unsigned int count = 0; | 995 | unsigned int count = 0; |
| 1006 | unsigned int x; | 996 | unsigned int x; |
| @@ -1008,14 +998,14 @@ void gfs2_quota_unlock(struct gfs2_inode *ip) | |||
| 1008 | if (!test_and_clear_bit(GIF_QD_LOCKED, &ip->i_flags)) | 998 | if (!test_and_clear_bit(GIF_QD_LOCKED, &ip->i_flags)) |
| 1009 | goto out; | 999 | goto out; |
| 1010 | 1000 | ||
| 1011 | for (x = 0; x < al->al_qd_num; x++) { | 1001 | for (x = 0; x < qa->qa_qd_num; x++) { |
| 1012 | struct gfs2_quota_data *qd; | 1002 | struct gfs2_quota_data *qd; |
| 1013 | int sync; | 1003 | int sync; |
| 1014 | 1004 | ||
| 1015 | qd = al->al_qd[x]; | 1005 | qd = qa->qa_qd[x]; |
| 1016 | sync = need_sync(qd); | 1006 | sync = need_sync(qd); |
| 1017 | 1007 | ||
| 1018 | gfs2_glock_dq_uninit(&al->al_qd_ghs[x]); | 1008 | gfs2_glock_dq_uninit(&qa->qa_qd_ghs[x]); |
| 1019 | 1009 | ||
| 1020 | if (sync && qd_trylock(qd)) | 1010 | if (sync && qd_trylock(qd)) |
| 1021 | qda[count++] = qd; | 1011 | qda[count++] = qd; |
| @@ -1048,7 +1038,7 @@ static int print_message(struct gfs2_quota_data *qd, char *type) | |||
| 1048 | int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid) | 1038 | int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid) |
| 1049 | { | 1039 | { |
| 1050 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 1040 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
| 1051 | struct gfs2_alloc *al = ip->i_alloc; | 1041 | struct gfs2_qadata *qa = ip->i_qadata; |
| 1052 | struct gfs2_quota_data *qd; | 1042 | struct gfs2_quota_data *qd; |
| 1053 | s64 value; | 1043 | s64 value; |
| 1054 | unsigned int x; | 1044 | unsigned int x; |
| @@ -1060,8 +1050,8 @@ int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid) | |||
| 1060 | if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON) | 1050 | if (sdp->sd_args.ar_quota != GFS2_QUOTA_ON) |
| 1061 | return 0; | 1051 | return 0; |
| 1062 | 1052 | ||
| 1063 | for (x = 0; x < al->al_qd_num; x++) { | 1053 | for (x = 0; x < qa->qa_qd_num; x++) { |
| 1064 | qd = al->al_qd[x]; | 1054 | qd = qa->qa_qd[x]; |
| 1065 | 1055 | ||
| 1066 | if (!((qd->qd_id == uid && test_bit(QDF_USER, &qd->qd_flags)) || | 1056 | if (!((qd->qd_id == uid && test_bit(QDF_USER, &qd->qd_flags)) || |
| 1067 | (qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags)))) | 1057 | (qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags)))) |
| @@ -1099,7 +1089,7 @@ int gfs2_quota_check(struct gfs2_inode *ip, u32 uid, u32 gid) | |||
| 1099 | void gfs2_quota_change(struct gfs2_inode *ip, s64 change, | 1089 | void gfs2_quota_change(struct gfs2_inode *ip, s64 change, |
| 1100 | u32 uid, u32 gid) | 1090 | u32 uid, u32 gid) |
| 1101 | { | 1091 | { |
| 1102 | struct gfs2_alloc *al = ip->i_alloc; | 1092 | struct gfs2_qadata *qa = ip->i_qadata; |
| 1103 | struct gfs2_quota_data *qd; | 1093 | struct gfs2_quota_data *qd; |
| 1104 | unsigned int x; | 1094 | unsigned int x; |
| 1105 | 1095 | ||
| @@ -1108,8 +1098,8 @@ void gfs2_quota_change(struct gfs2_inode *ip, s64 change, | |||
| 1108 | if (ip->i_diskflags & GFS2_DIF_SYSTEM) | 1098 | if (ip->i_diskflags & GFS2_DIF_SYSTEM) |
| 1109 | return; | 1099 | return; |
| 1110 | 1100 | ||
| 1111 | for (x = 0; x < al->al_qd_num; x++) { | 1101 | for (x = 0; x < qa->qa_qd_num; x++) { |
| 1112 | qd = al->al_qd[x]; | 1102 | qd = qa->qa_qd[x]; |
| 1113 | 1103 | ||
| 1114 | if ((qd->qd_id == uid && test_bit(QDF_USER, &qd->qd_flags)) || | 1104 | if ((qd->qd_id == uid && test_bit(QDF_USER, &qd->qd_flags)) || |
| 1115 | (qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags))) { | 1105 | (qd->qd_id == gid && !test_bit(QDF_USER, &qd->qd_flags))) { |
| @@ -1529,7 +1519,6 @@ static int gfs2_set_dqblk(struct super_block *sb, int type, qid_t id, | |||
| 1529 | unsigned int data_blocks, ind_blocks; | 1519 | unsigned int data_blocks, ind_blocks; |
| 1530 | unsigned int blocks = 0; | 1520 | unsigned int blocks = 0; |
| 1531 | int alloc_required; | 1521 | int alloc_required; |
| 1532 | struct gfs2_alloc *al; | ||
| 1533 | loff_t offset; | 1522 | loff_t offset; |
| 1534 | int error; | 1523 | int error; |
| 1535 | 1524 | ||
| @@ -1594,15 +1583,12 @@ static int gfs2_set_dqblk(struct super_block *sb, int type, qid_t id, | |||
| 1594 | if (gfs2_is_stuffed(ip)) | 1583 | if (gfs2_is_stuffed(ip)) |
| 1595 | alloc_required = 1; | 1584 | alloc_required = 1; |
| 1596 | if (alloc_required) { | 1585 | if (alloc_required) { |
| 1597 | al = gfs2_alloc_get(ip); | ||
| 1598 | if (al == NULL) | ||
| 1599 | goto out_i; | ||
| 1600 | gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota), | 1586 | gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota), |
| 1601 | &data_blocks, &ind_blocks); | 1587 | &data_blocks, &ind_blocks); |
| 1602 | blocks = al->al_requested = 1 + data_blocks + ind_blocks; | 1588 | blocks = 1 + data_blocks + ind_blocks; |
| 1603 | error = gfs2_inplace_reserve(ip); | 1589 | error = gfs2_inplace_reserve(ip, blocks); |
| 1604 | if (error) | 1590 | if (error) |
| 1605 | goto out_alloc; | 1591 | goto out_i; |
| 1606 | blocks += gfs2_rg_blocks(ip); | 1592 | blocks += gfs2_rg_blocks(ip); |
| 1607 | } | 1593 | } |
| 1608 | 1594 | ||
| @@ -1617,11 +1603,8 @@ static int gfs2_set_dqblk(struct super_block *sb, int type, qid_t id, | |||
| 1617 | 1603 | ||
| 1618 | gfs2_trans_end(sdp); | 1604 | gfs2_trans_end(sdp); |
| 1619 | out_release: | 1605 | out_release: |
| 1620 | if (alloc_required) { | 1606 | if (alloc_required) |
| 1621 | gfs2_inplace_release(ip); | 1607 | gfs2_inplace_release(ip); |
| 1622 | out_alloc: | ||
| 1623 | gfs2_alloc_put(ip); | ||
| 1624 | } | ||
| 1625 | out_i: | 1608 | out_i: |
| 1626 | gfs2_glock_dq_uninit(&i_gh); | 1609 | gfs2_glock_dq_uninit(&i_gh); |
| 1627 | out_q: | 1610 | out_q: |
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 6b6cc096756a..f6e05d63e8ab 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
| @@ -860,22 +860,36 @@ fail: | |||
| 860 | } | 860 | } |
| 861 | 861 | ||
| 862 | /** | 862 | /** |
| 863 | * gfs2_alloc_get - get the struct gfs2_alloc structure for an inode | 863 | * gfs2_qadata_get - get the struct gfs2_qadata structure for an inode |
| 864 | * @ip: the incore GFS2 inode structure | 864 | * @ip: the incore GFS2 inode structure |
| 865 | * | 865 | * |
| 866 | * Returns: the struct gfs2_alloc | 866 | * Returns: the struct gfs2_qadata |
| 867 | */ | 867 | */ |
| 868 | 868 | ||
| 869 | struct gfs2_alloc *gfs2_alloc_get(struct gfs2_inode *ip) | 869 | struct gfs2_qadata *gfs2_qadata_get(struct gfs2_inode *ip) |
| 870 | { | 870 | { |
| 871 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 871 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
| 872 | int error; | 872 | int error; |
| 873 | BUG_ON(ip->i_alloc != NULL); | 873 | BUG_ON(ip->i_qadata != NULL); |
| 874 | ip->i_alloc = kzalloc(sizeof(struct gfs2_alloc), GFP_NOFS); | 874 | ip->i_qadata = kzalloc(sizeof(struct gfs2_qadata), GFP_NOFS); |
| 875 | error = gfs2_rindex_update(sdp); | 875 | error = gfs2_rindex_update(sdp); |
| 876 | if (error) | 876 | if (error) |
| 877 | fs_warn(sdp, "rindex update returns %d\n", error); | 877 | fs_warn(sdp, "rindex update returns %d\n", error); |
| 878 | return ip->i_alloc; | 878 | return ip->i_qadata; |
| 879 | } | ||
| 880 | |||
| 881 | /** | ||
| 882 | * gfs2_blkrsv_get - get the struct gfs2_blkreserv structure for an inode | ||
| 883 | * @ip: the incore GFS2 inode structure | ||
| 884 | * | ||
| 885 | * Returns: the struct gfs2_qadata | ||
| 886 | */ | ||
| 887 | |||
| 888 | static struct gfs2_blkreserv *gfs2_blkrsv_get(struct gfs2_inode *ip) | ||
| 889 | { | ||
| 890 | BUG_ON(ip->i_res != NULL); | ||
| 891 | ip->i_res = kzalloc(sizeof(struct gfs2_blkreserv), GFP_NOFS); | ||
| 892 | return ip->i_res; | ||
| 879 | } | 893 | } |
| 880 | 894 | ||
| 881 | /** | 895 | /** |
| @@ -890,11 +904,11 @@ struct gfs2_alloc *gfs2_alloc_get(struct gfs2_inode *ip) | |||
| 890 | 904 | ||
| 891 | static int try_rgrp_fit(const struct gfs2_rgrpd *rgd, const struct gfs2_inode *ip) | 905 | static int try_rgrp_fit(const struct gfs2_rgrpd *rgd, const struct gfs2_inode *ip) |
| 892 | { | 906 | { |
| 893 | const struct gfs2_alloc *al = ip->i_alloc; | 907 | const struct gfs2_blkreserv *rs = ip->i_res; |
| 894 | 908 | ||
| 895 | if (rgd->rd_flags & (GFS2_RGF_NOALLOC | GFS2_RDF_ERROR)) | 909 | if (rgd->rd_flags & (GFS2_RGF_NOALLOC | GFS2_RDF_ERROR)) |
| 896 | return 0; | 910 | return 0; |
| 897 | if (rgd->rd_free_clone >= al->al_requested) | 911 | if (rgd->rd_free_clone >= rs->rs_requested) |
| 898 | return 1; | 912 | return 1; |
| 899 | return 0; | 913 | return 0; |
| 900 | } | 914 | } |
| @@ -982,7 +996,7 @@ static int get_local_rgrp(struct gfs2_inode *ip, u64 *last_unlinked) | |||
| 982 | { | 996 | { |
| 983 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 997 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
| 984 | struct gfs2_rgrpd *rgd, *begin = NULL; | 998 | struct gfs2_rgrpd *rgd, *begin = NULL; |
| 985 | struct gfs2_alloc *al = ip->i_alloc; | 999 | struct gfs2_blkreserv *rs = ip->i_res; |
| 986 | int error, rg_locked, flags = LM_FLAG_TRY; | 1000 | int error, rg_locked, flags = LM_FLAG_TRY; |
| 987 | int loops = 0; | 1001 | int loops = 0; |
| 988 | 1002 | ||
| @@ -1002,7 +1016,7 @@ static int get_local_rgrp(struct gfs2_inode *ip, u64 *last_unlinked) | |||
| 1002 | error = 0; | 1016 | error = 0; |
| 1003 | } else { | 1017 | } else { |
| 1004 | error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, | 1018 | error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, |
| 1005 | flags, &al->al_rgd_gh); | 1019 | flags, &rs->rs_rgd_gh); |
| 1006 | } | 1020 | } |
| 1007 | switch (error) { | 1021 | switch (error) { |
| 1008 | case 0: | 1022 | case 0: |
| @@ -1013,7 +1027,7 @@ static int get_local_rgrp(struct gfs2_inode *ip, u64 *last_unlinked) | |||
| 1013 | if (rgd->rd_flags & GFS2_RDF_CHECK) | 1027 | if (rgd->rd_flags & GFS2_RDF_CHECK) |
| 1014 | try_rgrp_unlink(rgd, last_unlinked, ip->i_no_addr); | 1028 | try_rgrp_unlink(rgd, last_unlinked, ip->i_no_addr); |
| 1015 | if (!rg_locked) | 1029 | if (!rg_locked) |
| 1016 | gfs2_glock_dq_uninit(&al->al_rgd_gh); | 1030 | gfs2_glock_dq_uninit(&rs->rs_rgd_gh); |
| 1017 | /* fall through */ | 1031 | /* fall through */ |
| 1018 | case GLR_TRYFAILED: | 1032 | case GLR_TRYFAILED: |
| 1019 | rgd = gfs2_rgrpd_get_next(rgd); | 1033 | rgd = gfs2_rgrpd_get_next(rgd); |
| @@ -1030,6 +1044,13 @@ static int get_local_rgrp(struct gfs2_inode *ip, u64 *last_unlinked) | |||
| 1030 | return -ENOSPC; | 1044 | return -ENOSPC; |
| 1031 | } | 1045 | } |
| 1032 | 1046 | ||
| 1047 | static void gfs2_blkrsv_put(struct gfs2_inode *ip) | ||
| 1048 | { | ||
| 1049 | BUG_ON(ip->i_res == NULL); | ||
| 1050 | kfree(ip->i_res); | ||
| 1051 | ip->i_res = NULL; | ||
| 1052 | } | ||
| 1053 | |||
| 1033 | /** | 1054 | /** |
| 1034 | * gfs2_inplace_reserve - Reserve space in the filesystem | 1055 | * gfs2_inplace_reserve - Reserve space in the filesystem |
| 1035 | * @ip: the inode to reserve space for | 1056 | * @ip: the inode to reserve space for |
| @@ -1037,16 +1058,23 @@ static int get_local_rgrp(struct gfs2_inode *ip, u64 *last_unlinked) | |||
| 1037 | * Returns: errno | 1058 | * Returns: errno |
| 1038 | */ | 1059 | */ |
| 1039 | 1060 | ||
| 1040 | int gfs2_inplace_reserve(struct gfs2_inode *ip) | 1061 | int gfs2_inplace_reserve(struct gfs2_inode *ip, u32 requested) |
| 1041 | { | 1062 | { |
| 1042 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 1063 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
| 1043 | struct gfs2_alloc *al = ip->i_alloc; | 1064 | struct gfs2_blkreserv *rs; |
| 1044 | int error = 0; | 1065 | int error = 0; |
| 1045 | u64 last_unlinked = NO_BLOCK; | 1066 | u64 last_unlinked = NO_BLOCK; |
| 1046 | int tries = 0; | 1067 | int tries = 0; |
| 1047 | 1068 | ||
| 1048 | if (gfs2_assert_warn(sdp, al->al_requested)) | 1069 | rs = gfs2_blkrsv_get(ip); |
| 1049 | return -EINVAL; | 1070 | if (!rs) |
| 1071 | return -ENOMEM; | ||
| 1072 | |||
| 1073 | rs->rs_requested = requested; | ||
| 1074 | if (gfs2_assert_warn(sdp, requested)) { | ||
| 1075 | error = -EINVAL; | ||
| 1076 | goto out; | ||
| 1077 | } | ||
| 1050 | 1078 | ||
| 1051 | do { | 1079 | do { |
| 1052 | error = get_local_rgrp(ip, &last_unlinked); | 1080 | error = get_local_rgrp(ip, &last_unlinked); |
| @@ -1063,6 +1091,9 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip) | |||
| 1063 | gfs2_log_flush(sdp, NULL); | 1091 | gfs2_log_flush(sdp, NULL); |
| 1064 | } while (tries++ < 3); | 1092 | } while (tries++ < 3); |
| 1065 | 1093 | ||
| 1094 | out: | ||
| 1095 | if (error) | ||
| 1096 | gfs2_blkrsv_put(ip); | ||
| 1066 | return error; | 1097 | return error; |
| 1067 | } | 1098 | } |
| 1068 | 1099 | ||
| @@ -1075,10 +1106,11 @@ int gfs2_inplace_reserve(struct gfs2_inode *ip) | |||
| 1075 | 1106 | ||
| 1076 | void gfs2_inplace_release(struct gfs2_inode *ip) | 1107 | void gfs2_inplace_release(struct gfs2_inode *ip) |
| 1077 | { | 1108 | { |
| 1078 | struct gfs2_alloc *al = ip->i_alloc; | 1109 | struct gfs2_blkreserv *rs = ip->i_res; |
| 1079 | 1110 | ||
| 1080 | if (al->al_rgd_gh.gh_gl) | 1111 | gfs2_blkrsv_put(ip); |
| 1081 | gfs2_glock_dq_uninit(&al->al_rgd_gh); | 1112 | if (rs->rs_rgd_gh.gh_gl) |
| 1113 | gfs2_glock_dq_uninit(&rs->rs_rgd_gh); | ||
| 1082 | } | 1114 | } |
| 1083 | 1115 | ||
| 1084 | /** | 1116 | /** |
| @@ -1338,7 +1370,6 @@ int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *ndata, | |||
| 1338 | { | 1370 | { |
| 1339 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 1371 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
| 1340 | struct buffer_head *dibh; | 1372 | struct buffer_head *dibh; |
| 1341 | struct gfs2_alloc *al = ip->i_alloc; | ||
| 1342 | struct gfs2_rgrpd *rgd; | 1373 | struct gfs2_rgrpd *rgd; |
| 1343 | u32 goal, extlen, blk; /* block, within the rgrp scope */ | 1374 | u32 goal, extlen, blk; /* block, within the rgrp scope */ |
| 1344 | u64 block; /* block, within the file system scope */ | 1375 | u64 block; /* block, within the file system scope */ |
| @@ -1348,7 +1379,7 @@ int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *ndata, | |||
| 1348 | /* Only happens if there is a bug in gfs2, return something distinctive | 1379 | /* Only happens if there is a bug in gfs2, return something distinctive |
| 1349 | * to ensure that it is noticed. | 1380 | * to ensure that it is noticed. |
| 1350 | */ | 1381 | */ |
| 1351 | if (al == NULL) | 1382 | if (ip->i_res == NULL) |
| 1352 | return -ECANCELED; | 1383 | return -ECANCELED; |
| 1353 | 1384 | ||
| 1354 | rgd = ip->i_rgd; | 1385 | rgd = ip->i_rgd; |
diff --git a/fs/gfs2/rgrp.h b/fs/gfs2/rgrp.h index b3b61b8f6d8f..ceec9106cdf4 100644 --- a/fs/gfs2/rgrp.h +++ b/fs/gfs2/rgrp.h | |||
| @@ -28,15 +28,15 @@ extern void gfs2_free_clones(struct gfs2_rgrpd *rgd); | |||
| 28 | extern int gfs2_rgrp_go_lock(struct gfs2_holder *gh); | 28 | extern int gfs2_rgrp_go_lock(struct gfs2_holder *gh); |
| 29 | extern void gfs2_rgrp_go_unlock(struct gfs2_holder *gh); | 29 | extern void gfs2_rgrp_go_unlock(struct gfs2_holder *gh); |
| 30 | 30 | ||
| 31 | extern struct gfs2_alloc *gfs2_alloc_get(struct gfs2_inode *ip); | 31 | extern struct gfs2_qadata *gfs2_qadata_get(struct gfs2_inode *ip); |
| 32 | static inline void gfs2_alloc_put(struct gfs2_inode *ip) | 32 | static inline void gfs2_qadata_put(struct gfs2_inode *ip) |
| 33 | { | 33 | { |
| 34 | BUG_ON(ip->i_alloc == NULL); | 34 | BUG_ON(ip->i_qadata == NULL); |
| 35 | kfree(ip->i_alloc); | 35 | kfree(ip->i_qadata); |
| 36 | ip->i_alloc = NULL; | 36 | ip->i_qadata = NULL; |
| 37 | } | 37 | } |
| 38 | 38 | ||
| 39 | extern int gfs2_inplace_reserve(struct gfs2_inode *ip); | 39 | extern int gfs2_inplace_reserve(struct gfs2_inode *ip, u32 requested); |
| 40 | extern void gfs2_inplace_release(struct gfs2_inode *ip); | 40 | extern void gfs2_inplace_release(struct gfs2_inode *ip); |
| 41 | 41 | ||
| 42 | extern int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *n, | 42 | extern int gfs2_alloc_blocks(struct gfs2_inode *ip, u64 *bn, unsigned int *n, |
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index 71e420989f77..69eb56876db4 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
| @@ -1399,8 +1399,9 @@ static void gfs2_final_release_pages(struct gfs2_inode *ip) | |||
| 1399 | static int gfs2_dinode_dealloc(struct gfs2_inode *ip) | 1399 | static int gfs2_dinode_dealloc(struct gfs2_inode *ip) |
| 1400 | { | 1400 | { |
| 1401 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 1401 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
| 1402 | struct gfs2_alloc *al; | 1402 | struct gfs2_qadata *qa; |
| 1403 | struct gfs2_rgrpd *rgd; | 1403 | struct gfs2_rgrpd *rgd; |
| 1404 | struct gfs2_holder gh; | ||
| 1404 | int error; | 1405 | int error; |
| 1405 | 1406 | ||
| 1406 | if (gfs2_get_inode_blocks(&ip->i_inode) != 1) { | 1407 | if (gfs2_get_inode_blocks(&ip->i_inode) != 1) { |
| @@ -1408,8 +1409,8 @@ static int gfs2_dinode_dealloc(struct gfs2_inode *ip) | |||
| 1408 | return -EIO; | 1409 | return -EIO; |
| 1409 | } | 1410 | } |
| 1410 | 1411 | ||
| 1411 | al = gfs2_alloc_get(ip); | 1412 | qa = gfs2_qadata_get(ip); |
| 1412 | if (!al) | 1413 | if (!qa) |
| 1413 | return -ENOMEM; | 1414 | return -ENOMEM; |
| 1414 | 1415 | ||
| 1415 | error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); | 1416 | error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); |
| @@ -1423,8 +1424,7 @@ static int gfs2_dinode_dealloc(struct gfs2_inode *ip) | |||
| 1423 | goto out_qs; | 1424 | goto out_qs; |
| 1424 | } | 1425 | } |
| 1425 | 1426 | ||
| 1426 | error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, | 1427 | error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, &gh); |
| 1427 | &al->al_rgd_gh); | ||
| 1428 | if (error) | 1428 | if (error) |
| 1429 | goto out_qs; | 1429 | goto out_qs; |
| 1430 | 1430 | ||
| @@ -1440,11 +1440,11 @@ static int gfs2_dinode_dealloc(struct gfs2_inode *ip) | |||
| 1440 | gfs2_trans_end(sdp); | 1440 | gfs2_trans_end(sdp); |
| 1441 | 1441 | ||
| 1442 | out_rg_gunlock: | 1442 | out_rg_gunlock: |
| 1443 | gfs2_glock_dq_uninit(&al->al_rgd_gh); | 1443 | gfs2_glock_dq_uninit(&gh); |
| 1444 | out_qs: | 1444 | out_qs: |
| 1445 | gfs2_quota_unhold(ip); | 1445 | gfs2_quota_unhold(ip); |
| 1446 | out: | 1446 | out: |
| 1447 | gfs2_alloc_put(ip); | 1447 | gfs2_qadata_put(ip); |
| 1448 | return error; | 1448 | return error; |
| 1449 | } | 1449 | } |
| 1450 | 1450 | ||
diff --git a/fs/gfs2/trans.h b/fs/gfs2/trans.h index f8f101ef600c..125d4572e1c0 100644 --- a/fs/gfs2/trans.h +++ b/fs/gfs2/trans.h | |||
| @@ -30,9 +30,9 @@ struct gfs2_glock; | |||
| 30 | * block, or all of the blocks in the rg, whichever is smaller */ | 30 | * block, or all of the blocks in the rg, whichever is smaller */ |
| 31 | static inline unsigned int gfs2_rg_blocks(const struct gfs2_inode *ip) | 31 | static inline unsigned int gfs2_rg_blocks(const struct gfs2_inode *ip) |
| 32 | { | 32 | { |
| 33 | const struct gfs2_alloc *al = ip->i_alloc; | 33 | const struct gfs2_blkreserv *rs = ip->i_res; |
| 34 | if (al->al_requested < ip->i_rgd->rd_length) | 34 | if (rs->rs_requested < ip->i_rgd->rd_length) |
| 35 | return al->al_requested + 1; | 35 | return rs->rs_requested + 1; |
| 36 | return ip->i_rgd->rd_length; | 36 | return ip->i_rgd->rd_length; |
| 37 | } | 37 | } |
| 38 | 38 | ||
diff --git a/fs/gfs2/xattr.c b/fs/gfs2/xattr.c index ef74e1591b89..e9636591b5d5 100644 --- a/fs/gfs2/xattr.c +++ b/fs/gfs2/xattr.c | |||
| @@ -321,11 +321,11 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, | |||
| 321 | struct gfs2_ea_header *ea, | 321 | struct gfs2_ea_header *ea, |
| 322 | struct gfs2_ea_header *prev, int leave) | 322 | struct gfs2_ea_header *prev, int leave) |
| 323 | { | 323 | { |
| 324 | struct gfs2_alloc *al; | 324 | struct gfs2_qadata *qa; |
| 325 | int error; | 325 | int error; |
| 326 | 326 | ||
| 327 | al = gfs2_alloc_get(ip); | 327 | qa = gfs2_qadata_get(ip); |
| 328 | if (!al) | 328 | if (!qa) |
| 329 | return -ENOMEM; | 329 | return -ENOMEM; |
| 330 | 330 | ||
| 331 | error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); | 331 | error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); |
| @@ -336,7 +336,7 @@ static int ea_remove_unstuffed(struct gfs2_inode *ip, struct buffer_head *bh, | |||
| 336 | 336 | ||
| 337 | gfs2_quota_unhold(ip); | 337 | gfs2_quota_unhold(ip); |
| 338 | out_alloc: | 338 | out_alloc: |
| 339 | gfs2_alloc_put(ip); | 339 | gfs2_qadata_put(ip); |
| 340 | return error; | 340 | return error; |
| 341 | } | 341 | } |
| 342 | 342 | ||
| @@ -709,21 +709,19 @@ static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er, | |||
| 709 | unsigned int blks, | 709 | unsigned int blks, |
| 710 | ea_skeleton_call_t skeleton_call, void *private) | 710 | ea_skeleton_call_t skeleton_call, void *private) |
| 711 | { | 711 | { |
| 712 | struct gfs2_alloc *al; | 712 | struct gfs2_qadata *qa; |
| 713 | struct buffer_head *dibh; | 713 | struct buffer_head *dibh; |
| 714 | int error; | 714 | int error; |
| 715 | 715 | ||
| 716 | al = gfs2_alloc_get(ip); | 716 | qa = gfs2_qadata_get(ip); |
| 717 | if (!al) | 717 | if (!qa) |
| 718 | return -ENOMEM; | 718 | return -ENOMEM; |
| 719 | 719 | ||
| 720 | error = gfs2_quota_lock_check(ip); | 720 | error = gfs2_quota_lock_check(ip); |
| 721 | if (error) | 721 | if (error) |
| 722 | goto out; | 722 | goto out; |
| 723 | 723 | ||
| 724 | al->al_requested = blks; | 724 | error = gfs2_inplace_reserve(ip, blks); |
| 725 | |||
| 726 | error = gfs2_inplace_reserve(ip); | ||
| 727 | if (error) | 725 | if (error) |
| 728 | goto out_gunlock_q; | 726 | goto out_gunlock_q; |
| 729 | 727 | ||
| @@ -752,7 +750,7 @@ out_ipres: | |||
| 752 | out_gunlock_q: | 750 | out_gunlock_q: |
| 753 | gfs2_quota_unlock(ip); | 751 | gfs2_quota_unlock(ip); |
| 754 | out: | 752 | out: |
| 755 | gfs2_alloc_put(ip); | 753 | gfs2_qadata_put(ip); |
| 756 | return error; | 754 | return error; |
| 757 | } | 755 | } |
| 758 | 756 | ||
| @@ -1436,9 +1434,9 @@ out: | |||
| 1436 | static int ea_dealloc_block(struct gfs2_inode *ip) | 1434 | static int ea_dealloc_block(struct gfs2_inode *ip) |
| 1437 | { | 1435 | { |
| 1438 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); | 1436 | struct gfs2_sbd *sdp = GFS2_SB(&ip->i_inode); |
| 1439 | struct gfs2_alloc *al = ip->i_alloc; | ||
| 1440 | struct gfs2_rgrpd *rgd; | 1437 | struct gfs2_rgrpd *rgd; |
| 1441 | struct buffer_head *dibh; | 1438 | struct buffer_head *dibh; |
| 1439 | struct gfs2_holder gh; | ||
| 1442 | int error; | 1440 | int error; |
| 1443 | 1441 | ||
| 1444 | rgd = gfs2_blk2rgrpd(sdp, ip->i_eattr); | 1442 | rgd = gfs2_blk2rgrpd(sdp, ip->i_eattr); |
| @@ -1447,8 +1445,7 @@ static int ea_dealloc_block(struct gfs2_inode *ip) | |||
| 1447 | return -EIO; | 1445 | return -EIO; |
| 1448 | } | 1446 | } |
| 1449 | 1447 | ||
| 1450 | error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, | 1448 | error = gfs2_glock_nq_init(rgd->rd_gl, LM_ST_EXCLUSIVE, 0, &gh); |
| 1451 | &al->al_rgd_gh); | ||
| 1452 | if (error) | 1449 | if (error) |
| 1453 | return error; | 1450 | return error; |
| 1454 | 1451 | ||
| @@ -1472,7 +1469,7 @@ static int ea_dealloc_block(struct gfs2_inode *ip) | |||
| 1472 | gfs2_trans_end(sdp); | 1469 | gfs2_trans_end(sdp); |
| 1473 | 1470 | ||
| 1474 | out_gunlock: | 1471 | out_gunlock: |
| 1475 | gfs2_glock_dq_uninit(&al->al_rgd_gh); | 1472 | gfs2_glock_dq_uninit(&gh); |
| 1476 | return error; | 1473 | return error; |
| 1477 | } | 1474 | } |
| 1478 | 1475 | ||
| @@ -1485,11 +1482,11 @@ out_gunlock: | |||
| 1485 | 1482 | ||
| 1486 | int gfs2_ea_dealloc(struct gfs2_inode *ip) | 1483 | int gfs2_ea_dealloc(struct gfs2_inode *ip) |
| 1487 | { | 1484 | { |
| 1488 | struct gfs2_alloc *al; | 1485 | struct gfs2_qadata *qa; |
| 1489 | int error; | 1486 | int error; |
| 1490 | 1487 | ||
| 1491 | al = gfs2_alloc_get(ip); | 1488 | qa = gfs2_qadata_get(ip); |
| 1492 | if (!al) | 1489 | if (!qa) |
| 1493 | return -ENOMEM; | 1490 | return -ENOMEM; |
| 1494 | 1491 | ||
| 1495 | error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); | 1492 | error = gfs2_quota_hold(ip, NO_QUOTA_CHANGE, NO_QUOTA_CHANGE); |
| @@ -1511,7 +1508,7 @@ int gfs2_ea_dealloc(struct gfs2_inode *ip) | |||
| 1511 | out_quota: | 1508 | out_quota: |
| 1512 | gfs2_quota_unhold(ip); | 1509 | gfs2_quota_unhold(ip); |
| 1513 | out_alloc: | 1510 | out_alloc: |
| 1514 | gfs2_alloc_put(ip); | 1511 | gfs2_qadata_put(ip); |
| 1515 | return error; | 1512 | return error; |
| 1516 | } | 1513 | } |
| 1517 | 1514 | ||
