From 2ed1aebaf605ef28a0b899ec019529e0ad381d39 Mon Sep 17 00:00:00 2001 From: Jitendra Patidar Date: Fri, 26 Jul 2024 05:48:11 +0530 Subject: [PATCH] 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 Closes #16290 Reviewed-by: Tony Hutter Reviewed-by: Tino Reichardt --- cmd/zdb/zdb.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index bb593b44f5..4dab0db302 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -8932,6 +8932,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) { @@ -9247,6 +9260,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;