Re: [PATCH] btrfs: fix extent changeset leak in encoded writes
David Sterba <[email protected]> Fri, 31 Jul 2026 17:04:08 +0200
| Newsgroups | org.kernel.vger.linux-btrfs,org.kernel.vger.linux-kernel,org.kernel.vger.stable |
|---|---|
| Message-ID | <[email protected]> |
On Fri, Jul 31, 2026 at 12:56:20PM +0100, Filipe Manana wrote: > On Fri, Jul 31, 2026 at 12:52 PM Breno Leitao <[email protected]> wrote: > > > > Investigating some machines with kmemleak, I am constantly seeing > > the following memory leak that seems real. > > > > kmemleak: unreferenced object 0xffff88869f7d01c0 (size 64): > > kmemleak: comm "btrfs", pid 1613416, jiffies 4316358595 > > kmemleak: backtrace (crc ab59040a): > > kmemleak: __kmalloc_cache_noprof > > kmemleak: qgroup_reserve_data > > kmemleak: btrfs_qgroup_reserve_data > > kmemleak: btrfs_do_encoded_write > > kmemleak: btrfs_do_write_iter > > kmemleak: btrfs_ioctl_encoded_write > > kmemleak: btrfs_ioctl > > kmemleak: ... and 2 more object(s) with the same backtrace > > > > and > > > > kmemleak: unreferenced object 0xffff88830d94edc0 (size 64): > > kmemleak: comm "btrfs", pid 1613416, jiffies 4316358595 > > <snip> > > kmemleak: ... and 2 more object(s) with the same backtrace > > > > Looking at the code, it seems we don't free data_reserved, but > > we should (!?). I was able to come up with a xfstest test that exposes > > the kmemleak above: > > > > https://github.com/leitao/xfstest/commit/81c83a3fbb20b4ad695055ede7fcb73d3ffa2e52 > > > > Free the changeset on the way out, as every other caller of > > btrfs_qgroup_reserve_data() already does. > > > > Fixes: 7c0c7269f7b5 ("btrfs: add BTRFS_IOC_ENCODED_WRITE") > > Cc: [email protected] > > Signed-off-by: Breno Leitao <[email protected]> > > This is already fixed here: > > https://lore.kernel.org/linux-btrfs/[email protected]/ Will be sent next week.