]> git.proxmox.com Git - mirror_zfs.git/commitdiff
DMU: Fix lock leak on dbuf_hold() error
authorAlexander Motin <mav@FreeBSD.org>
Sat, 9 Dec 2023 00:43:39 +0000 (19:43 -0500)
committerGitHub <noreply@github.com>
Sat, 9 Dec 2023 00:43:39 +0000 (16:43 -0800)
dmu_assign_arcbuf_by_dnode() should drop dn_struct_rwlock lock in
case dbuf_hold() failed.  I don't have reproduction for this, but
it looks inconsistent with dmu_buf_hold_noread_by_dnode() and co.

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Alexander Motin <mav@FreeBSD.org>
Sponsored by: iXsystems, Inc.
Closes #15644

module/zfs/dmu.c

index 6cf7f3c3b12e1df109a6567bc076bdcaa7938685..f5a5d0fc437f59faec99c40f1521c660449a4edd 100644 (file)
@@ -1501,9 +1501,9 @@ dmu_assign_arcbuf_by_dnode(dnode_t *dn, uint64_t offset, arc_buf_t *buf,
        rw_enter(&dn->dn_struct_rwlock, RW_READER);
        blkid = dbuf_whichblock(dn, 0, offset);
        db = dbuf_hold(dn, blkid, FTAG);
+       rw_exit(&dn->dn_struct_rwlock);
        if (db == NULL)
                return (SET_ERROR(EIO));
-       rw_exit(&dn->dn_struct_rwlock);
 
        /*
         * We can only assign if the offset is aligned and the arc buf is the