aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2
diff options
context:
space:
mode:
authorBob Peterson <rpeterso@redhat.com>2014-02-06 10:43:50 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2014-02-06 10:49:58 -0500
commita0846a534c5fbc40a08e2960a24bd0b8d647a840 (patch)
tree6ff563d46d745ceec2db5f58053f84c12a69d644 /fs/gfs2
parent774016b2d455017935b3e318b6cc4e055e9dd47f (diff)
GFS2: Lock i_mutex and use a local gfs2_holder for fallocate
This patch causes GFS2 to lock the i_mutex during fallocate. It also switches from using a dinode's inode glock to using a local holder like the other GFS2 i_operations. Signed-off-by: Bob Peterson <rpeterso@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r--fs/gfs2/file.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/fs/gfs2/file.c b/fs/gfs2/file.c
index efc078f0ee4e..6c794085abac 100644
--- a/fs/gfs2/file.c
+++ b/fs/gfs2/file.c
@@ -811,6 +811,8 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
811 loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1); 811 loff_t bsize_mask = ~((loff_t)sdp->sd_sb.sb_bsize - 1);
812 loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift; 812 loff_t next = (offset + len - 1) >> sdp->sd_sb.sb_bsize_shift;
813 loff_t max_chunk_size = UINT_MAX & bsize_mask; 813 loff_t max_chunk_size = UINT_MAX & bsize_mask;
814 struct gfs2_holder gh;
815
814 next = (next + 1) << sdp->sd_sb.sb_bsize_shift; 816 next = (next + 1) << sdp->sd_sb.sb_bsize_shift;
815 817
816 /* We only support the FALLOC_FL_KEEP_SIZE mode */ 818 /* We only support the FALLOC_FL_KEEP_SIZE mode */
@@ -831,8 +833,10 @@ static long gfs2_fallocate(struct file *file, int mode, loff_t offset,
831 if (error) 833 if (error)
832 return error; 834 return error;
833 835
834 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &ip->i_gh); 836 mutex_lock(&inode->i_mutex);
835 error = gfs2_glock_nq(&ip->i_gh); 837
838 gfs2_holder_init(ip->i_gl, LM_ST_EXCLUSIVE, 0, &gh);
839 error = gfs2_glock_nq(&gh);
836 if (unlikely(error)) 840 if (unlikely(error))
837 goto out_uninit; 841 goto out_uninit;
838 842
@@ -900,9 +904,10 @@ out_trans_fail:
900out_qunlock: 904out_qunlock:
901 gfs2_quota_unlock(ip); 905 gfs2_quota_unlock(ip);
902out_unlock: 906out_unlock:
903 gfs2_glock_dq(&ip->i_gh); 907 gfs2_glock_dq(&gh);
904out_uninit: 908out_uninit:
905 gfs2_holder_uninit(&ip->i_gh); 909 gfs2_holder_uninit(&gh);
910 mutex_unlock(&inode->i_mutex);
906 return error; 911 return error;
907} 912}
908 913