Skip to content

Commit

Permalink
quota: Do not dirty bad dquots
Browse files Browse the repository at this point in the history
Currently we mark dirty even dquots that are not active (i.e.,
initialization or reading failed for them). Thus later we have to check
whether dirty dquot is really active and just clear the dirty bit if
not. Avoid this complication by just never marking non-active dquot as
dirty.

Signed-off-by: Jan Kara <[email protected]>
  • Loading branch information
jankara committed Aug 17, 2017
1 parent 1551237 commit 4580b30
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions fs/quota/dquot.c
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,9 @@ int dquot_mark_dquot_dirty(struct dquot *dquot)
{
int ret = 1;

if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
return 0;

/* If quota is dirty already, we don't have to acquire dq_list_lock */
if (test_bit(DQ_MOD_B, &dquot->dq_flags))
return 1;
Expand Down Expand Up @@ -624,11 +627,9 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
while (!list_empty(dirty)) {
dquot = list_first_entry(dirty, struct dquot,
dq_dirty);
/* Dirty and inactive can be only bad dquot... */
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
clear_dquot_dirty(dquot);
continue;
}

WARN_ON(!test_bit(DQ_ACTIVE_B, &dquot->dq_flags));

/* Now we have active dquot from which someone is
* holding reference so we can safely just increase
* use count */
Expand Down Expand Up @@ -759,7 +760,7 @@ void dqput(struct dquot *dquot)
return;
}
/* Need to release dquot? */
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && dquot_dirty(dquot)) {
if (dquot_dirty(dquot)) {
spin_unlock(&dq_list_lock);
/* Commit dquot before releasing */
ret = dquot->dq_sb->dq_op->write_dquot(dquot);
Expand All @@ -777,8 +778,6 @@ void dqput(struct dquot *dquot)
}
goto we_slept;
}
/* Clear flag in case dquot was inactive (something bad happened) */
clear_dquot_dirty(dquot);
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
spin_unlock(&dq_list_lock);
dquot->dq_sb->dq_op->release_dquot(dquot);
Expand Down

0 comments on commit 4580b30

Please sign in to comment.