[XFS] getattr can return an error code, so propogate any from lower
[powerpc.git] / fs / xfs / xfs_inode.c
index 48146bd..df695e9 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
+ * Copyright (c) 2000-2006 Silicon Graphics, Inc.
  * All Rights Reserved.
  *
  * This program is free software; you can redistribute it and/or
@@ -812,6 +812,8 @@ _xfs_dic2xflags(
                        flags |= XFS_XFLAG_EXTSIZE;
                if (di_flags & XFS_DIFLAG_EXTSZINHERIT)
                        flags |= XFS_XFLAG_EXTSZINHERIT;
+               if (di_flags & XFS_DIFLAG_NODEFRAG)
+                       flags |= XFS_XFLAG_NODEFRAG;
        }
 
        return flags;
@@ -1221,6 +1223,9 @@ xfs_ialloc(
                                di_flags |= XFS_DIFLAG_NOSYMLINKS;
                        if (pip->i_d.di_flags & XFS_DIFLAG_PROJINHERIT)
                                di_flags |= XFS_DIFLAG_PROJINHERIT;
+                       if ((pip->i_d.di_flags & XFS_DIFLAG_NODEFRAG) &&
+                           xfs_inherit_nodefrag)
+                               di_flags |= XFS_DIFLAG_NODEFRAG;
                        ip->i_d.di_flags |= di_flags;
                }
                /* FALLTHROUGH */
@@ -1285,7 +1290,7 @@ xfs_isize_check(
                                       (xfs_ufsize_t)XFS_MAXIOFFSET(mp)) -
                          map_first),
                         XFS_BMAPI_ENTIRE, NULL, 0, imaps, &nimaps,
-                        NULL))
+                        NULL, NULL))
            return;
        ASSERT(nimaps == 1);
        ASSERT(imaps[0].br_startblock == HOLESTARTBLOCK);
@@ -1666,12 +1671,13 @@ xfs_itruncate_finish(
                 * runs.
                 */
                XFS_BMAP_INIT(&free_list, &first_block);
-               error = xfs_bunmapi(ntp, ip, first_unmap_block,
-                                   unmap_len,
+               error = XFS_BUNMAPI(mp, ntp, &ip->i_iocore,
+                                   first_unmap_block, unmap_len,
                                    XFS_BMAPI_AFLAG(fork) |
                                      (sync ? 0 : XFS_BMAPI_ASYNC),
                                    XFS_ITRUNC_MAX_EXTENTS,
-                                   &first_block, &free_list, &done);
+                                   &first_block, &free_list,
+                                   NULL, &done);
                if (error) {
                        /*
                         * If the bunmapi call encounters an error,
@@ -2732,16 +2738,30 @@ xfs_iunpin(
        ASSERT(atomic_read(&ip->i_pincount) > 0);
 
        if (atomic_dec_and_test(&ip->i_pincount)) {
-               vnode_t *vp = XFS_ITOV_NULL(ip);
+               /*
+                * If the inode is currently being reclaimed, the
+                * linux inode _and_ the xfs vnode may have been
+                * freed so we cannot reference either of them safely.
+                * Hence we should not try to do anything to them
+                * if the xfs inode is currently in the reclaim
+                * path.
+                *
+                * However, we still need to issue the unpin wakeup
+                * call as the inode reclaim may be blocked waiting for
+                * the inode to become unpinned.
+                */
+               if (!(ip->i_flags & (XFS_IRECLAIM|XFS_IRECLAIMABLE))) {
+                       vnode_t *vp = XFS_ITOV_NULL(ip);
 
-               /* make sync come back and flush this inode */
-               if (vp) {
-                       struct inode    *inode = vn_to_inode(vp);
+                       /* make sync come back and flush this inode */
+                       if (vp) {
+                               struct inode    *inode = vn_to_inode(vp);
 
-                       if (!(inode->i_state & I_NEW))
-                               mark_inode_dirty_sync(inode);
+                               if (!(inode->i_state &
+                                               (I_NEW|I_FREEING|I_CLEAR)))
+                                       mark_inode_dirty_sync(inode);
+                       }
                }
-
                wake_up(&ip->i_ipin_wait);
        }
 }
@@ -4167,7 +4187,7 @@ xfs_iext_direct_to_inline(
         */
        memcpy(ifp->if_u2.if_inline_ext, ifp->if_u1.if_extents,
                nextents * sizeof(xfs_bmbt_rec_t));
-       kmem_free(ifp->if_u1.if_extents, KM_SLEEP);
+       kmem_free(ifp->if_u1.if_extents, ifp->if_real_bytes);
        ifp->if_u1.if_extents = ifp->if_u2.if_inline_ext;
        ifp->if_real_bytes = 0;
 }