Skip to content

Commit

Permalink
[2.2.5-only] Make 'rmmod zfs' work after zfs-2.2.4 (openzfs#16406)
Browse files Browse the repository at this point in the history
db65272 was added to zfs-2.2.4 to stub in the
VDEV_PROP_RAIDZ_EXPANDING enum without adding the RAIDz expansion
feature.  This was needed to provide the right enum count for when the
VDEV_PROP_SLOW_IO proprieties got added.  This had the unfortunate side
effect of breaking module removal though.

Specifically, with the VDEV_PROP_RAIDZ_EXPANDING stub added,
the module would correctly omit making kobjects for the RAIDz expansion
vdev property, but then would try to blindly remove its non-existent
kobjects during module unload.

This commit fixes the issue by checking for an uninitialized kobject.

Fixes: openzfs#16249

Signed-off-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Reviewed-by: Ameer Hamza <ahamza@ixsystems.com>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
  • Loading branch information
tonyhutter authored and ptr1337 committed Aug 4, 2024
1 parent 4ec8b5a commit ffcf1fc
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions module/os/linux/zfs/zfs_sysfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,17 @@ zfs_kobj_fini(zfs_mod_kobj_t *zkobj)
}

/* kobject_put() will call zfs_kobj_release() to release memory */
kobject_del(&zkobj->zko_kobj);
kobject_put(&zkobj->zko_kobj);
/*
* Special case note:
*
* We have to check for 'zkobj->zko_kobj.name != NULL' as
* a workaround for #16249 which was added to zfs-2.2.4
* and fixed (with this change) in zfs-2.2.5.
*/
if (zkobj->zko_kobj.name != NULL) {
kobject_del(&zkobj->zko_kobj);
kobject_put(&zkobj->zko_kobj);
}
}

static void
Expand Down

0 comments on commit ffcf1fc

Please sign in to comment.