* [PATCH] xfs: release dquot buffer after dqflush failure
@ 2026-06-25 13:16 Yingjie Gao
2026-06-25 17:55 ` Darrick J. Wong
2026-07-01 12:50 ` Carlos Maiolino
0 siblings, 2 replies; 4+ messages in thread
From: Yingjie Gao @ 2026-06-25 13:16 UTC (permalink / raw)
To: Carlos Maiolino, Darrick J. Wong
Cc: linux-xfs, linux-kernel, Yingjie Gao, stable
xfs_qm_dqpurge() gets a locked buffer from xfs_dquot_use_attached_buf().
If xfs_qm_dqflush() fails, the error path skips xfs_buf_relse() and then
calls xfs_dquot_detach_buf(), which tries to lock the same buffer again.
Release the buffer after xfs_qm_dqflush() returns so the error path drops
the caller hold and unlocks the buffer before the dquot is detached,
matching the other dqflush callers.
Fixes: a40fe30868ba ("xfs: separate dquot buffer reads from xfs_dqflush")
Cc: stable@vger.kernel.org # v6.13+
Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
---
fs/xfs/xfs_qm.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
index aa0d2976f1c3..896b24f87ac9 100644
--- a/fs/xfs/xfs_qm.c
+++ b/fs/xfs/xfs_qm.c
@@ -166,10 +166,9 @@ xfs_qm_dqpurge(
* does it on success.
*/
error = xfs_qm_dqflush(dqp, bp);
- if (!error) {
+ if (!error)
error = xfs_bwrite(bp);
- xfs_buf_relse(bp);
- }
+ xfs_buf_relse(bp);
xfs_dqflock(dqp);
}
xfs_dquot_detach_buf(dqp);
--
2.20.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] xfs: release dquot buffer after dqflush failure
2026-06-25 13:16 [PATCH] xfs: release dquot buffer after dqflush failure Yingjie Gao
@ 2026-06-25 17:55 ` Darrick J. Wong
2026-06-26 13:40 ` Yingjie Gao
2026-07-01 12:50 ` Carlos Maiolino
1 sibling, 1 reply; 4+ messages in thread
From: Darrick J. Wong @ 2026-06-25 17:55 UTC (permalink / raw)
To: Yingjie Gao; +Cc: Carlos Maiolino, linux-xfs, linux-kernel, stable
On Thu, Jun 25, 2026 at 09:16:23PM +0800, Yingjie Gao wrote:
> xfs_qm_dqpurge() gets a locked buffer from xfs_dquot_use_attached_buf().
> If xfs_qm_dqflush() fails, the error path skips xfs_buf_relse() and then
> calls xfs_dquot_detach_buf(), which tries to lock the same buffer again.
>
> Release the buffer after xfs_qm_dqflush() returns so the error path drops
> the caller hold and unlocks the buffer before the dquot is detached,
> matching the other dqflush callers.
>
> Fixes: a40fe30868ba ("xfs: separate dquot buffer reads from xfs_dqflush")
> Cc: stable@vger.kernel.org # v6.13+
> Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
Looks fine, though scanning this function further, I suspect that "goto
out_funlock" in the "resurrect the refcount from the dead" isn't quite
right either.
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
--D
> ---
> fs/xfs/xfs_qm.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
> index aa0d2976f1c3..896b24f87ac9 100644
> --- a/fs/xfs/xfs_qm.c
> +++ b/fs/xfs/xfs_qm.c
> @@ -166,10 +166,9 @@ xfs_qm_dqpurge(
> * does it on success.
> */
> error = xfs_qm_dqflush(dqp, bp);
> - if (!error) {
> + if (!error)
> error = xfs_bwrite(bp);
> - xfs_buf_relse(bp);
> - }
> + xfs_buf_relse(bp);
> xfs_dqflock(dqp);
> }
> xfs_dquot_detach_buf(dqp);
> --
> 2.20.1
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] xfs: release dquot buffer after dqflush failure
2026-06-25 17:55 ` Darrick J. Wong
@ 2026-06-26 13:40 ` Yingjie Gao
0 siblings, 0 replies; 4+ messages in thread
From: Yingjie Gao @ 2026-06-26 13:40 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Carlos Maiolino, linux-xfs, linux-kernel, stable
在 2026/6/26 01:55, Darrick J. Wong 写道:
> On Thu, Jun 25, 2026 at 09:16:23PM +0800, Yingjie Gao wrote:
>> xfs_qm_dqpurge() gets a locked buffer from xfs_dquot_use_attached_buf().
>> If xfs_qm_dqflush() fails, the error path skips xfs_buf_relse() and then
>> calls xfs_dquot_detach_buf(), which tries to lock the same buffer again.
>>
>> Release the buffer after xfs_qm_dqflush() returns so the error path drops
>> the caller hold and unlocks the buffer before the dquot is detached,
>> matching the other dqflush callers.
>>
>> Fixes: a40fe30868ba ("xfs: separate dquot buffer reads from xfs_dqflush")
>> Cc: stable@vger.kernel.org # v6.13+
>> Signed-off-by: Yingjie Gao <gaoyingjie@uniontech.com>
>
> Looks fine, though scanning this function further, I suspect that "goto
> out_funlock" in the "resurrect the refcount from the dead" isn't quite
> right either.
Thanks for taking a look.
I checked the "resurrect the refcount from the dead" path and sent a
separate fix for it:
https://lore.kernel.org/linux-xfs/20260626095253.3445540-1-gaoyingjie@uniontech.com/
Thanks,
Yingjie
>
> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
>
> --D
>
>> ---
>> fs/xfs/xfs_qm.c | 5 ++---
>> 1 file changed, 2 insertions(+), 3 deletions(-)
>>
>> diff --git a/fs/xfs/xfs_qm.c b/fs/xfs/xfs_qm.c
>> index aa0d2976f1c3..896b24f87ac9 100644
>> --- a/fs/xfs/xfs_qm.c
>> +++ b/fs/xfs/xfs_qm.c
>> @@ -166,10 +166,9 @@ xfs_qm_dqpurge(
>> * does it on success.
>> */
>> error = xfs_qm_dqflush(dqp, bp);
>> - if (!error) {
>> + if (!error)
>> error = xfs_bwrite(bp);
>> - xfs_buf_relse(bp);
>> - }
>> + xfs_buf_relse(bp);
>> xfs_dqflock(dqp);
>> }
>> xfs_dquot_detach_buf(dqp);
>> --
>> 2.20.1
>>
>>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] xfs: release dquot buffer after dqflush failure
2026-06-25 13:16 [PATCH] xfs: release dquot buffer after dqflush failure Yingjie Gao
2026-06-25 17:55 ` Darrick J. Wong
@ 2026-07-01 12:50 ` Carlos Maiolino
1 sibling, 0 replies; 4+ messages in thread
From: Carlos Maiolino @ 2026-07-01 12:50 UTC (permalink / raw)
To: Darrick J. Wong, Yingjie Gao; +Cc: linux-xfs, linux-kernel, stable
On Thu, 25 Jun 2026 21:16:23 +0800, Yingjie Gao wrote:
> xfs_qm_dqpurge() gets a locked buffer from xfs_dquot_use_attached_buf().
> If xfs_qm_dqflush() fails, the error path skips xfs_buf_relse() and then
> calls xfs_dquot_detach_buf(), which tries to lock the same buffer again.
>
> Release the buffer after xfs_qm_dqflush() returns so the error path drops
> the caller hold and unlocks the buffer before the dquot is detached,
> matching the other dqflush callers.
>
> [...]
Applied to for-next, thanks!
[1/1] xfs: release dquot buffer after dqflush failure
commit: 0c1b3a823a22af623d55f225fe2ac7e8b9052821
Best regards,
--
Carlos Maiolino <cem@kernel.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-01 12:50 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-25 13:16 [PATCH] xfs: release dquot buffer after dqflush failure Yingjie Gao
2026-06-25 17:55 ` Darrick J. Wong
2026-06-26 13:40 ` Yingjie Gao
2026-07-01 12:50 ` Carlos Maiolino
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox