Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ZDB to dump projid for projectquota enabled #16291

Merged
merged 1 commit into from
Jul 26, 2024

Conversation

jsai20
Copy link
Contributor

@jsai20 jsai20 commented Jun 23, 2024

Motivation and Context

Description

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.

How Has This Been Tested?

$ zfs list
NAME             USED  AVAIL  REFER  MOUNTPOINT
mytestpool       179K   832M    25K  /mytestpool
mytestpool/fs1    25K   832M    25K  /mytestpool/fs1
$ ls -i /mytestpool/fs1/file1
2 /mytestpool/fs1/file1
$ sudo zfs project /mytestpool/fs1/file1
  100 - /mytestpool/fs1/file1
$

zdb dump of ino 2 without fix doesn't list projid field.

$ sudo zdb -ddddd mytestpool/fs1 2
Dataset mytestpool/fs1 [ZPL], ID 144, cr_txg 11, 25K, 9 objects, rootbp DVA[0]=<0:2c00bc00:200> DVA[1]=<0:3000bc00:200> [L0 DMU objset] fletcher4 lz4 unencrypted LE contiguous unique double size=1000L/200P birth=178L/178P fill=9 cksum=000000117b3a1df4:000005f259dca352:000111b9fd9582ee:002278be1dfbd514

    Object  lvl   iblk   dblk  dsize  dnsize  lsize   %full  type
         2    1   128K    512      0     512    512    0.00  ZFS plain file
                                               184   bonus  System attributes
        dnode flags: USERUSED_ACCOUNTED USEROBJUSED_ACCOUNTED
        dnode maxblkid: 0
        path    /file1
        uid     0
        gid     0
        atime   Sat Jun 22 13:03:02 2024
        mtime   Sat Jun 22 13:03:02 2024
        ctime   Sat Jun 22 13:03:02 2024
        crtime  Sat Jun 22 13:03:02 2024
        gen     56
        mode    100600
        size    0
        parent  34
        links   1
        pflags  840800000004
        xattr   3
Indirect blocks:

zdb dump of ino 2 with Fix lists projid field.

$ sudo ./zdb -ddddd mytestpool/fs1 2
Dataset mytestpool/fs1 [ZPL], ID 144, cr_txg 11, 25K, 9 objects, rootbp DVA[0]=<0:2c00bc00:200> DVA[1]=<0:3000bc00:200> [L0 DMU objset] fletcher4 lz4 unencrypted LE contiguous unique double size=1000L/200P birth=178L/178P fill=9 cksum=000000117b3a1df4:000005f259dca352:000111b9fd9582ee:002278be1dfbd514

    Object  lvl   iblk   dblk  dsize  dnsize  lsize   %full  type
         2    1   128K    512      0     512    512    0.00  ZFS plain file
                                               184   bonus  System attributes
        dnode flags: USERUSED_ACCOUNTED USEROBJUSED_ACCOUNTED
        dnode maxblkid: 0
        path    /file1
        uid     0
        gid     0
        atime   Sat Jun 22 13:03:02 2024
        mtime   Sat Jun 22 13:03:02 2024
        ctime   Sat Jun 22 13:03:02 2024
        crtime  Sat Jun 22 13:03:02 2024
        gen     56
        mode    100600
        size    0
        parent  34
        links   1
        pflags  840800000004
        projid  100
        xattr   3
Indirect blocks:

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Performance enhancement (non-breaking change which improves efficiency)
  • Code cleanup (non-breaking change which makes code smaller or more readable)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Library ABI change (libzfs, libzfs_core, libnvpair, libuutil and libzfsbootenv)
  • Documentation (a change to man pages or other documentation)

Checklist:

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 <[email protected]>
Closes openzfs#16290
@tonyhutter tonyhutter merged commit 2ed1aeb into openzfs:master Jul 26, 2024
21 of 25 checks passed
@jsai20 jsai20 deleted the zdb-projid-fix branch August 21, 2024 09:42
lundman pushed a commit to openzfsonwindows/openzfs that referenced this pull request Sep 4, 2024
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 <[email protected]>
Closes openzfs#16290
Reviewed-by: Tony Hutter <[email protected]>
Reviewed-by: Tino Reichardt <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants