[XFS] getattr can return an error code, so propogate any from lower
[powerpc.git] / fs / xfs / xfs_vfsops.c
index 7bdbd99..36ea1b2 100644 (file)
@@ -53,8 +53,9 @@
 #include "xfs_acl.h"
 #include "xfs_attr.h"
 #include "xfs_clnt.h"
+#include "xfs_fsops.h"
 
-STATIC int xfs_sync(bhv_desc_t *, int, cred_t *);
+STATIC int     xfs_sync(bhv_desc_t *, int, cred_t *);
 
 int
 xfs_init(void)
@@ -76,11 +77,12 @@ xfs_init(void)
                                                 "xfs_bmap_free_item");
        xfs_btree_cur_zone = kmem_zone_init(sizeof(xfs_btree_cur_t),
                                            "xfs_btree_cur");
-       xfs_inode_zone = kmem_zone_init(sizeof(xfs_inode_t), "xfs_inode");
        xfs_trans_zone = kmem_zone_init(sizeof(xfs_trans_t), "xfs_trans");
        xfs_da_state_zone =
                kmem_zone_init(sizeof(xfs_da_state_t), "xfs_da_state");
        xfs_dabuf_zone = kmem_zone_init(sizeof(xfs_dabuf_t), "xfs_dabuf");
+       xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork");
+       xfs_acl_zone_init(xfs_acl_zone, "xfs_acl");
 
        /*
         * The size of the zone allocated buf log item is the maximum
@@ -92,17 +94,30 @@ xfs_init(void)
                                (((XFS_MAX_BLOCKSIZE / XFS_BLI_CHUNK) /
                                  NBWORD) * sizeof(int))),
                               "xfs_buf_item");
-       xfs_efd_zone = kmem_zone_init((sizeof(xfs_efd_log_item_t) +
-                                      ((XFS_EFD_MAX_FAST_EXTENTS - 1) * sizeof(xfs_extent_t))),
+       xfs_efd_zone =
+               kmem_zone_init((sizeof(xfs_efd_log_item_t) +
+                              ((XFS_EFD_MAX_FAST_EXTENTS - 1) *
+                                sizeof(xfs_extent_t))),
                                      "xfs_efd_item");
-       xfs_efi_zone = kmem_zone_init((sizeof(xfs_efi_log_item_t) +
-                                      ((XFS_EFI_MAX_FAST_EXTENTS - 1) * sizeof(xfs_extent_t))),
+       xfs_efi_zone =
+               kmem_zone_init((sizeof(xfs_efi_log_item_t) +
+                              ((XFS_EFI_MAX_FAST_EXTENTS - 1) *
+                                sizeof(xfs_extent_t))),
                                      "xfs_efi_item");
-       xfs_ifork_zone = kmem_zone_init(sizeof(xfs_ifork_t), "xfs_ifork");
-       xfs_ili_zone = kmem_zone_init(sizeof(xfs_inode_log_item_t), "xfs_ili");
-       xfs_chashlist_zone = kmem_zone_init(sizeof(xfs_chashlist_t),
-                                           "xfs_chashlist");
-       xfs_acl_zone_init(xfs_acl_zone, "xfs_acl");
+
+       /*
+        * These zones warrant special memory allocator hints
+        */
+       xfs_inode_zone =
+               kmem_zone_init_flags(sizeof(xfs_inode_t), "xfs_inode",
+                                       KM_ZONE_HWALIGN | KM_ZONE_RECLAIM |
+                                       KM_ZONE_SPREAD, NULL);
+       xfs_ili_zone =
+               kmem_zone_init_flags(sizeof(xfs_inode_log_item_t), "xfs_ili",
+                                       KM_ZONE_SPREAD, NULL);
+       xfs_chashlist_zone =
+               kmem_zone_init_flags(sizeof(xfs_chashlist_t), "xfs_chashlist",
+                                       KM_ZONE_SPREAD, NULL);
 
        /*
         * Allocate global trace buffers.
@@ -175,18 +190,18 @@ xfs_cleanup(void)
        ktrace_free(xfs_alloc_trace_buf);
 #endif
 
-       kmem_cache_destroy(xfs_bmap_free_item_zone);
-       kmem_cache_destroy(xfs_btree_cur_zone);
-       kmem_cache_destroy(xfs_inode_zone);
-       kmem_cache_destroy(xfs_trans_zone);
-       kmem_cache_destroy(xfs_da_state_zone);
-       kmem_cache_destroy(xfs_dabuf_zone);
-       kmem_cache_destroy(xfs_buf_item_zone);
-       kmem_cache_destroy(xfs_efd_zone);
-       kmem_cache_destroy(xfs_efi_zone);
-       kmem_cache_destroy(xfs_ifork_zone);
-       kmem_cache_destroy(xfs_ili_zone);
-       kmem_cache_destroy(xfs_chashlist_zone);
+       kmem_zone_destroy(xfs_bmap_free_item_zone);
+       kmem_zone_destroy(xfs_btree_cur_zone);
+       kmem_zone_destroy(xfs_inode_zone);
+       kmem_zone_destroy(xfs_trans_zone);
+       kmem_zone_destroy(xfs_da_state_zone);
+       kmem_zone_destroy(xfs_dabuf_zone);
+       kmem_zone_destroy(xfs_buf_item_zone);
+       kmem_zone_destroy(xfs_efd_zone);
+       kmem_zone_destroy(xfs_efi_zone);
+       kmem_zone_destroy(xfs_ifork_zone);
+       kmem_zone_destroy(xfs_ili_zone);
+       kmem_zone_destroy(xfs_chashlist_zone);
 }
 
 /*
@@ -257,8 +272,6 @@ xfs_start_flags(
                mp->m_inoadd = XFS_INO64_OFFSET;
        }
 #endif
-       if (ap->flags & XFSMNT_NOATIME)
-               mp->m_flags |= XFS_MOUNT_NOATIME;
        if (ap->flags & XFSMNT_RETERR)
                mp->m_flags |= XFS_MOUNT_RETERR;
        if (ap->flags & XFSMNT_NOALIGN)
@@ -290,8 +303,8 @@ xfs_start_flags(
                mp->m_flags |= XFS_MOUNT_IDELETE;
        if (ap->flags & XFSMNT_DIRSYNC)
                mp->m_flags |= XFS_MOUNT_DIRSYNC;
-       if (ap->flags & XFSMNT_COMPAT_ATTR)
-               mp->m_flags |= XFS_MOUNT_COMPAT_ATTR;
+       if (ap->flags & XFSMNT_ATTR2)
+               mp->m_flags |= XFS_MOUNT_ATTR2;
 
        if (ap->flags2 & XFSMNT2_COMPAT_IOSIZE)
                mp->m_flags |= XFS_MOUNT_COMPAT_IOSIZE;
@@ -312,6 +325,8 @@ xfs_start_flags(
                mp->m_flags |= XFS_MOUNT_NOUUID;
        if (ap->flags & XFSMNT_BARRIER)
                mp->m_flags |= XFS_MOUNT_BARRIER;
+       else
+               mp->m_flags &= ~XFS_MOUNT_BARRIER;
 
        return 0;
 }
@@ -330,10 +345,11 @@ xfs_finish_flags(
 
        /* Fail a mount where the logbuf is smaller then the log stripe */
        if (XFS_SB_VERSION_HASLOGV2(&mp->m_sb)) {
-               if ((ap->logbufsize == -1) &&
+               if ((ap->logbufsize <= 0) &&
                    (mp->m_sb.sb_logsunit > XLOG_BIG_RECORD_BSIZE)) {
                        mp->m_logbsize = mp->m_sb.sb_logsunit;
-               } else if (ap->logbufsize < mp->m_sb.sb_logsunit) {
+               } else if (ap->logbufsize > 0 &&
+                          ap->logbufsize < mp->m_sb.sb_logsunit) {
                        cmn_err(CE_WARN,
        "XFS: logbuf size must be greater than or equal to log stripe size");
                        return XFS_ERROR(EINVAL);
@@ -347,6 +363,10 @@ xfs_finish_flags(
                }
        }
 
+       if (XFS_SB_VERSION_HASATTR2(&mp->m_sb)) {
+               mp->m_flags |= XFS_MOUNT_ATTR2;
+       }
+
        /*
         * prohibit r/w mounts of read-only filesystems
         */
@@ -382,10 +402,6 @@ xfs_finish_flags(
                        return XFS_ERROR(EINVAL);
        }
 
-       if (XFS_SB_VERSION_HASATTR2(&mp->m_sb)) {
-               mp->m_flags &= ~XFS_MOUNT_COMPAT_ATTR;
-       }
-
        return 0;
 }
 
@@ -426,6 +442,9 @@ xfs_mount(
        p = vfs_bhv_lookup(vfsp, VFS_POSITION_IO);
        mp->m_io_ops = p ? *(xfs_ioops_t *) vfs_bhv_custom(p) : xfs_iocore_xfs;
 
+       if (args->flags & XFSMNT_QUIET)
+               flags |= XFS_MFSI_QUIET;
+
        /*
         * Open real time and log devices - order is important.
         */
@@ -476,7 +495,7 @@ xfs_mount(
        error = xfs_start_flags(vfsp, args, mp);
        if (error)
                goto error1;
-       error = xfs_readsb(mp);
+       error = xfs_readsb(mp, flags);
        if (error)
                goto error1;
        error = xfs_finish_flags(vfsp, args, mp);
@@ -504,13 +523,13 @@ xfs_mount(
        if (error)
                goto error2;
 
+       if ((mp->m_flags & XFS_MOUNT_BARRIER) && !(vfsp->vfs_flag & VFS_RDONLY))
+               xfs_mountfs_check_barriers(mp);
+
        error = XFS_IOINIT(vfsp, args, flags);
        if (error)
                goto error2;
 
-       if ((args->flags & XFSMNT_BARRIER) &&
-           !(XFS_MTOVFS(mp)->vfs_flag & VFS_RDONLY))
-               xfs_mountfs_check_barriers(mp);
        return 0;
 
 error2:
@@ -616,7 +635,7 @@ xfs_quiesce_fs(
        xfs_mount_t             *mp)
 {
        int                     count = 0, pincount;
-               
+
        xfs_refcache_purge_mp(mp);
        xfs_flush_buftarg(mp->m_ddev_targp, 0);
        xfs_finish_reclaim_all(mp, 0);
@@ -627,7 +646,7 @@ xfs_quiesce_fs(
         * meta data (typically directory updates).
         * Which then must be flushed and logged before
         * we can write the unmount record.
-        */ 
+        */
        do {
                xfs_syncsub(mp, SYNC_REMOUNT|SYNC_ATTR|SYNC_WAIT, 0, NULL);
                pincount = xfs_flush_buftarg(mp->m_ddev_targp, 1);
@@ -650,31 +669,22 @@ xfs_mntupdate(
        xfs_mount_t     *mp = XFS_BHVTOM(bdp);
        int             error;
 
-       if (args->flags & XFSMNT_NOATIME)
-               mp->m_flags |= XFS_MOUNT_NOATIME;
-       else
-               mp->m_flags &= ~XFS_MOUNT_NOATIME;
-
-       if ((vfsp->vfs_flag & VFS_RDONLY) &&
-           !(*flags & MS_RDONLY)) {
-               vfsp->vfs_flag &= ~VFS_RDONLY;
-
-               if (args->flags & XFSMNT_BARRIER)
+       if (!(*flags & MS_RDONLY)) {                    /* rw/ro -> rw */
+               if (vfsp->vfs_flag & VFS_RDONLY)
+                       vfsp->vfs_flag &= ~VFS_RDONLY;
+               if (args->flags & XFSMNT_BARRIER) {
+                       mp->m_flags |= XFS_MOUNT_BARRIER;
                        xfs_mountfs_check_barriers(mp);
-       }
-
-       if (!(vfsp->vfs_flag & VFS_RDONLY) &&
-           (*flags & MS_RDONLY)) {
+               } else {
+                       mp->m_flags &= ~XFS_MOUNT_BARRIER;
+               }
+       } else if (!(vfsp->vfs_flag & VFS_RDONLY)) {    /* rw -> ro */
                VFS_SYNC(vfsp, SYNC_FSDATA|SYNC_BDFLUSH|SYNC_ATTR, NULL, error);
-
                xfs_quiesce_fs(mp);
-
-               /* Ok now write out an unmount record */
                xfs_log_unmount_write(mp);
                xfs_unmountfs_writesb(mp);
                vfsp->vfs_flag |= VFS_RDONLY;
        }
-
        return 0;
 }
 
@@ -805,6 +815,7 @@ xfs_statvfs(
 
        statp->f_type = XFS_SB_MAGIC;
 
+       xfs_icsb_sync_counters_lazy(mp);
        s = XFS_SB_LOCK(mp);
        statp->f_bsize = sbp->sb_blocksize;
        lsize = sbp->sb_logstart ? sbp->sb_logblocks : 0;
@@ -863,10 +874,10 @@ xfs_statvfs(
  *                    determine if they should be flushed sync, async, or
  *                    delwri.
  *      SYNC_CLOSE   - This flag is passed when the system is being
- *                    unmounted.  We should sync and invalidate everthing.
+ *                    unmounted.  We should sync and invalidate everything.
  *      SYNC_FSDATA  - This indicates that the caller would like to make
  *                    sure the superblock is safe on disk.  We can ensure
- *                    this by simply makeing sure the log gets flushed
+ *                    this by simply making sure the log gets flushed
  *                    if SYNC_BDFLUSH is set, and by actually writing it
  *                    out otherwise.
  *
@@ -891,7 +902,7 @@ xfs_sync(
  *
  * This routine supports all of the flags defined for the generic VFS_SYNC
  * interface as explained above under xfs_sync.  In the interests of not
- * changing interfaces within the 6.5 family, additional internallly-
+ * changing interfaces within the 6.5 family, additional internally-
  * required functions are specified within a separate xflags parameter,
  * only available by calling this routine.
  *
@@ -1073,7 +1084,7 @@ xfs_sync_inodes(
                 * If this is just vfs_sync() or pflushd() calling
                 * then we can skip inodes for which it looks like
                 * there is nothing to do.  Since we don't have the
-                * inode locked this is racey, but these are periodic
+                * inode locked this is racy, but these are periodic
                 * calls so it doesn't matter.  For the others we want
                 * to know for sure, so we at least try to lock them.
                 */
@@ -1212,7 +1223,7 @@ xfs_sync_inodes(
                                        xfs_iunlock(ip, XFS_ILOCK_SHARED);
 
                                        error = xfs_itobp(mp, NULL, ip,
-                                                         &dip, &bp, 0);
+                                                         &dip, &bp, 0, 0);
                                        if (!error) {
                                                xfs_buf_relse(bp);
                                        } else {
@@ -1412,7 +1423,7 @@ xfs_sync_inodes(
  *
  * This routine supports all of the flags defined for the generic VFS_SYNC
  * interface as explained above under xfs_sync.  In the interests of not
- * changing interfaces within the 6.5 family, additional internallly-
+ * changing interfaces within the 6.5 family, additional internally-
  * required functions are specified within a separate xflags parameter,
  * only available by calling this routine.
  *
@@ -1634,6 +1645,7 @@ xfs_vget(
 #define MNTOPT_NORECOVERY   "norecovery"   /* don't run XFS recovery */
 #define MNTOPT_BARRIER "barrier"       /* use writer barriers for log write and
                                         * unwritten extent conversion */
+#define MNTOPT_NOBARRIER "nobarrier"   /* .. disable */
 #define MNTOPT_OSYNCISOSYNC "osyncisosync" /* o_sync is REALLY o_sync */
 #define MNTOPT_64BITINODE   "inode64"  /* inodes can be allocated anywhere */
 #define MNTOPT_IKEEP   "ikeep"         /* do not free empty inode clusters */
@@ -1679,12 +1691,9 @@ xfs_parseargs(
        int                     dsunit, dswidth, vol_dsunit, vol_dswidth;
        int                     iosize;
 
+       args->flags |= XFSMNT_IDELETE;
+       args->flags |= XFSMNT_BARRIER;
        args->flags2 |= XFSMNT2_COMPAT_IOSIZE;
-       args->flags |= XFSMNT_COMPAT_ATTR;
-
-#if 0  /* XXX: off by default, until some remaining issues ironed out */
-       args->flags |= XFSMNT_IDELETE; /* default to on */
-#endif
 
        if (!options)
                goto done;
@@ -1806,6 +1815,8 @@ xfs_parseargs(
                        args->flags |= XFSMNT_NOUUID;
                } else if (!strcmp(this_char, MNTOPT_BARRIER)) {
                        args->flags |= XFSMNT_BARRIER;
+               } else if (!strcmp(this_char, MNTOPT_NOBARRIER)) {
+                       args->flags &= ~XFSMNT_BARRIER;
                } else if (!strcmp(this_char, MNTOPT_IKEEP)) {
                        args->flags &= ~XFSMNT_IDELETE;
                } else if (!strcmp(this_char, MNTOPT_NOIKEEP)) {
@@ -1815,9 +1826,9 @@ xfs_parseargs(
                } else if (!strcmp(this_char, MNTOPT_NOLARGEIO)) {
                        args->flags2 |= XFSMNT2_COMPAT_IOSIZE;
                } else if (!strcmp(this_char, MNTOPT_ATTR2)) {
-                       args->flags &= ~XFSMNT_COMPAT_ATTR;
+                       args->flags |= XFSMNT_ATTR2;
                } else if (!strcmp(this_char, MNTOPT_NOATTR2)) {
-                       args->flags |= XFSMNT_COMPAT_ATTR;
+                       args->flags &= ~XFSMNT_ATTR2;
                } else if (!strcmp(this_char, "osyncisdsync")) {
                        /* no-op, this is now the default */
 printk("XFS: osyncisdsync is now the default, option is deprecated.\n");
@@ -1892,8 +1903,6 @@ xfs_showargs(
                { XFS_MOUNT_NOUUID,             "," MNTOPT_NOUUID },
                { XFS_MOUNT_NORECOVERY,         "," MNTOPT_NORECOVERY },
                { XFS_MOUNT_OSYNCISOSYNC,       "," MNTOPT_OSYNCISOSYNC },
-               { XFS_MOUNT_BARRIER,            "," MNTOPT_BARRIER },
-               { XFS_MOUNT_IDELETE,            "," MNTOPT_NOIKEEP },
                { 0, NULL }
        };
        struct proc_xfs_info    *xfs_infop;
@@ -1914,33 +1923,28 @@ xfs_showargs(
 
        if (mp->m_logbufs > 0)
                seq_printf(m, "," MNTOPT_LOGBUFS "=%d", mp->m_logbufs);
-
        if (mp->m_logbsize > 0)
                seq_printf(m, "," MNTOPT_LOGBSIZE "=%dk", mp->m_logbsize >> 10);
 
        if (mp->m_logname)
                seq_printf(m, "," MNTOPT_LOGDEV "=%s", mp->m_logname);
-
        if (mp->m_rtname)
                seq_printf(m, "," MNTOPT_RTDEV "=%s", mp->m_rtname);
 
        if (mp->m_dalign > 0)
                seq_printf(m, "," MNTOPT_SUNIT "=%d",
                                (int)XFS_FSB_TO_BB(mp, mp->m_dalign));
-
        if (mp->m_swidth > 0)
                seq_printf(m, "," MNTOPT_SWIDTH "=%d",
                                (int)XFS_FSB_TO_BB(mp, mp->m_swidth));
 
-       if (!(mp->m_flags & XFS_MOUNT_COMPAT_ATTR))
-               seq_printf(m, "," MNTOPT_ATTR2);
-
+       if (!(mp->m_flags & XFS_MOUNT_IDELETE))
+               seq_printf(m, "," MNTOPT_IKEEP);
        if (!(mp->m_flags & XFS_MOUNT_COMPAT_IOSIZE))
                seq_printf(m, "," MNTOPT_LARGEIO);
 
        if (!(vfsp->vfs_flag & VFS_32BITINODES))
                seq_printf(m, "," MNTOPT_64BITINODE);
-
        if (vfsp->vfs_flag & VFS_GRPID)
                seq_printf(m, "," MNTOPT_GRPID);
 
@@ -1959,6 +1963,7 @@ xfs_freeze(
        /* Push the superblock and write an unmount record */
        xfs_log_unmount_write(mp);
        xfs_unmountfs_writesb(mp);
+       xfs_fs_log_dummy(mp);
 }