diff options
author | Steven Whitehouse <swhiteho@redhat.com> | 2013-10-04 06:14:46 -0400 |
---|---|---|
committer | Steven Whitehouse <swhiteho@redhat.com> | 2013-10-04 06:14:46 -0400 |
commit | 1bf59bf6ded8411058b4c9acc45d9dd8d6965464 (patch) | |
tree | aa53c3615dcd8c7b6d65aaa4f1c40a9e9e1ebb33 /fs/gfs2 | |
parent | bef292a72daf215c00aa20f68603de181afbb4d3 (diff) |
GFS2: Make two similar quota code fragments into a function
There should be no functional change bar the removal of a
test of the MS_READONLY flag which would never be reachable.
This merges the common code from qd_fish and qd_trylock into
a single function and calls it from both those places.
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Cc: Abhijith Das <adas@redhat.com>
Diffstat (limited to 'fs/gfs2')
-rw-r--r-- | fs/gfs2/quota.c | 60 |
1 files changed, 26 insertions, 34 deletions
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index 658abe26a098..75414e773ab4 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
@@ -383,6 +383,25 @@ static void bh_put(struct gfs2_quota_data *qd) | |||
383 | mutex_unlock(&sdp->sd_quota_mutex); | 383 | mutex_unlock(&sdp->sd_quota_mutex); |
384 | } | 384 | } |
385 | 385 | ||
386 | static int qd_check_sync(struct gfs2_sbd *sdp, struct gfs2_quota_data *qd, | ||
387 | u64 *sync_gen) | ||
388 | { | ||
389 | if (test_bit(QDF_LOCKED, &qd->qd_flags) || | ||
390 | !test_bit(QDF_CHANGE, &qd->qd_flags) || | ||
391 | (sync_gen && (qd->qd_sync_gen >= *sync_gen))) | ||
392 | return 0; | ||
393 | |||
394 | list_move_tail(&qd->qd_list, &sdp->sd_quota_list); | ||
395 | |||
396 | set_bit(QDF_LOCKED, &qd->qd_flags); | ||
397 | gfs2_assert_warn(sdp, atomic_read(&qd->qd_count)); | ||
398 | atomic_inc(&qd->qd_count); | ||
399 | qd->qd_change_sync = qd->qd_change; | ||
400 | gfs2_assert_warn(sdp, qd->qd_slot_count); | ||
401 | qd->qd_slot_count++; | ||
402 | return 1; | ||
403 | } | ||
404 | |||
386 | static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp) | 405 | static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp) |
387 | { | 406 | { |
388 | struct gfs2_quota_data *qd = NULL; | 407 | struct gfs2_quota_data *qd = NULL; |
@@ -397,22 +416,9 @@ static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp) | |||
397 | spin_lock(&qd_lru_lock); | 416 | spin_lock(&qd_lru_lock); |
398 | 417 | ||
399 | list_for_each_entry(qd, &sdp->sd_quota_list, qd_list) { | 418 | list_for_each_entry(qd, &sdp->sd_quota_list, qd_list) { |
400 | if (test_bit(QDF_LOCKED, &qd->qd_flags) || | 419 | found = qd_check_sync(sdp, qd, &sdp->sd_quota_sync_gen); |
401 | !test_bit(QDF_CHANGE, &qd->qd_flags) || | 420 | if (found) |
402 | qd->qd_sync_gen >= sdp->sd_quota_sync_gen) | 421 | break; |
403 | continue; | ||
404 | |||
405 | list_move_tail(&qd->qd_list, &sdp->sd_quota_list); | ||
406 | |||
407 | set_bit(QDF_LOCKED, &qd->qd_flags); | ||
408 | gfs2_assert_warn(sdp, atomic_read(&qd->qd_count)); | ||
409 | atomic_inc(&qd->qd_count); | ||
410 | qd->qd_change_sync = qd->qd_change; | ||
411 | gfs2_assert_warn(sdp, qd->qd_slot_count); | ||
412 | qd->qd_slot_count++; | ||
413 | found = 1; | ||
414 | |||
415 | break; | ||
416 | } | 422 | } |
417 | 423 | ||
418 | if (!found) | 424 | if (!found) |
@@ -439,28 +445,14 @@ static int qd_fish(struct gfs2_sbd *sdp, struct gfs2_quota_data **qdp) | |||
439 | static int qd_trylock(struct gfs2_quota_data *qd) | 445 | static int qd_trylock(struct gfs2_quota_data *qd) |
440 | { | 446 | { |
441 | struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; | 447 | struct gfs2_sbd *sdp = qd->qd_gl->gl_sbd; |
442 | 448 | int found; | |
443 | if (sdp->sd_vfs->s_flags & MS_RDONLY) | ||
444 | return 0; | ||
445 | 449 | ||
446 | spin_lock(&qd_lru_lock); | 450 | spin_lock(&qd_lru_lock); |
451 | found = qd_check_sync(sdp, qd, NULL); | ||
452 | spin_unlock(&qd_lru_lock); | ||
447 | 453 | ||
448 | if (test_bit(QDF_LOCKED, &qd->qd_flags) || | 454 | if (!found) |
449 | !test_bit(QDF_CHANGE, &qd->qd_flags)) { | ||
450 | spin_unlock(&qd_lru_lock); | ||
451 | return 0; | 455 | return 0; |
452 | } | ||
453 | |||
454 | list_move_tail(&qd->qd_list, &sdp->sd_quota_list); | ||
455 | |||
456 | set_bit(QDF_LOCKED, &qd->qd_flags); | ||
457 | gfs2_assert_warn(sdp, atomic_read(&qd->qd_count)); | ||
458 | atomic_inc(&qd->qd_count); | ||
459 | qd->qd_change_sync = qd->qd_change; | ||
460 | gfs2_assert_warn(sdp, qd->qd_slot_count); | ||
461 | qd->qd_slot_count++; | ||
462 | |||
463 | spin_unlock(&qd_lru_lock); | ||
464 | 456 | ||
465 | gfs2_assert_warn(sdp, qd->qd_change_sync); | 457 | gfs2_assert_warn(sdp, qd->qd_change_sync); |
466 | if (bh_get(qd)) { | 458 | if (bh_get(qd)) { |