]> err.no Git - linux-2.6/blobdiff - fs/xfs/xfs_vnodeops.c
[PATCH] blk: Use blk_queue_xxx functions to set parameters
[linux-2.6] / fs / xfs / xfs_vnodeops.c
index 695978b2749715f4f11c911bc3468855ddad79cf..1377c868f3f4929aec4106f187b01c03f480c433 100644 (file)
@@ -507,8 +507,6 @@ xfs_setattr(
                 * that the group ID supplied to the chown() function
                 * shall be equal to either the group ID or one of the
                 * supplementary group IDs of the calling process.
-                *
-                * XXX: How does restricted_chown affect projid?
                 */
                if (restricted_chown &&
                    (iuid != uid || (igid != gid &&
@@ -860,6 +858,8 @@ xfs_setattr(
                                di_flags |= XFS_DIFLAG_NOATIME;
                        if (vap->va_xflags & XFS_XFLAG_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 (vap->va_xflags & XFS_XFLAG_RTINHERIT)
                                        di_flags |= XFS_DIFLAG_RTINHERIT;
@@ -1915,7 +1915,9 @@ xfs_create(
        /* Return through std_return after this point. */
 
        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;
        else
                prid = (xfs_prid_t)dfltprid;
@@ -2621,17 +2623,7 @@ xfs_link(
        if (src_vp->v_type == VDIR)
                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);
-       if (src_bdp == NULL) {
-               return XFS_ERROR(EXDEV);
-       }
        sip = XFS_BHVTOI(src_bdp);
        tdp = XFS_BHVTOI(target_dir_bdp);
        mp = tdp->i_mount;
@@ -2698,6 +2690,17 @@ xfs_link(
                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 &&
            (error = XFS_DIR_CANENTER(mp, tp, tdp, target_name,
                        target_namelen)))
@@ -2820,7 +2823,9 @@ xfs_mkdir(
 
        mp = dp->i_mount;
        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;
        else
                prid = (xfs_prid_t)dfltprid;
@@ -3374,7 +3379,9 @@ xfs_symlink(
        /* Return through std_return after this point. */
 
        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;
        else
                prid = (xfs_prid_t)dfltprid;
@@ -4168,9 +4175,8 @@ retry:
                        break;
                }
                xfs_ilock(ip, XFS_ILOCK_EXCL);
-               error = XFS_TRANS_RESERVE_QUOTA_BYDQUOTS(mp, tp,
-                               ip->i_udquot, ip->i_gdquot, resblks, 0, rt ?
-                               XFS_QMOPT_RES_RTBLKS : XFS_QMOPT_RES_REGBLKS);
+               error = XFS_TRANS_RESERVE_QUOTA(mp, tp,
+                               ip->i_udquot, ip->i_gdquot, resblks, 0, 0);
                if (error)
                        goto error1;
 
@@ -4322,6 +4328,7 @@ xfs_free_file_space(
        xfs_off_t               len,
        int                     attr_flags)
 {
+       vnode_t                 *vp;
        int                     committed;
        int                     done;
        xfs_off_t               end_dmi_offset;
@@ -4342,9 +4349,11 @@ xfs_free_file_space(
        xfs_trans_t             *tp;
        int                     need_iolock = 1;
 
-       vn_trace_entry(XFS_ITOV(ip), __FUNCTION__, (inst_t *)__return_address);
+       vp = XFS_ITOV(ip);
        mp = ip->i_mount;
 
+       vn_trace_entry(vp, __FUNCTION__, (inst_t *)__return_address);
+
        if ((error = XFS_QM_DQATTACH(mp, ip, 0)))
                return error;
 
@@ -4361,7 +4370,7 @@ xfs_free_file_space(
            DM_EVENT_ENABLED(XFS_MTOVFS(mp), ip, DM_EVENT_WRITE)) {
                if (end_dmi_offset > ip->i_d.di_size)
                        end_dmi_offset = ip->i_d.di_size;
-               error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, XFS_ITOV(ip),
+               error = XFS_SEND_DATA(mp, DM_EVENT_WRITE, vp,
                                offset, end_dmi_offset - offset,
                                AT_DELAY_FLAG(attr_flags), NULL);
                if (error)
@@ -4380,7 +4389,14 @@ xfs_free_file_space(
        ioffset = offset & ~(rounding - 1);
        if (ilen & (rounding - 1))
                ilen = (ilen + rounding) & ~(rounding - 1);
-       xfs_inval_cached_pages(XFS_ITOV(ip), &(ip->i_iocore), ioffset, 0, 0);
+
+       if (VN_CACHED(vp) != 0) {
+               xfs_inval_cached_trace(&ip->i_iocore, ioffset, -1,
+                               ctooff(offtoct(ioffset)), -1);
+               VOP_FLUSHINVAL_PAGES(vp, ctooff(offtoct(ioffset)),
+                               -1, FI_REMAPF_LOCKED);
+       }
+
        /*
         * Need to zero the stuff we're not freeing, on disk.
         * If its a realtime file & can't use unwritten extents then we