提交 3fb7aa3a 编写于 作者: B Baokun Li

quota: add new helper dquot_active()

maillist inclusion
category: bugfix
bugzilla: 188812,https://gitee.com/openeuler/kernel/issues/I7E0YR

Reference: https://www.spinics.net/lists/kernel/msg4844759.html

----------------------------------------

Add new helper function dquot_active() to make the code more concise.
Signed-off-by: NBaokun Li <libaokun1@huawei.com>
上级 329a1eb4
...@@ -338,6 +338,11 @@ static void wait_on_dquot(struct dquot *dquot) ...@@ -338,6 +338,11 @@ static void wait_on_dquot(struct dquot *dquot)
mutex_unlock(&dquot->dq_lock); mutex_unlock(&dquot->dq_lock);
} }
static inline int dquot_active(struct dquot *dquot)
{
return test_bit(DQ_ACTIVE_B, &dquot->dq_flags);
}
static inline int dquot_dirty(struct dquot *dquot) static inline int dquot_dirty(struct dquot *dquot)
{ {
return test_bit(DQ_MOD_B, &dquot->dq_flags); return test_bit(DQ_MOD_B, &dquot->dq_flags);
...@@ -353,14 +358,14 @@ int dquot_mark_dquot_dirty(struct dquot *dquot) ...@@ -353,14 +358,14 @@ int dquot_mark_dquot_dirty(struct dquot *dquot)
{ {
int ret = 1; int ret = 1;
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) if (!dquot_active(dquot))
return 0; return 0;
if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NOLIST_DIRTY) if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NOLIST_DIRTY)
return test_and_set_bit(DQ_MOD_B, &dquot->dq_flags); return test_and_set_bit(DQ_MOD_B, &dquot->dq_flags);
/* If quota is dirty already, we don't have to acquire dq_list_lock */ /* If quota is dirty already, we don't have to acquire dq_list_lock */
if (test_bit(DQ_MOD_B, &dquot->dq_flags)) if (dquot_dirty(dquot))
return 1; return 1;
spin_lock(&dq_list_lock); spin_lock(&dq_list_lock);
...@@ -442,7 +447,7 @@ int dquot_acquire(struct dquot *dquot) ...@@ -442,7 +447,7 @@ int dquot_acquire(struct dquot *dquot)
smp_mb__before_atomic(); smp_mb__before_atomic();
set_bit(DQ_READ_B, &dquot->dq_flags); set_bit(DQ_READ_B, &dquot->dq_flags);
/* Instantiate dquot if needed */ /* Instantiate dquot if needed */
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && !dquot->dq_off) { if (!dquot_active(dquot) && !dquot->dq_off) {
ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot); ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
/* Write the info if needed */ /* Write the info if needed */
if (info_dirty(&dqopt->info[dquot->dq_id.type])) { if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
...@@ -484,7 +489,7 @@ int dquot_commit(struct dquot *dquot) ...@@ -484,7 +489,7 @@ int dquot_commit(struct dquot *dquot)
goto out_lock; goto out_lock;
/* Inactive dquot can be only if there was error during read/init /* Inactive dquot can be only if there was error during read/init
* => we have better not writing it */ * => we have better not writing it */
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) if (dquot_active(dquot))
ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot); ret = dqopt->ops[dquot->dq_id.type]->commit_dqblk(dquot);
else else
ret = -EIO; ret = -EIO;
...@@ -599,7 +604,7 @@ int dquot_scan_active(struct super_block *sb, ...@@ -599,7 +604,7 @@ int dquot_scan_active(struct super_block *sb,
spin_lock(&dq_list_lock); spin_lock(&dq_list_lock);
list_for_each_entry(dquot, &inuse_list, dq_inuse) { list_for_each_entry(dquot, &inuse_list, dq_inuse) {
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) if (!dquot_active(dquot))
continue; continue;
if (dquot->dq_sb != sb) if (dquot->dq_sb != sb)
continue; continue;
...@@ -614,7 +619,7 @@ int dquot_scan_active(struct super_block *sb, ...@@ -614,7 +619,7 @@ int dquot_scan_active(struct super_block *sb,
* outstanding call and recheck the DQ_ACTIVE_B after that. * outstanding call and recheck the DQ_ACTIVE_B after that.
*/ */
wait_on_dquot(dquot); wait_on_dquot(dquot);
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) { if (dquot_active(dquot)) {
ret = fn(dquot, priv); ret = fn(dquot, priv);
if (ret < 0) if (ret < 0)
goto out; goto out;
...@@ -665,7 +670,7 @@ int dquot_writeback_dquots(struct super_block *sb, int type) ...@@ -665,7 +670,7 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
dquot = list_first_entry(&dirty, struct dquot, dquot = list_first_entry(&dirty, struct dquot,
dq_dirty); dq_dirty);
WARN_ON(!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)); WARN_ON(!dquot_active(dquot));
/* Now we have active dquot from which someone is /* Now we have active dquot from which someone is
* holding reference so we can safely just increase * holding reference so we can safely just increase
...@@ -802,7 +807,7 @@ void dqput(struct dquot *dquot) ...@@ -802,7 +807,7 @@ void dqput(struct dquot *dquot)
dquot_write_dquot(dquot); dquot_write_dquot(dquot);
goto we_slept; goto we_slept;
} }
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) { if (dquot_active(dquot)) {
spin_unlock(&dq_list_lock); spin_unlock(&dq_list_lock);
dquot->dq_sb->dq_op->release_dquot(dquot); dquot->dq_sb->dq_op->release_dquot(dquot);
goto we_slept; goto we_slept;
...@@ -903,7 +908,7 @@ struct dquot *dqget(struct super_block *sb, struct kqid qid) ...@@ -903,7 +908,7 @@ struct dquot *dqget(struct super_block *sb, struct kqid qid)
* already finished or it will be canceled due to dq_count > 1 test */ * already finished or it will be canceled due to dq_count > 1 test */
wait_on_dquot(dquot); wait_on_dquot(dquot);
/* Read the dquot / allocate space in quota file */ /* Read the dquot / allocate space in quota file */
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) { if (!dquot_active(dquot)) {
int err; int err;
err = sb->dq_op->acquire_dquot(dquot); err = sb->dq_op->acquire_dquot(dquot);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册