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 /fs/gfs2/file.c | |
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>
Diffstat (limited to 'fs/gfs2/file.c')
-rw-r--r-- | fs/gfs2/file.c | 25 |
1 files changed, 11 insertions, 14 deletions
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: |