[XFS] Add degframentation exclusion support
authorBarry Naujok <bnaujok@sgi.com>
Fri, 9 Jun 2006 04:54:19 +0000 (14:54 +1000)
committerNathan Scott <nathans@sgi.com>
Fri, 9 Jun 2006 04:54:19 +0000 (14:54 +1000)
SGI-PV: 953061
SGI-Modid: xfs-linux-melb:xfs-kern:25986a

Signed-off-by: Barry Naujok <bnaujok@sgi.com>
Signed-off-by: Nathan Scott <nathans@sgi.com>
fs/xfs/linux-2.6/xfs_globals.c
fs/xfs/linux-2.6/xfs_linux.h
fs/xfs/linux-2.6/xfs_sysctl.c
fs/xfs/linux-2.6/xfs_sysctl.h
fs/xfs/xfs_dinode.h
fs/xfs/xfs_fs.h
fs/xfs/xfs_inode.c
fs/xfs/xfs_vnodeops.c

index 6e8085f346357679a89e3c2292ced09ed61e8fa7..6c162c3dde7efb44ee4f1abbb430591974244b82 100644 (file)
@@ -45,6 +45,7 @@ xfs_param_t xfs_params = {
        .xfs_buf_age    = {     1*100,          15*100,         7200*100},
        .inherit_nosym  = {     0,              0,              1       },
        .rotorstep      = {     1,              1,              255     },
+       .inherit_nodfrg = {     0,              1,              1       },
 };
 
 /*
index e9fe43d74768a965f95a72c82741198bd9a65a15..7d15cb910275c8e2750f78b21c1e5badd5b543ea 100644 (file)
@@ -134,6 +134,7 @@ BUFFER_FNS(PrivateStart, unwritten);
 #define xfs_buf_age_centisecs  xfs_params.xfs_buf_age.val
 #define xfs_inherit_nosymlinks xfs_params.inherit_nosym.val
 #define xfs_rotorstep          xfs_params.rotorstep.val
+#define xfs_inherit_nodefrag   xfs_params.inherit_nodfrg.val
 
 #ifndef raw_smp_processor_id
 #define raw_smp_processor_id() smp_processor_id()
index 7079cc8372100aa8b2f7a3c3bd95e708a9a11531..4af97682bec8e066a62e7207ac5440eaaaa0b37f 100644 (file)
@@ -120,6 +120,11 @@ STATIC ctl_table xfs_table[] = {
        &sysctl_intvec, NULL,
        &xfs_params.rotorstep.min, &xfs_params.rotorstep.max},
 
+       {XFS_INHERIT_NODFRG, "inherit_nodefrag", &xfs_params.inherit_nodfrg.val,
+       sizeof(int), 0644, NULL, &proc_dointvec_minmax,
+       &sysctl_intvec, NULL,
+       &xfs_params.inherit_nodfrg.min, &xfs_params.inherit_nodfrg.max},
+
        /* please keep this the last entry */
 #ifdef CONFIG_PROC_FS
        {XFS_STATS_CLEAR, "stats_clear", &xfs_params.stats_clear.val,
index bc8c11f1372203b400dfd62c81bbe2a7b1636803..a631fb8cc5ac4c57ad04e9090184eef58fcec75a 100644 (file)
@@ -46,6 +46,7 @@ typedef struct xfs_param {
        xfs_sysctl_val_t xfs_buf_age;   /* Metadata buffer age before flush. */
        xfs_sysctl_val_t inherit_nosym; /* Inherit the "nosymlinks" flag. */
        xfs_sysctl_val_t rotorstep;     /* inode32 AG rotoring control knob */
+       xfs_sysctl_val_t inherit_nodfrg;/* Inherit the "nodefrag" inode flag. */
 } xfs_param_t;
 
 /*
@@ -84,6 +85,7 @@ enum {
        /* XFS_IO_BYPASS = 18 */
        XFS_INHERIT_NOSYM = 19,
        XFS_ROTORSTEP = 20,
+       XFS_INHERIT_NODFRG = 21,
 };
 
 extern xfs_param_t     xfs_params;
index 79d0d9e1fbabc8d4f38061c1191dd978fc447791..77d537782586242a10d4525542af5dfd2efa0ab0 100644 (file)
@@ -257,6 +257,7 @@ typedef enum xfs_dinode_fmt
 #define XFS_DIFLAG_NOSYMLINKS_BIT   10 /* disallow symlink creation */
 #define XFS_DIFLAG_EXTSIZE_BIT      11 /* inode extent size allocator hint */
 #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */
+#define XFS_DIFLAG_NODEFRAG_BIT     13 /* do not reorganize/defragment */
 #define XFS_DIFLAG_REALTIME      (1 << XFS_DIFLAG_REALTIME_BIT)
 #define XFS_DIFLAG_PREALLOC      (1 << XFS_DIFLAG_PREALLOC_BIT)
 #define XFS_DIFLAG_NEWRTBM       (1 << XFS_DIFLAG_NEWRTBM_BIT)
@@ -270,12 +271,13 @@ typedef enum xfs_dinode_fmt
 #define XFS_DIFLAG_NOSYMLINKS    (1 << XFS_DIFLAG_NOSYMLINKS_BIT)
 #define XFS_DIFLAG_EXTSIZE       (1 << XFS_DIFLAG_EXTSIZE_BIT)
 #define XFS_DIFLAG_EXTSZINHERIT  (1 << XFS_DIFLAG_EXTSZINHERIT_BIT)
+#define XFS_DIFLAG_NODEFRAG      (1 << XFS_DIFLAG_NODEFRAG_BIT)
 
 #define XFS_DIFLAG_ANY \
        (XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \
         XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \
         XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \
         XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \
-        XFS_DIFLAG_EXTSZINHERIT)
+        XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG)
 
 #endif /* __XFS_DINODE_H__ */
index df66f3a59fac4d5beed2270edd1cac360817aee6..0f0ad1535951c8b137278d5bf4c994910adfa8bf 100644 (file)
@@ -67,6 +67,7 @@ struct fsxattr {
 #define XFS_XFLAG_NOSYMLINKS   0x00000400      /* disallow symlink creation */
 #define XFS_XFLAG_EXTSIZE      0x00000800      /* extent size allocator hint */
 #define XFS_XFLAG_EXTSZINHERIT 0x00001000      /* inherit inode extent size */
+#define XFS_XFLAG_NODEFRAG     0x00002000      /* do not defragment */
 #define XFS_XFLAG_HASATTR      0x80000000      /* no DIFLAG for this   */
 
 /*
index f5284453441bba587e8346f5c868bdae24b762f2..083fc0479e694181753b078f56517c65796e2e2d 100644 (file)
@@ -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 */
index 2b814f04176d35c5335bc9148880217efcdb944c..d1c6349e4018ea68927fa40209b51a1ff07d0e68 100644 (file)
@@ -799,6 +799,8 @@ xfs_setattr(
                                di_flags |= XFS_DIFLAG_NODUMP;
                        if (vap->va_xflags & XFS_XFLAG_PROJINHERIT)
                                di_flags |= XFS_DIFLAG_PROJINHERIT;
+                       if (vap->va_xflags & XFS_XFLAG_NODEFRAG)
+                               di_flags |= XFS_DIFLAG_NODEFRAG;
                        if ((ip->i_d.di_mode & S_IFMT) == S_IFDIR) {
                                if (vap->va_xflags & XFS_XFLAG_RTINHERIT)
                                        di_flags |= XFS_DIFLAG_RTINHERIT;