<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/linux.git/include/linux/quotaops.h, branch v5.10.258</title>
<subtitle>Linux kernel stable tree (mirror)</subtitle>
<id>https://git.radix-linux.su/kernel/linux.git/atom?h=v5.10.258</id>
<link rel='self' href='https://git.radix-linux.su/kernel/linux.git/atom?h=v5.10.258'/>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/'/>
<updated>2026-06-01T15:29:34+00:00</updated>
<entry>
<title>quota: Fix race of dquot_scan_active() with quota deactivation</title>
<updated>2026-06-01T15:29:34+00:00</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2026-02-27T13:22:16+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=2bdc80f4619411e5bd4a3ef23f51e14021ed457c'/>
<id>urn:sha1:2bdc80f4619411e5bd4a3ef23f51e14021ed457c</id>
<content type='text'>
[ Upstream commit e93ab401da4b2e2c1b8ef2424de2f238d51c8b2d ]

dquot_scan_active() can race with quota deactivation in
quota_release_workfn() like:

  CPU0 (quota_release_workfn)         CPU1 (dquot_scan_active)
  ==============================      ==============================
  spin_lock(&amp;dq_list_lock);
  list_replace_init(
    &amp;releasing_dquots, &amp;rls_head);
    /* dquot X on rls_head,
       dq_count == 0,
       DQ_ACTIVE_B still set */
  spin_unlock(&amp;dq_list_lock);
  synchronize_srcu(&amp;dquot_srcu);
                                      spin_lock(&amp;dq_list_lock);
                                      list_for_each_entry(dquot,
                                          &amp;inuse_list, dq_inuse) {
                                        /* finds dquot X */
                                        dquot_active(X) -&gt; true
                                        atomic_inc(&amp;X-&gt;dq_count);
                                      }
                                      spin_unlock(&amp;dq_list_lock);
  spin_lock(&amp;dq_list_lock);
  dquot = list_first_entry(&amp;rls_head);
  WARN_ON_ONCE(atomic_read(&amp;dquot-&gt;dq_count));

The problem is not only a cosmetic one as under memory pressure the
caller of dquot_scan_active() can end up working on freed dquot.

Fix the problem by making sure the dquot is removed from releasing list
when we acquire a reference to it.

Fixes: 869b6ea1609f ("quota: Fix slow quotaoff")
Reported-by: Sam Sun &lt;samsun1006219@gmail.com&gt;
Link: https://lore.kernel.org/all/CAEkJfYPTt3uP1vAYnQ5V2ZWn5O9PLhhGi5HbOcAzyP9vbXyjeg@mail.gmail.com
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>quota: Fix slow quotaoff</title>
<updated>2023-10-25T09:54:13+00:00</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2023-10-04T13:32:01+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=22c06bf1f99ec3ec16b1a81342becba4c59a1f16'/>
<id>urn:sha1:22c06bf1f99ec3ec16b1a81342becba4c59a1f16</id>
<content type='text'>
commit 869b6ea1609f655a43251bf41757aa44e5350a8f upstream.

Eric has reported that commit dabc8b207566 ("quota: fix dqput() to
follow the guarantees dquot_srcu should provide") heavily increases
runtime of generic/270 xfstest for ext4 in nojournal mode. The reason
for this is that ext4 in nojournal mode leaves dquots dirty until the last
dqput() and thus the cleanup done in quota_release_workfn() has to write
them all. Due to the way quota_release_workfn() is written this results
in synchronize_srcu() call for each dirty dquot which makes the dquot
cleanup when turning quotas off extremely slow.

To be able to avoid synchronize_srcu() for each dirty dquot we need to
rework how we track dquots to be cleaned up. Instead of keeping the last
dquot reference while it is on releasing_dquots list, we drop it right
away and mark the dquot with new DQ_RELEASING_B bit instead. This way we
can we can remove dquot from releasing_dquots list when new reference to
it is acquired and thus there's no need to call synchronize_srcu() each
time we drop dq_list_lock.

References: https://lore.kernel.org/all/ZRytn6CxFK2oECUt@debian-BULLSEYE-live-builder-AMD64
Reported-by: Eric Whitney &lt;enwlinux@gmail.com&gt;
Fixes: dabc8b207566 ("quota: fix dqput() to follow the guarantees dquot_srcu should provide")
CC: stable@vger.kernel.org
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Greg Kroah-Hartman &lt;gregkh@linuxfoundation.org&gt;
</content>
</entry>
<entry>
<title>quota: simplify the quotactl compat handling</title>
<updated>2020-09-17T17:00:46+00:00</updated>
<author>
<name>Christoph Hellwig</name>
<email>hch@lst.de</email>
</author>
<published>2020-09-17T07:41:59+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=80bdad3d7e3ec03f812471d9309f5f682e10f52b'/>
<id>urn:sha1:80bdad3d7e3ec03f812471d9309f5f682e10f52b</id>
<content type='text'>
Fold the misaligned u64 workarounds into the main quotactl flow instead
of implementing a separate compat syscall handler.

Signed-off-by: Christoph Hellwig &lt;hch@lst.de&gt;
Acked-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Al Viro &lt;viro@zeniv.linux.org.uk&gt;
</content>
</entry>
<entry>
<title>Pull series refactoring quota enabling and disabling code.</title>
<updated>2019-11-06T09:52:10+00:00</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2019-11-06T09:52:10+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=dae82c7fd0926840c832151f3258ba751f73d348'/>
<id>urn:sha1:dae82c7fd0926840c832151f3258ba751f73d348</id>
<content type='text'>
</content>
</entry>
<entry>
<title>quota: Drop dquot_enable()</title>
<updated>2019-11-04T08:58:06+00:00</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2019-11-01T17:57:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=069a9166369773627e51c5249cd7f9169aecd7fa'/>
<id>urn:sha1:069a9166369773627e51c5249cd7f9169aecd7fa</id>
<content type='text'>
Now dquot_enable() has only two internal callers and both of them just
need to update quota flags and don't need most of checks. Just drop
dquot_enable() and fold necessary functionality into the two calling
places.

Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
</entry>
<entry>
<title>quota: Rename vfs_load_quota_inode() to dquot_load_quota_inode()</title>
<updated>2019-11-04T08:58:05+00:00</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2019-11-01T17:37:44+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=dc19432ae1c22d696f91edea11ae06c348b4e88a'/>
<id>urn:sha1:dc19432ae1c22d696f91edea11ae06c348b4e88a</id>
<content type='text'>
Rename vfs_load_quota_inode() to dquot_load_quota_inode() to be
consistent with naming of other functions used for enabling quota
accounting from filesystems. Also export the function and add some
sanity checks to assure filesystems are calling the function properly.

Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
</entry>
<entry>
<title>quota: Factor out setup of quota inode</title>
<updated>2019-11-04T08:58:01+00:00</updated>
<author>
<name>Jan Kara</name>
<email>jack@suse.cz</email>
</author>
<published>2019-11-01T16:45:31+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=c7d3d28360fdb3ed3a5aa0bab19315e0fdc994a1'/>
<id>urn:sha1:c7d3d28360fdb3ed3a5aa0bab19315e0fdc994a1</id>
<content type='text'>
Factor out setting up of quota inode and eventual error cleanup from
vfs_load_quota_inode(). This will simplify situation for filesystems
that don't have any quota inodes.

Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
</entry>
<entry>
<title>quota: Check that quota is not dirty before release</title>
<updated>2019-10-31T18:07:42+00:00</updated>
<author>
<name>Dmitry Monakhov</name>
<email>dmtrmonakhov@yandex-team.ru</email>
</author>
<published>2019-10-31T10:39:20+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=df4bb5d128e2c44848aeb36b7ceceba3ac85080d'/>
<id>urn:sha1:df4bb5d128e2c44848aeb36b7ceceba3ac85080d</id>
<content type='text'>
There is a race window where quota was redirted once we drop dq_list_lock inside dqput(),
but before we grab dquot-&gt;dq_lock inside dquot_release()

TASK1                                                       TASK2 (chowner)
-&gt;dqput()
  we_slept:
    spin_lock(&amp;dq_list_lock)
    if (dquot_dirty(dquot)) {
          spin_unlock(&amp;dq_list_lock);
          dquot-&gt;dq_sb-&gt;dq_op-&gt;write_dquot(dquot);
          goto we_slept
    if (test_bit(DQ_ACTIVE_B, &amp;dquot-&gt;dq_flags)) {
          spin_unlock(&amp;dq_list_lock);
          dquot-&gt;dq_sb-&gt;dq_op-&gt;release_dquot(dquot);
                                                            dqget()
							    mark_dquot_dirty()
							    dqput()
          goto we_slept;
        }
So dquot dirty quota will be released by TASK1, but on next we_sleept loop
we detect this and call -&gt;write_dquot() for it.
XFSTEST: https://github.com/dmonakhov/xfstests/commit/440a80d4cbb39e9234df4d7240aee1d551c36107

Link: https://lore.kernel.org/r/20191031103920.3919-2-dmonakhov@openvz.org
CC: stable@vger.kernel.org
Signed-off-by: Dmitry Monakhov &lt;dmtrmonakhov@yandex-team.ru&gt;
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
</entry>
<entry>
<title>quota: fix wrong condition in is_quota_modification()</title>
<updated>2019-09-12T10:09:16+00:00</updated>
<author>
<name>Chao Yu</name>
<email>yuchao0@huawei.com</email>
</author>
<published>2019-09-11T09:36:50+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=6565c182094f69e4ffdece337d395eb7ec760efc'/>
<id>urn:sha1:6565c182094f69e4ffdece337d395eb7ec760efc</id>
<content type='text'>
Quoted from
commit 3da40c7b0898 ("ext4: only call ext4_truncate when size &lt;= isize")

" At LSF we decided that if we truncate up from isize we shouldn't trim
  fallocated blocks that were fallocated with KEEP_SIZE and are past the
 new i_size.  This patch fixes ext4 to do this. "

And generic/092 of fstest have covered this case for long time, however
is_quota_modification() didn't adjust based on that rule, so that in
below condition, we will lose to quota block change:
- fallocate blocks beyond EOF
- remount
- truncate(file_path, file_size)

Fix it.

Link: https://lore.kernel.org/r/20190911093650.35329-1-yuchao0@huawei.com
Fixes: 3da40c7b0898 ("ext4: only call ext4_truncate when size &lt;= isize")
CC: stable@vger.kernel.org
Signed-off-by: Chao Yu &lt;yuchao0@huawei.com&gt;
Signed-off-by: Jan Kara &lt;jack@suse.cz&gt;
</content>
</entry>
<entry>
<title>fs/quota: add kernel_quotactl() helper; remove in-kernel call to syscall</title>
<updated>2018-04-02T18:15:46+00:00</updated>
<author>
<name>Dominik Brodowski</name>
<email>linux@dominikbrodowski.net</email>
</author>
<published>2018-03-17T15:26:56+00:00</published>
<link rel='alternate' type='text/html' href='https://git.radix-linux.su/kernel/linux.git/commit/?id=cb0b476ab12ca3bd9dd9122047660f3a73e8d647'/>
<id>urn:sha1:cb0b476ab12ca3bd9dd9122047660f3a73e8d647</id>
<content type='text'>
Using the fs-internal kernel_quotactl() helper allows us to get rid of
the fs-internal call to the sys_quotactl() syscall.

This patch is part of a series which removes in-kernel calls to syscalls.
On this basis, the syscall entry path can be streamlined. For details, see
http://lkml.kernel.org/r/20180325162527.GA17492@light.dominikbrodowski.net

Acked-by: Jan Kara &lt;jack@suse.cz&gt;
Signed-off-by: Dominik Brodowski &lt;linux@dominikbrodowski.net&gt;
</content>
</entry>
</feed>
