aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorSteven Whitehouse <swhiteho@redhat.com>2013-10-04 07:29:34 -0400
committerSteven Whitehouse <swhiteho@redhat.com>2013-10-04 07:29:34 -0400
commite46c772dbafc2059b0c7ee87c6a7232baadaf6c7 (patch)
tree43e33f6a25ba196b9391e5f03e137a46455a0807 /fs
parentaabd7c72f52145fcf13f9251770b0b0246b5e406 (diff)
GFS2: Protect quota sync generation
Now that gfs2_quota_sync can be potentially called from multiple threads, we should protect this bit of code, and the sync generation number in particular in order to ensure that there are no races when syncing quotas. Signed-off-by: Steven Whitehouse <swhiteho@redhat.com> Cc: Abhijith Das <adas@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/gfs2/incore.h1
-rw-r--r--fs/gfs2/ops_fstype.c1
-rw-r--r--fs/gfs2/quota.c6
3 files changed, 6 insertions, 2 deletions
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h
index 37b3cd795d6c..2ab4f8d8f4c4 100644
--- a/fs/gfs2/incore.h
+++ b/fs/gfs2/incore.h
@@ -714,6 +714,7 @@ struct gfs2_sbd {
714 struct list_head sd_quota_list; 714 struct list_head sd_quota_list;
715 atomic_t sd_quota_count; 715 atomic_t sd_quota_count;
716 struct mutex sd_quota_mutex; 716 struct mutex sd_quota_mutex;
717 struct mutex sd_quota_sync_mutex;
717 wait_queue_head_t sd_quota_wait; 718 wait_queue_head_t sd_quota_wait;
718 struct list_head sd_trunc_list; 719 struct list_head sd_trunc_list;
719 spinlock_t sd_trunc_lock; 720 spinlock_t sd_trunc_lock;
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c
index 8e40fda985d6..82303b474958 100644
--- a/fs/gfs2/ops_fstype.c
+++ b/fs/gfs2/ops_fstype.c
@@ -93,6 +93,7 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb)
93 93
94 INIT_LIST_HEAD(&sdp->sd_quota_list); 94 INIT_LIST_HEAD(&sdp->sd_quota_list);
95 mutex_init(&sdp->sd_quota_mutex); 95 mutex_init(&sdp->sd_quota_mutex);
96 mutex_init(&sdp->sd_quota_sync_mutex);
96 init_waitqueue_head(&sdp->sd_quota_wait); 97 init_waitqueue_head(&sdp->sd_quota_wait);
97 INIT_LIST_HEAD(&sdp->sd_trunc_list); 98 INIT_LIST_HEAD(&sdp->sd_trunc_list);
98 spin_lock_init(&sdp->sd_trunc_lock); 99 spin_lock_init(&sdp->sd_trunc_lock);
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c
index cfb4cdeddacb..4a9726aa191f 100644
--- a/fs/gfs2/quota.c
+++ b/fs/gfs2/quota.c
@@ -1132,12 +1132,13 @@ int gfs2_quota_sync(struct super_block *sb, int type)
1132 unsigned int x; 1132 unsigned int x;
1133 int error = 0; 1133 int error = 0;
1134 1134
1135 sdp->sd_quota_sync_gen++;
1136
1137 qda = kcalloc(max_qd, sizeof(struct gfs2_quota_data *), GFP_KERNEL); 1135 qda = kcalloc(max_qd, sizeof(struct gfs2_quota_data *), GFP_KERNEL);
1138 if (!qda) 1136 if (!qda)
1139 return -ENOMEM; 1137 return -ENOMEM;
1140 1138
1139 mutex_lock(&sdp->sd_quota_sync_mutex);
1140 sdp->sd_quota_sync_gen++;
1141
1141 do { 1142 do {
1142 num_qd = 0; 1143 num_qd = 0;
1143 1144
@@ -1162,6 +1163,7 @@ int gfs2_quota_sync(struct super_block *sb, int type)
1162 } 1163 }
1163 } while (!error && num_qd == max_qd); 1164 } while (!error && num_qd == max_qd);
1164 1165
1166 mutex_unlock(&sdp->sd_quota_sync_mutex);
1165 kfree(qda); 1167 kfree(qda);
1166 1168
1167 return error; 1169 return error;