]> git.baikalelectronics.ru Git - kernel.git/commit
quota: Fix quota corruption with generic/232 test
authorJan Kara <jack@suse.cz>
Tue, 26 Sep 2017 08:36:05 +0000 (10:36 +0200)
committerJan Kara <jack@suse.cz>
Wed, 27 Sep 2017 09:33:47 +0000 (11:33 +0200)
commitcd9f9ee935a4d414388fb98ecc74f6dffe47377b
tree90bd7195506aefbee10704635b11c71244918a8a
parent5b6a1da7c3fe3061508f820d4bb2f38724590e83
quota: Fix quota corruption with generic/232 test

Eric has reported that since commit 0a8c34e98a6c "quota: Do not acquire
dqio_sem for dquot overwrites in v2 format" test generic/232
occasionally fails due to quota information being incorrect. Indeed that
commit was too eager to remove dqio_sem completely from the path that
just overwrites quota structure with updated information. Although that
is innocent on its own, another process that inserts new quota structure
to the same block can perform read-modify-write cycle of that block thus
effectively discarding quota information update if they race in a wrong
way.

Fix the problem by acquiring dqio_sem for reading for overwrites of
quota structure. Note that it *is* possible to completely avoid taking
dqio_sem in the overwrite path however that will require modifying path
inserting / deleting quota structures to avoid RMW cycles of the full
block and for now it is not clear whether it is worth the hassle.

Fixes: 0a8c34e98a6cb7e5d309d0710f8cc8c3e3833d78
Reported-and-tested-by: Eric Whitney <enwlinux@gmail.com>
Signed-off-by: Jan Kara <jack@suse.cz>
fs/quota/quota_v2.c