Add inode accessors to common code
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Jorgen Lundman <lundman@lundman.net> Signed-off-by: Matt Macy <mmacy@FreeBSD.org> Closes #9389
This commit is contained in:
parent
13a4027a7c
commit
6360e2779e
|
@ -258,7 +258,15 @@ zfs_inherit_projid(znode_t *dzp)
|
||||||
#define ZTOZSB(znode) ((zfsvfs_t *)(ZTOI(znode)->i_sb->s_fs_info))
|
#define ZTOZSB(znode) ((zfsvfs_t *)(ZTOI(znode)->i_sb->s_fs_info))
|
||||||
#define ITOZSB(inode) ((zfsvfs_t *)((inode)->i_sb->s_fs_info))
|
#define ITOZSB(inode) ((zfsvfs_t *)((inode)->i_sb->s_fs_info))
|
||||||
|
|
||||||
#define S_ISDEV(mode) (S_ISCHR(mode) || S_ISBLK(mode) || S_ISFIFO(mode))
|
#define ZTOTYPE(zp) (ZTOI(zp)->i_mode)
|
||||||
|
#define ZTOGID(zp) (ZTOI(zp)->i_gid)
|
||||||
|
#define ZTOUID(zp) (ZTOI(zp)->i_uid)
|
||||||
|
#define ZTONLNK(zp) (ZTOI(zp)->i_nlink)
|
||||||
|
|
||||||
|
#define Z_ISBLK(type) S_ISBLK(type)
|
||||||
|
#define Z_ISCHR(type) S_ISCHR(type)
|
||||||
|
#define Z_ISLNK(type) S_ISLNK(type)
|
||||||
|
#define S_ISDEV(type) (S_ISCHR(type) || S_ISBLK(type) || S_ISFIFO(type))
|
||||||
|
|
||||||
/* Called on entry to each ZFS inode and vfs operation. */
|
/* Called on entry to each ZFS inode and vfs operation. */
|
||||||
#define ZFS_ENTER_ERROR(zfsvfs, error) \
|
#define ZFS_ENTER_ERROR(zfsvfs, error) \
|
||||||
|
|
|
@ -1586,7 +1586,7 @@ sa_add_projid(sa_handle_t *hdl, dmu_tx_t *tx, uint64_t projid)
|
||||||
&ctime, 16);
|
&ctime, 16);
|
||||||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CRTIME(zfsvfs), NULL,
|
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_CRTIME(zfsvfs), NULL,
|
||||||
&crtime, 16);
|
&crtime, 16);
|
||||||
if (S_ISBLK(ZTOI(zp)->i_mode) || S_ISCHR(ZTOI(zp)->i_mode))
|
if (Z_ISBLK(ZTOTYPE(zp)) || Z_ISCHR(ZTOTYPE(zp)))
|
||||||
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_RDEV(zfsvfs), NULL,
|
SA_ADD_BULK_ATTR(bulk, count, SA_ZPL_RDEV(zfsvfs), NULL,
|
||||||
&rdev, 8);
|
&rdev, 8);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1625,7 +1625,7 @@ sa_add_projid(sa_handle_t *hdl, dmu_tx_t *tx, uint64_t projid)
|
||||||
|
|
||||||
zp->z_projid = projid;
|
zp->z_projid = projid;
|
||||||
zp->z_pflags |= ZFS_PROJID;
|
zp->z_pflags |= ZFS_PROJID;
|
||||||
links = ZTOI(zp)->i_nlink;
|
links = ZTONLNK(zp);
|
||||||
count = 0;
|
count = 0;
|
||||||
err = 0;
|
err = 0;
|
||||||
|
|
||||||
|
@ -1646,7 +1646,7 @@ sa_add_projid(sa_handle_t *hdl, dmu_tx_t *tx, uint64_t projid)
|
||||||
SA_ADD_BULK_ATTR(attrs, count, SA_ZPL_LINKS(zfsvfs), NULL, &links, 8);
|
SA_ADD_BULK_ATTR(attrs, count, SA_ZPL_LINKS(zfsvfs), NULL, &links, 8);
|
||||||
SA_ADD_BULK_ATTR(attrs, count, SA_ZPL_PROJID(zfsvfs), NULL, &projid, 8);
|
SA_ADD_BULK_ATTR(attrs, count, SA_ZPL_PROJID(zfsvfs), NULL, &projid, 8);
|
||||||
|
|
||||||
if (S_ISBLK(ZTOI(zp)->i_mode) || S_ISCHR(ZTOI(zp)->i_mode))
|
if (Z_ISBLK(ZTOTYPE(zp)) || Z_ISCHR(ZTOTYPE(zp)))
|
||||||
SA_ADD_BULK_ATTR(attrs, count, SA_ZPL_RDEV(zfsvfs), NULL,
|
SA_ADD_BULK_ATTR(attrs, count, SA_ZPL_RDEV(zfsvfs), NULL,
|
||||||
&rdev, 8);
|
&rdev, 8);
|
||||||
|
|
||||||
|
|
|
@ -382,9 +382,9 @@ zfs_fuid_find_by_idx(zfsvfs_t *zfsvfs, uint32_t idx)
|
||||||
void
|
void
|
||||||
zfs_fuid_map_ids(znode_t *zp, cred_t *cr, uid_t *uidp, uid_t *gidp)
|
zfs_fuid_map_ids(znode_t *zp, cred_t *cr, uid_t *uidp, uid_t *gidp)
|
||||||
{
|
{
|
||||||
*uidp = zfs_fuid_map_id(ZTOZSB(zp), KUID_TO_SUID(ZTOI(zp)->i_uid),
|
*uidp = zfs_fuid_map_id(ZTOZSB(zp), KUID_TO_SUID(ZTOUID(zp)),
|
||||||
cr, ZFS_OWNER);
|
cr, ZFS_OWNER);
|
||||||
*gidp = zfs_fuid_map_id(ZTOZSB(zp), KGID_TO_SGID(ZTOI(zp)->i_gid),
|
*gidp = zfs_fuid_map_id(ZTOZSB(zp), KGID_TO_SGID(ZTOGID(zp)),
|
||||||
cr, ZFS_GROUP);
|
cr, ZFS_GROUP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -322,13 +322,13 @@ zfs_log_create(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
|
||||||
/* Store dnode slot count in 8 bits above object id. */
|
/* Store dnode slot count in 8 bits above object id. */
|
||||||
LR_FOID_SET_SLOTS(lr->lr_foid, zp->z_dnodesize >> DNODE_SHIFT);
|
LR_FOID_SET_SLOTS(lr->lr_foid, zp->z_dnodesize >> DNODE_SHIFT);
|
||||||
lr->lr_mode = zp->z_mode;
|
lr->lr_mode = zp->z_mode;
|
||||||
if (!IS_EPHEMERAL(KUID_TO_SUID(ZTOI(zp)->i_uid))) {
|
if (!IS_EPHEMERAL(KUID_TO_SUID(ZTOUID(zp)))) {
|
||||||
lr->lr_uid = (uint64_t)KUID_TO_SUID(ZTOI(zp)->i_uid);
|
lr->lr_uid = (uint64_t)KUID_TO_SUID(ZTOUID(zp));
|
||||||
} else {
|
} else {
|
||||||
lr->lr_uid = fuidp->z_fuid_owner;
|
lr->lr_uid = fuidp->z_fuid_owner;
|
||||||
}
|
}
|
||||||
if (!IS_EPHEMERAL(KGID_TO_SGID(ZTOI(zp)->i_gid))) {
|
if (!IS_EPHEMERAL(KGID_TO_SGID(ZTOGID(zp)))) {
|
||||||
lr->lr_gid = (uint64_t)KGID_TO_SGID(ZTOI(zp)->i_gid);
|
lr->lr_gid = (uint64_t)KGID_TO_SGID(ZTOGID(zp));
|
||||||
} else {
|
} else {
|
||||||
lr->lr_gid = fuidp->z_fuid_group;
|
lr->lr_gid = fuidp->z_fuid_group;
|
||||||
}
|
}
|
||||||
|
@ -460,8 +460,8 @@ zfs_log_symlink(zilog_t *zilog, dmu_tx_t *tx, uint64_t txtype,
|
||||||
lr = (lr_create_t *)&itx->itx_lr;
|
lr = (lr_create_t *)&itx->itx_lr;
|
||||||
lr->lr_doid = dzp->z_id;
|
lr->lr_doid = dzp->z_id;
|
||||||
lr->lr_foid = zp->z_id;
|
lr->lr_foid = zp->z_id;
|
||||||
lr->lr_uid = KUID_TO_SUID(ZTOI(zp)->i_uid);
|
lr->lr_uid = KUID_TO_SUID(ZTOUID(zp));
|
||||||
lr->lr_gid = KGID_TO_SGID(ZTOI(zp)->i_gid);
|
lr->lr_gid = KGID_TO_SGID(ZTOGID(zp));
|
||||||
lr->lr_mode = zp->z_mode;
|
lr->lr_mode = zp->z_mode;
|
||||||
(void) sa_lookup(zp->z_sa_hdl, SA_ZPL_GEN(ZTOZSB(zp)), &lr->lr_gen,
|
(void) sa_lookup(zp->z_sa_hdl, SA_ZPL_GEN(ZTOZSB(zp)), &lr->lr_gen,
|
||||||
sizeof (uint64_t));
|
sizeof (uint64_t));
|
||||||
|
|
|
@ -300,7 +300,7 @@ zfs_sa_upgrade(sa_handle_t *hdl, dmu_tx_t *tx)
|
||||||
* and ready the ACL would require special "locked"
|
* and ready the ACL would require special "locked"
|
||||||
* interfaces that would be messy
|
* interfaces that would be messy
|
||||||
*/
|
*/
|
||||||
if (zp->z_acl_cached == NULL || S_ISLNK(ZTOI(zp)->i_mode))
|
if (zp->z_acl_cached == NULL || Z_ISLNK(ZTOTYPE(zp)))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -369,13 +369,13 @@ zfs_sa_upgrade(sa_handle_t *hdl, dmu_tx_t *tx)
|
||||||
&ctime, 16);
|
&ctime, 16);
|
||||||
SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_CRTIME(zfsvfs), NULL,
|
SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_CRTIME(zfsvfs), NULL,
|
||||||
&crtime, 16);
|
&crtime, 16);
|
||||||
links = ZTOI(zp)->i_nlink;
|
links = ZTONLNK(zp);
|
||||||
SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_LINKS(zfsvfs), NULL,
|
SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_LINKS(zfsvfs), NULL,
|
||||||
&links, 8);
|
&links, 8);
|
||||||
if (dmu_objset_projectquota_enabled(hdl->sa_os))
|
if (dmu_objset_projectquota_enabled(hdl->sa_os))
|
||||||
SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_PROJID(zfsvfs), NULL,
|
SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_PROJID(zfsvfs), NULL,
|
||||||
&zp->z_projid, 8);
|
&zp->z_projid, 8);
|
||||||
if (S_ISBLK(ZTOI(zp)->i_mode) || S_ISCHR(ZTOI(zp)->i_mode))
|
if (Z_ISBLK(ZTOTYPE(zp)) || Z_ISCHR(ZTOTYPE(zp)))
|
||||||
SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_RDEV(zfsvfs), NULL,
|
SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_RDEV(zfsvfs), NULL,
|
||||||
&rdev, 8);
|
&rdev, 8);
|
||||||
SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_DACL_COUNT(zfsvfs), NULL,
|
SA_ADD_BULK_ATTR(sa_attrs, count, SA_ZPL_DACL_COUNT(zfsvfs), NULL,
|
||||||
|
|
Loading…
Reference in New Issue