Commit 365ca83d authored by Nathan Scott's avatar Nathan Scott

[XFS] Add support for project quota inheritance, a merge of Glens changes.

SGI-PV: 932952
SGI-Modid: xfs-linux:xfs-kern:22806a
Signed-off-by: default avatarNathan Scott <nathans@sgi.com>
parent c8ad20ff
...@@ -1202,26 +1202,32 @@ xfs_ialloc( ...@@ -1202,26 +1202,32 @@ xfs_ialloc(
case S_IFREG: case S_IFREG:
case S_IFDIR: case S_IFDIR:
if (unlikely(pip->i_d.di_flags & XFS_DIFLAG_ANY)) { if (unlikely(pip->i_d.di_flags & XFS_DIFLAG_ANY)) {
if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT) { uint di_flags = 0;
if ((mode & S_IFMT) == S_IFDIR) {
ip->i_d.di_flags |= XFS_DIFLAG_RTINHERIT; if ((mode & S_IFMT) == S_IFDIR) {
} else { if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT)
ip->i_d.di_flags |= XFS_DIFLAG_REALTIME; di_flags |= XFS_DIFLAG_RTINHERIT;
} else {
if (pip->i_d.di_flags & XFS_DIFLAG_RTINHERIT) {
di_flags |= XFS_DIFLAG_REALTIME;
ip->i_iocore.io_flags |= XFS_IOCORE_RT; ip->i_iocore.io_flags |= XFS_IOCORE_RT;
} }
} }
if ((pip->i_d.di_flags & XFS_DIFLAG_NOATIME) && if ((pip->i_d.di_flags & XFS_DIFLAG_NOATIME) &&
xfs_inherit_noatime) xfs_inherit_noatime)
ip->i_d.di_flags |= XFS_DIFLAG_NOATIME; di_flags |= XFS_DIFLAG_NOATIME;
if ((pip->i_d.di_flags & XFS_DIFLAG_NODUMP) && if ((pip->i_d.di_flags & XFS_DIFLAG_NODUMP) &&
xfs_inherit_nodump) xfs_inherit_nodump)
ip->i_d.di_flags |= XFS_DIFLAG_NODUMP; di_flags |= XFS_DIFLAG_NODUMP;
if ((pip->i_d.di_flags & XFS_DIFLAG_SYNC) && if ((pip->i_d.di_flags & XFS_DIFLAG_SYNC) &&
xfs_inherit_sync) xfs_inherit_sync)
ip->i_d.di_flags |= XFS_DIFLAG_SYNC; di_flags |= XFS_DIFLAG_SYNC;
if ((pip->i_d.di_flags & XFS_DIFLAG_NOSYMLINKS) && if ((pip->i_d.di_flags & XFS_DIFLAG_NOSYMLINKS) &&
xfs_inherit_nosymlinks) xfs_inherit_nosymlinks)
ip->i_d.di_flags |= XFS_DIFLAG_NOSYMLINKS; di_flags |= XFS_DIFLAG_NOSYMLINKS;
if (pip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
di_flags |= XFS_DIFLAG_PROJINHERIT;
ip->i_d.di_flags |= di_flags;
} }
/* FALLTHROUGH */ /* FALLTHROUGH */
case S_IFLNK: case S_IFLNK:
......
...@@ -507,8 +507,6 @@ xfs_setattr( ...@@ -507,8 +507,6 @@ xfs_setattr(
* that the group ID supplied to the chown() function * that the group ID supplied to the chown() function
* shall be equal to either the group ID or one of the * shall be equal to either the group ID or one of the
* supplementary group IDs of the calling process. * supplementary group IDs of the calling process.
*
* XXX: How does restricted_chown affect projid?
*/ */
if (restricted_chown && if (restricted_chown &&
(iuid != uid || (igid != gid && (iuid != uid || (igid != gid &&
...@@ -860,6 +858,8 @@ xfs_setattr( ...@@ -860,6 +858,8 @@ xfs_setattr(
di_flags |= XFS_DIFLAG_NOATIME; di_flags |= XFS_DIFLAG_NOATIME;
if (vap->va_xflags & XFS_XFLAG_NODUMP) if (vap->va_xflags & XFS_XFLAG_NODUMP)
di_flags |= XFS_DIFLAG_NODUMP; di_flags |= XFS_DIFLAG_NODUMP;
if (vap->va_xflags & XFS_XFLAG_PROJINHERIT)
di_flags |= XFS_DIFLAG_PROJINHERIT;
if ((ip->i_d.di_mode & S_IFMT) == S_IFDIR) { if ((ip->i_d.di_mode & S_IFMT) == S_IFDIR) {
if (vap->va_xflags & XFS_XFLAG_RTINHERIT) if (vap->va_xflags & XFS_XFLAG_RTINHERIT)
di_flags |= XFS_DIFLAG_RTINHERIT; di_flags |= XFS_DIFLAG_RTINHERIT;
...@@ -1915,7 +1915,9 @@ xfs_create( ...@@ -1915,7 +1915,9 @@ xfs_create(
/* Return through std_return after this point. */ /* Return through std_return after this point. */
udqp = gdqp = NULL; udqp = gdqp = NULL;
if (vap->va_mask & XFS_AT_PROJID) if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
prid = dp->i_d.di_projid;
else if (vap->va_mask & XFS_AT_PROJID)
prid = (xfs_prid_t)vap->va_projid; prid = (xfs_prid_t)vap->va_projid;
else else
prid = (xfs_prid_t)dfltprid; prid = (xfs_prid_t)dfltprid;
...@@ -2621,17 +2623,7 @@ xfs_link( ...@@ -2621,17 +2623,7 @@ xfs_link(
if (src_vp->v_type == VDIR) if (src_vp->v_type == VDIR)
return XFS_ERROR(EPERM); return XFS_ERROR(EPERM);
/*
* For now, manually find the XFS behavior descriptor for
* the source vnode. If it doesn't exist then something
* is wrong and we should just return an error.
* Eventually we need to figure out how link is going to
* work in the face of stacked vnodes.
*/
src_bdp = vn_bhv_lookup_unlocked(VN_BHV_HEAD(src_vp), &xfs_vnodeops); src_bdp = vn_bhv_lookup_unlocked(VN_BHV_HEAD(src_vp), &xfs_vnodeops);
if (src_bdp == NULL) {
return XFS_ERROR(EXDEV);
}
sip = XFS_BHVTOI(src_bdp); sip = XFS_BHVTOI(src_bdp);
tdp = XFS_BHVTOI(target_dir_bdp); tdp = XFS_BHVTOI(target_dir_bdp);
mp = tdp->i_mount; mp = tdp->i_mount;
...@@ -2698,6 +2690,17 @@ xfs_link( ...@@ -2698,6 +2690,17 @@ xfs_link(
goto error_return; goto error_return;
} }
/*
* If we are using project inheritance, we only allow hard link
* creation in our tree when the project IDs are the same; else
* the tree quota mechanism could be circumvented.
*/
if (unlikely((tdp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT) &&
(tdp->i_d.di_projid != sip->i_d.di_projid))) {
error = XFS_ERROR(EPERM);
goto error_return;
}
if (resblks == 0 && if (resblks == 0 &&
(error = XFS_DIR_CANENTER(mp, tp, tdp, target_name, (error = XFS_DIR_CANENTER(mp, tp, tdp, target_name,
target_namelen))) target_namelen)))
...@@ -2820,7 +2823,9 @@ xfs_mkdir( ...@@ -2820,7 +2823,9 @@ xfs_mkdir(
mp = dp->i_mount; mp = dp->i_mount;
udqp = gdqp = NULL; udqp = gdqp = NULL;
if (vap->va_mask & XFS_AT_PROJID) if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
prid = dp->i_d.di_projid;
else if (vap->va_mask & XFS_AT_PROJID)
prid = (xfs_prid_t)vap->va_projid; prid = (xfs_prid_t)vap->va_projid;
else else
prid = (xfs_prid_t)dfltprid; prid = (xfs_prid_t)dfltprid;
...@@ -3374,7 +3379,9 @@ xfs_symlink( ...@@ -3374,7 +3379,9 @@ xfs_symlink(
/* Return through std_return after this point. */ /* Return through std_return after this point. */
udqp = gdqp = NULL; udqp = gdqp = NULL;
if (vap->va_mask & XFS_AT_PROJID) if (dp->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
prid = dp->i_d.di_projid;
else if (vap->va_mask & XFS_AT_PROJID)
prid = (xfs_prid_t)vap->va_projid; prid = (xfs_prid_t)vap->va_projid;
else else
prid = (xfs_prid_t)dfltprid; prid = (xfs_prid_t)dfltprid;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment