dbuf: separate refcount calls for dbuf and dbuf_user
commite675852bc1d50404fcbe4fa0e1f57b6c318e6349
authorRob N <rob.norris@klarasystems.com>
Wed, 15 May 2024 20:03:41 +0000 (16 06:03 +1000)
committerGitHub <noreply@github.com>
Wed, 15 May 2024 20:03:41 +0000 (15 13:03 -0700)
tree4bd7cd520b7ea5017082d55b0ee1ddae6bcd09c3
parent3c941d18183455138f7c5dcc212177bd3cea8afc
dbuf: separate refcount calls for dbuf and dbuf_user

In 92dc4ad83 I updated the dbuf_cache accounting to track the size of
userdata associated with dbufs. This adds the size of the dbuf+userdata
together in a single call to zfs_refcount_add_many(), but sometime
removes them in separate calls to zfs_refcount_remove_many(), if dbuf
and userdata are evicted separately.

What I didn't realise is that when refcount tracking is on,
zfs_refcount_add_many() and zfs_refcount_remove_many() are expected to
be paired, with their second & third args (count & holder) the same on
both sides. Splitting the remove part into two calls means the counts
don't match up, tripping a panic.

This commit fixes that, by always adding and removing the dbuf and
userdata counts separately.

Sponsored-by: Klara, Inc.
Sponsored-by: Wasabi Technology, Inc.
Reported-by: Mark Johnston <markj@FreeBSD.org>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Alexander Motin <mav@FreeBSD.org>
Signed-off-by: Rob Norris <rob.norris@klarasystems.com>
Closes #16191
module/zfs/dbuf.c