From ed832ad2dcc8dcdbae089e4246d49ddc3a4e01da Mon Sep 17 00:00:00 2001 From: Barry Naujok Date: Fri, 19 May 2006 06:08:50 +0000 Subject: [PATCH] Add degframentation exclusion support Merge of master-melb:xfs-cmds:25987a by kenmcd. Add no-defrag flag support to xfs_db --- db/inode.c | 3 +++ include/xfs_dinode.h | 4 +++- include/xfs_fs.h | 1 + io/attr.c | 5 ++++- man/man3/xfsctl.3 | 5 +++++ 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/db/inode.c b/db/inode.c index 7a76e178f..597464aed 100644 --- a/db/inode.c +++ b/db/inode.c @@ -138,6 +138,9 @@ const field_t inode_core_flds[] = { { "extszinherit", FLDT_UINT1, OI(COFF(flags) + bitsz(__uint16_t) - XFS_DIFLAG_EXTSZINHERIT_BIT-1),C1, 0, TYP_NONE }, + { "nodefrag", FLDT_UINT1, + OI(COFF(flags) + bitsz(__uint16_t) - XFS_DIFLAG_NODEFRAG_BIT-1),C1, + 0, TYP_NONE }, { "gen", FLDT_UINT32D, OI(COFF(gen)), C1, 0, TYP_NONE }, { NULL } }; diff --git a/include/xfs_dinode.h b/include/xfs_dinode.h index 79d0d9e1f..77d537782 100644 --- a/include/xfs_dinode.h +++ b/include/xfs_dinode.h @@ -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__ */ diff --git a/include/xfs_fs.h b/include/xfs_fs.h index 14010f1fa..a55914471 100644 --- a/include/xfs_fs.h +++ b/include/xfs_fs.h @@ -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 */ /* diff --git a/io/attr.c b/io/attr.c index c59b3d928..a2c6d55ec 100644 --- a/io/attr.c +++ b/io/attr.c @@ -46,9 +46,10 @@ static struct xflags { { XFS_XFLAG_NOSYMLINKS, "n", "nosymlinks" }, { XFS_XFLAG_EXTSIZE, "e", "extsize" }, { XFS_XFLAG_EXTSZINHERIT, "E", "extsz-inherit" }, + { XFS_XFLAG_NODEFRAG, "f", "no-defrag" }, { 0, NULL, NULL } }; -#define CHATTR_XFLAG_LIST "r"/*p*/"iasAdtPneE" +#define CHATTR_XFLAG_LIST "r"/*p*/"iasAdtPneEf" static void lsattr_help(void) @@ -70,6 +71,7 @@ lsattr_help(void) " n -- symbolic links cannot be created in this directory\n" " e -- for non-realtime files, observe the inode extent size value\n" " E -- children created in this directory inherit the extent size value\n" +" f -- do not include this file when defragmenting the filesystem\n" "\n" " Options:\n" " -R -- recursively descend (useful when current file is a directory)\n" @@ -103,6 +105,7 @@ chattr_help(void) " +/-n -- set/clear the no-symbolic-links flag\n" " +/-e -- set/clear the extent-size flag\n" " +/-E -- set/clear the extent-size inheritance flag\n" +" +/-f -- set/clear the no-defrag flag\n" " Note1: user must have certain capabilities to modify immutable/append-only.\n" " Note2: immutable/append-only files cannot be deleted; removing these files\n" " requires the immutable/append-only flag to be cleared first.\n" diff --git a/man/man3/xfsctl.3 b/man/man3/xfsctl.3 index 78cf7af13..e88339978 100644 --- a/man/man3/xfsctl.3 +++ b/man/man3/xfsctl.3 @@ -221,6 +221,11 @@ the directory will inherit the parents basic extent size value (see below). Can only be set on a directory. .TP +.SM "Bit 13 (0x2000) \- XFS_XFLAG_NODEFRAG" +The file should be skipped during a defragment operation. When +applied to a directory, new files and directories created will +inherit the no\-defrag bit. +.TP .SM "Bit 31 (0x80000000) \- XFS_XFLAG_HASATTR" The file has extended attributes associated with it. .RE -- 2.47.2