mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-11-24 04:34:08 +08:00
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>
This commit is contained in:
parent
4b9bdfa165
commit
33bcfafc48
@ -336,6 +336,11 @@ static void wait_on_dquot(struct dquot *dquot)
|
||||
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)
|
||||
{
|
||||
return test_bit(DQ_MOD_B, &dquot->dq_flags);
|
||||
@ -351,14 +356,14 @@ int dquot_mark_dquot_dirty(struct dquot *dquot)
|
||||
{
|
||||
int ret = 1;
|
||||
|
||||
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
|
||||
if (!dquot_active(dquot))
|
||||
return 0;
|
||||
|
||||
if (sb_dqopt(dquot->dq_sb)->flags & DQUOT_NOLIST_DIRTY)
|
||||
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 (test_bit(DQ_MOD_B, &dquot->dq_flags))
|
||||
if (dquot_dirty(dquot))
|
||||
return 1;
|
||||
|
||||
spin_lock(&dq_list_lock);
|
||||
@ -440,7 +445,7 @@ int dquot_acquire(struct dquot *dquot)
|
||||
smp_mb__before_atomic();
|
||||
set_bit(DQ_READ_B, &dquot->dq_flags);
|
||||
/* 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);
|
||||
/* Write the info if needed */
|
||||
if (info_dirty(&dqopt->info[dquot->dq_id.type])) {
|
||||
@ -482,7 +487,7 @@ int dquot_commit(struct dquot *dquot)
|
||||
goto out_lock;
|
||||
/* Inactive dquot can be only if there was error during read/init
|
||||
* => 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);
|
||||
else
|
||||
ret = -EIO;
|
||||
@ -597,7 +602,7 @@ int dquot_scan_active(struct super_block *sb,
|
||||
|
||||
spin_lock(&dq_list_lock);
|
||||
list_for_each_entry(dquot, &inuse_list, dq_inuse) {
|
||||
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
|
||||
if (!dquot_active(dquot))
|
||||
continue;
|
||||
if (dquot->dq_sb != sb)
|
||||
continue;
|
||||
@ -612,7 +617,7 @@ int dquot_scan_active(struct super_block *sb,
|
||||
* outstanding call and recheck the DQ_ACTIVE_B after that.
|
||||
*/
|
||||
wait_on_dquot(dquot);
|
||||
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
|
||||
if (dquot_active(dquot)) {
|
||||
ret = fn(dquot, priv);
|
||||
if (ret < 0)
|
||||
goto out;
|
||||
@ -663,7 +668,7 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
|
||||
dquot = list_first_entry(&dirty, struct dquot,
|
||||
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
|
||||
* holding reference so we can safely just increase
|
||||
@ -800,7 +805,7 @@ we_slept:
|
||||
dquot_write_dquot(dquot);
|
||||
goto we_slept;
|
||||
}
|
||||
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
|
||||
if (dquot_active(dquot)) {
|
||||
spin_unlock(&dq_list_lock);
|
||||
dquot->dq_sb->dq_op->release_dquot(dquot);
|
||||
goto we_slept;
|
||||
@ -901,7 +906,7 @@ we_slept:
|
||||
* already finished or it will be canceled due to dq_count > 1 test */
|
||||
wait_on_dquot(dquot);
|
||||
/* Read the dquot / allocate space in quota file */
|
||||
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
|
||||
if (!dquot_active(dquot)) {
|
||||
int err;
|
||||
|
||||
err = sb->dq_op->acquire_dquot(dquot);
|
||||
|
Loading…
Reference in New Issue
Block a user