Skip to content

Commit 33bcfaf

Browse files
LiBaokun96jankara
authored andcommitted
quota: add new helper dquot_active()
Add new helper function dquot_active() to make the code more concise. Signed-off-by: Baokun Li <libaokun1@huawei.com> Signed-off-by: Jan Kara <jack@suse.cz> Message-Id: <20230630110822.3881712-4-libaokun1@huawei.com>
1 parent 4b9bdfa commit 33bcfaf

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

fs/quota/dquot.c

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,11 @@ static void wait_on_dquot(struct dquot *dquot)
336336
mutex_unlock(&dquot->dq_lock);
337337
}
338338

339+
static inline int dquot_active(struct dquot *dquot)
340+
{
341+
return test_bit(DQ_ACTIVE_B, &dquot->dq_flags);
342+
}
343+
339344
static inline int dquot_dirty(struct dquot *dquot)
340345
{
341346
return test_bit(DQ_MOD_B, &dquot->dq_flags);
@@ -351,14 +356,14 @@ int dquot_mark_dquot_dirty(struct dquot *dquot)
351356
{
352357
int ret = 1;
353358

354-
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
359+
if (!dquot_active(dquot))
355360
return 0;
356361

357362
if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NOLIST_DIRTY)
358363
return test_and_set_bit(DQ_MOD_B, &dquot->dq_flags);
359364

360365
/* If quota is dirty already, we don't have to acquire dq_list_lock */
361-
if (test_bit(DQ_MOD_B, &dquot->dq_flags))
366+
if (dquot_dirty(dquot))
362367
return 1;
363368

364369
spin_lock(&dq_list_lock);
@@ -440,7 +445,7 @@ int dquot_acquire(struct dquot *dquot)
440445
smp_mb__before_atomic();
441446
set_bit(DQ_READ_B, &dquot->dq_flags);
442447
/* Instantiate dquot if needed */
443-
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) {
448+
if (!dquot_active(dquot) && !dquot->dq_off) {
444449
ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
445450
/* Write the info if needed */
446451
if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
@@ -482,7 +487,7 @@ int dquot_commit(struct dquot *dquot)
482487
goto out_lock;
483488
/* Inactive dquot can be only if there was error during read/init
484489
* => we have better not writing it */
485-
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
490+
if (dquot_active(dquot))
486491
ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
487492
else
488493
ret = -EIO;
@@ -597,7 +602,7 @@ int dquot_scan_active(struct super_block *sb,
597602

598603
spin_lock(&dq_list_lock);
599604
list_for_each_entry(dquot, &inuse_list, dq_inuse) {
600-
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
605+
if (!dquot_active(dquot))
601606
continue;
602607
if (dquot->dq_sb != sb)
603608
continue;
@@ -612,7 +617,7 @@ int dquot_scan_active(struct super_block *sb,
612617
* outstanding call and recheck the DQ_ACTIVE_B after that.
613618
*/
614619
wait_on_dquot(dquot);
615-
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
620+
if (dquot_active(dquot)) {
616621
ret = fn(dquot, priv);
617622
if (ret < 0)
618623
goto out;
@@ -663,7 +668,7 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
663668
dquot = list_first_entry(&dirty, struct dquot,
664669
dq_dirty);
665670

666-
WARN_ON(!test_bit(DQ_ACTIVE_B, &dquot->dq_flags));
671+
WARN_ON(!dquot_active(dquot));
667672

668673
/* Now we have active dquot from which someone is
669674
* holding reference so we can safely just increase
@@ -800,7 +805,7 @@ void dqput(struct dquot *dquot)
800805
dquot_write_dquot(dquot);
801806
goto we_slept;
802807
}
803-
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
808+
if (dquot_active(dquot)) {
804809
spin_unlock(&dq_list_lock);
805810
dquot->dq_sb->dq_op->release_dquot(dquot);
806811
goto we_slept;
@@ -901,7 +906,7 @@ struct dquot *dqget(struct super_block *sb, struct kqid qid)
901906
* already finished or it will be canceled due to dq_count > 1 test */
902907
wait_on_dquot(dquot);
903908
/* Read the dquot / allocate space in quota file */
904-
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
909+
if (!dquot_active(dquot)) {
905910
int err;
906911

907912
err = sb->dq_op->acquire_dquot(dquot);

0 commit comments

Comments
 (0)