diff options
Diffstat (limited to 'fs/xfs/libxfs')
| -rw-r--r-- | fs/xfs/libxfs/xfs_attr_leaf.c | 2 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_bmap.c | 20 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_bmap.h | 33 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_format.h | 24 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_fs.h | 576 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_sb.c | 320 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_sb.h | 11 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_shared.h | 33 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_symlink_remote.c | 2 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_trans_resv.c | 14 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_trans_resv.h | 1 | ||||
| -rw-r--r-- | fs/xfs/libxfs/xfs_types.h | 137 |
12 files changed, 929 insertions, 244 deletions
diff --git a/fs/xfs/libxfs/xfs_attr_leaf.c b/fs/xfs/libxfs/xfs_attr_leaf.c index 5d38e8b8a913..15105dbc9e28 100644 --- a/fs/xfs/libxfs/xfs_attr_leaf.c +++ b/fs/xfs/libxfs/xfs_attr_leaf.c | |||
| @@ -403,7 +403,7 @@ xfs_sbversion_add_attr2(xfs_mount_t *mp, xfs_trans_t *tp) | |||
| 403 | if (!xfs_sb_version_hasattr2(&mp->m_sb)) { | 403 | if (!xfs_sb_version_hasattr2(&mp->m_sb)) { |
| 404 | xfs_sb_version_addattr2(&mp->m_sb); | 404 | xfs_sb_version_addattr2(&mp->m_sb); |
| 405 | spin_unlock(&mp->m_sb_lock); | 405 | spin_unlock(&mp->m_sb_lock); |
| 406 | xfs_mod_sb(tp, XFS_SB_VERSIONNUM | XFS_SB_FEATURES2); | 406 | xfs_log_sb(tp); |
| 407 | } else | 407 | } else |
| 408 | spin_unlock(&mp->m_sb_lock); | 408 | spin_unlock(&mp->m_sb_lock); |
| 409 | } | 409 | } |
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c index b5eb4743f75a..61ec015dca16 100644 --- a/fs/xfs/libxfs/xfs_bmap.c +++ b/fs/xfs/libxfs/xfs_bmap.c | |||
| @@ -973,7 +973,11 @@ xfs_bmap_local_to_extents( | |||
| 973 | *firstblock = args.fsbno; | 973 | *firstblock = args.fsbno; |
| 974 | bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0); | 974 | bp = xfs_btree_get_bufl(args.mp, tp, args.fsbno, 0); |
| 975 | 975 | ||
| 976 | /* initialise the block and copy the data */ | 976 | /* |
| 977 | * Initialise the block and copy the data | ||
| 978 | * | ||
| 979 | * Note: init_fn must set the buffer log item type correctly! | ||
| 980 | */ | ||
| 977 | init_fn(tp, bp, ip, ifp); | 981 | init_fn(tp, bp, ip, ifp); |
| 978 | 982 | ||
| 979 | /* account for the change in fork size and log everything */ | 983 | /* account for the change in fork size and log everything */ |
| @@ -1221,22 +1225,20 @@ xfs_bmap_add_attrfork( | |||
| 1221 | goto bmap_cancel; | 1225 | goto bmap_cancel; |
| 1222 | if (!xfs_sb_version_hasattr(&mp->m_sb) || | 1226 | if (!xfs_sb_version_hasattr(&mp->m_sb) || |
| 1223 | (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2)) { | 1227 | (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2)) { |
| 1224 | __int64_t sbfields = 0; | 1228 | bool log_sb = false; |
| 1225 | 1229 | ||
| 1226 | spin_lock(&mp->m_sb_lock); | 1230 | spin_lock(&mp->m_sb_lock); |
| 1227 | if (!xfs_sb_version_hasattr(&mp->m_sb)) { | 1231 | if (!xfs_sb_version_hasattr(&mp->m_sb)) { |
| 1228 | xfs_sb_version_addattr(&mp->m_sb); | 1232 | xfs_sb_version_addattr(&mp->m_sb); |
| 1229 | sbfields |= XFS_SB_VERSIONNUM; | 1233 | log_sb = true; |
| 1230 | } | 1234 | } |
| 1231 | if (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2) { | 1235 | if (!xfs_sb_version_hasattr2(&mp->m_sb) && version == 2) { |
| 1232 | xfs_sb_version_addattr2(&mp->m_sb); | 1236 | xfs_sb_version_addattr2(&mp->m_sb); |
| 1233 | sbfields |= (XFS_SB_VERSIONNUM | XFS_SB_FEATURES2); | 1237 | log_sb = true; |
| 1234 | } | 1238 | } |
| 1235 | if (sbfields) { | 1239 | spin_unlock(&mp->m_sb_lock); |
| 1236 | spin_unlock(&mp->m_sb_lock); | 1240 | if (log_sb) |
| 1237 | xfs_mod_sb(tp, sbfields); | 1241 | xfs_log_sb(tp); |
| 1238 | } else | ||
| 1239 | spin_unlock(&mp->m_sb_lock); | ||
| 1240 | } | 1242 | } |
| 1241 | 1243 | ||
| 1242 | error = xfs_bmap_finish(&tp, &flist, &committed); | 1244 | error = xfs_bmap_finish(&tp, &flist, &committed); |
diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h index 44db6db86402..b9d8a499d2c4 100644 --- a/fs/xfs/libxfs/xfs_bmap.h +++ b/fs/xfs/libxfs/xfs_bmap.h | |||
| @@ -28,6 +28,37 @@ struct xfs_trans; | |||
| 28 | extern kmem_zone_t *xfs_bmap_free_item_zone; | 28 | extern kmem_zone_t *xfs_bmap_free_item_zone; |
| 29 | 29 | ||
| 30 | /* | 30 | /* |
| 31 | * Argument structure for xfs_bmap_alloc. | ||
| 32 | */ | ||
| 33 | struct xfs_bmalloca { | ||
| 34 | xfs_fsblock_t *firstblock; /* i/o first block allocated */ | ||
| 35 | struct xfs_bmap_free *flist; /* bmap freelist */ | ||
| 36 | struct xfs_trans *tp; /* transaction pointer */ | ||
| 37 | struct xfs_inode *ip; /* incore inode pointer */ | ||
| 38 | struct xfs_bmbt_irec prev; /* extent before the new one */ | ||
| 39 | struct xfs_bmbt_irec got; /* extent after, or delayed */ | ||
| 40 | |||
| 41 | xfs_fileoff_t offset; /* offset in file filling in */ | ||
| 42 | xfs_extlen_t length; /* i/o length asked/allocated */ | ||
| 43 | xfs_fsblock_t blkno; /* starting block of new extent */ | ||
| 44 | |||
| 45 | struct xfs_btree_cur *cur; /* btree cursor */ | ||
| 46 | xfs_extnum_t idx; /* current extent index */ | ||
| 47 | int nallocs;/* number of extents alloc'd */ | ||
| 48 | int logflags;/* flags for transaction logging */ | ||
| 49 | |||
| 50 | xfs_extlen_t total; /* total blocks needed for xaction */ | ||
| 51 | xfs_extlen_t minlen; /* minimum allocation size (blocks) */ | ||
| 52 | xfs_extlen_t minleft; /* amount must be left after alloc */ | ||
| 53 | bool eof; /* set if allocating past last extent */ | ||
| 54 | bool wasdel; /* replacing a delayed allocation */ | ||
| 55 | bool userdata;/* set if is user data */ | ||
| 56 | bool aeof; /* allocated space at eof */ | ||
| 57 | bool conv; /* overwriting unwritten extents */ | ||
| 58 | int flags; | ||
| 59 | }; | ||
| 60 | |||
| 61 | /* | ||
| 31 | * List of extents to be free "later". | 62 | * List of extents to be free "later". |
| 32 | * The list is kept sorted on xbf_startblock. | 63 | * The list is kept sorted on xbf_startblock. |
| 33 | */ | 64 | */ |
| @@ -149,6 +180,8 @@ void xfs_bmap_local_to_extents_empty(struct xfs_inode *ip, int whichfork); | |||
| 149 | void xfs_bmap_add_free(xfs_fsblock_t bno, xfs_filblks_t len, | 180 | void xfs_bmap_add_free(xfs_fsblock_t bno, xfs_filblks_t len, |
| 150 | struct xfs_bmap_free *flist, struct xfs_mount *mp); | 181 | struct xfs_bmap_free *flist, struct xfs_mount *mp); |
| 151 | void xfs_bmap_cancel(struct xfs_bmap_free *flist); | 182 | void xfs_bmap_cancel(struct xfs_bmap_free *flist); |
| 183 | int xfs_bmap_finish(struct xfs_trans **tp, struct xfs_bmap_free *flist, | ||
| 184 | int *committed); | ||
| 152 | void xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork); | 185 | void xfs_bmap_compute_maxlevels(struct xfs_mount *mp, int whichfork); |
| 153 | int xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip, | 186 | int xfs_bmap_first_unused(struct xfs_trans *tp, struct xfs_inode *ip, |
| 154 | xfs_extlen_t len, xfs_fileoff_t *unused, int whichfork); | 187 | xfs_extlen_t len, xfs_fileoff_t *unused, int whichfork); |
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index fbd6da263571..8eb718979383 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h | |||
| @@ -151,10 +151,13 @@ typedef struct xfs_sb { | |||
| 151 | __uint32_t sb_features2; /* additional feature bits */ | 151 | __uint32_t sb_features2; /* additional feature bits */ |
| 152 | 152 | ||
| 153 | /* | 153 | /* |
| 154 | * bad features2 field as a result of failing to pad the sb | 154 | * bad features2 field as a result of failing to pad the sb structure to |
| 155 | * structure to 64 bits. Some machines will be using this field | 155 | * 64 bits. Some machines will be using this field for features2 bits. |
| 156 | * for features2 bits. Easiest just to mark it bad and not use | 156 | * Easiest just to mark it bad and not use it for anything else. |
| 157 | * it for anything else. | 157 | * |
| 158 | * This is not kept up to date in memory; it is always overwritten by | ||
| 159 | * the value in sb_features2 when formatting the incore superblock to | ||
| 160 | * the disk buffer. | ||
| 158 | */ | 161 | */ |
| 159 | __uint32_t sb_bad_features2; | 162 | __uint32_t sb_bad_features2; |
| 160 | 163 | ||
| @@ -304,8 +307,8 @@ typedef enum { | |||
| 304 | #define XFS_SB_ICOUNT XFS_SB_MVAL(ICOUNT) | 307 | #define XFS_SB_ICOUNT XFS_SB_MVAL(ICOUNT) |
| 305 | #define XFS_SB_IFREE XFS_SB_MVAL(IFREE) | 308 | #define XFS_SB_IFREE XFS_SB_MVAL(IFREE) |
| 306 | #define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS) | 309 | #define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS) |
| 307 | #define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2) | 310 | #define XFS_SB_FEATURES2 (XFS_SB_MVAL(FEATURES2) | \ |
| 308 | #define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2) | 311 | XFS_SB_MVAL(BAD_FEATURES2)) |
| 309 | #define XFS_SB_FEATURES_COMPAT XFS_SB_MVAL(FEATURES_COMPAT) | 312 | #define XFS_SB_FEATURES_COMPAT XFS_SB_MVAL(FEATURES_COMPAT) |
| 310 | #define XFS_SB_FEATURES_RO_COMPAT XFS_SB_MVAL(FEATURES_RO_COMPAT) | 313 | #define XFS_SB_FEATURES_RO_COMPAT XFS_SB_MVAL(FEATURES_RO_COMPAT) |
| 311 | #define XFS_SB_FEATURES_INCOMPAT XFS_SB_MVAL(FEATURES_INCOMPAT) | 314 | #define XFS_SB_FEATURES_INCOMPAT XFS_SB_MVAL(FEATURES_INCOMPAT) |
| @@ -319,9 +322,9 @@ typedef enum { | |||
| 319 | XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \ | 322 | XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \ |
| 320 | XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \ | 323 | XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \ |
| 321 | XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \ | 324 | XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \ |
| 322 | XFS_SB_BAD_FEATURES2 | XFS_SB_FEATURES_COMPAT | \ | 325 | XFS_SB_FEATURES_COMPAT | XFS_SB_FEATURES_RO_COMPAT | \ |
| 323 | XFS_SB_FEATURES_RO_COMPAT | XFS_SB_FEATURES_INCOMPAT | \ | 326 | XFS_SB_FEATURES_INCOMPAT | XFS_SB_FEATURES_LOG_INCOMPAT | \ |
| 324 | XFS_SB_FEATURES_LOG_INCOMPAT | XFS_SB_PQUOTINO) | 327 | XFS_SB_PQUOTINO) |
| 325 | 328 | ||
| 326 | 329 | ||
| 327 | /* | 330 | /* |
| @@ -453,13 +456,11 @@ static inline void xfs_sb_version_addattr2(struct xfs_sb *sbp) | |||
| 453 | { | 456 | { |
| 454 | sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; | 457 | sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; |
| 455 | sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT; | 458 | sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT; |
| 456 | sbp->sb_bad_features2 |= XFS_SB_VERSION2_ATTR2BIT; | ||
| 457 | } | 459 | } |
| 458 | 460 | ||
| 459 | static inline void xfs_sb_version_removeattr2(struct xfs_sb *sbp) | 461 | static inline void xfs_sb_version_removeattr2(struct xfs_sb *sbp) |
| 460 | { | 462 | { |
| 461 | sbp->sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT; | 463 | sbp->sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT; |
| 462 | sbp->sb_bad_features2 &= ~XFS_SB_VERSION2_ATTR2BIT; | ||
| 463 | if (!sbp->sb_features2) | 464 | if (!sbp->sb_features2) |
| 464 | sbp->sb_versionnum &= ~XFS_SB_VERSION_MOREBITSBIT; | 465 | sbp->sb_versionnum &= ~XFS_SB_VERSION_MOREBITSBIT; |
| 465 | } | 466 | } |
| @@ -475,7 +476,6 @@ static inline void xfs_sb_version_addprojid32bit(struct xfs_sb *sbp) | |||
| 475 | { | 476 | { |
| 476 | sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; | 477 | sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; |
| 477 | sbp->sb_features2 |= XFS_SB_VERSION2_PROJID32BIT; | 478 | sbp->sb_features2 |= XFS_SB_VERSION2_PROJID32BIT; |
| 478 | sbp->sb_bad_features2 |= XFS_SB_VERSION2_PROJID32BIT; | ||
| 479 | } | 479 | } |
| 480 | 480 | ||
| 481 | /* | 481 | /* |
diff --git a/fs/xfs/libxfs/xfs_fs.h b/fs/xfs/libxfs/xfs_fs.h new file mode 100644 index 000000000000..18dc721ca19f --- /dev/null +++ b/fs/xfs/libxfs/xfs_fs.h | |||
| @@ -0,0 +1,576 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 1995-2005 Silicon Graphics, Inc. | ||
| 3 | * All Rights Reserved. | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or | ||
| 6 | * modify it under the terms of the GNU Lesser General Public License | ||
| 7 | * as published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it would be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU Lesser General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU Lesser General Public License | ||
| 15 | * along with this program; if not, write the Free Software Foundation, | ||
| 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | #ifndef __XFS_FS_H__ | ||
| 19 | #define __XFS_FS_H__ | ||
| 20 | |||
| 21 | /* | ||
| 22 | * SGI's XFS filesystem's major stuff (constants, structures) | ||
| 23 | */ | ||
| 24 | |||
| 25 | /* | ||
| 26 | * Direct I/O attribute record used with XFS_IOC_DIOINFO | ||
| 27 | * d_miniosz is the min xfer size, xfer size multiple and file seek offset | ||
| 28 | * alignment. | ||
| 29 | */ | ||
| 30 | #ifndef HAVE_DIOATTR | ||
| 31 | struct dioattr { | ||
| 32 | __u32 d_mem; /* data buffer memory alignment */ | ||
| 33 | __u32 d_miniosz; /* min xfer size */ | ||
| 34 | __u32 d_maxiosz; /* max xfer size */ | ||
| 35 | }; | ||
| 36 | #endif | ||
| 37 | |||
| 38 | /* | ||
| 39 | * Structure for XFS_IOC_FSGETXATTR[A] and XFS_IOC_FSSETXATTR. | ||
| 40 | */ | ||
| 41 | #ifndef HAVE_FSXATTR | ||
| 42 | struct fsxattr { | ||
| 43 | __u32 fsx_xflags; /* xflags field value (get/set) */ | ||
| 44 | __u32 fsx_extsize; /* extsize field value (get/set)*/ | ||
| 45 | __u32 fsx_nextents; /* nextents field value (get) */ | ||
| 46 | __u32 fsx_projid; /* project identifier (get/set) */ | ||
| 47 | unsigned char fsx_pad[12]; | ||
| 48 | }; | ||
| 49 | #endif | ||
| 50 | |||
| 51 | /* | ||
| 52 | * Flags for the bs_xflags/fsx_xflags field | ||
| 53 | * There should be a one-to-one correspondence between these flags and the | ||
| 54 | * XFS_DIFLAG_s. | ||
| 55 | */ | ||
| 56 | #define XFS_XFLAG_REALTIME 0x00000001 /* data in realtime volume */ | ||
| 57 | #define XFS_XFLAG_PREALLOC 0x00000002 /* preallocated file extents */ | ||
| 58 | #define XFS_XFLAG_IMMUTABLE 0x00000008 /* file cannot be modified */ | ||
| 59 | #define XFS_XFLAG_APPEND 0x00000010 /* all writes append */ | ||
| 60 | #define XFS_XFLAG_SYNC 0x00000020 /* all writes synchronous */ | ||
| 61 | #define XFS_XFLAG_NOATIME 0x00000040 /* do not update access time */ | ||
| 62 | #define XFS_XFLAG_NODUMP 0x00000080 /* do not include in backups */ | ||
| 63 | #define XFS_XFLAG_RTINHERIT 0x00000100 /* create with rt bit set */ | ||
| 64 | #define XFS_XFLAG_PROJINHERIT 0x00000200 /* create with parents projid */ | ||
| 65 | #define XFS_XFLAG_NOSYMLINKS 0x00000400 /* disallow symlink creation */ | ||
| 66 | #define XFS_XFLAG_EXTSIZE 0x00000800 /* extent size allocator hint */ | ||
| 67 | #define XFS_XFLAG_EXTSZINHERIT 0x00001000 /* inherit inode extent size */ | ||
| 68 | #define XFS_XFLAG_NODEFRAG 0x00002000 /* do not defragment */ | ||
| 69 | #define XFS_XFLAG_FILESTREAM 0x00004000 /* use filestream allocator */ | ||
| 70 | #define XFS_XFLAG_HASATTR 0x80000000 /* no DIFLAG for this */ | ||
| 71 | |||
| 72 | /* | ||
| 73 | * Structure for XFS_IOC_GETBMAP. | ||
| 74 | * On input, fill in bmv_offset and bmv_length of the first structure | ||
| 75 | * to indicate the area of interest in the file, and bmv_entries with | ||
| 76 | * the number of array elements given back. The first structure is | ||
| 77 | * updated on return to give the offset and length for the next call. | ||
| 78 | */ | ||
| 79 | #ifndef HAVE_GETBMAP | ||
| 80 | struct getbmap { | ||
| 81 | __s64 bmv_offset; /* file offset of segment in blocks */ | ||
| 82 | __s64 bmv_block; /* starting block (64-bit daddr_t) */ | ||
| 83 | __s64 bmv_length; /* length of segment, blocks */ | ||
| 84 | __s32 bmv_count; /* # of entries in array incl. 1st */ | ||
| 85 | __s32 bmv_entries; /* # of entries filled in (output) */ | ||
| 86 | }; | ||
| 87 | #endif | ||
| 88 | |||
| 89 | /* | ||
| 90 | * Structure for XFS_IOC_GETBMAPX. Fields bmv_offset through bmv_entries | ||
| 91 | * are used exactly as in the getbmap structure. The getbmapx structure | ||
| 92 | * has additional bmv_iflags and bmv_oflags fields. The bmv_iflags field | ||
| 93 | * is only used for the first structure. It contains input flags | ||
| 94 | * specifying XFS_IOC_GETBMAPX actions. The bmv_oflags field is filled | ||
| 95 | * in by the XFS_IOC_GETBMAPX command for each returned structure after | ||
| 96 | * the first. | ||
| 97 | */ | ||
| 98 | #ifndef HAVE_GETBMAPX | ||
| 99 | struct getbmapx { | ||
| 100 | __s64 bmv_offset; /* file offset of segment in blocks */ | ||
| 101 | __s64 bmv_block; /* starting block (64-bit daddr_t) */ | ||
| 102 | __s64 bmv_length; /* length of segment, blocks */ | ||
| 103 | __s32 bmv_count; /* # of entries in array incl. 1st */ | ||
| 104 | __s32 bmv_entries; /* # of entries filled in (output). */ | ||
| 105 | __s32 bmv_iflags; /* input flags (1st structure) */ | ||
| 106 | __s32 bmv_oflags; /* output flags (after 1st structure)*/ | ||
| 107 | __s32 bmv_unused1; /* future use */ | ||
| 108 | __s32 bmv_unused2; /* future use */ | ||
| 109 | }; | ||
| 110 | #endif | ||
| 111 | |||
| 112 | /* bmv_iflags values - set by XFS_IOC_GETBMAPX caller. */ | ||
| 113 | #define BMV_IF_ATTRFORK 0x1 /* return attr fork rather than data */ | ||
| 114 | #define BMV_IF_NO_DMAPI_READ 0x2 /* Do not generate DMAPI read event */ | ||
| 115 | #define BMV_IF_PREALLOC 0x4 /* rtn status BMV_OF_PREALLOC if req */ | ||
| 116 | #define BMV_IF_DELALLOC 0x8 /* rtn status BMV_OF_DELALLOC if req */ | ||
| 117 | #define BMV_IF_NO_HOLES 0x10 /* Do not return holes */ | ||
| 118 | #define BMV_IF_VALID \ | ||
| 119 | (BMV_IF_ATTRFORK|BMV_IF_NO_DMAPI_READ|BMV_IF_PREALLOC| \ | ||
| 120 | BMV_IF_DELALLOC|BMV_IF_NO_HOLES) | ||
| 121 | |||
| 122 | /* bmv_oflags values - returned for each non-header segment */ | ||
| 123 | #define BMV_OF_PREALLOC 0x1 /* segment = unwritten pre-allocation */ | ||
| 124 | #define BMV_OF_DELALLOC 0x2 /* segment = delayed allocation */ | ||
| 125 | #define BMV_OF_LAST 0x4 /* segment is the last in the file */ | ||
| 126 | |||
| 127 | /* | ||
| 128 | * Structure for XFS_IOC_FSSETDM. | ||
| 129 | * For use by backup and restore programs to set the XFS on-disk inode | ||
| 130 | * fields di_dmevmask and di_dmstate. These must be set to exactly and | ||
| 131 | * only values previously obtained via xfs_bulkstat! (Specifically the | ||
| 132 | * xfs_bstat_t fields bs_dmevmask and bs_dmstate.) | ||
| 133 | */ | ||
| 134 | #ifndef HAVE_FSDMIDATA | ||
| 135 | struct fsdmidata { | ||
| 136 | __u32 fsd_dmevmask; /* corresponds to di_dmevmask */ | ||
| 137 | __u16 fsd_padding; | ||
| 138 | __u16 fsd_dmstate; /* corresponds to di_dmstate */ | ||
| 139 | }; | ||
| 140 | #endif | ||
| 141 | |||
| 142 | /* | ||
| 143 | * File segment locking set data type for 64 bit access. | ||
| 144 | * Also used for all the RESV/FREE interfaces. | ||
| 145 | */ | ||
| 146 | typedef struct xfs_flock64 { | ||
| 147 | __s16 l_type; | ||
| 148 | __s16 l_whence; | ||
| 149 | __s64 l_start; | ||
| 150 | __s64 l_len; /* len == 0 means until end of file */ | ||
| 151 | __s32 l_sysid; | ||
| 152 | __u32 l_pid; | ||
| 153 | __s32 l_pad[4]; /* reserve area */ | ||
| 154 | } xfs_flock64_t; | ||
| 155 | |||
| 156 | /* | ||
| 157 | * Output for XFS_IOC_FSGEOMETRY_V1 | ||
| 158 | */ | ||
| 159 | typedef struct xfs_fsop_geom_v1 { | ||
| 160 | __u32 blocksize; /* filesystem (data) block size */ | ||
| 161 | __u32 rtextsize; /* realtime extent size */ | ||
| 162 | __u32 agblocks; /* fsblocks in an AG */ | ||
| 163 | __u32 agcount; /* number of allocation groups */ | ||
| 164 | __u32 logblocks; /* fsblocks in the log */ | ||
| 165 | __u32 sectsize; /* (data) sector size, bytes */ | ||
| 166 | __u32 inodesize; /* inode size in bytes */ | ||
| 167 | __u32 imaxpct; /* max allowed inode space(%) */ | ||
| 168 | __u64 datablocks; /* fsblocks in data subvolume */ | ||
| 169 | __u64 rtblocks; /* fsblocks in realtime subvol */ | ||
| 170 | __u64 rtextents; /* rt extents in realtime subvol*/ | ||
| 171 | __u64 logstart; /* starting fsblock of the log */ | ||
| 172 | unsigned char uuid[16]; /* unique id of the filesystem */ | ||
| 173 | __u32 sunit; /* stripe unit, fsblocks */ | ||
| 174 | __u32 swidth; /* stripe width, fsblocks */ | ||
| 175 | __s32 version; /* structure version */ | ||
| 176 | __u32 flags; /* superblock version flags */ | ||
| 177 | __u32 logsectsize; /* log sector size, bytes */ | ||
| 178 | __u32 rtsectsize; /* realtime sector size, bytes */ | ||
| 179 | __u32 dirblocksize; /* directory block size, bytes */ | ||
| 180 | } xfs_fsop_geom_v1_t; | ||
| 181 | |||
| 182 | /* | ||
| 183 | * Output for XFS_IOC_FSGEOMETRY | ||
| 184 | */ | ||
| 185 | typedef struct xfs_fsop_geom { | ||
| 186 | __u32 blocksize; /* filesystem (data) block size */ | ||
| 187 | __u32 rtextsize; /* realtime extent size */ | ||
| 188 | __u32 agblocks; /* fsblocks in an AG */ | ||
| 189 | __u32 agcount; /* number of allocation groups */ | ||
| 190 | __u32 logblocks; /* fsblocks in the log */ | ||
| 191 | __u32 sectsize; /* (data) sector size, bytes */ | ||
| 192 | __u32 inodesize; /* inode size in bytes */ | ||
| 193 | __u32 imaxpct; /* max allowed inode space(%) */ | ||
| 194 | __u64 datablocks; /* fsblocks in data subvolume */ | ||
| 195 | __u64 rtblocks; /* fsblocks in realtime subvol */ | ||
| 196 | __u64 rtextents; /* rt extents in realtime subvol*/ | ||
| 197 | __u64 logstart; /* starting fsblock of the log */ | ||
| 198 | unsigned char uuid[16]; /* unique id of the filesystem */ | ||
| 199 | __u32 sunit; /* stripe unit, fsblocks */ | ||
| 200 | __u32 swidth; /* stripe width, fsblocks */ | ||
| 201 | __s32 version; /* structure version */ | ||
| 202 | __u32 flags; /* superblock version flags */ | ||
| 203 | __u32 logsectsize; /* log sector size, bytes */ | ||
| 204 | __u32 rtsectsize; /* realtime sector size, bytes */ | ||
| 205 | __u32 dirblocksize; /* directory block size, bytes */ | ||
| 206 | __u32 logsunit; /* log stripe unit, bytes */ | ||
| 207 | } xfs_fsop_geom_t; | ||
| 208 | |||
| 209 | /* Output for XFS_FS_COUNTS */ | ||
| 210 | typedef struct xfs_fsop_counts { | ||
| 211 | __u64 freedata; /* free data section blocks */ | ||
| 212 | __u64 freertx; /* free rt extents */ | ||
| 213 | __u64 freeino; /* free inodes */ | ||
| 214 | __u64 allocino; /* total allocated inodes */ | ||
| 215 | } xfs_fsop_counts_t; | ||
| 216 | |||
| 217 | /* Input/Output for XFS_GET_RESBLKS and XFS_SET_RESBLKS */ | ||
| 218 | typedef struct xfs_fsop_resblks { | ||
| 219 | __u64 resblks; | ||
| 220 | __u64 resblks_avail; | ||
| 221 | } xfs_fsop_resblks_t; | ||
| 222 | |||
| 223 | #define XFS_FSOP_GEOM_VERSION 0 | ||
| 224 | |||
| 225 | #define XFS_FSOP_GEOM_FLAGS_ATTR 0x0001 /* attributes in use */ | ||
| 226 | #define XFS_FSOP_GEOM_FLAGS_NLINK 0x0002 /* 32-bit nlink values */ | ||
| 227 | #define XFS_FSOP_GEOM_FLAGS_QUOTA 0x0004 /* quotas enabled */ | ||
| 228 | #define XFS_FSOP_GEOM_FLAGS_IALIGN 0x0008 /* inode alignment */ | ||
| 229 | #define XFS_FSOP_GEOM_FLAGS_DALIGN 0x0010 /* large data alignment */ | ||
| 230 | #define XFS_FSOP_GEOM_FLAGS_SHARED 0x0020 /* read-only shared */ | ||
| 231 | #define XFS_FSOP_GEOM_FLAGS_EXTFLG 0x0040 /* special extent flag */ | ||
| 232 | #define XFS_FSOP_GEOM_FLAGS_DIRV2 0x0080 /* directory version 2 */ | ||
| 233 | #define XFS_FSOP_GEOM_FLAGS_LOGV2 0x0100 /* log format version 2 */ | ||
| 234 | #define XFS_FSOP_GEOM_FLAGS_SECTOR 0x0200 /* sector sizes >1BB */ | ||
| 235 | #define XFS_FSOP_GEOM_FLAGS_ATTR2 0x0400 /* inline attributes rework */ | ||
| 236 | #define XFS_FSOP_GEOM_FLAGS_PROJID32 0x0800 /* 32-bit project IDs */ | ||
| 237 | #define XFS_FSOP_GEOM_FLAGS_DIRV2CI 0x1000 /* ASCII only CI names */ | ||
| 238 | #define XFS_FSOP_GEOM_FLAGS_LAZYSB 0x4000 /* lazy superblock counters */ | ||
| 239 | #define XFS_FSOP_GEOM_FLAGS_V5SB 0x8000 /* version 5 superblock */ | ||
| 240 | #define XFS_FSOP_GEOM_FLAGS_FTYPE 0x10000 /* inode directory types */ | ||
| 241 | #define XFS_FSOP_GEOM_FLAGS_FINOBT 0x20000 /* free inode btree */ | ||
| 242 | |||
| 243 | /* | ||
| 244 | * Minimum and maximum sizes need for growth checks. | ||
| 245 | * | ||
| 246 | * Block counts are in units of filesystem blocks, not basic blocks. | ||
| 247 | */ | ||
| 248 | #define XFS_MIN_AG_BLOCKS 64 | ||
| 249 | #define XFS_MIN_LOG_BLOCKS 512ULL | ||
| 250 | #define XFS_MAX_LOG_BLOCKS (1024 * 1024ULL) | ||
| 251 | #define XFS_MIN_LOG_BYTES (10 * 1024 * 1024ULL) | ||
| 252 | |||
| 253 | /* keep the maximum size under 2^31 by a small amount */ | ||
| 254 | #define XFS_MAX_LOG_BYTES \ | ||
| 255 | ((2 * 1024 * 1024 * 1024ULL) - XFS_MIN_LOG_BYTES) | ||
| 256 | |||
| 257 | /* Used for sanity checks on superblock */ | ||
| 258 | #define XFS_MAX_DBLOCKS(s) ((xfs_rfsblock_t)(s)->sb_agcount * (s)->sb_agblocks) | ||
| 259 | #define XFS_MIN_DBLOCKS(s) ((xfs_rfsblock_t)((s)->sb_agcount - 1) * \ | ||
| 260 | (s)->sb_agblocks + XFS_MIN_AG_BLOCKS) | ||
| 261 | |||
| 262 | /* | ||
| 263 | * Structures for XFS_IOC_FSGROWFSDATA, XFS_IOC_FSGROWFSLOG & XFS_IOC_FSGROWFSRT | ||
| 264 | */ | ||
| 265 | typedef struct xfs_growfs_data { | ||
| 266 | __u64 newblocks; /* new data subvol size, fsblocks */ | ||
| 267 | __u32 imaxpct; /* new inode space percentage limit */ | ||
| 268 | } xfs_growfs_data_t; | ||
| 269 | |||
| 270 | typedef struct xfs_growfs_log { | ||
| 271 | __u32 newblocks; /* new log size, fsblocks */ | ||
| 272 | __u32 isint; /* 1 if new log is internal */ | ||
| 273 | } xfs_growfs_log_t; | ||
| 274 | |||
| 275 | typedef struct xfs_growfs_rt { | ||
| 276 | __u64 newblocks; /* new realtime size, fsblocks */ | ||
| 277 | __u32 extsize; /* new realtime extent size, fsblocks */ | ||
| 278 | } xfs_growfs_rt_t; | ||
| 279 | |||
| 280 | |||
| 281 | /* | ||
| 282 | * Structures returned from ioctl XFS_IOC_FSBULKSTAT & XFS_IOC_FSBULKSTAT_SINGLE | ||
| 283 | */ | ||
| 284 | typedef struct xfs_bstime { | ||
| 285 | time_t tv_sec; /* seconds */ | ||
| 286 | __s32 tv_nsec; /* and nanoseconds */ | ||
| 287 | } xfs_bstime_t; | ||
| 288 | |||
| 289 | typedef struct xfs_bstat { | ||
| 290 | __u64 bs_ino; /* inode number */ | ||
| 291 | __u16 bs_mode; /* type and mode */ | ||
| 292 | __u16 bs_nlink; /* number of links */ | ||
| 293 | __u32 bs_uid; /* user id */ | ||
| 294 | __u32 bs_gid; /* group id */ | ||
| 295 | __u32 bs_rdev; /* device value */ | ||
| 296 | __s32 bs_blksize; /* block size */ | ||
| 297 | __s64 bs_size; /* file size */ | ||
| 298 | xfs_bstime_t bs_atime; /* access time */ | ||
| 299 | xfs_bstime_t bs_mtime; /* modify time */ | ||
| 300 | xfs_bstime_t bs_ctime; /* inode change time */ | ||
| 301 | int64_t bs_blocks; /* number of blocks */ | ||
| 302 | __u32 bs_xflags; /* extended flags */ | ||
| 303 | __s32 bs_extsize; /* extent size */ | ||
| 304 | __s32 bs_extents; /* number of extents */ | ||
| 305 | __u32 bs_gen; /* generation count */ | ||
| 306 | __u16 bs_projid_lo; /* lower part of project id */ | ||
| 307 | #define bs_projid bs_projid_lo /* (previously just bs_projid) */ | ||
| 308 | __u16 bs_forkoff; /* inode fork offset in bytes */ | ||
| 309 | __u16 bs_projid_hi; /* higher part of project id */ | ||
| 310 | unsigned char bs_pad[10]; /* pad space, unused */ | ||
| 311 | __u32 bs_dmevmask; /* DMIG event mask */ | ||
| 312 | __u16 bs_dmstate; /* DMIG state info */ | ||
| 313 | __u16 bs_aextents; /* attribute number of extents */ | ||
| 314 | } xfs_bstat_t; | ||
| 315 | |||
| 316 | /* | ||
| 317 | * Project quota id helpers (previously projid was 16bit only | ||
| 318 | * and using two 16bit values to hold new 32bit projid was choosen | ||
| 319 | * to retain compatibility with "old" filesystems). | ||
| 320 | */ | ||
| 321 | static inline __uint32_t | ||
| 322 | bstat_get_projid(struct xfs_bstat *bs) | ||
| 323 | { | ||
| 324 | return (__uint32_t)bs->bs_projid_hi << 16 | bs->bs_projid_lo; | ||
| 325 | } | ||
| 326 | |||
| 327 | /* | ||
| 328 | * The user-level BulkStat Request interface structure. | ||
| 329 | */ | ||
| 330 | typedef struct xfs_fsop_bulkreq { | ||
| 331 | __u64 __user *lastip; /* last inode # pointer */ | ||
| 332 | __s32 icount; /* count of entries in buffer */ | ||
| 333 | void __user *ubuffer;/* user buffer for inode desc. */ | ||
| 334 | __s32 __user *ocount; /* output count pointer */ | ||
| 335 | } xfs_fsop_bulkreq_t; | ||
| 336 | |||
| 337 | |||
| 338 | /* | ||
| 339 | * Structures returned from xfs_inumbers routine (XFS_IOC_FSINUMBERS). | ||
| 340 | */ | ||
| 341 | typedef struct xfs_inogrp { | ||
| 342 | __u64 xi_startino; /* starting inode number */ | ||
| 343 | __s32 xi_alloccount; /* # bits set in allocmask */ | ||
| 344 | __u64 xi_allocmask; /* mask of allocated inodes */ | ||
| 345 | } xfs_inogrp_t; | ||
| 346 | |||
| 347 | |||
| 348 | /* | ||
| 349 | * Error injection. | ||
| 350 | */ | ||
| 351 | typedef struct xfs_error_injection { | ||
| 352 | __s32 fd; | ||
| 353 | __s32 errtag; | ||
| 354 | } xfs_error_injection_t; | ||
| 355 | |||
| 356 | |||
| 357 | /* | ||
| 358 | * Speculative preallocation trimming. | ||
| 359 | */ | ||
| 360 | #define XFS_EOFBLOCKS_VERSION 1 | ||
| 361 | struct xfs_fs_eofblocks { | ||
| 362 | __u32 eof_version; | ||
| 363 | __u32 eof_flags; | ||
| 364 | uid_t eof_uid; | ||
| 365 | gid_t eof_gid; | ||
| 366 | prid_t eof_prid; | ||
| 367 | __u32 pad32; | ||
| 368 | __u64 eof_min_file_size; | ||
| 369 | __u64 pad64[12]; | ||
| 370 | }; | ||
| 371 | |||
| 372 | /* eof_flags values */ | ||
| 373 | #define XFS_EOF_FLAGS_SYNC (1 << 0) /* sync/wait mode scan */ | ||
| 374 | #define XFS_EOF_FLAGS_UID (1 << 1) /* filter by uid */ | ||
| 375 | #define XFS_EOF_FLAGS_GID (1 << 2) /* filter by gid */ | ||
| 376 | #define XFS_EOF_FLAGS_PRID (1 << 3) /* filter by project id */ | ||
| 377 | #define XFS_EOF_FLAGS_MINFILESIZE (1 << 4) /* filter by min file size */ | ||
| 378 | #define XFS_EOF_FLAGS_UNION (1 << 5) /* union filter algorithm; | ||
| 379 | * kernel only, not included in | ||
| 380 | * valid mask */ | ||
| 381 | #define XFS_EOF_FLAGS_VALID \ | ||
| 382 | (XFS_EOF_FLAGS_SYNC | \ | ||
| 383 | XFS_EOF_FLAGS_UID | \ | ||
| 384 | XFS_EOF_FLAGS_GID | \ | ||
| 385 | XFS_EOF_FLAGS_PRID | \ | ||
| 386 | XFS_EOF_FLAGS_MINFILESIZE) | ||
| 387 | |||
| 388 | |||
| 389 | /* | ||
| 390 | * The user-level Handle Request interface structure. | ||
| 391 | */ | ||
| 392 | typedef struct xfs_fsop_handlereq { | ||
| 393 | __u32 fd; /* fd for FD_TO_HANDLE */ | ||
| 394 | void __user *path; /* user pathname */ | ||
| 395 | __u32 oflags; /* open flags */ | ||
| 396 | void __user *ihandle;/* user supplied handle */ | ||
| 397 | __u32 ihandlen; /* user supplied length */ | ||
| 398 | void __user *ohandle;/* user buffer for handle */ | ||
| 399 | __u32 __user *ohandlen;/* user buffer length */ | ||
| 400 | } xfs_fsop_handlereq_t; | ||
| 401 | |||
| 402 | /* | ||
| 403 | * Compound structures for passing args through Handle Request interfaces | ||
| 404 | * xfs_fssetdm_by_handle, xfs_attrlist_by_handle, xfs_attrmulti_by_handle | ||
| 405 | * - ioctls: XFS_IOC_FSSETDM_BY_HANDLE, XFS_IOC_ATTRLIST_BY_HANDLE, and | ||
| 406 | * XFS_IOC_ATTRMULTI_BY_HANDLE | ||
| 407 | */ | ||
| 408 | |||
| 409 | typedef struct xfs_fsop_setdm_handlereq { | ||
| 410 | struct xfs_fsop_handlereq hreq; /* handle information */ | ||
| 411 | struct fsdmidata __user *data; /* DMAPI data */ | ||
| 412 | } xfs_fsop_setdm_handlereq_t; | ||
| 413 | |||
| 414 | typedef struct xfs_attrlist_cursor { | ||
| 415 | __u32 opaque[4]; | ||
| 416 | } xfs_attrlist_cursor_t; | ||
| 417 | |||
| 418 | typedef struct xfs_fsop_attrlist_handlereq { | ||
| 419 | struct xfs_fsop_handlereq hreq; /* handle interface structure */ | ||
| 420 | struct xfs_attrlist_cursor pos; /* opaque cookie, list offset */ | ||
| 421 | __u32 flags; /* which namespace to use */ | ||
| 422 | __u32 buflen; /* length of buffer supplied */ | ||
| 423 | void __user *buffer; /* returned names */ | ||
| 424 | } xfs_fsop_attrlist_handlereq_t; | ||
| 425 | |||
| 426 | typedef struct xfs_attr_multiop { | ||
| 427 | __u32 am_opcode; | ||
| 428 | #define ATTR_OP_GET 1 /* return the indicated attr's value */ | ||
| 429 | #define ATTR_OP_SET 2 /* set/create the indicated attr/value pair */ | ||
| 430 | #define ATTR_OP_REMOVE 3 /* remove the indicated attr */ | ||
| 431 | __s32 am_error; | ||
| 432 | void __user *am_attrname; | ||
| 433 | void __user *am_attrvalue; | ||
| 434 | __u32 am_length; | ||
| 435 | __u32 am_flags; | ||
| 436 | } xfs_attr_multiop_t; | ||
| 437 | |||
| 438 | typedef struct xfs_fsop_attrmulti_handlereq { | ||
| 439 | struct xfs_fsop_handlereq hreq; /* handle interface structure */ | ||
| 440 | __u32 opcount;/* count of following multiop */ | ||
| 441 | struct xfs_attr_multiop __user *ops; /* attr_multi data */ | ||
| 442 | } xfs_fsop_attrmulti_handlereq_t; | ||
| 443 | |||
| 444 | /* | ||
| 445 | * per machine unique filesystem identifier types. | ||
| 446 | */ | ||
| 447 | typedef struct { __u32 val[2]; } xfs_fsid_t; /* file system id type */ | ||
| 448 | |||
| 449 | typedef struct xfs_fid { | ||
| 450 | __u16 fid_len; /* length of remainder */ | ||
| 451 | __u16 fid_pad; | ||
| 452 | __u32 fid_gen; /* generation number */ | ||
| 453 | __u64 fid_ino; /* 64 bits inode number */ | ||
| 454 | } xfs_fid_t; | ||
| 455 | |||
| 456 | typedef struct xfs_handle { | ||
| 457 | union { | ||
| 458 | __s64 align; /* force alignment of ha_fid */ | ||
| 459 | xfs_fsid_t _ha_fsid; /* unique file system identifier */ | ||
| 460 | } ha_u; | ||
| 461 | xfs_fid_t ha_fid; /* file system specific file ID */ | ||
| 462 | } xfs_handle_t; | ||
| 463 | #define ha_fsid ha_u._ha_fsid | ||
| 464 | |||
| 465 | #define XFS_HSIZE(handle) (((char *) &(handle).ha_fid.fid_pad \ | ||
| 466 | - (char *) &(handle)) \ | ||
| 467 | + (handle).ha_fid.fid_len) | ||
| 468 | |||
| 469 | /* | ||
| 470 | * Structure passed to XFS_IOC_SWAPEXT | ||
| 471 | */ | ||
| 472 | typedef struct xfs_swapext | ||
| 473 | { | ||
| 474 | __int64_t sx_version; /* version */ | ||
| 475 | #define XFS_SX_VERSION 0 | ||
| 476 | __int64_t sx_fdtarget; /* fd of target file */ | ||
| 477 | __int64_t sx_fdtmp; /* fd of tmp file */ | ||
| 478 | xfs_off_t sx_offset; /* offset into file */ | ||
| 479 | xfs_off_t sx_length; /* leng from offset */ | ||
| 480 | char sx_pad[16]; /* pad space, unused */ | ||
| 481 | xfs_bstat_t sx_stat; /* stat of target b4 copy */ | ||
| 482 | } xfs_swapext_t; | ||
| 483 | |||
| 484 | /* | ||
| 485 | * Flags for going down operation | ||
| 486 | */ | ||
| 487 | #define XFS_FSOP_GOING_FLAGS_DEFAULT 0x0 /* going down */ | ||
| 488 | #define XFS_FSOP_GOING_FLAGS_LOGFLUSH 0x1 /* flush log but not data */ | ||
| 489 | #define XFS_FSOP_GOING_FLAGS_NOLOGFLUSH 0x2 /* don't flush log nor data */ | ||
| 490 | |||
| 491 | /* | ||
| 492 | * ioctl commands that are used by Linux filesystems | ||
| 493 | */ | ||
| 494 | #define XFS_IOC_GETXFLAGS FS_IOC_GETFLAGS | ||
| 495 | #define XFS_IOC_SETXFLAGS FS_IOC_SETFLAGS | ||
| 496 | #define XFS_IOC_GETVERSION FS_IOC_GETVERSION | ||
| 497 | |||
| 498 | /* | ||
| 499 | * ioctl commands that replace IRIX fcntl()'s | ||
| 500 | * For 'documentation' purposed more than anything else, | ||
| 501 | * the "cmd #" field reflects the IRIX fcntl number. | ||
| 502 | */ | ||
| 503 | #define XFS_IOC_ALLOCSP _IOW ('X', 10, struct xfs_flock64) | ||
| 504 | #define XFS_IOC_FREESP _IOW ('X', 11, struct xfs_flock64) | ||
| 505 | #define XFS_IOC_DIOINFO _IOR ('X', 30, struct dioattr) | ||
| 506 | #define XFS_IOC_FSGETXATTR _IOR ('X', 31, struct fsxattr) | ||
| 507 | #define XFS_IOC_FSSETXATTR _IOW ('X', 32, struct fsxattr) | ||
| 508 | #define XFS_IOC_ALLOCSP64 _IOW ('X', 36, struct xfs_flock64) | ||
| 509 | #define XFS_IOC_FREESP64 _IOW ('X', 37, struct xfs_flock64) | ||
| 510 | #define XFS_IOC_GETBMAP _IOWR('X', 38, struct getbmap) | ||
| 511 | #define XFS_IOC_FSSETDM _IOW ('X', 39, struct fsdmidata) | ||
| 512 | #define XFS_IOC_RESVSP _IOW ('X', 40, struct xfs_flock64) | ||
| 513 | #define XFS_IOC_UNRESVSP _IOW ('X', 41, struct xfs_flock64) | ||
| 514 | #define XFS_IOC_RESVSP64 _IOW ('X', 42, struct xfs_flock64) | ||
| 515 | #define XFS_IOC_UNRESVSP64 _IOW ('X', 43, struct xfs_flock64) | ||
| 516 | #define XFS_IOC_GETBMAPA _IOWR('X', 44, struct getbmap) | ||
| 517 | #define XFS_IOC_FSGETXATTRA _IOR ('X', 45, struct fsxattr) | ||
| 518 | /* XFS_IOC_SETBIOSIZE ---- deprecated 46 */ | ||
| 519 | /* XFS_IOC_GETBIOSIZE ---- deprecated 47 */ | ||
| 520 | #define XFS_IOC_GETBMAPX _IOWR('X', 56, struct getbmap) | ||
| 521 | #define XFS_IOC_ZERO_RANGE _IOW ('X', 57, struct xfs_flock64) | ||
| 522 | #define XFS_IOC_FREE_EOFBLOCKS _IOR ('X', 58, struct xfs_fs_eofblocks) | ||
| 523 | |||
| 524 | /* | ||
| 525 | * ioctl commands that replace IRIX syssgi()'s | ||
| 526 | */ | ||
| 527 | #define XFS_IOC_FSGEOMETRY_V1 _IOR ('X', 100, struct xfs_fsop_geom_v1) | ||
| 528 | #define XFS_IOC_FSBULKSTAT _IOWR('X', 101, struct xfs_fsop_bulkreq) | ||
| 529 | #define XFS_IOC_FSBULKSTAT_SINGLE _IOWR('X', 102, struct xfs_fsop_bulkreq) | ||
| 530 | #define XFS_IOC_FSINUMBERS _IOWR('X', 103, struct xfs_fsop_bulkreq) | ||
| 531 | #define XFS_IOC_PATH_TO_FSHANDLE _IOWR('X', 104, struct xfs_fsop_handlereq) | ||
| 532 | #define XFS_IOC_PATH_TO_HANDLE _IOWR('X', 105, struct xfs_fsop_handlereq) | ||
| 533 | #define XFS_IOC_FD_TO_HANDLE _IOWR('X', 106, struct xfs_fsop_handlereq) | ||
| 534 | #define XFS_IOC_OPEN_BY_HANDLE _IOWR('X', 107, struct xfs_fsop_handlereq) | ||
| 535 | #define XFS_IOC_READLINK_BY_HANDLE _IOWR('X', 108, struct xfs_fsop_handlereq) | ||
| 536 | #define XFS_IOC_SWAPEXT _IOWR('X', 109, struct xfs_swapext) | ||
| 537 | #define XFS_IOC_FSGROWFSDATA _IOW ('X', 110, struct xfs_growfs_data) | ||
| 538 | #define XFS_IOC_FSGROWFSLOG _IOW ('X', 111, struct xfs_growfs_log) | ||
| 539 | #define XFS_IOC_FSGROWFSRT _IOW ('X', 112, struct xfs_growfs_rt) | ||
| 540 | #define XFS_IOC_FSCOUNTS _IOR ('X', 113, struct xfs_fsop_counts) | ||
| 541 | #define XFS_IOC_SET_RESBLKS _IOWR('X', 114, struct xfs_fsop_resblks) | ||
| 542 | #define XFS_IOC_GET_RESBLKS _IOR ('X', 115, struct xfs_fsop_resblks) | ||
| 543 | #define XFS_IOC_ERROR_INJECTION _IOW ('X', 116, struct xfs_error_injection) | ||
| 544 | #define XFS_IOC_ERROR_CLEARALL _IOW ('X', 117, struct xfs_error_injection) | ||
| 545 | /* XFS_IOC_ATTRCTL_BY_HANDLE -- deprecated 118 */ | ||
| 546 | |||
| 547 | /* XFS_IOC_FREEZE -- FIFREEZE 119 */ | ||
| 548 | /* XFS_IOC_THAW -- FITHAW 120 */ | ||
| 549 | #ifndef FIFREEZE | ||
| 550 | #define XFS_IOC_FREEZE _IOWR('X', 119, int) | ||
| 551 | #define XFS_IOC_THAW _IOWR('X', 120, int) | ||
| 552 | #endif | ||
| 553 | |||
| 554 | #define XFS_IOC_FSSETDM_BY_HANDLE _IOW ('X', 121, struct xfs_fsop_setdm_handlereq) | ||
| 555 | #define XFS_IOC_ATTRLIST_BY_HANDLE _IOW ('X', 122, struct xfs_fsop_attrlist_handlereq) | ||
| 556 | #define XFS_IOC_ATTRMULTI_BY_HANDLE _IOW ('X', 123, struct xfs_fsop_attrmulti_handlereq) | ||
| 557 | #define XFS_IOC_FSGEOMETRY _IOR ('X', 124, struct xfs_fsop_geom) | ||
| 558 | #define XFS_IOC_GOINGDOWN _IOR ('X', 125, __uint32_t) | ||
| 559 | /* XFS_IOC_GETFSUUID ---------- deprecated 140 */ | ||
| 560 | |||
| 561 | |||
| 562 | #ifndef HAVE_BBMACROS | ||
| 563 | /* | ||
| 564 | * Block I/O parameterization. A basic block (BB) is the lowest size of | ||
| 565 | * filesystem allocation, and must equal 512. Length units given to bio | ||
| 566 | * routines are in BB's. | ||
| 567 | */ | ||
| 568 | #define BBSHIFT 9 | ||
| 569 | #define BBSIZE (1<<BBSHIFT) | ||
| 570 | #define BBMASK (BBSIZE-1) | ||
| 571 | #define BTOBB(bytes) (((__u64)(bytes) + BBSIZE - 1) >> BBSHIFT) | ||
| 572 | #define BTOBBT(bytes) ((__u64)(bytes) >> BBSHIFT) | ||
| 573 | #define BBTOB(bbs) ((bbs) << BBSHIFT) | ||
| 574 | #endif | ||
| 575 | |||
| 576 | #endif /* __XFS_FS_H__ */ | ||
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 752915fa775a..b0a5fe95a3e2 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c | |||
| @@ -40,69 +40,6 @@ | |||
| 40 | * Physical superblock buffer manipulations. Shared with libxfs in userspace. | 40 | * Physical superblock buffer manipulations. Shared with libxfs in userspace. |
| 41 | */ | 41 | */ |
| 42 | 42 | ||
| 43 | static const struct { | ||
| 44 | short offset; | ||
| 45 | short type; /* 0 = integer | ||
| 46 | * 1 = binary / string (no translation) | ||
| 47 | */ | ||
| 48 | } xfs_sb_info[] = { | ||
| 49 | { offsetof(xfs_sb_t, sb_magicnum), 0 }, | ||
| 50 | { offsetof(xfs_sb_t, sb_blocksize), 0 }, | ||
| 51 | { offsetof(xfs_sb_t, sb_dblocks), 0 }, | ||
| 52 | { offsetof(xfs_sb_t, sb_rblocks), 0 }, | ||
| 53 | { offsetof(xfs_sb_t, sb_rextents), 0 }, | ||
| 54 | { offsetof(xfs_sb_t, sb_uuid), 1 }, | ||
| 55 | { offsetof(xfs_sb_t, sb_logstart), 0 }, | ||
| 56 | { offsetof(xfs_sb_t, sb_rootino), 0 }, | ||
| 57 | { offsetof(xfs_sb_t, sb_rbmino), 0 }, | ||
| 58 | { offsetof(xfs_sb_t, sb_rsumino), 0 }, | ||
| 59 | { offsetof(xfs_sb_t, sb_rextsize), 0 }, | ||
| 60 | { offsetof(xfs_sb_t, sb_agblocks), 0 }, | ||
| 61 | { offsetof(xfs_sb_t, sb_agcount), 0 }, | ||
| 62 | { offsetof(xfs_sb_t, sb_rbmblocks), 0 }, | ||
| 63 | { offsetof(xfs_sb_t, sb_logblocks), 0 }, | ||
| 64 | { offsetof(xfs_sb_t, sb_versionnum), 0 }, | ||
| 65 | { offsetof(xfs_sb_t, sb_sectsize), 0 }, | ||
| 66 | { offsetof(xfs_sb_t, sb_inodesize), 0 }, | ||
| 67 | { offsetof(xfs_sb_t, sb_inopblock), 0 }, | ||
| 68 | { offsetof(xfs_sb_t, sb_fname[0]), 1 }, | ||
| 69 | { offsetof(xfs_sb_t, sb_blocklog), 0 }, | ||
| 70 | { offsetof(xfs_sb_t, sb_sectlog), 0 }, | ||
| 71 | { offsetof(xfs_sb_t, sb_inodelog), 0 }, | ||
| 72 | { offsetof(xfs_sb_t, sb_inopblog), 0 }, | ||
| 73 | { offsetof(xfs_sb_t, sb_agblklog), 0 }, | ||
| 74 | { offsetof(xfs_sb_t, sb_rextslog), 0 }, | ||
| 75 | { offsetof(xfs_sb_t, sb_inprogress), 0 }, | ||
| 76 | { offsetof(xfs_sb_t, sb_imax_pct), 0 }, | ||
| 77 | { offsetof(xfs_sb_t, sb_icount), 0 }, | ||
| 78 | { offsetof(xfs_sb_t, sb_ifree), 0 }, | ||
| 79 | { offsetof(xfs_sb_t, sb_fdblocks), 0 }, | ||
| 80 | { offsetof(xfs_sb_t, sb_frextents), 0 }, | ||
| 81 | { offsetof(xfs_sb_t, sb_uquotino), 0 }, | ||
| 82 | { offsetof(xfs_sb_t, sb_gquotino), 0 }, | ||
| 83 | { offsetof(xfs_sb_t, sb_qflags), 0 }, | ||
| 84 | { offsetof(xfs_sb_t, sb_flags), 0 }, | ||
| 85 | { offsetof(xfs_sb_t, sb_shared_vn), 0 }, | ||
| 86 | { offsetof(xfs_sb_t, sb_inoalignmt), 0 }, | ||
| 87 | { offsetof(xfs_sb_t, sb_unit), 0 }, | ||
| 88 | { offsetof(xfs_sb_t, sb_width), 0 }, | ||
| 89 | { offsetof(xfs_sb_t, sb_dirblklog), 0 }, | ||
| 90 | { offsetof(xfs_sb_t, sb_logsectlog), 0 }, | ||
| 91 | { offsetof(xfs_sb_t, sb_logsectsize), 0 }, | ||
| 92 | { offsetof(xfs_sb_t, sb_logsunit), 0 }, | ||
| 93 | { offsetof(xfs_sb_t, sb_features2), 0 }, | ||
| 94 | { offsetof(xfs_sb_t, sb_bad_features2), 0 }, | ||
| 95 | { offsetof(xfs_sb_t, sb_features_compat), 0 }, | ||
| 96 | { offsetof(xfs_sb_t, sb_features_ro_compat), 0 }, | ||
| 97 | { offsetof(xfs_sb_t, sb_features_incompat), 0 }, | ||
| 98 | { offsetof(xfs_sb_t, sb_features_log_incompat), 0 }, | ||
| 99 | { offsetof(xfs_sb_t, sb_crc), 0 }, | ||
| 100 | { offsetof(xfs_sb_t, sb_pad), 0 }, | ||
| 101 | { offsetof(xfs_sb_t, sb_pquotino), 0 }, | ||
| 102 | { offsetof(xfs_sb_t, sb_lsn), 0 }, | ||
| 103 | { sizeof(xfs_sb_t), 0 } | ||
| 104 | }; | ||
| 105 | |||
| 106 | /* | 43 | /* |
| 107 | * Reference counting access wrappers to the perag structures. | 44 | * Reference counting access wrappers to the perag structures. |
| 108 | * Because we never free per-ag structures, the only thing we | 45 | * Because we never free per-ag structures, the only thing we |
| @@ -461,58 +398,49 @@ xfs_sb_from_disk( | |||
| 461 | __xfs_sb_from_disk(to, from, true); | 398 | __xfs_sb_from_disk(to, from, true); |
| 462 | } | 399 | } |
| 463 | 400 | ||
| 464 | static inline void | 401 | static void |
| 465 | xfs_sb_quota_to_disk( | 402 | xfs_sb_quota_to_disk( |
| 466 | xfs_dsb_t *to, | 403 | struct xfs_dsb *to, |
| 467 | xfs_sb_t *from, | 404 | struct xfs_sb *from) |
| 468 | __int64_t *fields) | ||
| 469 | { | 405 | { |
| 470 | __uint16_t qflags = from->sb_qflags; | 406 | __uint16_t qflags = from->sb_qflags; |
| 471 | 407 | ||
| 408 | to->sb_uquotino = cpu_to_be64(from->sb_uquotino); | ||
| 409 | if (xfs_sb_version_has_pquotino(from)) { | ||
| 410 | to->sb_qflags = cpu_to_be16(from->sb_qflags); | ||
| 411 | to->sb_gquotino = cpu_to_be64(from->sb_gquotino); | ||
| 412 | to->sb_pquotino = cpu_to_be64(from->sb_pquotino); | ||
| 413 | return; | ||
| 414 | } | ||
| 415 | |||
| 472 | /* | 416 | /* |
| 473 | * We need to do these manipilations only if we are working | 417 | * The in-core version of sb_qflags do not have XFS_OQUOTA_* |
| 474 | * with an older version of on-disk superblock. | 418 | * flags, whereas the on-disk version does. So, convert incore |
| 419 | * XFS_{PG}QUOTA_* flags to on-disk XFS_OQUOTA_* flags. | ||
| 475 | */ | 420 | */ |
| 476 | if (xfs_sb_version_has_pquotino(from)) | 421 | qflags &= ~(XFS_PQUOTA_ENFD | XFS_PQUOTA_CHKD | |
| 477 | return; | 422 | XFS_GQUOTA_ENFD | XFS_GQUOTA_CHKD); |
| 478 | 423 | ||
| 479 | if (*fields & XFS_SB_QFLAGS) { | 424 | if (from->sb_qflags & |
| 480 | /* | 425 | (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD)) |
| 481 | * The in-core version of sb_qflags do not have | 426 | qflags |= XFS_OQUOTA_ENFD; |
| 482 | * XFS_OQUOTA_* flags, whereas the on-disk version | 427 | if (from->sb_qflags & |
| 483 | * does. So, convert incore XFS_{PG}QUOTA_* flags | 428 | (XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD)) |
| 484 | * to on-disk XFS_OQUOTA_* flags. | 429 | qflags |= XFS_OQUOTA_CHKD; |
| 485 | */ | 430 | to->sb_qflags = cpu_to_be16(qflags); |
| 486 | qflags &= ~(XFS_PQUOTA_ENFD | XFS_PQUOTA_CHKD | | ||
| 487 | XFS_GQUOTA_ENFD | XFS_GQUOTA_CHKD); | ||
| 488 | |||
| 489 | if (from->sb_qflags & | ||
| 490 | (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD)) | ||
| 491 | qflags |= XFS_OQUOTA_ENFD; | ||
| 492 | if (from->sb_qflags & | ||
| 493 | (XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD)) | ||
| 494 | qflags |= XFS_OQUOTA_CHKD; | ||
| 495 | to->sb_qflags = cpu_to_be16(qflags); | ||
| 496 | *fields &= ~XFS_SB_QFLAGS; | ||
| 497 | } | ||
| 498 | 431 | ||
| 499 | /* | 432 | /* |
| 500 | * GQUOTINO and PQUOTINO cannot be used together in versions of | 433 | * GQUOTINO and PQUOTINO cannot be used together in versions |
| 501 | * superblock that do not have pquotino. from->sb_flags tells us which | 434 | * of superblock that do not have pquotino. from->sb_flags |
| 502 | * quota is active and should be copied to disk. If neither are active, | 435 | * tells us which quota is active and should be copied to |
| 503 | * make sure we write NULLFSINO to the sb_gquotino field as a quota | 436 | * disk. If neither are active, we should NULL the inode. |
| 504 | * inode value of "0" is invalid when the XFS_SB_VERSION_QUOTA feature | ||
| 505 | * bit is set. | ||
| 506 | * | 437 | * |
| 507 | * Note that we don't need to handle the sb_uquotino or sb_pquotino here | 438 | * In all cases, the separate pquotino must remain 0 because it |
| 508 | * as they do not require any translation. Hence the main sb field loop | 439 | * it beyond the "end" of the valid non-pquotino superblock. |
| 509 | * will write them appropriately from the in-core superblock. | ||
| 510 | */ | 440 | */ |
| 511 | if ((*fields & XFS_SB_GQUOTINO) && | 441 | if (from->sb_qflags & XFS_GQUOTA_ACCT) |
| 512 | (from->sb_qflags & XFS_GQUOTA_ACCT)) | ||
| 513 | to->sb_gquotino = cpu_to_be64(from->sb_gquotino); | 442 | to->sb_gquotino = cpu_to_be64(from->sb_gquotino); |
| 514 | else if ((*fields & XFS_SB_PQUOTINO) && | 443 | else if (from->sb_qflags & XFS_PQUOTA_ACCT) |
| 515 | (from->sb_qflags & XFS_PQUOTA_ACCT)) | ||
| 516 | to->sb_gquotino = cpu_to_be64(from->sb_pquotino); | 444 | to->sb_gquotino = cpu_to_be64(from->sb_pquotino); |
| 517 | else { | 445 | else { |
| 518 | /* | 446 | /* |
| @@ -526,63 +454,78 @@ xfs_sb_quota_to_disk( | |||
| 526 | to->sb_gquotino = cpu_to_be64(NULLFSINO); | 454 | to->sb_gquotino = cpu_to_be64(NULLFSINO); |
| 527 | } | 455 | } |
| 528 | 456 | ||
| 529 | *fields &= ~(XFS_SB_PQUOTINO | XFS_SB_GQUOTINO); | 457 | to->sb_pquotino = 0; |
| 530 | } | 458 | } |
| 531 | 459 | ||
| 532 | /* | ||
| 533 | * Copy in core superblock to ondisk one. | ||
| 534 | * | ||
| 535 | * The fields argument is mask of superblock fields to copy. | ||
| 536 | */ | ||
| 537 | void | 460 | void |
| 538 | xfs_sb_to_disk( | 461 | xfs_sb_to_disk( |
| 539 | xfs_dsb_t *to, | 462 | struct xfs_dsb *to, |
| 540 | xfs_sb_t *from, | 463 | struct xfs_sb *from) |
| 541 | __int64_t fields) | ||
| 542 | { | 464 | { |
| 543 | xfs_caddr_t to_ptr = (xfs_caddr_t)to; | 465 | xfs_sb_quota_to_disk(to, from); |
| 544 | xfs_caddr_t from_ptr = (xfs_caddr_t)from; | ||
| 545 | xfs_sb_field_t f; | ||
| 546 | int first; | ||
| 547 | int size; | ||
| 548 | |||
| 549 | ASSERT(fields); | ||
| 550 | if (!fields) | ||
| 551 | return; | ||
| 552 | 466 | ||
| 553 | /* We should never write the crc here, it's updated in the IO path */ | 467 | to->sb_magicnum = cpu_to_be32(from->sb_magicnum); |
| 554 | fields &= ~XFS_SB_CRC; | 468 | to->sb_blocksize = cpu_to_be32(from->sb_blocksize); |
| 555 | 469 | to->sb_dblocks = cpu_to_be64(from->sb_dblocks); | |
| 556 | xfs_sb_quota_to_disk(to, from, &fields); | 470 | to->sb_rblocks = cpu_to_be64(from->sb_rblocks); |
| 557 | while (fields) { | 471 | to->sb_rextents = cpu_to_be64(from->sb_rextents); |
| 558 | f = (xfs_sb_field_t)xfs_lowbit64((__uint64_t)fields); | 472 | memcpy(&to->sb_uuid, &from->sb_uuid, sizeof(to->sb_uuid)); |
| 559 | first = xfs_sb_info[f].offset; | 473 | to->sb_logstart = cpu_to_be64(from->sb_logstart); |
| 560 | size = xfs_sb_info[f + 1].offset - first; | 474 | to->sb_rootino = cpu_to_be64(from->sb_rootino); |
| 561 | 475 | to->sb_rbmino = cpu_to_be64(from->sb_rbmino); | |
| 562 | ASSERT(xfs_sb_info[f].type == 0 || xfs_sb_info[f].type == 1); | 476 | to->sb_rsumino = cpu_to_be64(from->sb_rsumino); |
| 563 | 477 | to->sb_rextsize = cpu_to_be32(from->sb_rextsize); | |
| 564 | if (size == 1 || xfs_sb_info[f].type == 1) { | 478 | to->sb_agblocks = cpu_to_be32(from->sb_agblocks); |
| 565 | memcpy(to_ptr + first, from_ptr + first, size); | 479 | to->sb_agcount = cpu_to_be32(from->sb_agcount); |
| 566 | } else { | 480 | to->sb_rbmblocks = cpu_to_be32(from->sb_rbmblocks); |
| 567 | switch (size) { | 481 | to->sb_logblocks = cpu_to_be32(from->sb_logblocks); |
| 568 | case 2: | 482 | to->sb_versionnum = cpu_to_be16(from->sb_versionnum); |
| 569 | *(__be16 *)(to_ptr + first) = | 483 | to->sb_sectsize = cpu_to_be16(from->sb_sectsize); |
| 570 | cpu_to_be16(*(__u16 *)(from_ptr + first)); | 484 | to->sb_inodesize = cpu_to_be16(from->sb_inodesize); |
| 571 | break; | 485 | to->sb_inopblock = cpu_to_be16(from->sb_inopblock); |
| 572 | case 4: | 486 | memcpy(&to->sb_fname, &from->sb_fname, sizeof(to->sb_fname)); |
| 573 | *(__be32 *)(to_ptr + first) = | 487 | to->sb_blocklog = from->sb_blocklog; |
| 574 | cpu_to_be32(*(__u32 *)(from_ptr + first)); | 488 | to->sb_sectlog = from->sb_sectlog; |
| 575 | break; | 489 | to->sb_inodelog = from->sb_inodelog; |
| 576 | case 8: | 490 | to->sb_inopblog = from->sb_inopblog; |
| 577 | *(__be64 *)(to_ptr + first) = | 491 | to->sb_agblklog = from->sb_agblklog; |
| 578 | cpu_to_be64(*(__u64 *)(from_ptr + first)); | 492 | to->sb_rextslog = from->sb_rextslog; |
| 579 | break; | 493 | to->sb_inprogress = from->sb_inprogress; |
| 580 | default: | 494 | to->sb_imax_pct = from->sb_imax_pct; |
| 581 | ASSERT(0); | 495 | to->sb_icount = cpu_to_be64(from->sb_icount); |
| 582 | } | 496 | to->sb_ifree = cpu_to_be64(from->sb_ifree); |
| 583 | } | 497 | to->sb_fdblocks = cpu_to_be64(from->sb_fdblocks); |
| 498 | to->sb_frextents = cpu_to_be64(from->sb_frextents); | ||
| 584 | 499 | ||
| 585 | fields &= ~(1LL << f); | 500 | to->sb_flags = from->sb_flags; |
| 501 | to->sb_shared_vn = from->sb_shared_vn; | ||
| 502 | to->sb_inoalignmt = cpu_to_be32(from->sb_inoalignmt); | ||
| 503 | to->sb_unit = cpu_to_be32(from->sb_unit); | ||
| 504 | to->sb_width = cpu_to_be32(from->sb_width); | ||
| 505 | to->sb_dirblklog = from->sb_dirblklog; | ||
| 506 | to->sb_logsectlog = from->sb_logsectlog; | ||
| 507 | to->sb_logsectsize = cpu_to_be16(from->sb_logsectsize); | ||
| 508 | to->sb_logsunit = cpu_to_be32(from->sb_logsunit); | ||
| 509 | |||
| 510 | /* | ||
| 511 | * We need to ensure that bad_features2 always matches features2. | ||
| 512 | * Hence we enforce that here rather than having to remember to do it | ||
| 513 | * everywhere else that updates features2. | ||
| 514 | */ | ||
| 515 | from->sb_bad_features2 = from->sb_features2; | ||
| 516 | to->sb_features2 = cpu_to_be32(from->sb_features2); | ||
| 517 | to->sb_bad_features2 = cpu_to_be32(from->sb_bad_features2); | ||
| 518 | |||
| 519 | if (xfs_sb_version_hascrc(from)) { | ||
| 520 | to->sb_features_compat = cpu_to_be32(from->sb_features_compat); | ||
| 521 | to->sb_features_ro_compat = | ||
| 522 | cpu_to_be32(from->sb_features_ro_compat); | ||
| 523 | to->sb_features_incompat = | ||
| 524 | cpu_to_be32(from->sb_features_incompat); | ||
| 525 | to->sb_features_log_incompat = | ||
| 526 | cpu_to_be32(from->sb_features_log_incompat); | ||
| 527 | to->sb_pad = 0; | ||
| 528 | to->sb_lsn = cpu_to_be64(from->sb_lsn); | ||
| 586 | } | 529 | } |
| 587 | } | 530 | } |
| 588 | 531 | ||
| @@ -816,42 +759,51 @@ xfs_initialize_perag_data( | |||
| 816 | } | 759 | } |
| 817 | 760 | ||
| 818 | /* | 761 | /* |
| 819 | * xfs_mod_sb() can be used to copy arbitrary changes to the | 762 | * xfs_log_sb() can be used to copy arbitrary changes to the in-core superblock |
| 820 | * in-core superblock into the superblock buffer to be logged. | 763 | * into the superblock buffer to be logged. It does not provide the higher |
| 821 | * It does not provide the higher level of locking that is | 764 | * level of locking that is needed to protect the in-core superblock from |
| 822 | * needed to protect the in-core superblock from concurrent | 765 | * concurrent access. |
| 823 | * access. | ||
| 824 | */ | 766 | */ |
| 825 | void | 767 | void |
| 826 | xfs_mod_sb(xfs_trans_t *tp, __int64_t fields) | 768 | xfs_log_sb( |
| 769 | struct xfs_trans *tp) | ||
| 827 | { | 770 | { |
| 828 | xfs_buf_t *bp; | 771 | struct xfs_mount *mp = tp->t_mountp; |
| 829 | int first; | 772 | struct xfs_buf *bp = xfs_trans_getsb(tp, mp, 0); |
| 830 | int last; | ||
| 831 | xfs_mount_t *mp; | ||
| 832 | xfs_sb_field_t f; | ||
| 833 | |||
| 834 | ASSERT(fields); | ||
| 835 | if (!fields) | ||
| 836 | return; | ||
| 837 | mp = tp->t_mountp; | ||
| 838 | bp = xfs_trans_getsb(tp, mp, 0); | ||
| 839 | first = sizeof(xfs_sb_t); | ||
| 840 | last = 0; | ||
| 841 | |||
| 842 | /* translate/copy */ | ||
| 843 | 773 | ||
| 844 | xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb, fields); | 774 | xfs_sb_to_disk(XFS_BUF_TO_SBP(bp), &mp->m_sb); |
| 775 | xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); | ||
| 776 | xfs_trans_log_buf(tp, bp, 0, sizeof(struct xfs_dsb)); | ||
| 777 | } | ||
| 845 | 778 | ||
| 846 | /* find modified range */ | 779 | /* |
| 847 | f = (xfs_sb_field_t)xfs_highbit64((__uint64_t)fields); | 780 | * xfs_sync_sb |
| 848 | ASSERT((1LL << f) & XFS_SB_MOD_BITS); | 781 | * |
| 849 | last = xfs_sb_info[f + 1].offset - 1; | 782 | * Sync the superblock to disk. |
| 783 | * | ||
| 784 | * Note that the caller is responsible for checking the frozen state of the | ||
| 785 | * filesystem. This procedure uses the non-blocking transaction allocator and | ||
| 786 | * thus will allow modifications to a frozen fs. This is required because this | ||
| 787 | * code can be called during the process of freezing where use of the high-level | ||
| 788 | * allocator would deadlock. | ||
| 789 | */ | ||
| 790 | int | ||
| 791 | xfs_sync_sb( | ||
| 792 | struct xfs_mount *mp, | ||
| 793 | bool wait) | ||
| 794 | { | ||
| 795 | struct xfs_trans *tp; | ||
| 796 | int error; | ||
| 850 | 797 | ||
| 851 | f = (xfs_sb_field_t)xfs_lowbit64((__uint64_t)fields); | 798 | tp = _xfs_trans_alloc(mp, XFS_TRANS_SB_CHANGE, KM_SLEEP); |
| 852 | ASSERT((1LL << f) & XFS_SB_MOD_BITS); | 799 | error = xfs_trans_reserve(tp, &M_RES(mp)->tr_sb, 0, 0); |
| 853 | first = xfs_sb_info[f].offset; | 800 | if (error) { |
| 801 | xfs_trans_cancel(tp, 0); | ||
| 802 | return error; | ||
| 803 | } | ||
| 854 | 804 | ||
| 855 | xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SB_BUF); | 805 | xfs_log_sb(tp); |
| 856 | xfs_trans_log_buf(tp, bp, first, last); | 806 | if (wait) |
| 807 | xfs_trans_set_sync(tp); | ||
| 808 | return xfs_trans_commit(tp, 0); | ||
| 857 | } | 809 | } |
diff --git a/fs/xfs/libxfs/xfs_sb.h b/fs/xfs/libxfs/xfs_sb.h index 8eb1c54bafbf..b25bb9a343f3 100644 --- a/fs/xfs/libxfs/xfs_sb.h +++ b/fs/xfs/libxfs/xfs_sb.h | |||
| @@ -27,11 +27,12 @@ extern struct xfs_perag *xfs_perag_get_tag(struct xfs_mount *, xfs_agnumber_t, | |||
| 27 | extern void xfs_perag_put(struct xfs_perag *pag); | 27 | extern void xfs_perag_put(struct xfs_perag *pag); |
| 28 | extern int xfs_initialize_perag_data(struct xfs_mount *, xfs_agnumber_t); | 28 | extern int xfs_initialize_perag_data(struct xfs_mount *, xfs_agnumber_t); |
| 29 | 29 | ||
| 30 | extern void xfs_sb_calc_crc(struct xfs_buf *); | 30 | extern void xfs_sb_calc_crc(struct xfs_buf *bp); |
| 31 | extern void xfs_mod_sb(struct xfs_trans *, __int64_t); | 31 | extern void xfs_log_sb(struct xfs_trans *tp); |
| 32 | extern void xfs_sb_mount_common(struct xfs_mount *, struct xfs_sb *); | 32 | extern int xfs_sync_sb(struct xfs_mount *mp, bool wait); |
| 33 | extern void xfs_sb_from_disk(struct xfs_sb *, struct xfs_dsb *); | 33 | extern void xfs_sb_mount_common(struct xfs_mount *mp, struct xfs_sb *sbp); |
| 34 | extern void xfs_sb_to_disk(struct xfs_dsb *, struct xfs_sb *, __int64_t); | 34 | extern void xfs_sb_from_disk(struct xfs_sb *to, struct xfs_dsb *from); |
| 35 | extern void xfs_sb_to_disk(struct xfs_dsb *to, struct xfs_sb *from); | ||
| 35 | extern void xfs_sb_quota_from_disk(struct xfs_sb *sbp); | 36 | extern void xfs_sb_quota_from_disk(struct xfs_sb *sbp); |
| 36 | 37 | ||
| 37 | #endif /* __XFS_SB_H__ */ | 38 | #endif /* __XFS_SB_H__ */ |
diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h index 82404da2ca67..8dda4b321343 100644 --- a/fs/xfs/libxfs/xfs_shared.h +++ b/fs/xfs/libxfs/xfs_shared.h | |||
| @@ -82,7 +82,7 @@ extern const struct xfs_buf_ops xfs_symlink_buf_ops; | |||
| 82 | #define XFS_TRANS_ATTR_RM 23 | 82 | #define XFS_TRANS_ATTR_RM 23 |
| 83 | #define XFS_TRANS_ATTR_FLAG 24 | 83 | #define XFS_TRANS_ATTR_FLAG 24 |
| 84 | #define XFS_TRANS_CLEAR_AGI_BUCKET 25 | 84 | #define XFS_TRANS_CLEAR_AGI_BUCKET 25 |
| 85 | #define XFS_TRANS_QM_SBCHANGE 26 | 85 | #define XFS_TRANS_SB_CHANGE 26 |
| 86 | /* | 86 | /* |
| 87 | * Dummy entries since we use the transaction type to index into the | 87 | * Dummy entries since we use the transaction type to index into the |
| 88 | * trans_type[] in xlog_recover_print_trans_head() | 88 | * trans_type[] in xlog_recover_print_trans_head() |
| @@ -95,17 +95,15 @@ extern const struct xfs_buf_ops xfs_symlink_buf_ops; | |||
| 95 | #define XFS_TRANS_QM_DQCLUSTER 32 | 95 | #define XFS_TRANS_QM_DQCLUSTER 32 |
| 96 | #define XFS_TRANS_QM_QINOCREATE 33 | 96 | #define XFS_TRANS_QM_QINOCREATE 33 |
| 97 | #define XFS_TRANS_QM_QUOTAOFF_END 34 | 97 | #define XFS_TRANS_QM_QUOTAOFF_END 34 |
| 98 | #define XFS_TRANS_SB_UNIT 35 | 98 | #define XFS_TRANS_FSYNC_TS 35 |
| 99 | #define XFS_TRANS_FSYNC_TS 36 | 99 | #define XFS_TRANS_GROWFSRT_ALLOC 36 |
| 100 | #define XFS_TRANS_GROWFSRT_ALLOC 37 | 100 | #define XFS_TRANS_GROWFSRT_ZERO 37 |
| 101 | #define XFS_TRANS_GROWFSRT_ZERO 38 | 101 | #define XFS_TRANS_GROWFSRT_FREE 38 |
| 102 | #define XFS_TRANS_GROWFSRT_FREE 39 | 102 | #define XFS_TRANS_SWAPEXT 39 |
| 103 | #define XFS_TRANS_SWAPEXT 40 | 103 | #define XFS_TRANS_CHECKPOINT 40 |
| 104 | #define XFS_TRANS_SB_COUNT 41 | 104 | #define XFS_TRANS_ICREATE 41 |
| 105 | #define XFS_TRANS_CHECKPOINT 42 | 105 | #define XFS_TRANS_CREATE_TMPFILE 42 |
| 106 | #define XFS_TRANS_ICREATE 43 | 106 | #define XFS_TRANS_TYPE_MAX 43 |
| 107 | #define XFS_TRANS_CREATE_TMPFILE 44 | ||
| 108 | #define XFS_TRANS_TYPE_MAX 44 | ||
| 109 | /* new transaction types need to be reflected in xfs_logprint(8) */ | 107 | /* new transaction types need to be reflected in xfs_logprint(8) */ |
| 110 | 108 | ||
| 111 | #define XFS_TRANS_TYPES \ | 109 | #define XFS_TRANS_TYPES \ |
| @@ -113,7 +111,6 @@ extern const struct xfs_buf_ops xfs_symlink_buf_ops; | |||
| 113 | { XFS_TRANS_SETATTR_SIZE, "SETATTR_SIZE" }, \ | 111 | { XFS_TRANS_SETATTR_SIZE, "SETATTR_SIZE" }, \ |
| 114 | { XFS_TRANS_INACTIVE, "INACTIVE" }, \ | 112 | { XFS_TRANS_INACTIVE, "INACTIVE" }, \ |
| 115 | { XFS_TRANS_CREATE, "CREATE" }, \ | 113 | { XFS_TRANS_CREATE, "CREATE" }, \ |
| 116 | { XFS_TRANS_CREATE_TMPFILE, "CREATE_TMPFILE" }, \ | ||
| 117 | { XFS_TRANS_CREATE_TRUNC, "CREATE_TRUNC" }, \ | 114 | { XFS_TRANS_CREATE_TRUNC, "CREATE_TRUNC" }, \ |
| 118 | { XFS_TRANS_TRUNCATE_FILE, "TRUNCATE_FILE" }, \ | 115 | { XFS_TRANS_TRUNCATE_FILE, "TRUNCATE_FILE" }, \ |
| 119 | { XFS_TRANS_REMOVE, "REMOVE" }, \ | 116 | { XFS_TRANS_REMOVE, "REMOVE" }, \ |
| @@ -134,23 +131,23 @@ extern const struct xfs_buf_ops xfs_symlink_buf_ops; | |||
| 134 | { XFS_TRANS_ATTR_RM, "ATTR_RM" }, \ | 131 | { XFS_TRANS_ATTR_RM, "ATTR_RM" }, \ |
| 135 | { XFS_TRANS_ATTR_FLAG, "ATTR_FLAG" }, \ | 132 | { XFS_TRANS_ATTR_FLAG, "ATTR_FLAG" }, \ |
| 136 | { XFS_TRANS_CLEAR_AGI_BUCKET, "CLEAR_AGI_BUCKET" }, \ | 133 | { XFS_TRANS_CLEAR_AGI_BUCKET, "CLEAR_AGI_BUCKET" }, \ |
| 137 | { XFS_TRANS_QM_SBCHANGE, "QM_SBCHANGE" }, \ | 134 | { XFS_TRANS_SB_CHANGE, "SBCHANGE" }, \ |
| 135 | { XFS_TRANS_DUMMY1, "DUMMY1" }, \ | ||
| 136 | { XFS_TRANS_DUMMY2, "DUMMY2" }, \ | ||
| 138 | { XFS_TRANS_QM_QUOTAOFF, "QM_QUOTAOFF" }, \ | 137 | { XFS_TRANS_QM_QUOTAOFF, "QM_QUOTAOFF" }, \ |
| 139 | { XFS_TRANS_QM_DQALLOC, "QM_DQALLOC" }, \ | 138 | { XFS_TRANS_QM_DQALLOC, "QM_DQALLOC" }, \ |
| 140 | { XFS_TRANS_QM_SETQLIM, "QM_SETQLIM" }, \ | 139 | { XFS_TRANS_QM_SETQLIM, "QM_SETQLIM" }, \ |
| 141 | { XFS_TRANS_QM_DQCLUSTER, "QM_DQCLUSTER" }, \ | 140 | { XFS_TRANS_QM_DQCLUSTER, "QM_DQCLUSTER" }, \ |
| 142 | { XFS_TRANS_QM_QINOCREATE, "QM_QINOCREATE" }, \ | 141 | { XFS_TRANS_QM_QINOCREATE, "QM_QINOCREATE" }, \ |
| 143 | { XFS_TRANS_QM_QUOTAOFF_END, "QM_QOFF_END" }, \ | 142 | { XFS_TRANS_QM_QUOTAOFF_END, "QM_QOFF_END" }, \ |
| 144 | { XFS_TRANS_SB_UNIT, "SB_UNIT" }, \ | ||
| 145 | { XFS_TRANS_FSYNC_TS, "FSYNC_TS" }, \ | 143 | { XFS_TRANS_FSYNC_TS, "FSYNC_TS" }, \ |
| 146 | { XFS_TRANS_GROWFSRT_ALLOC, "GROWFSRT_ALLOC" }, \ | 144 | { XFS_TRANS_GROWFSRT_ALLOC, "GROWFSRT_ALLOC" }, \ |
| 147 | { XFS_TRANS_GROWFSRT_ZERO, "GROWFSRT_ZERO" }, \ | 145 | { XFS_TRANS_GROWFSRT_ZERO, "GROWFSRT_ZERO" }, \ |
| 148 | { XFS_TRANS_GROWFSRT_FREE, "GROWFSRT_FREE" }, \ | 146 | { XFS_TRANS_GROWFSRT_FREE, "GROWFSRT_FREE" }, \ |
| 149 | { XFS_TRANS_SWAPEXT, "SWAPEXT" }, \ | 147 | { XFS_TRANS_SWAPEXT, "SWAPEXT" }, \ |
| 150 | { XFS_TRANS_SB_COUNT, "SB_COUNT" }, \ | ||
| 151 | { XFS_TRANS_CHECKPOINT, "CHECKPOINT" }, \ | 148 | { XFS_TRANS_CHECKPOINT, "CHECKPOINT" }, \ |
| 152 | { XFS_TRANS_DUMMY1, "DUMMY1" }, \ | 149 | { XFS_TRANS_ICREATE, "ICREATE" }, \ |
| 153 | { XFS_TRANS_DUMMY2, "DUMMY2" }, \ | 150 | { XFS_TRANS_CREATE_TMPFILE, "CREATE_TMPFILE" }, \ |
| 154 | { XLOG_UNMOUNT_REC_TYPE, "UNMOUNT" } | 151 | { XLOG_UNMOUNT_REC_TYPE, "UNMOUNT" } |
| 155 | 152 | ||
| 156 | /* | 153 | /* |
diff --git a/fs/xfs/libxfs/xfs_symlink_remote.c b/fs/xfs/libxfs/xfs_symlink_remote.c index c80c5236c3da..e7e26bd6468f 100644 --- a/fs/xfs/libxfs/xfs_symlink_remote.c +++ b/fs/xfs/libxfs/xfs_symlink_remote.c | |||
| @@ -178,6 +178,8 @@ xfs_symlink_local_to_remote( | |||
| 178 | struct xfs_mount *mp = ip->i_mount; | 178 | struct xfs_mount *mp = ip->i_mount; |
| 179 | char *buf; | 179 | char *buf; |
| 180 | 180 | ||
| 181 | xfs_trans_buf_set_type(tp, bp, XFS_BLFT_SYMLINK_BUF); | ||
| 182 | |||
| 181 | if (!xfs_sb_version_hascrc(&mp->m_sb)) { | 183 | if (!xfs_sb_version_hascrc(&mp->m_sb)) { |
| 182 | bp->b_ops = NULL; | 184 | bp->b_ops = NULL; |
| 183 | memcpy(bp->b_addr, ifp->if_u1.if_data, ifp->if_bytes); | 185 | memcpy(bp->b_addr, ifp->if_u1.if_data, ifp->if_bytes); |
diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c index 6c1330f29050..68cb1e7bf2bb 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.c +++ b/fs/xfs/libxfs/xfs_trans_resv.c | |||
| @@ -716,17 +716,6 @@ xfs_calc_clear_agi_bucket_reservation( | |||
| 716 | } | 716 | } |
| 717 | 717 | ||
| 718 | /* | 718 | /* |
| 719 | * Clearing the quotaflags in the superblock. | ||
| 720 | * the super block for changing quota flags: sector size | ||
| 721 | */ | ||
| 722 | STATIC uint | ||
| 723 | xfs_calc_qm_sbchange_reservation( | ||
| 724 | struct xfs_mount *mp) | ||
| 725 | { | ||
| 726 | return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize); | ||
| 727 | } | ||
| 728 | |||
| 729 | /* | ||
| 730 | * Adjusting quota limits. | 719 | * Adjusting quota limits. |
| 731 | * the xfs_disk_dquot_t: sizeof(struct xfs_disk_dquot) | 720 | * the xfs_disk_dquot_t: sizeof(struct xfs_disk_dquot) |
| 732 | */ | 721 | */ |
| @@ -864,9 +853,6 @@ xfs_trans_resv_calc( | |||
| 864 | * The following transactions are logged in logical format with | 853 | * The following transactions are logged in logical format with |
| 865 | * a default log count. | 854 | * a default log count. |
| 866 | */ | 855 | */ |
| 867 | resp->tr_qm_sbchange.tr_logres = xfs_calc_qm_sbchange_reservation(mp); | ||
| 868 | resp->tr_qm_sbchange.tr_logcount = XFS_DEFAULT_LOG_COUNT; | ||
| 869 | |||
| 870 | resp->tr_qm_setqlim.tr_logres = xfs_calc_qm_setqlim_reservation(mp); | 856 | resp->tr_qm_setqlim.tr_logres = xfs_calc_qm_setqlim_reservation(mp); |
| 871 | resp->tr_qm_setqlim.tr_logcount = XFS_DEFAULT_LOG_COUNT; | 857 | resp->tr_qm_setqlim.tr_logcount = XFS_DEFAULT_LOG_COUNT; |
| 872 | 858 | ||
diff --git a/fs/xfs/libxfs/xfs_trans_resv.h b/fs/xfs/libxfs/xfs_trans_resv.h index 1097d14cd583..2d5bdfce6d8f 100644 --- a/fs/xfs/libxfs/xfs_trans_resv.h +++ b/fs/xfs/libxfs/xfs_trans_resv.h | |||
| @@ -56,7 +56,6 @@ struct xfs_trans_resv { | |||
| 56 | struct xfs_trans_res tr_growrtalloc; /* grow realtime allocations */ | 56 | struct xfs_trans_res tr_growrtalloc; /* grow realtime allocations */ |
| 57 | struct xfs_trans_res tr_growrtzero; /* grow realtime zeroing */ | 57 | struct xfs_trans_res tr_growrtzero; /* grow realtime zeroing */ |
| 58 | struct xfs_trans_res tr_growrtfree; /* grow realtime freeing */ | 58 | struct xfs_trans_res tr_growrtfree; /* grow realtime freeing */ |
| 59 | struct xfs_trans_res tr_qm_sbchange; /* change quota flags */ | ||
| 60 | struct xfs_trans_res tr_qm_setqlim; /* adjust quota limits */ | 59 | struct xfs_trans_res tr_qm_setqlim; /* adjust quota limits */ |
| 61 | struct xfs_trans_res tr_qm_dqalloc; /* allocate quota on disk */ | 60 | struct xfs_trans_res tr_qm_dqalloc; /* allocate quota on disk */ |
| 62 | struct xfs_trans_res tr_qm_quotaoff; /* turn quota off */ | 61 | struct xfs_trans_res tr_qm_quotaoff; /* turn quota off */ |
diff --git a/fs/xfs/libxfs/xfs_types.h b/fs/xfs/libxfs/xfs_types.h new file mode 100644 index 000000000000..b79dc66b2ecd --- /dev/null +++ b/fs/xfs/libxfs/xfs_types.h | |||
| @@ -0,0 +1,137 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. | ||
| 3 | * All Rights Reserved. | ||
| 4 | * | ||
| 5 | * This program is free software; you can redistribute it and/or | ||
| 6 | * modify it under the terms of the GNU General Public License as | ||
| 7 | * published by the Free Software Foundation. | ||
| 8 | * | ||
| 9 | * This program is distributed in the hope that it would be useful, | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 12 | * GNU General Public License for more details. | ||
| 13 | * | ||
| 14 | * You should have received a copy of the GNU General Public License | ||
| 15 | * along with this program; if not, write the Free Software Foundation, | ||
| 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
| 17 | */ | ||
| 18 | #ifndef __XFS_TYPES_H__ | ||
| 19 | #define __XFS_TYPES_H__ | ||
| 20 | |||
| 21 | typedef __uint32_t prid_t; /* project ID */ | ||
| 22 | |||
| 23 | typedef __uint32_t xfs_agblock_t; /* blockno in alloc. group */ | ||
| 24 | typedef __uint32_t xfs_agino_t; /* inode # within allocation grp */ | ||
| 25 | typedef __uint32_t xfs_extlen_t; /* extent length in blocks */ | ||
| 26 | typedef __uint32_t xfs_agnumber_t; /* allocation group number */ | ||
| 27 | typedef __int32_t xfs_extnum_t; /* # of extents in a file */ | ||
| 28 | typedef __int16_t xfs_aextnum_t; /* # extents in an attribute fork */ | ||
| 29 | typedef __int64_t xfs_fsize_t; /* bytes in a file */ | ||
| 30 | typedef __uint64_t xfs_ufsize_t; /* unsigned bytes in a file */ | ||
| 31 | |||
| 32 | typedef __int32_t xfs_suminfo_t; /* type of bitmap summary info */ | ||
| 33 | typedef __int32_t xfs_rtword_t; /* word type for bitmap manipulations */ | ||
| 34 | |||
| 35 | typedef __int64_t xfs_lsn_t; /* log sequence number */ | ||
| 36 | typedef __int32_t xfs_tid_t; /* transaction identifier */ | ||
| 37 | |||
| 38 | typedef __uint32_t xfs_dablk_t; /* dir/attr block number (in file) */ | ||
| 39 | typedef __uint32_t xfs_dahash_t; /* dir/attr hash value */ | ||
| 40 | |||
| 41 | typedef __uint64_t xfs_fsblock_t; /* blockno in filesystem (agno|agbno) */ | ||
| 42 | typedef __uint64_t xfs_rfsblock_t; /* blockno in filesystem (raw) */ | ||
| 43 | typedef __uint64_t xfs_rtblock_t; /* extent (block) in realtime area */ | ||
| 44 | typedef __uint64_t xfs_fileoff_t; /* block number in a file */ | ||
| 45 | typedef __uint64_t xfs_filblks_t; /* number of blocks in a file */ | ||
| 46 | |||
| 47 | typedef __int64_t xfs_srtblock_t; /* signed version of xfs_rtblock_t */ | ||
| 48 | typedef __int64_t xfs_sfiloff_t; /* signed block number in a file */ | ||
| 49 | |||
| 50 | /* | ||
| 51 | * Null values for the types. | ||
| 52 | */ | ||
| 53 | #define NULLFSBLOCK ((xfs_fsblock_t)-1) | ||
| 54 | #define NULLRFSBLOCK ((xfs_rfsblock_t)-1) | ||
| 55 | #define NULLRTBLOCK ((xfs_rtblock_t)-1) | ||
| 56 | #define NULLFILEOFF ((xfs_fileoff_t)-1) | ||
| 57 | |||
| 58 | #define NULLAGBLOCK ((xfs_agblock_t)-1) | ||
| 59 | #define NULLAGNUMBER ((xfs_agnumber_t)-1) | ||
| 60 | #define NULLEXTNUM ((xfs_extnum_t)-1) | ||
| 61 | |||
| 62 | #define NULLCOMMITLSN ((xfs_lsn_t)-1) | ||
| 63 | |||
| 64 | #define NULLFSINO ((xfs_ino_t)-1) | ||
| 65 | #define NULLAGINO ((xfs_agino_t)-1) | ||
| 66 | |||
| 67 | /* | ||
| 68 | * Max values for extlen, extnum, aextnum. | ||
| 69 | */ | ||
| 70 | #define MAXEXTLEN ((xfs_extlen_t)0x001fffff) /* 21 bits */ | ||
| 71 | #define MAXEXTNUM ((xfs_extnum_t)0x7fffffff) /* signed int */ | ||
| 72 | #define MAXAEXTNUM ((xfs_aextnum_t)0x7fff) /* signed short */ | ||
| 73 | |||
| 74 | /* | ||
| 75 | * Minimum and maximum blocksize and sectorsize. | ||
| 76 | * The blocksize upper limit is pretty much arbitrary. | ||
| 77 | * The sectorsize upper limit is due to sizeof(sb_sectsize). | ||
| 78 | */ | ||
| 79 | #define XFS_MIN_BLOCKSIZE_LOG 9 /* i.e. 512 bytes */ | ||
| 80 | #define XFS_MAX_BLOCKSIZE_LOG 16 /* i.e. 65536 bytes */ | ||
| 81 | #define XFS_MIN_BLOCKSIZE (1 << XFS_MIN_BLOCKSIZE_LOG) | ||
| 82 | #define XFS_MAX_BLOCKSIZE (1 << XFS_MAX_BLOCKSIZE_LOG) | ||
| 83 | #define XFS_MIN_SECTORSIZE_LOG 9 /* i.e. 512 bytes */ | ||
| 84 | #define XFS_MAX_SECTORSIZE_LOG 15 /* i.e. 32768 bytes */ | ||
| 85 | #define XFS_MIN_SECTORSIZE (1 << XFS_MIN_SECTORSIZE_LOG) | ||
| 86 | #define XFS_MAX_SECTORSIZE (1 << XFS_MAX_SECTORSIZE_LOG) | ||
| 87 | |||
| 88 | /* | ||
| 89 | * Inode fork identifiers. | ||
| 90 | */ | ||
| 91 | #define XFS_DATA_FORK 0 | ||
| 92 | #define XFS_ATTR_FORK 1 | ||
| 93 | |||
| 94 | /* | ||
| 95 | * Min numbers of data/attr fork btree root pointers. | ||
| 96 | */ | ||
| 97 | #define MINDBTPTRS 3 | ||
| 98 | #define MINABTPTRS 2 | ||
| 99 | |||
| 100 | /* | ||
| 101 | * MAXNAMELEN is the length (including the terminating null) of | ||
| 102 | * the longest permissible file (component) name. | ||
| 103 | */ | ||
| 104 | #define MAXNAMELEN 256 | ||
| 105 | |||
| 106 | typedef enum { | ||
| 107 | XFS_LOOKUP_EQi, XFS_LOOKUP_LEi, XFS_LOOKUP_GEi | ||
| 108 | } xfs_lookup_t; | ||
| 109 | |||
| 110 | typedef enum { | ||
| 111 | XFS_BTNUM_BNOi, XFS_BTNUM_CNTi, XFS_BTNUM_BMAPi, XFS_BTNUM_INOi, | ||
| 112 | XFS_BTNUM_FINOi, XFS_BTNUM_MAX | ||
| 113 | } xfs_btnum_t; | ||
| 114 | |||
| 115 | struct xfs_name { | ||
| 116 | const unsigned char *name; | ||
| 117 | int len; | ||
| 118 | int type; | ||
| 119 | }; | ||
| 120 | |||
| 121 | /* | ||
| 122 | * uid_t and gid_t are hard-coded to 32 bits in the inode. | ||
| 123 | * Hence, an 'id' in a dquot is 32 bits.. | ||
| 124 | */ | ||
| 125 | typedef __uint32_t xfs_dqid_t; | ||
| 126 | |||
| 127 | /* | ||
| 128 | * Constants for bit manipulations. | ||
| 129 | */ | ||
| 130 | #define XFS_NBBYLOG 3 /* log2(NBBY) */ | ||
| 131 | #define XFS_WORDLOG 2 /* log2(sizeof(xfs_rtword_t)) */ | ||
| 132 | #define XFS_NBWORDLOG (XFS_NBBYLOG + XFS_WORDLOG) | ||
| 133 | #define XFS_NBWORD (1 << XFS_NBWORDLOG) | ||
| 134 | #define XFS_WORDMASK ((1 << XFS_WORDLOG) - 1) | ||
| 135 | |||
| 136 | |||
| 137 | #endif /* __XFS_TYPES_H__ */ | ||
