use xfs_trans_ijoin in xfs_trans_iget
[safe/jmp/linux-2.6] / fs / xfs / xfs_vnodeops.c
index c5dc7ea..b29a0eb 100644 (file)
 #include "xfs_vnodeops.h"
 
 int
-xfs_open(
-       xfs_inode_t     *ip)
-{
-       int             mode;
-
-       if (XFS_FORCED_SHUTDOWN(ip->i_mount))
-               return XFS_ERROR(EIO);
-
-       /*
-        * If it's a directory with any blocks, read-ahead block 0
-        * as we're almost certain to have the next operation be a read there.
-        */
-       if (S_ISDIR(ip->i_d.di_mode) && ip->i_d.di_nextents > 0) {
-               mode = xfs_ilock_map_shared(ip);
-               if (ip->i_d.di_nextents > 0)
-                       (void)xfs_da_reada_buf(NULL, ip, 0, XFS_DATA_FORK);
-               xfs_iunlock(ip, mode);
-       }
-       return 0;
-}
-
-int
 xfs_setattr(
        struct xfs_inode        *ip,
        struct iattr            *iattr,
-       int                     flags,
-       cred_t                  *credp)
+       int                     flags)
 {
        xfs_mount_t             *mp = ip->i_mount;
        struct inode            *inode = VFS_I(ip);
@@ -182,7 +159,7 @@ xfs_setattr(
        xfs_ilock(ip, lock_flags);
 
        /* boolean: are we the file owner? */
-       file_owner = (current_fsuid(credp) == ip->i_d.di_uid);
+       file_owner = (current_fsuid() == ip->i_d.di_uid);
 
        /*
         * Change various properties of a file.
@@ -233,10 +210,6 @@ xfs_setattr(
 
        /*
         * Change file ownership.  Must be the owner or privileged.
-        * If the system was configured with the "restricted_chown"
-        * option, the owner is not permitted to give away the file,
-        * and can change the group id only to a group of which he
-        * or she is a member.
         */
        if (mask & (ATTR_UID|ATTR_GID)) {
                /*
@@ -260,9 +233,8 @@ xfs_setattr(
                 * shall be equal to either the group ID or one of the
                 * supplementary group IDs of the calling process.
                 */
-               if (restricted_chown &&
-                   (iuid != uid || (igid != gid &&
-                                    !in_group_p((gid_t)gid))) &&
+               if ((iuid != uid ||
+                    (igid != gid && !in_group_p((gid_t)gid))) &&
                    !capable(CAP_CHOWN)) {
                        code = XFS_ERROR(EPERM);
                        goto error_return;
@@ -456,10 +428,6 @@ xfs_setattr(
 
        /*
         * Change file ownership.  Must be the owner or privileged.
-        * If the system was configured with the "restricted_chown"
-        * option, the owner is not permitted to give away the file,
-        * and can change the group id only to a group of which he
-        * or she is a member.
         */
        if (mask & (ATTR_UID|ATTR_GID)) {
                /*
@@ -513,7 +481,6 @@ xfs_setattr(
                        ip->i_d.di_atime.t_sec = iattr->ia_atime.tv_sec;
                        ip->i_d.di_atime.t_nsec = iattr->ia_atime.tv_nsec;
                        ip->i_update_core = 1;
-                       timeflags &= ~XFS_ICHGTIME_ACC;
                }
                if (mask & ATTR_MTIME) {
                        inode->i_mtime = iattr->ia_mtime;
@@ -714,7 +681,7 @@ xfs_fsync(
                return XFS_ERROR(EIO);
 
        /* capture size updates in I/O completion before writing the inode. */
-       error = filemap_fdatawait(VFS_I(ip)->i_mapping);
+       error = xfs_wait_on_pages(ip, 0, -1);
        if (error)
                return XFS_ERROR(error);
 
@@ -1030,6 +997,12 @@ xfs_inactive_symlink_rmt(
                goto error0;
        }
        /*
+        * transaction commit worked ok so we can drop the extra ticket
+        * reference that we gained in xfs_trans_dup()
+        */
+       xfs_log_ticket_put(tp->t_ticket);
+
+       /*
         * Remove the memory for extent descriptions (just bookkeeping).
         */
        if (ip->i_df.if_bytes)
@@ -1160,7 +1133,6 @@ int
 xfs_release(
        xfs_inode_t     *ip)
 {
-       bhv_vnode_t     *vp = VFS_I(ip);
        xfs_mount_t     *mp = ip->i_mount;
        int             error;
 
@@ -1195,13 +1167,13 @@ xfs_release(
                 * be exposed to that problem.
                 */
                truncated = xfs_iflags_test_and_clear(ip, XFS_ITRUNCATED);
-               if (truncated && VN_DIRTY(vp) && ip->i_delayed_blks > 0)
+               if (truncated && VN_DIRTY(VFS_I(ip)) && ip->i_delayed_blks > 0)
                        xfs_flush_pages(ip, 0, -1, XFS_B_ASYNC, FI_NONE);
        }
 
        if (ip->i_d.di_nlink != 0) {
                if ((((ip->i_d.di_mode & S_IFMT) == S_IFREG) &&
-                    ((ip->i_size > 0) || (VN_CACHED(vp) > 0 ||
+                    ((ip->i_size > 0) || (VN_CACHED(VFS_I(ip)) > 0 ||
                       ip->i_delayed_blks > 0)) &&
                     (ip->i_df.if_flags & XFS_IFEXTENTS))  &&
                    (!(ip->i_d.di_flags &
@@ -1227,7 +1199,6 @@ int
 xfs_inactive(
        xfs_inode_t     *ip)
 {
-       bhv_vnode_t     *vp = VFS_I(ip);
        xfs_bmap_free_t free_list;
        xfs_fsblock_t   first_block;
        int             committed;
@@ -1242,7 +1213,7 @@ xfs_inactive(
         * If the inode is already free, then there can be nothing
         * to clean up here.
         */
-       if (ip->i_d.di_mode == 0 || VN_BAD(vp)) {
+       if (ip->i_d.di_mode == 0 || VN_BAD(VFS_I(ip))) {
                ASSERT(ip->i_df.if_real_bytes == 0);
                ASSERT(ip->i_df.if_broot_bytes == 0);
                return VN_INACTIVE_CACHE;
@@ -1272,7 +1243,7 @@ xfs_inactive(
 
        if (ip->i_d.di_nlink != 0) {
                if ((((ip->i_d.di_mode & S_IFMT) == S_IFREG) &&
-                     ((ip->i_size > 0) || (VN_CACHED(vp) > 0 ||
+                     ((ip->i_size > 0) || (VN_CACHED(VFS_I(ip)) > 0 ||
                        ip->i_delayed_blks > 0)) &&
                      (ip->i_df.if_flags & XFS_IFEXTENTS) &&
                     (!(ip->i_d.di_flags &
@@ -1536,7 +1507,7 @@ xfs_create(
         * Make sure that we have allocated dquot(s) on disk.
         */
        error = XFS_QM_DQVOPALLOC(mp, dp,
-                       current_fsuid(credp), current_fsgid(credp), prid,
+                       current_fsuid(), current_fsgid(), prid,
                        XFS_QMOPT_QUOTALL|XFS_QMOPT_INHERIT, &udqp, &gdqp);
        if (error)
                goto std_return;
@@ -1628,8 +1599,6 @@ xfs_create(
                xfs_trans_set_sync(tp);
        }
 
-       dp->i_gen++;
-
        /*
         * Attach the dquot(s) to the inodes and modify them incore.
         * These ids of the inode couldn't have changed since the new
@@ -1708,111 +1677,6 @@ std_return:
 }
 
 #ifdef DEBUG
-/*
- * Some counters to see if (and how often) we are hitting some deadlock
- * prevention code paths.
- */
-
-int xfs_rm_locks;
-int xfs_rm_lock_delays;
-int xfs_rm_attempts;
-#endif
-
-/*
- * The following routine will lock the inodes associated with the
- * directory and the named entry in the directory. The locks are
- * acquired in increasing inode number.
- *
- * If the entry is "..", then only the directory is locked. The
- * vnode ref count will still include that from the .. entry in
- * this case.
- *
- * There is a deadlock we need to worry about. If the locked directory is
- * in the AIL, it might be blocking up the log. The next inode we lock
- * could be already locked by another thread waiting for log space (e.g
- * a permanent log reservation with a long running transaction (see
- * xfs_itruncate_finish)). To solve this, we must check if the directory
- * is in the ail and use lock_nowait. If we can't lock, we need to
- * drop the inode lock on the directory and try again. xfs_iunlock will
- * potentially push the tail if we were holding up the log.
- */
-STATIC int
-xfs_lock_dir_and_entry(
-       xfs_inode_t     *dp,
-       xfs_inode_t     *ip)    /* inode of entry 'name' */
-{
-       int             attempts;
-       xfs_ino_t       e_inum;
-       xfs_inode_t     *ips[2];
-       xfs_log_item_t  *lp;
-
-#ifdef DEBUG
-       xfs_rm_locks++;
-#endif
-       attempts = 0;
-
-again:
-       xfs_ilock(dp, XFS_ILOCK_EXCL | XFS_ILOCK_PARENT);
-
-       e_inum = ip->i_ino;
-
-       xfs_itrace_ref(ip);
-
-       /*
-        * We want to lock in increasing inum. Since we've already
-        * acquired the lock on the directory, we may need to release
-        * if if the inum of the entry turns out to be less.
-        */
-       if (e_inum > dp->i_ino) {
-               /*
-                * We are already in the right order, so just
-                * lock on the inode of the entry.
-                * We need to use nowait if dp is in the AIL.
-                */
-
-               lp = (xfs_log_item_t *)dp->i_itemp;
-               if (lp && (lp->li_flags & XFS_LI_IN_AIL)) {
-                       if (!xfs_ilock_nowait(ip, XFS_ILOCK_EXCL)) {
-                               attempts++;
-#ifdef DEBUG
-                               xfs_rm_attempts++;
-#endif
-
-                               /*
-                                * Unlock dp and try again.
-                                * xfs_iunlock will try to push the tail
-                                * if the inode is in the AIL.
-                                */
-
-                               xfs_iunlock(dp, XFS_ILOCK_EXCL);
-
-                               if ((attempts % 5) == 0) {
-                                       delay(1); /* Don't just spin the CPU */
-#ifdef DEBUG
-                                       xfs_rm_lock_delays++;
-#endif
-                               }
-                               goto again;
-                       }
-               } else {
-                       xfs_ilock(ip, XFS_ILOCK_EXCL);
-               }
-       } else if (e_inum < dp->i_ino) {
-               xfs_iunlock(dp, XFS_ILOCK_EXCL);
-
-               ips[0] = ip;
-               ips[1] = dp;
-               xfs_lock_inodes(ips, 2, XFS_ILOCK_EXCL);
-       }
-       /* else  e_inum == dp->i_ino */
-       /*     This can happen if we're asked to lock /x/..
-        *     the entry is "..", which is also the parent directory.
-        */
-
-       return 0;
-}
-
-#ifdef DEBUG
 int xfs_locked_n;
 int xfs_small_retries;
 int xfs_middle_retries;
@@ -1946,6 +1810,53 @@ again:
 #endif
 }
 
+/*
+ * xfs_lock_two_inodes() can only be used to lock one type of lock
+ * at a time - the iolock or the ilock, but not both at once. If
+ * we lock both at once, lockdep will report false positives saying
+ * we have violated locking orders.
+ */
+void
+xfs_lock_two_inodes(
+       xfs_inode_t             *ip0,
+       xfs_inode_t             *ip1,
+       uint                    lock_mode)
+{
+       xfs_inode_t             *temp;
+       int                     attempts = 0;
+       xfs_log_item_t          *lp;
+
+       if (lock_mode & (XFS_IOLOCK_SHARED|XFS_IOLOCK_EXCL))
+               ASSERT((lock_mode & (XFS_ILOCK_SHARED|XFS_ILOCK_EXCL)) == 0);
+       ASSERT(ip0->i_ino != ip1->i_ino);
+
+       if (ip0->i_ino > ip1->i_ino) {
+               temp = ip0;
+               ip0 = ip1;
+               ip1 = temp;
+       }
+
+ again:
+       xfs_ilock(ip0, xfs_lock_inumorder(lock_mode, 0));
+
+       /*
+        * If the first lock we have locked is in the AIL, we must TRY to get
+        * the second lock. If we can't get it, we must release the first one
+        * and try again.
+        */
+       lp = (xfs_log_item_t *)ip0->i_itemp;
+       if (lp && (lp->li_flags & XFS_LI_IN_AIL)) {
+               if (!xfs_ilock_nowait(ip1, xfs_lock_inumorder(lock_mode, 1))) {
+                       xfs_iunlock(ip0, lock_mode);
+                       if ((++attempts % 5) == 0)
+                               delay(1); /* Don't just spin the CPU */
+                       goto again;
+               }
+       } else {
+               xfs_ilock(ip1, xfs_lock_inumorder(lock_mode, 1));
+       }
+}
+
 int
 xfs_remove(
        xfs_inode_t             *dp,
@@ -2018,9 +1929,7 @@ xfs_remove(
                goto out_trans_cancel;
        }
 
-       error = xfs_lock_dir_and_entry(dp, ip);
-       if (error)
-               goto out_trans_cancel;
+       xfs_lock_two_inodes(dp, ip, XFS_ILOCK_EXCL);
 
        /*
         * At this point, we've gotten both the directory and the entry
@@ -2047,9 +1956,6 @@ xfs_remove(
                }
        }
 
-       /*
-        * Entry must exist since we did a lookup in xfs_lock_dir_and_entry.
-        */
        XFS_BMAP_INIT(&free_list, &first_block);
        error = xfs_dir_removename(tp, dp, name, ip->i_ino,
                                        &first_block, &free_list, resblks);
@@ -2059,13 +1965,6 @@ xfs_remove(
        }
        xfs_ichgtime(dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
 
-       /*
-        * Bump the in memory generation count on the parent
-        * directory so that other can know that it has changed.
-        */
-       dp->i_gen++;
-       xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
-
        if (is_dir) {
                /*
                 * Drop the link from ip's "..".
@@ -2075,7 +1974,7 @@ xfs_remove(
                        goto out_bmap_cancel;
 
                /*
-                * Drop the link from dp to ip.
+                * Drop the "." link from ip to self.
                 */
                error = xfs_droplink(tp, ip);
                if (error)
@@ -2083,14 +1982,14 @@ xfs_remove(
        } else {
                /*
                 * When removing a non-directory we need to log the parent
-                * inode here for the i_gen update.  For a directory this is
-                * done implicitly by the xfs_droplink call for the ".." entry.
+                * inode here.  For a directory this is done implicitly
+                * by the xfs_droplink call for the ".." entry.
                 */
                xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
        }
 
        /*
-        * Drop the "." link from ip to self.
+        * Drop the link from dp to ip.
         */
        error = xfs_droplink(tp, ip);
        if (error)
@@ -2155,7 +2054,6 @@ xfs_link(
 {
        xfs_mount_t             *mp = tdp->i_mount;
        xfs_trans_t             *tp;
-       xfs_inode_t             *ips[2];
        int                     error;
        xfs_bmap_free_t         free_list;
        xfs_fsblock_t           first_block;
@@ -2203,15 +2101,7 @@ xfs_link(
                goto error_return;
        }
 
-       if (sip->i_ino < tdp->i_ino) {
-               ips[0] = sip;
-               ips[1] = tdp;
-       } else {
-               ips[0] = tdp;
-               ips[1] = sip;
-       }
-
-       xfs_lock_inodes(ips, 2, XFS_ILOCK_EXCL);
+       xfs_lock_two_inodes(sip, tdp, XFS_ILOCK_EXCL);
 
        /*
         * Increment vnode ref counts since xfs_trans_commit &
@@ -2253,7 +2143,6 @@ xfs_link(
        if (error)
                goto abort_return;
        xfs_ichgtime(tdp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
-       tdp->i_gen++;
        xfs_trans_log_inode(tp, tdp, XFS_ILOG_CORE);
 
        error = xfs_bumplink(tp, sip);
@@ -2352,7 +2241,7 @@ xfs_mkdir(
         * Make sure that we have allocated dquot(s) on disk.
         */
        error = XFS_QM_DQVOPALLOC(mp, dp,
-                       current_fsuid(credp), current_fsgid(credp), prid,
+                       current_fsuid(), current_fsgid(), prid,
                        XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp);
        if (error)
                goto std_return;
@@ -2430,18 +2319,10 @@ xfs_mkdir(
        }
        xfs_ichgtime(dp, XFS_ICHGTIME_MOD | XFS_ICHGTIME_CHG);
 
-       /*
-        * Bump the in memory version number of the parent directory
-        * so that other processes accessing it will recognize that
-        * the directory has changed.
-        */
-       dp->i_gen++;
-
        error = xfs_dir_init(tp, cdp, dp);
        if (error)
                goto error2;
 
-       cdp->i_gen = 1;
        error = xfs_bumplink(tp, dp);
        if (error)
                goto error2;
@@ -2578,7 +2459,7 @@ xfs_symlink(
         * Make sure that we have allocated dquot(s) on disk.
         */
        error = XFS_QM_DQVOPALLOC(mp, dp,
-                       current_fsuid(credp), current_fsgid(credp), prid,
+                       current_fsuid(), current_fsgid(), prid,
                        XFS_QMOPT_QUOTALL | XFS_QMOPT_INHERIT, &udqp, &gdqp);
        if (error)
                goto std_return;
@@ -2728,13 +2609,6 @@ xfs_symlink(
        xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
 
        /*
-        * Bump the in memory version number of the parent directory
-        * so that other processes accessing it will recognize that
-        * the directory has changed.
-        */
-       dp->i_gen++;
-
-       /*
         * If this is a synchronous mount, make sure that the
         * symlink transaction goes to disk before returning to
         * the user.
@@ -2873,14 +2747,13 @@ int
 xfs_reclaim(
        xfs_inode_t     *ip)
 {
-       bhv_vnode_t     *vp = VFS_I(ip);
 
        xfs_itrace_entry(ip);
 
-       ASSERT(!VN_MAPPED(vp));
+       ASSERT(!VN_MAPPED(VFS_I(ip)));
 
        /* bad inode, get out here ASAP */
-       if (VN_BAD(vp)) {
+       if (VN_BAD(VFS_I(ip))) {
                xfs_ireclaim(ip);
                return 0;
        }
@@ -2909,122 +2782,10 @@ xfs_reclaim(
        if (!ip->i_update_core && (ip->i_itemp == NULL)) {
                xfs_ilock(ip, XFS_ILOCK_EXCL);
                xfs_iflock(ip);
-               return xfs_finish_reclaim(ip, 1, XFS_IFLUSH_DELWRI_ELSE_SYNC);
-       } else {
-               xfs_mount_t     *mp = ip->i_mount;
-
-               /* Protect sync and unpin from us */
-               XFS_MOUNT_ILOCK(mp);
-               spin_lock(&ip->i_flags_lock);
-               __xfs_iflags_set(ip, XFS_IRECLAIMABLE);
-               vp->i_private = NULL;
-               ip->i_vnode = NULL;
-               spin_unlock(&ip->i_flags_lock);
-               list_add_tail(&ip->i_reclaim, &mp->m_del_inodes);
-               XFS_MOUNT_IUNLOCK(mp);
-       }
-       return 0;
-}
-
-int
-xfs_finish_reclaim(
-       xfs_inode_t     *ip,
-       int             locked,
-       int             sync_mode)
-{
-       xfs_perag_t     *pag = xfs_get_perag(ip->i_mount, ip->i_ino);
-       bhv_vnode_t     *vp = VFS_I(ip);
-
-       if (vp && VN_BAD(vp))
-               goto reclaim;
-
-       /* The hash lock here protects a thread in xfs_iget_core from
-        * racing with us on linking the inode back with a vnode.
-        * Once we have the XFS_IRECLAIM flag set it will not touch
-        * us.
-        */
-       write_lock(&pag->pag_ici_lock);
-       spin_lock(&ip->i_flags_lock);
-       if (__xfs_iflags_test(ip, XFS_IRECLAIM) ||
-           (!__xfs_iflags_test(ip, XFS_IRECLAIMABLE) && vp == NULL)) {
-               spin_unlock(&ip->i_flags_lock);
-               write_unlock(&pag->pag_ici_lock);
-               if (locked) {
-                       xfs_ifunlock(ip);
-                       xfs_iunlock(ip, XFS_ILOCK_EXCL);
-               }
-               return 1;
-       }
-       __xfs_iflags_set(ip, XFS_IRECLAIM);
-       spin_unlock(&ip->i_flags_lock);
-       write_unlock(&pag->pag_ici_lock);
-       xfs_put_perag(ip->i_mount, pag);
-
-       /*
-        * If the inode is still dirty, then flush it out.  If the inode
-        * is not in the AIL, then it will be OK to flush it delwri as
-        * long as xfs_iflush() does not keep any references to the inode.
-        * We leave that decision up to xfs_iflush() since it has the
-        * knowledge of whether it's OK to simply do a delwri flush of
-        * the inode or whether we need to wait until the inode is
-        * pulled from the AIL.
-        * We get the flush lock regardless, though, just to make sure
-        * we don't free it while it is being flushed.
-        */
-       if (!locked) {
-               xfs_ilock(ip, XFS_ILOCK_EXCL);
-               xfs_iflock(ip);
+               xfs_iflags_set(ip, XFS_IRECLAIMABLE);
+               return xfs_reclaim_inode(ip, 1, XFS_IFLUSH_DELWRI_ELSE_SYNC);
        }
-
-       /*
-        * In the case of a forced shutdown we rely on xfs_iflush() to
-        * wait for the inode to be unpinned before returning an error.
-        */
-       if (xfs_iflush(ip, sync_mode) == 0) {
-               /* synchronize with xfs_iflush_done */
-               xfs_iflock(ip);
-               xfs_ifunlock(ip);
-       }
-
-       xfs_iunlock(ip, XFS_ILOCK_EXCL);
-
- reclaim:
-       xfs_ireclaim(ip);
-       return 0;
-}
-
-int
-xfs_finish_reclaim_all(xfs_mount_t *mp, int noblock)
-{
-       int             purged;
-       xfs_inode_t     *ip, *n;
-       int             done = 0;
-
-       while (!done) {
-               purged = 0;
-               XFS_MOUNT_ILOCK(mp);
-               list_for_each_entry_safe(ip, n, &mp->m_del_inodes, i_reclaim) {
-                       if (noblock) {
-                               if (xfs_ilock_nowait(ip, XFS_ILOCK_EXCL) == 0)
-                                       continue;
-                               if (xfs_ipincount(ip) ||
-                                   !xfs_iflock_nowait(ip)) {
-                                       xfs_iunlock(ip, XFS_ILOCK_EXCL);
-                                       continue;
-                               }
-                       }
-                       XFS_MOUNT_IUNLOCK(mp);
-                       if (xfs_finish_reclaim(ip, noblock,
-                                       XFS_IFLUSH_DELWRI_ELSE_ASYNC))
-                               delay(1);
-                       purged = 1;
-                       break;
-               }
-
-               done = !purged;
-       }
-
-       XFS_MOUNT_IUNLOCK(mp);
+       xfs_inode_set_reclaim_tag(ip);
        return 0;
 }
 
@@ -3236,6 +2997,13 @@ error1:  /* Just cancel transaction */
 /*
  * Zero file bytes between startoff and endoff inclusive.
  * The iolock is held exclusive and no blocks are buffered.
+ *
+ * This function is used by xfs_free_file_space() to zero
+ * partial blocks when the range to free is not block aligned.
+ * When unreserving space with boundaries that are not block
+ * aligned we round up the start and round down the end
+ * boundaries and then use this function to zero the parts of
+ * the blocks that got dropped during the rounding.
  */
 STATIC int
 xfs_zero_remaining_bytes(
@@ -3252,6 +3020,17 @@ xfs_zero_remaining_bytes(
        int                     nimap;
        int                     error = 0;
 
+       /*
+        * Avoid doing I/O beyond eof - it's not necessary
+        * since nothing can read beyond eof.  The space will
+        * be zeroed when the file is extended anyway.
+        */
+       if (startoff >= ip->i_size)
+               return 0;
+
+       if (endoff > ip->i_size)
+               endoff = ip->i_size;
+
        bp = xfs_buf_get_noaddr(mp->m_sb.sb_blocksize,
                                XFS_IS_REALTIME_INODE(ip) ?
                                mp->m_rtdev_targp : mp->m_ddev_targp);
@@ -3321,7 +3100,6 @@ xfs_free_file_space(
        xfs_off_t               len,
        int                     attr_flags)
 {
-       bhv_vnode_t             *vp;
        int                     committed;
        int                     done;
        xfs_off_t               end_dmi_offset;
@@ -3341,7 +3119,6 @@ xfs_free_file_space(
        xfs_trans_t             *tp;
        int                     need_iolock = 1;
 
-       vp = VFS_I(ip);
        mp = ip->i_mount;
 
        xfs_itrace_entry(ip);
@@ -3378,7 +3155,7 @@ xfs_free_file_space(
        rounding = max_t(uint, 1 << mp->m_sb.sb_blocklog, PAGE_CACHE_SIZE);
        ioffset = offset & ~(rounding - 1);
 
-       if (VN_CACHED(vp) != 0) {
+       if (VN_CACHED(VFS_I(ip)) != 0) {
                xfs_inval_cached_trace(ip, ioffset, -1, ioffset, -1);
                error = xfs_flushinval_pages(ip, ioffset, -1, FI_REMAPF_LOCKED);
                if (error)
@@ -3534,7 +3311,6 @@ xfs_change_file_space(
        int             cmd,
        xfs_flock64_t   *bf,
        xfs_off_t       offset,
-       cred_t          *credp,
        int             attr_flags)
 {
        xfs_mount_t     *mp = ip->i_mount;
@@ -3622,7 +3398,7 @@ xfs_change_file_space(
                iattr.ia_valid = ATTR_SIZE;
                iattr.ia_size = startoffset;
 
-               error = xfs_setattr(ip, &iattr, attr_flags, credp);
+               error = xfs_setattr(ip, &iattr, attr_flags);
 
                if (error)
                        return error;