Project

General

Profile

Bug #13234

Prevent race condition in dnode_dest

Added by Jason King 3 months ago. Updated 3 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
zfs - Zettabyte File System
Start date:
Due date:
% Done:

100%

Estimated time:
Difficulty:
Medium
Tags:
Gerrit CR:

Description

Port of OpenZFS #10101:

dnode_special_close() waits for the refcount of dn_holds to go to zero without holding the dn_mtx. dnode_rele_and_unlock() does the final remove to dn_holds with dn_mtx being held:

 refs = zfs_refcount_remove(&dn->dn_holds, tag);
 mutex_exit(&dn->dn_mtx);

So, there is a race condition after the remove until dn_mtx is dropped. During that time, dnode_destroy() can get called, which ends up in dnode_dest() calling mutex_destroy() and a panic since the lock is still held.

This change adds a condvar to wait for the final dnode_rele_and_unlock() to release the dn_mtx before calling dnode_destroy().

Reviewed-by: Paul Dagnelie <>
Reviewed-by: Brian Behlendorf <>
Reviewed-by: Matthew Ahrens <>


Related issues

Has duplicate illumos gate - Bug #7395: mutex not owner panic in dnode_dest() -> mutex_destroy()Closed2016-09-21

Actions
#1

Updated by Electric Monk 3 months ago

  • Gerrit CR set to 1003
#2

Updated by Jason King 3 months ago

To test, the zfs test suite was run. The only failures were known issues with existing tickets.

#3

Updated by Jason King 3 months ago

  • Has duplicate Bug #7395: mutex not owner panic in dnode_dest() -> mutex_destroy() added
#4

Updated by Electric Monk 3 months ago

  • Status changed from New to Closed
  • % Done changed from 0 to 100

git commit b390f3a9a166c4ae80f78a79961396a4847672b7

commit  b390f3a9a166c4ae80f78a79961396a4847672b7
Author: John Poduska <jpoduska@datto.com>
Date:   2020-10-22T21:47:39.000Z

    13234 Prevent race condition in dnode_dest
    Portions contributed by: Jason King <jason.king@joyent.com>
    Reviewed by: Paul Dagnelie <pcd@delphix.com>
    Reviewed by: Brian Behlendorf <behlendorf1@llnl.gov>
    Reviewed by: Matthew Ahrens <mahrens@delphix.com>
    Reviewed by: Andy Fiddaman <andy@omniosce.org>
    Approved by: Dan McDonald <danmcd@joyent.com>

Also available in: Atom PDF