diff options
Diffstat (limited to 'fs/gfs2/file.c')
-rw-r--r-- | fs/gfs2/file.c | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c index b8927d4f3bf2..c5fb3597f696 100644 --- a/fs/gfs2/file.c +++ b/fs/gfs2/file.c | |||
@@ -105,7 +105,7 @@ static int gfs2_readdir(struct file *file, void *dirent, filldir_t filldir) | |||
105 | return error; | 105 | return error; |
106 | } | 106 | } |
107 | 107 | ||
108 | error = gfs2_dir_read(dir, &offset, dirent, filldir); | 108 | error = gfs2_dir_read(dir, &offset, dirent, filldir, &file->f_ra); |
109 | 109 | ||
110 | gfs2_glock_dq_uninit(&d_gh); | 110 | gfs2_glock_dq_uninit(&d_gh); |
111 | 111 | ||
@@ -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: |
@@ -609,7 +608,7 @@ static int gfs2_fsync(struct file *file, loff_t start, loff_t end, | |||
609 | struct inode *inode = mapping->host; | 608 | struct inode *inode = mapping->host; |
610 | int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC); | 609 | int sync_state = inode->i_state & (I_DIRTY_SYNC|I_DIRTY_DATASYNC); |
611 | struct gfs2_inode *ip = GFS2_I(inode); | 610 | struct gfs2_inode *ip = GFS2_I(inode); |
612 | int ret, ret1 = 0; | 611 | int ret = 0, ret1 = 0; |
613 | 612 | ||
614 | if (mapping->nrpages) { | 613 | if (mapping->nrpages) { |
615 | ret1 = filemap_fdatawrite_range(mapping, start, end); | 614 | ret1 = filemap_fdatawrite_range(mapping, start, end); |
@@ -750,8 +749,10 @@ 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; |
754 | const loff_t pos = offset; | ||
755 | const loff_t count = len; | ||
755 | loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1); | 756 | loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1); |
756 | loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift; | 757 | loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift; |
757 | loff_t max_chunk_size = UINT_MAX & bsize_mask; | 758 | loff_t max_chunk_size = UINT_MAX & bsize_mask; |
@@ -782,8 +783,8 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, | |||
782 | while (len > 0) { | 783 | while (len > 0) { |
783 | if (len < bytes) | 784 | if (len < bytes) |
784 | bytes = len; | 785 | bytes = len; |
785 | al = gfs2_alloc_get(ip); | 786 | qa = gfs2_qadata_get(ip); |
786 | if (!al) { | 787 | if (!qa) { |
787 | error = -ENOMEM; | 788 | error = -ENOMEM; |
788 | goto out_unlock; | 789 | goto out_unlock; |
789 | } | 790 | } |
@@ -795,8 +796,7 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset, | |||
795 | retry: | 796 | retry: |
796 | gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks); | 797 | gfs2_write_calc_reserv(ip, bytes, &data_blocks, &ind_blocks); |
797 | 798 | ||
798 | al->al_requested = data_blocks + ind_blocks; | 799 | error = gfs2_inplace_reserve(ip, data_blocks + ind_blocks); |
799 | error = gfs2_inplace_reserve(ip); | ||
800 | if (error) { | 800 | if (error) { |
801 | if (error == -ENOSPC && bytes > sdp->sd_sb.sb_bsize) { | 801 | if (error == -ENOSPC && bytes > sdp->sd_sb.sb_bsize) { |
802 | bytes >>= 1; | 802 | bytes >>= 1; |
@@ -810,7 +810,6 @@ retry: | |||
810 | max_bytes = bytes; | 810 | max_bytes = bytes; |
811 | 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, |
812 | &max_bytes, &data_blocks, &ind_blocks); | 812 | &max_bytes, &data_blocks, &ind_blocks); |
813 | al->al_requested = data_blocks + ind_blocks; | ||
814 | 813 | ||
815 | rblocks = RES_DINODE + ind_blocks + RES_STATFS + RES_QUOTA + | 814 | rblocks = RES_DINODE + ind_blocks + RES_STATFS + RES_QUOTA + |
816 | RES_RG_HDR + gfs2_rg_blocks(ip); | 815 | RES_RG_HDR + gfs2_rg_blocks(ip); |
@@ -832,8 +831,11 @@ retry: | |||
832 | offset += max_bytes; | 831 | offset += max_bytes; |
833 | gfs2_inplace_release(ip); | 832 | gfs2_inplace_release(ip); |
834 | gfs2_quota_unlock(ip); | 833 | gfs2_quota_unlock(ip); |
835 | gfs2_alloc_put(ip); | 834 | gfs2_qadata_put(ip); |
836 | } | 835 | } |
836 | |||
837 | if (error == 0) | ||
838 | error = generic_write_sync(file, pos, count); | ||
837 | goto out_unlock; | 839 | goto out_unlock; |
838 | 840 | ||
839 | out_trans_fail: | 841 | out_trans_fail: |
@@ -841,7 +843,7 @@ out_trans_fail: | |||
841 | out_qunlock: | 843 | out_qunlock: |
842 | gfs2_quota_unlock(ip); | 844 | gfs2_quota_unlock(ip); |
843 | out_alloc_put: | 845 | out_alloc_put: |
844 | gfs2_alloc_put(ip); | 846 | gfs2_qadata_put(ip); |
845 | out_unlock: | 847 | out_unlock: |
846 | gfs2_glock_dq(&ip->i_gh); | 848 | gfs2_glock_dq(&ip->i_gh); |
847 | out_uninit: | 849 | out_uninit: |