Skip to content

Commit

Permalink
Fix ZDB to dump projid for projectquota enabled
Browse files Browse the repository at this point in the history
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 openzfs#16290
  • Loading branch information
jsai20 committed Jun 23, 2024
1 parent c98295e commit 105d646
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions cmd/zdb/zdb.c
Original file line number Diff line number Diff line change
Expand Up @@ -8905,6 +8905,19 @@ zdb_numeric(char *str)
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
main(int argc, char **argv)
{
Expand Down Expand Up @@ -9220,6 +9233,7 @@ main(int argc, char **argv)
libzfs_core_fini();
}

dmu_objset_register_type(DMU_OST_ZFS, dummy_get_file_info);
kernel_init(SPA_MODE_READ);
kernel_init_done = B_TRUE;

Expand Down

0 comments on commit 105d646

Please sign in to comment.