Skip to content

Commit 4580b30

Browse files
committed
quota: Do not dirty bad dquots
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 <jack@suse.cz>
1 parent 1551237 commit 4580b30

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

fs/quota/dquot.c

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,9 @@ int dquot_mark_dquot_dirty(struct dquot *dquot)
339339
{
340340
int ret = 1;
341341

342+
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags))
343+
return 0;
344+
342345
/* If quota is dirty already, we don't have to acquire dq_list_lock */
343346
if (test_bit(DQ_MOD_B, &dquot->dq_flags))
344347
return 1;
@@ -624,11 +627,9 @@ int dquot_writeback_dquots(struct super_block *sb, int type)
624627
while (!list_empty(dirty)) {
625628
dquot = list_first_entry(dirty, struct dquot,
626629
dq_dirty);
627-
/* Dirty and inactive can be only bad dquot... */
628-
if (!test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
629-
clear_dquot_dirty(dquot);
630-
continue;
631-
}
630+
631+
WARN_ON(!test_bit(DQ_ACTIVE_B, &dquot->dq_flags));
632+
632633
/* Now we have active dquot from which someone is
633634
* holding reference so we can safely just increase
634635
* use count */
@@ -759,7 +760,7 @@ void dqput(struct dquot *dquot)
759760
return;
760761
}
761762
/* Need to release dquot? */
762-
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags) && dquot_dirty(dquot)) {
763+
if (dquot_dirty(dquot)) {
763764
spin_unlock(&dq_list_lock);
764765
/* Commit dquot before releasing */
765766
ret = dquot->dq_sb->dq_op->write_dquot(dquot);
@@ -777,8 +778,6 @@ void dqput(struct dquot *dquot)
777778
}
778779
goto we_slept;
779780
}
780-
/* Clear flag in case dquot was inactive (something bad happened) */
781-
clear_dquot_dirty(dquot);
782781
if (test_bit(DQ_ACTIVE_B, &dquot->dq_flags)) {
783782
spin_unlock(&dq_list_lock);
784783
dquot->dq_sb->dq_op->release_dquot(dquot);

0 commit comments

Comments
 (0)