Fix ZDB to dump projid for projectquota enabled (#16291)

ZDB is supposed to dump "projid" via dump_znode(), when projectquota
is enabled.
-----------
static void
dump_znode(objset_t *os, uint64_t object, void *data, size_t size)
{
...
    if (dmu_objset_projectquota_enabled(os) && (pflags & ZFS_PROJID)) {
	uint64_t projid;

	if (sa_lookup(hdl, sa_attr_table[ZPL_PROJID], &projid,
	    sizeof (uint64_t)) == 0)
		(void) printf("\tprojid %llu\n", (u_longlong_t)projid);
    }
...
}
----------
But its not dumping "projid", even for project quota enabled.

dmu_objset_projectquota_enabled() does following 3 checks,
----------
boolean_t
dmu_objset_projectquota_enabled(objset_t *os)
{
        return (file_cbs[os->os_phys->os_type] != NULL &&
            DMU_PROJECTUSED_DNODE(os) != NULL &&
            spa_feature_is_enabled(os->os_spa,
		SPA_FEATURE_PROJECT_QUOTA));
}
----------
It fails on file_cbs[] check. file_cbs[] gets initialised via
dmu_objset_register_type(); which is not done for the ZDB, its done for
the kernel via zfs_init().

Register a dummy callback handle for the DMU_OST_ZFS type in
ZDB main() function to dump the projid for projectquota enabled.

Signed-off-by: Jitendra Patidar <jitendra.patidar@nutanix.com>
Closes #16290
Reviewed-by: Tony Hutter <hutter2@llnl.gov>
Reviewed-by: Tino Reichardt <milky-zfs@mcmilk.de>
This commit is contained in:
Jitendra Patidar 2024-07-26 05:48:11 +05:30 committed by GitHub
parent 7ddc1f737f
commit 2ed1aebaf6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 14 additions and 0 deletions

View File

@ -8932,6 +8932,19 @@ zdb_numeric(char *str)
return (B_TRUE); return (B_TRUE);
} }
static int
dummy_get_file_info(dmu_object_type_t bonustype, const void *data,
zfs_file_info_t *zoi)
{
(void) data, (void) zoi;
if (bonustype != DMU_OT_ZNODE && bonustype != DMU_OT_SA)
return (ENOENT);
(void) fprintf(stderr, "dummy_get_file_info: not implemented");
abort();
}
int int
main(int argc, char **argv) main(int argc, char **argv)
{ {
@ -9247,6 +9260,7 @@ main(int argc, char **argv)
libzfs_core_fini(); libzfs_core_fini();
} }
dmu_objset_register_type(DMU_OST_ZFS, dummy_get_file_info);
kernel_init(SPA_MODE_READ); kernel_init(SPA_MODE_READ);
kernel_init_done = B_TRUE; kernel_init_done = B_TRUE;