diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2013-12-13 06:46:28 -0500 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2014-01-14 14:29:06 -0500 |
commit | 2d9e72303d538024627fb1fe2cbde48aec12acc0 (patch) | |
tree | f1aa745cf372cfe899524bfaad9ee4d28977ca4a /fs/gfs2 | |
parent | ee2411a8db49a21bc55dc124e1b434ba194c8903 (diff) |
GFS2: Move quota bitmap operations under their own lock
Gradually, the global qd_lock is being used for less and less.
After this patch it will only be used for the per super block
list whose purpose is to allow syncing of changes back to the
master quota file from the local quota changes file. Fixing
up that process to make it more efficient will be the subject
of a later patch, however this patch removes another barrier
to doing that.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Cc: Abhijith Das <adas@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/incore.h | 1 | ||||
-rw-r--r-- | fs/gfs2/ops_fstype.c | 1 | ||||
-rw-r--r-- | fs/gfs2/quota.c | 16 |
3 files changed, 10 insertions, 8 deletions
diff --git a/fs/gfs2/incore.h b/fs/gfs2/incore.h index 4b9aa5b6908c..8c64e268b7ef 100644 --- a/fs/gfs2/incore.h +++ b/fs/gfs2/incore.h | |||
@@ -734,6 +734,7 @@ struct gfs2_sbd { | |||
734 | 734 | ||
735 | unsigned int sd_quota_slots; | 735 | unsigned int sd_quota_slots; |
736 | unsigned long *sd_quota_bitmap; | 736 | unsigned long *sd_quota_bitmap; |
737 | spinlock_t sd_bitmap_lock; | ||
737 | 738 | ||
738 | u64 sd_quota_sync_gen; | 739 | u64 sd_quota_sync_gen; |
739 | 740 | ||
diff --git a/fs/gfs2/ops_fstype.c b/fs/gfs2/ops_fstype.c index 27648e803d1e..06a66c9624e6 100644 --- a/fs/gfs2/ops_fstype.c +++ b/fs/gfs2/ops_fstype.c | |||
@@ -99,6 +99,7 @@ static struct gfs2_sbd *init_sbd(struct super_block *sb) | |||
99 | init_waitqueue_head(&sdp->sd_quota_wait); | 99 | init_waitqueue_head(&sdp->sd_quota_wait); |
100 | INIT_LIST_HEAD(&sdp->sd_trunc_list); | 100 | INIT_LIST_HEAD(&sdp->sd_trunc_list); |
101 | spin_lock_init(&sdp->sd_trunc_lock); | 101 | spin_lock_init(&sdp->sd_trunc_lock); |
102 | spin_lock_init(&sdp->sd_bitmap_lock); | ||
102 | 103 | ||
103 | mapping = &sdp->sd_aspace; | 104 | mapping = &sdp->sd_aspace; |
104 | 105 | ||
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 79be67ab8603..02a2740f2468 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
@@ -76,6 +76,7 @@ | |||
76 | #define GFS2_QD_HASH_MASK (GFS2_QD_HASH_SIZE - 1) | 76 | #define GFS2_QD_HASH_MASK (GFS2_QD_HASH_SIZE - 1) |
77 | 77 | ||
78 | /* Lock order: qd_lock -> bucket lock -> qd->lockref.lock -> lru lock */ | 78 | /* Lock order: qd_lock -> bucket lock -> qd->lockref.lock -> lru lock */ |
79 | /* -> sd_bitmap_lock */ | ||
79 | static DEFINE_SPINLOCK(qd_lock); | 80 | static DEFINE_SPINLOCK(qd_lock); |
80 | struct list_lru gfs2_qd_lru; | 81 | struct list_lru gfs2_qd_lru; |
81 | 82 | ||
@@ -319,7 +320,7 @@ static int slot_get(struct gfs2_quota_data *qd) | |||
319 | unsigned int bit; | 320 | unsigned int bit; |
320 | int error = 0; | 321 | int error = 0; |
321 | 322 | ||
322 | spin_lock(&qd_lock); | 323 | spin_lock(&sdp->sd_bitmap_lock); |
323 | if (qd->qd_slot_count != 0) | 324 | if (qd->qd_slot_count != 0) |
324 | goto out; | 325 | goto out; |
325 | 326 | ||
@@ -331,7 +332,7 @@ static int slot_get(struct gfs2_quota_data *qd) | |||
331 | out: | 332 | out: |
332 | qd->qd_slot_count++; | 333 | qd->qd_slot_count++; |
333 | } | 334 | } |
334 | spin_unlock(&qd_lock); | 335 | spin_unlock(&sdp->sd_bitmap_lock); |
335 | 336 | ||
336 | return error; | 337 | return error; |
337 | } | 338 | } |
@@ -340,23 +341,23 @@ static void slot_hold(struct gfs2_quota_data *qd) | |||
340 | { | 341 | { |
341 | struct gfs2_sbd *sdp = qd->qd_sbd; | 342 | struct gfs2_sbd *sdp = qd->qd_sbd; |
342 | 343 | ||
343 | spin_lock(&qd_lock); | 344 | spin_lock(&sdp->sd_bitmap_lock); |
344 | gfs2_assert(sdp, qd->qd_slot_count); | 345 | gfs2_assert(sdp, qd->qd_slot_count); |
345 | qd->qd_slot_count++; | 346 | qd->qd_slot_count++; |
346 | spin_unlock(&qd_lock); | 347 | spin_unlock(&sdp->sd_bitmap_lock); |
347 | } | 348 | } |
348 | 349 | ||
349 | static void slot_put(struct gfs2_quota_data *qd) | 350 | static void slot_put(struct gfs2_quota_data *qd) |
350 | { | 351 | { |
351 | struct gfs2_sbd *sdp = qd->qd_sbd; | 352 | struct gfs2_sbd *sdp = qd->qd_sbd; |
352 | 353 | ||
353 | spin_lock(&qd_lock); | 354 | spin_lock(&sdp->sd_bitmap_lock); |
354 | gfs2_assert(sdp, qd->qd_slot_count); | 355 | gfs2_assert(sdp, qd->qd_slot_count); |
355 | if (!--qd->qd_slot_count) { | 356 | if (!--qd->qd_slot_count) { |
356 | BUG_ON(!test_and_clear_bit(qd->qd_slot, sdp->sd_quota_bitmap)); | 357 | BUG_ON(!test_and_clear_bit(qd->qd_slot, sdp->sd_quota_bitmap)); |
357 | qd->qd_slot = -1; | 358 | qd->qd_slot = -1; |
358 | } | 359 | } |
359 | spin_unlock(&qd_lock); | 360 | spin_unlock(&sdp->sd_bitmap_lock); |
360 | } | 361 | } |
361 | 362 | ||
362 | static int bh_get(struct gfs2_quota_data *qd) | 363 | static int bh_get(struct gfs2_quota_data *qd) |
@@ -434,8 +435,7 @@ static int qd_check_sync(struct gfs2_sbd *sdp, struct gfs2_quota_data *qd, | |||
434 | list_move_tail(&qd->qd_list, &sdp->sd_quota_list); | 435 | list_move_tail(&qd->qd_list, &sdp->sd_quota_list); |
435 | set_bit(QDF_LOCKED, &qd->qd_flags); | 436 | set_bit(QDF_LOCKED, &qd->qd_flags); |
436 | qd->qd_change_sync = qd->qd_change; | 437 | qd->qd_change_sync = qd->qd_change; |
437 | gfs2_assert_warn(sdp, qd->qd_slot_count); | 438 | slot_hold(qd); |
438 | qd->qd_slot_count++; | ||
439 | return 1; | 439 | return 1; |
440 | } | 440 | } |
441 | 441 | ||