提交 7aab1b28 编写于 作者: D Dwight Engen 提交者: Ben Myers

xfs: convert kuid_t to/from uid_t for internal structures

Use uint32 from init_user_ns for xfs internal uid/gid
representation in xfs_icdinode, xfs_dqid_t.
Reviewed-by: NDave Chinner <dchinner@redhat.com>
Reviewed-by: NGao feng <gaofeng@cn.fujitsu.com>
Signed-off-by: NDwight Engen <dwight.engen@oracle.com>
Signed-off-by: NBen Myers <bpm@sgi.com>
上级 fd5e2aa8
...@@ -690,8 +690,8 @@ xfs_ialloc( ...@@ -690,8 +690,8 @@ xfs_ialloc(
ip->i_d.di_onlink = 0; ip->i_d.di_onlink = 0;
ip->i_d.di_nlink = nlink; ip->i_d.di_nlink = nlink;
ASSERT(ip->i_d.di_nlink == nlink); ASSERT(ip->i_d.di_nlink == nlink);
ip->i_d.di_uid = current_fsuid(); ip->i_d.di_uid = xfs_kuid_to_uid(current_fsuid());
ip->i_d.di_gid = current_fsgid(); ip->i_d.di_gid = xfs_kgid_to_gid(current_fsgid());
xfs_set_projid(ip, prid); xfs_set_projid(ip, prid);
memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad)); memset(&(ip->i_d.di_pad[0]), 0, sizeof(ip->i_d.di_pad));
...@@ -730,7 +730,7 @@ xfs_ialloc( ...@@ -730,7 +730,7 @@ xfs_ialloc(
*/ */
if ((irix_sgid_inherit) && if ((irix_sgid_inherit) &&
(ip->i_d.di_mode & S_ISGID) && (ip->i_d.di_mode & S_ISGID) &&
(!in_group_p((gid_t)ip->i_d.di_gid))) { (!in_group_p(xfs_gid_to_kgid(ip->i_d.di_gid)))) {
ip->i_d.di_mode &= ~S_ISGID; ip->i_d.di_mode &= ~S_ISGID;
} }
...@@ -1178,7 +1178,8 @@ xfs_create( ...@@ -1178,7 +1178,8 @@ xfs_create(
/* /*
* Make sure that we have allocated dquot(s) on disk. * Make sure that we have allocated dquot(s) on disk.
*/ */
error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid, error = xfs_qm_vop_dqalloc(dp, xfs_kuid_to_uid(current_fsuid()),
xfs_kgid_to_gid(current_fsgid()), prid,
XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT,
&udqp, &gdqp, &pdqp); &udqp, &gdqp, &pdqp);
if (error) if (error)
......
...@@ -421,8 +421,8 @@ xfs_vn_getattr( ...@@ -421,8 +421,8 @@ xfs_vn_getattr(
stat->dev = inode->i_sb->s_dev; stat->dev = inode->i_sb->s_dev;
stat->mode = ip->i_d.di_mode; stat->mode = ip->i_d.di_mode;
stat->nlink = ip->i_d.di_nlink; stat->nlink = ip->i_d.di_nlink;
stat->uid = ip->i_d.di_uid; stat->uid = inode->i_uid;
stat->gid = ip->i_d.di_gid; stat->gid = inode->i_gid;
stat->ino = ip->i_ino; stat->ino = ip->i_ino;
stat->atime = inode->i_atime; stat->atime = inode->i_atime;
stat->mtime = inode->i_mtime; stat->mtime = inode->i_mtime;
...@@ -486,8 +486,8 @@ xfs_setattr_nonsize( ...@@ -486,8 +486,8 @@ xfs_setattr_nonsize(
int mask = iattr->ia_valid; int mask = iattr->ia_valid;
xfs_trans_t *tp; xfs_trans_t *tp;
int error; int error;
uid_t uid = 0, iuid = 0; kuid_t uid = GLOBAL_ROOT_UID, iuid = GLOBAL_ROOT_UID;
gid_t gid = 0, igid = 0; kgid_t gid = GLOBAL_ROOT_GID, igid = GLOBAL_ROOT_GID;
struct xfs_dquot *udqp = NULL, *gdqp = NULL; struct xfs_dquot *udqp = NULL, *gdqp = NULL;
struct xfs_dquot *olddquot1 = NULL, *olddquot2 = NULL; struct xfs_dquot *olddquot1 = NULL, *olddquot2 = NULL;
...@@ -523,13 +523,13 @@ xfs_setattr_nonsize( ...@@ -523,13 +523,13 @@ xfs_setattr_nonsize(
uid = iattr->ia_uid; uid = iattr->ia_uid;
qflags |= XFS_QMOPT_UQUOTA; qflags |= XFS_QMOPT_UQUOTA;
} else { } else {
uid = ip->i_d.di_uid; uid = inode->i_uid;
} }
if ((mask & ATTR_GID) && XFS_IS_GQUOTA_ON(mp)) { if ((mask & ATTR_GID) && XFS_IS_GQUOTA_ON(mp)) {
gid = iattr->ia_gid; gid = iattr->ia_gid;
qflags |= XFS_QMOPT_GQUOTA; qflags |= XFS_QMOPT_GQUOTA;
} else { } else {
gid = ip->i_d.di_gid; gid = inode->i_gid;
} }
/* /*
...@@ -539,8 +539,10 @@ xfs_setattr_nonsize( ...@@ -539,8 +539,10 @@ xfs_setattr_nonsize(
*/ */
ASSERT(udqp == NULL); ASSERT(udqp == NULL);
ASSERT(gdqp == NULL); ASSERT(gdqp == NULL);
error = xfs_qm_vop_dqalloc(ip, uid, gid, xfs_get_projid(ip), error = xfs_qm_vop_dqalloc(ip, xfs_kuid_to_uid(uid),
qflags, &udqp, &gdqp, NULL); xfs_kgid_to_gid(gid),
xfs_get_projid(ip),
qflags, &udqp, &gdqp, NULL);
if (error) if (error)
return error; return error;
} }
...@@ -562,8 +564,8 @@ xfs_setattr_nonsize( ...@@ -562,8 +564,8 @@ xfs_setattr_nonsize(
* while we didn't have the inode locked, inode's dquot(s) * while we didn't have the inode locked, inode's dquot(s)
* would have changed also. * would have changed also.
*/ */
iuid = ip->i_d.di_uid; iuid = inode->i_uid;
igid = ip->i_d.di_gid; igid = inode->i_gid;
gid = (mask & ATTR_GID) ? iattr->ia_gid : igid; gid = (mask & ATTR_GID) ? iattr->ia_gid : igid;
uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid; uid = (mask & ATTR_UID) ? iattr->ia_uid : iuid;
...@@ -572,8 +574,8 @@ xfs_setattr_nonsize( ...@@ -572,8 +574,8 @@ xfs_setattr_nonsize(
* going to change. * going to change.
*/ */
if (XFS_IS_QUOTA_RUNNING(mp) && if (XFS_IS_QUOTA_RUNNING(mp) &&
((XFS_IS_UQUOTA_ON(mp) && iuid != uid) || ((XFS_IS_UQUOTA_ON(mp) && !uid_eq(iuid, uid)) ||
(XFS_IS_GQUOTA_ON(mp) && igid != gid))) { (XFS_IS_GQUOTA_ON(mp) && !gid_eq(igid, gid)))) {
ASSERT(tp); ASSERT(tp);
error = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp, error = xfs_qm_vop_chown_reserve(tp, ip, udqp, gdqp,
NULL, capable(CAP_FOWNER) ? NULL, capable(CAP_FOWNER) ?
...@@ -603,17 +605,17 @@ xfs_setattr_nonsize( ...@@ -603,17 +605,17 @@ xfs_setattr_nonsize(
* Change the ownerships and register quota modifications * Change the ownerships and register quota modifications
* in the transaction. * in the transaction.
*/ */
if (iuid != uid) { if (!uid_eq(iuid, uid)) {
if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) { if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_UQUOTA_ON(mp)) {
ASSERT(mask & ATTR_UID); ASSERT(mask & ATTR_UID);
ASSERT(udqp); ASSERT(udqp);
olddquot1 = xfs_qm_vop_chown(tp, ip, olddquot1 = xfs_qm_vop_chown(tp, ip,
&ip->i_udquot, udqp); &ip->i_udquot, udqp);
} }
ip->i_d.di_uid = uid; ip->i_d.di_uid = xfs_kuid_to_uid(uid);
inode->i_uid = uid; inode->i_uid = uid;
} }
if (igid != gid) { if (!gid_eq(igid, gid)) {
if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_GQUOTA_ON(mp)) { if (XFS_IS_QUOTA_RUNNING(mp) && XFS_IS_GQUOTA_ON(mp)) {
ASSERT(!XFS_IS_PQUOTA_ON(mp)); ASSERT(!XFS_IS_PQUOTA_ON(mp));
ASSERT(mask & ATTR_GID); ASSERT(mask & ATTR_GID);
...@@ -621,7 +623,7 @@ xfs_setattr_nonsize( ...@@ -621,7 +623,7 @@ xfs_setattr_nonsize(
olddquot2 = xfs_qm_vop_chown(tp, ip, olddquot2 = xfs_qm_vop_chown(tp, ip,
&ip->i_gdquot, gdqp); &ip->i_gdquot, gdqp);
} }
ip->i_d.di_gid = gid; ip->i_d.di_gid = xfs_kgid_to_gid(gid);
inode->i_gid = gid; inode->i_gid = gid;
} }
} }
...@@ -1172,8 +1174,8 @@ xfs_setup_inode( ...@@ -1172,8 +1174,8 @@ xfs_setup_inode(
inode->i_mode = ip->i_d.di_mode; inode->i_mode = ip->i_d.di_mode;
set_nlink(inode, ip->i_d.di_nlink); set_nlink(inode, ip->i_d.di_nlink);
inode->i_uid = ip->i_d.di_uid; inode->i_uid = xfs_uid_to_kuid(ip->i_d.di_uid);
inode->i_gid = ip->i_d.di_gid; inode->i_gid = xfs_gid_to_kgid(ip->i_d.di_gid);
switch (inode->i_mode & S_IFMT) { switch (inode->i_mode & S_IFMT) {
case S_IFBLK: case S_IFBLK:
......
...@@ -1767,8 +1767,8 @@ xfs_qm_write_sb_changes( ...@@ -1767,8 +1767,8 @@ xfs_qm_write_sb_changes(
int int
xfs_qm_vop_dqalloc( xfs_qm_vop_dqalloc(
struct xfs_inode *ip, struct xfs_inode *ip,
uid_t uid, xfs_dqid_t uid,
gid_t gid, xfs_dqid_t gid,
prid_t prid, prid_t prid,
uint flags, uint flags,
struct xfs_dquot **O_udqpp, struct xfs_dquot **O_udqpp,
...@@ -1815,7 +1815,7 @@ xfs_qm_vop_dqalloc( ...@@ -1815,7 +1815,7 @@ xfs_qm_vop_dqalloc(
* holding ilock. * holding ilock.
*/ */
xfs_iunlock(ip, lockflags); xfs_iunlock(ip, lockflags);
error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t) uid, error = xfs_qm_dqget(mp, NULL, uid,
XFS_DQ_USER, XFS_DQ_USER,
XFS_QMOPT_DQALLOC | XFS_QMOPT_DQALLOC |
XFS_QMOPT_DOWARN, XFS_QMOPT_DOWARN,
...@@ -1842,7 +1842,7 @@ xfs_qm_vop_dqalloc( ...@@ -1842,7 +1842,7 @@ xfs_qm_vop_dqalloc(
if ((flags & XFS_QMOPT_GQUOTA) && XFS_IS_GQUOTA_ON(mp)) { if ((flags & XFS_QMOPT_GQUOTA) && XFS_IS_GQUOTA_ON(mp)) {
if (ip->i_d.di_gid != gid) { if (ip->i_d.di_gid != gid) {
xfs_iunlock(ip, lockflags); xfs_iunlock(ip, lockflags);
error = xfs_qm_dqget(mp, NULL, (xfs_dqid_t)gid, error = xfs_qm_dqget(mp, NULL, gid,
XFS_DQ_GROUP, XFS_DQ_GROUP,
XFS_QMOPT_DQALLOC | XFS_QMOPT_DQALLOC |
XFS_QMOPT_DOWARN, XFS_QMOPT_DOWARN,
...@@ -1976,7 +1976,7 @@ xfs_qm_vop_chown_reserve( ...@@ -1976,7 +1976,7 @@ xfs_qm_vop_chown_reserve(
XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS; XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS;
if (XFS_IS_UQUOTA_ON(mp) && udqp && if (XFS_IS_UQUOTA_ON(mp) && udqp &&
ip->i_d.di_uid != (uid_t)be32_to_cpu(udqp->q_core.d_id)) { ip->i_d.di_uid != be32_to_cpu(udqp->q_core.d_id)) {
udq_delblks = udqp; udq_delblks = udqp;
/* /*
* If there are delayed allocation blocks, then we have to * If there are delayed allocation blocks, then we have to
......
...@@ -87,8 +87,9 @@ extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *, ...@@ -87,8 +87,9 @@ extern int xfs_trans_reserve_quota_bydquots(struct xfs_trans *,
struct xfs_mount *, struct xfs_dquot *, struct xfs_mount *, struct xfs_dquot *,
struct xfs_dquot *, struct xfs_dquot *, long, long, uint); struct xfs_dquot *, struct xfs_dquot *, long, long, uint);
extern int xfs_qm_vop_dqalloc(struct xfs_inode *, uid_t, gid_t, prid_t, uint, extern int xfs_qm_vop_dqalloc(struct xfs_inode *, xfs_dqid_t, xfs_dqid_t,
struct xfs_dquot **, struct xfs_dquot **, struct xfs_dquot **); prid_t, uint, struct xfs_dquot **, struct xfs_dquot **,
struct xfs_dquot **);
extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *, extern void xfs_qm_vop_create_dqattach(struct xfs_trans *, struct xfs_inode *,
struct xfs_dquot *, struct xfs_dquot *, struct xfs_dquot *); struct xfs_dquot *, struct xfs_dquot *, struct xfs_dquot *);
extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **); extern int xfs_qm_vop_rename_dqattach(struct xfs_inode **);
...@@ -109,9 +110,9 @@ extern void xfs_qm_unmount_quotas(struct xfs_mount *); ...@@ -109,9 +110,9 @@ extern void xfs_qm_unmount_quotas(struct xfs_mount *);
#else #else
static inline int static inline int
xfs_qm_vop_dqalloc(struct xfs_inode *ip, uid_t uid, gid_t gid, prid_t prid, xfs_qm_vop_dqalloc(struct xfs_inode *ip, xfs_dqid_t uid, xfs_dqid_t gid,
uint flags, struct xfs_dquot **udqp, struct xfs_dquot **gdqp, prid_t prid, uint flags, struct xfs_dquot **udqp,
struct xfs_dquot **pdqp) struct xfs_dquot **gdqp, struct xfs_dquot **pdqp)
{ {
*udqp = NULL; *udqp = NULL;
*gdqp = NULL; *gdqp = NULL;
......
...@@ -215,8 +215,11 @@ xfs_symlink( ...@@ -215,8 +215,11 @@ xfs_symlink(
/* /*
* Make sure that we have allocated dquot(s) on disk. * Make sure that we have allocated dquot(s) on disk.
*/ */
error = xfs_qm_vop_dqalloc(dp, current_fsuid(), current_fsgid(), prid, error = xfs_qm_vop_dqalloc(dp,
XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp, &pdqp); xfs_kuid_to_uid(current_fsuid()),
xfs_kgid_to_gid(current_fsgid()), prid,
XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT,
&udqp, &gdqp, &pdqp);
if (error) if (error)
goto std_return; goto std_return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册