[XFS] Remove xfs_macros.c, xfs_macros.h, rework headers a whole lot.
[profile/ivi/kernel-adaptation-intel-automotive.git] / fs / xfs / linux-2.6 / xfs_super.c
index 0da87bf..fac4862 100644 (file)
  *
  * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
  */
-
 #include "xfs.h"
-
-#include "xfs_inum.h"
+#include "xfs_bit.h"
 #include "xfs_log.h"
 #include "xfs_clnt.h"
+#include "xfs_inum.h"
 #include "xfs_trans.h"
 #include "xfs_sb.h"
+#include "xfs_ag.h"
 #include "xfs_dir.h"
 #include "xfs_dir2.h"
 #include "xfs_alloc.h"
 #include "xfs_dmapi.h"
 #include "xfs_quota.h"
 #include "xfs_mount.h"
-#include "xfs_alloc_btree.h"
 #include "xfs_bmap_btree.h"
+#include "xfs_alloc_btree.h"
 #include "xfs_ialloc_btree.h"
-#include "xfs_btree.h"
-#include "xfs_ialloc.h"
-#include "xfs_attr_sf.h"
 #include "xfs_dir_sf.h"
 #include "xfs_dir2_sf.h"
+#include "xfs_attr_sf.h"
 #include "xfs_dinode.h"
 #include "xfs_inode.h"
+#include "xfs_btree.h"
+#include "xfs_ialloc.h"
 #include "xfs_bmap.h"
-#include "xfs_bit.h"
 #include "xfs_rtalloc.h"
 #include "xfs_error.h"
 #include "xfs_itable.h"
@@ -189,7 +188,7 @@ xfs_revalidate_inode(
                break;
        }
 
-       inode->i_blksize = PAGE_CACHE_SIZE;
+       inode->i_blksize = xfs_preferred_iosize(mp);
        inode->i_generation = ip->i_d.di_gen;
        i_size_write(inode, ip->i_d.di_size);
        inode->i_blocks =
@@ -278,6 +277,72 @@ xfs_blkdev_put(
                close_bdev_excl(bdev);
 }
 
+/*
+ * Try to write out the superblock using barriers.
+ */
+STATIC int
+xfs_barrier_test(
+       xfs_mount_t     *mp)
+{
+       xfs_buf_t       *sbp = xfs_getsb(mp, 0);
+       int             error;
+
+       XFS_BUF_UNDONE(sbp);
+       XFS_BUF_UNREAD(sbp);
+       XFS_BUF_UNDELAYWRITE(sbp);
+       XFS_BUF_WRITE(sbp);
+       XFS_BUF_UNASYNC(sbp);
+       XFS_BUF_ORDERED(sbp);
+
+       xfsbdstrat(mp, sbp);
+       error = xfs_iowait(sbp);
+
+       /*
+        * Clear all the flags we set and possible error state in the
+        * buffer.  We only did the write to try out whether barriers
+        * worked and shouldn't leave any traces in the superblock
+        * buffer.
+        */
+       XFS_BUF_DONE(sbp);
+       XFS_BUF_ERROR(sbp, 0);
+       XFS_BUF_UNORDERED(sbp);
+
+       xfs_buf_relse(sbp);
+       return error;
+}
+
+void
+xfs_mountfs_check_barriers(xfs_mount_t *mp)
+{
+       int error;
+
+       if (mp->m_logdev_targp != mp->m_ddev_targp) {
+               xfs_fs_cmn_err(CE_NOTE, mp,
+                 "Disabling barriers, not supported with external log device");
+               mp->m_flags &= ~XFS_MOUNT_BARRIER;
+       }
+
+       if (mp->m_ddev_targp->pbr_bdev->bd_disk->queue->ordered ==
+                                       QUEUE_ORDERED_NONE) {
+               xfs_fs_cmn_err(CE_NOTE, mp,
+                 "Disabling barriers, not supported by the underlying device");
+               mp->m_flags &= ~XFS_MOUNT_BARRIER;
+       }
+
+       error = xfs_barrier_test(mp);
+       if (error) {
+               xfs_fs_cmn_err(CE_NOTE, mp,
+                 "Disabling barriers, trial barrier write failed");
+               mp->m_flags &= ~XFS_MOUNT_BARRIER;
+       }
+}
+
+void
+xfs_blkdev_issue_flush(
+       xfs_buftarg_t           *buftarg)
+{
+       blkdev_issue_flush(buftarg->pbr_bdev, NULL);
+}
 
 STATIC struct inode *
 linvfs_alloc_inode(
@@ -467,7 +532,7 @@ xfs_flush_inode(
 
        igrab(inode);
        xfs_syncd_queue_work(vfs, inode, xfs_flush_inode_work);
-       delay(HZ/2);
+       delay(msecs_to_jiffies(500));
 }
 
 /*
@@ -492,7 +557,7 @@ xfs_flush_device(
 
        igrab(inode);
        xfs_syncd_queue_work(vfs, inode, xfs_flush_device_work);
-       delay(HZ/2);
+       delay(msecs_to_jiffies(500));
        xfs_log_force(ip->i_mount, (xfs_lsn_t)0, XFS_LOG_FORCE|XFS_LOG_SYNC);
 }
 
@@ -520,10 +585,9 @@ xfssyncd(
        struct vfs_sync_work    *work, *n;
        LIST_HEAD               (tmp);
 
-       timeleft = (xfs_syncd_centisecs * HZ) / 100;
+       timeleft = xfs_syncd_centisecs * msecs_to_jiffies(10);
        for (;;) {
-               set_current_state(TASK_INTERRUPTIBLE);
-               timeleft = schedule_timeout(timeleft);
+               timeleft = schedule_timeout_interruptible(timeleft);
                /* swsusp */
                try_to_freeze();
                if (kthread_should_stop())
@@ -537,7 +601,8 @@ xfssyncd(
                 */
                if (!timeleft || list_empty(&vfsp->vfs_sync_list)) {
                        if (!timeleft)
-                               timeleft = (xfs_syncd_centisecs * HZ) / 100;
+                               timeleft = xfs_syncd_centisecs *
+                                                       msecs_to_jiffies(10);
                        INIT_LIST_HEAD(&vfsp->vfs_sync_work.w_list);
                        list_add_tail(&vfsp->vfs_sync_work.w_list,
                                        &vfsp->vfs_sync_list);
@@ -701,6 +766,18 @@ linvfs_show_options(
 }
 
 STATIC int
+linvfs_quotasync(
+       struct super_block      *sb,
+       int                     type)
+{
+       struct vfs              *vfsp = LINVFS_GET_VFS(sb);
+       int                     error;
+
+       VFS_QUOTACTL(vfsp, Q_XQUOTASYNC, 0, (caddr_t)NULL, error);
+       return -error;
+}
+
+STATIC int
 linvfs_getxstate(
        struct super_block      *sb,
        struct fs_quota_stat    *fqs)
@@ -868,6 +945,7 @@ STATIC struct super_operations linvfs_sops = {
 };
 
 STATIC struct quotactl_ops linvfs_qops = {
+       .quota_sync             = linvfs_quotasync,
        .get_xstate             = linvfs_getxstate,
        .set_xstate             = linvfs_setxstate,
        .get_xquota             = linvfs_getxquota,