Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 | * Copyright (c) 2000-2005 Silicon Graphics, Inc. |
| 3 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. |
| 8 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 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 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
| 18 | #ifndef __XFS_SB_H__ |
| 19 | #define __XFS_SB_H__ |
| 20 | |
| 21 | /* |
| 22 | * Super block |
| 23 | * Fits into a sector-sized buffer at address 0 of each allocation group. |
| 24 | * Only the first of these is ever updated except during growfs. |
| 25 | */ |
| 26 | |
| 27 | struct xfs_buf; |
| 28 | struct xfs_mount; |
| 29 | |
| 30 | #define XFS_SB_MAGIC 0x58465342 /* 'XFSB' */ |
| 31 | #define XFS_SB_VERSION_1 1 /* 5.3, 6.0.1, 6.1 */ |
| 32 | #define XFS_SB_VERSION_2 2 /* 6.2 - attributes */ |
| 33 | #define XFS_SB_VERSION_3 3 /* 6.2 - new inode version */ |
| 34 | #define XFS_SB_VERSION_4 4 /* 6.2+ - bitmask version */ |
| 35 | #define XFS_SB_VERSION_NUMBITS 0x000f |
| 36 | #define XFS_SB_VERSION_ALLFBITS 0xfff0 |
| 37 | #define XFS_SB_VERSION_SASHFBITS 0xf000 |
| 38 | #define XFS_SB_VERSION_REALFBITS 0x0ff0 |
| 39 | #define XFS_SB_VERSION_ATTRBIT 0x0010 |
| 40 | #define XFS_SB_VERSION_NLINKBIT 0x0020 |
| 41 | #define XFS_SB_VERSION_QUOTABIT 0x0040 |
| 42 | #define XFS_SB_VERSION_ALIGNBIT 0x0080 |
| 43 | #define XFS_SB_VERSION_DALIGNBIT 0x0100 |
| 44 | #define XFS_SB_VERSION_SHAREDBIT 0x0200 |
| 45 | #define XFS_SB_VERSION_LOGV2BIT 0x0400 |
| 46 | #define XFS_SB_VERSION_SECTORBIT 0x0800 |
| 47 | #define XFS_SB_VERSION_EXTFLGBIT 0x1000 |
| 48 | #define XFS_SB_VERSION_DIRV2BIT 0x2000 |
Barry Naujok | 189f4bf | 2008-05-21 16:58:55 +1000 | [diff] [blame] | 49 | #define XFS_SB_VERSION_BORGBIT 0x4000 /* ASCII only case-insens. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | #define XFS_SB_VERSION_MOREBITSBIT 0x8000 |
| 51 | #define XFS_SB_VERSION_OKSASHFBITS \ |
| 52 | (XFS_SB_VERSION_EXTFLGBIT | \ |
Barry Naujok | 189f4bf | 2008-05-21 16:58:55 +1000 | [diff] [blame] | 53 | XFS_SB_VERSION_DIRV2BIT | \ |
| 54 | XFS_SB_VERSION_BORGBIT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 55 | #define XFS_SB_VERSION_OKREALFBITS \ |
| 56 | (XFS_SB_VERSION_ATTRBIT | \ |
| 57 | XFS_SB_VERSION_NLINKBIT | \ |
| 58 | XFS_SB_VERSION_QUOTABIT | \ |
| 59 | XFS_SB_VERSION_ALIGNBIT | \ |
| 60 | XFS_SB_VERSION_DALIGNBIT | \ |
| 61 | XFS_SB_VERSION_SHAREDBIT | \ |
| 62 | XFS_SB_VERSION_LOGV2BIT | \ |
Nathan Scott | d8cc890 | 2005-11-02 10:34:53 +1100 | [diff] [blame] | 63 | XFS_SB_VERSION_SECTORBIT | \ |
| 64 | XFS_SB_VERSION_MOREBITSBIT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 65 | #define XFS_SB_VERSION_OKREALBITS \ |
| 66 | (XFS_SB_VERSION_NUMBITS | \ |
| 67 | XFS_SB_VERSION_OKREALFBITS | \ |
| 68 | XFS_SB_VERSION_OKSASHFBITS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | |
| 70 | /* |
| 71 | * There are two words to hold XFS "feature" bits: the original |
| 72 | * word, sb_versionnum, and sb_features2. Whenever a bit is set in |
| 73 | * sb_features2, the feature bit XFS_SB_VERSION_MOREBITSBIT must be set. |
| 74 | * |
| 75 | * These defines represent bits in sb_features2. |
| 76 | */ |
| 77 | #define XFS_SB_VERSION2_REALFBITS 0x00ffffff /* Mask: features */ |
| 78 | #define XFS_SB_VERSION2_RESERVED1BIT 0x00000001 |
David Chinner | 92821e2 | 2007-05-24 15:26:31 +1000 | [diff] [blame] | 79 | #define XFS_SB_VERSION2_LAZYSBCOUNTBIT 0x00000002 /* Superblk counters */ |
Nathan Scott | d8cc890 | 2005-11-02 10:34:53 +1100 | [diff] [blame] | 80 | #define XFS_SB_VERSION2_RESERVED4BIT 0x00000004 |
| 81 | #define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */ |
Christoph Hellwig | 6d73cf1 | 2008-12-09 04:47:32 -0500 | [diff] [blame] | 82 | #define XFS_SB_VERSION2_PARENTBIT 0x00000010 /* parent pointers */ |
Arkadiusz Mi?kiewicz | 6743099 | 2010-09-26 06:10:18 +0000 | [diff] [blame] | 83 | #define XFS_SB_VERSION2_PROJID32BIT 0x00000080 /* 32 bit project id */ |
Christoph Hellwig | bc02e86 | 2012-11-16 09:20:37 +1100 | [diff] [blame] | 84 | #define XFS_SB_VERSION2_CRCBIT 0x00000100 /* metadata CRCs */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 85 | |
| 86 | #define XFS_SB_VERSION2_OKREALFBITS \ |
David Chinner | 92821e2 | 2007-05-24 15:26:31 +1000 | [diff] [blame] | 87 | (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \ |
Arkadiusz Mi?kiewicz | 6743099 | 2010-09-26 06:10:18 +0000 | [diff] [blame] | 88 | XFS_SB_VERSION2_ATTR2BIT | \ |
| 89 | XFS_SB_VERSION2_PROJID32BIT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | #define XFS_SB_VERSION2_OKSASHFBITS \ |
| 91 | (0) |
| 92 | #define XFS_SB_VERSION2_OKREALBITS \ |
| 93 | (XFS_SB_VERSION2_OKREALFBITS | \ |
| 94 | XFS_SB_VERSION2_OKSASHFBITS ) |
| 95 | |
Christoph Hellwig | 2bdf7cd | 2007-08-28 13:58:06 +1000 | [diff] [blame] | 96 | /* |
| 97 | * Superblock - in core version. Must match the ondisk version below. |
David Chinner | ee1c090 | 2008-03-06 13:45:50 +1100 | [diff] [blame] | 98 | * Must be padded to 64 bit alignment. |
Christoph Hellwig | 2bdf7cd | 2007-08-28 13:58:06 +1000 | [diff] [blame] | 99 | */ |
| 100 | typedef struct xfs_sb { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 101 | __uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */ |
| 102 | __uint32_t sb_blocksize; /* logical block size, bytes */ |
| 103 | xfs_drfsbno_t sb_dblocks; /* number of data blocks */ |
| 104 | xfs_drfsbno_t sb_rblocks; /* number of realtime blocks */ |
| 105 | xfs_drtbno_t sb_rextents; /* number of realtime extents */ |
| 106 | uuid_t sb_uuid; /* file system unique id */ |
| 107 | xfs_dfsbno_t sb_logstart; /* starting block of log if internal */ |
| 108 | xfs_ino_t sb_rootino; /* root inode number */ |
| 109 | xfs_ino_t sb_rbmino; /* bitmap inode for realtime extents */ |
| 110 | xfs_ino_t sb_rsumino; /* summary inode for rt bitmap */ |
| 111 | xfs_agblock_t sb_rextsize; /* realtime extent size, blocks */ |
| 112 | xfs_agblock_t sb_agblocks; /* size of an allocation group */ |
| 113 | xfs_agnumber_t sb_agcount; /* number of allocation groups */ |
| 114 | xfs_extlen_t sb_rbmblocks; /* number of rt bitmap blocks */ |
| 115 | xfs_extlen_t sb_logblocks; /* number of log blocks */ |
| 116 | __uint16_t sb_versionnum; /* header version == XFS_SB_VERSION */ |
| 117 | __uint16_t sb_sectsize; /* volume sector size, bytes */ |
| 118 | __uint16_t sb_inodesize; /* inode size, bytes */ |
| 119 | __uint16_t sb_inopblock; /* inodes per block */ |
| 120 | char sb_fname[12]; /* file system name */ |
| 121 | __uint8_t sb_blocklog; /* log2 of sb_blocksize */ |
| 122 | __uint8_t sb_sectlog; /* log2 of sb_sectsize */ |
| 123 | __uint8_t sb_inodelog; /* log2 of sb_inodesize */ |
| 124 | __uint8_t sb_inopblog; /* log2 of sb_inopblock */ |
| 125 | __uint8_t sb_agblklog; /* log2 of sb_agblocks (rounded up) */ |
| 126 | __uint8_t sb_rextslog; /* log2 of sb_rextents */ |
| 127 | __uint8_t sb_inprogress; /* mkfs is in progress, don't mount */ |
| 128 | __uint8_t sb_imax_pct; /* max % of fs for inode space */ |
| 129 | /* statistics */ |
| 130 | /* |
| 131 | * These fields must remain contiguous. If you really |
| 132 | * want to change their layout, make sure you fix the |
| 133 | * code in xfs_trans_apply_sb_deltas(). |
| 134 | */ |
| 135 | __uint64_t sb_icount; /* allocated inodes */ |
| 136 | __uint64_t sb_ifree; /* free inodes */ |
| 137 | __uint64_t sb_fdblocks; /* free data blocks */ |
| 138 | __uint64_t sb_frextents; /* free realtime extents */ |
| 139 | /* |
| 140 | * End contiguous fields. |
| 141 | */ |
| 142 | xfs_ino_t sb_uquotino; /* user quota inode */ |
| 143 | xfs_ino_t sb_gquotino; /* group quota inode */ |
| 144 | __uint16_t sb_qflags; /* quota flags */ |
| 145 | __uint8_t sb_flags; /* misc. flags */ |
| 146 | __uint8_t sb_shared_vn; /* shared version number */ |
| 147 | xfs_extlen_t sb_inoalignmt; /* inode chunk alignment, fsblocks */ |
| 148 | __uint32_t sb_unit; /* stripe or raid unit */ |
| 149 | __uint32_t sb_width; /* stripe or raid width */ |
| 150 | __uint8_t sb_dirblklog; /* log2 of dir block size (fsbs) */ |
| 151 | __uint8_t sb_logsectlog; /* log2 of the log sector size */ |
| 152 | __uint16_t sb_logsectsize; /* sector size for the log, bytes */ |
| 153 | __uint32_t sb_logsunit; /* stripe unit size for the log */ |
Nathan Scott | d8cc890 | 2005-11-02 10:34:53 +1100 | [diff] [blame] | 154 | __uint32_t sb_features2; /* additional feature bits */ |
David Chinner | ee1c090 | 2008-03-06 13:45:50 +1100 | [diff] [blame] | 155 | |
| 156 | /* |
| 157 | * bad features2 field as a result of failing to pad the sb |
| 158 | * structure to 64 bits. Some machines will be using this field |
| 159 | * for features2 bits. Easiest just to mark it bad and not use |
| 160 | * it for anything else. |
| 161 | */ |
| 162 | __uint32_t sb_bad_features2; |
| 163 | |
| 164 | /* must be padded to 64 bit alignment */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 165 | } xfs_sb_t; |
| 166 | |
| 167 | /* |
David Chinner | ee1c090 | 2008-03-06 13:45:50 +1100 | [diff] [blame] | 168 | * Superblock - on disk version. Must match the in core version above. |
| 169 | * Must be padded to 64 bit alignment. |
Christoph Hellwig | 2bdf7cd | 2007-08-28 13:58:06 +1000 | [diff] [blame] | 170 | */ |
| 171 | typedef struct xfs_dsb { |
| 172 | __be32 sb_magicnum; /* magic number == XFS_SB_MAGIC */ |
| 173 | __be32 sb_blocksize; /* logical block size, bytes */ |
| 174 | __be64 sb_dblocks; /* number of data blocks */ |
| 175 | __be64 sb_rblocks; /* number of realtime blocks */ |
| 176 | __be64 sb_rextents; /* number of realtime extents */ |
| 177 | uuid_t sb_uuid; /* file system unique id */ |
| 178 | __be64 sb_logstart; /* starting block of log if internal */ |
| 179 | __be64 sb_rootino; /* root inode number */ |
| 180 | __be64 sb_rbmino; /* bitmap inode for realtime extents */ |
| 181 | __be64 sb_rsumino; /* summary inode for rt bitmap */ |
| 182 | __be32 sb_rextsize; /* realtime extent size, blocks */ |
| 183 | __be32 sb_agblocks; /* size of an allocation group */ |
| 184 | __be32 sb_agcount; /* number of allocation groups */ |
| 185 | __be32 sb_rbmblocks; /* number of rt bitmap blocks */ |
| 186 | __be32 sb_logblocks; /* number of log blocks */ |
| 187 | __be16 sb_versionnum; /* header version == XFS_SB_VERSION */ |
| 188 | __be16 sb_sectsize; /* volume sector size, bytes */ |
| 189 | __be16 sb_inodesize; /* inode size, bytes */ |
| 190 | __be16 sb_inopblock; /* inodes per block */ |
| 191 | char sb_fname[12]; /* file system name */ |
| 192 | __u8 sb_blocklog; /* log2 of sb_blocksize */ |
| 193 | __u8 sb_sectlog; /* log2 of sb_sectsize */ |
| 194 | __u8 sb_inodelog; /* log2 of sb_inodesize */ |
| 195 | __u8 sb_inopblog; /* log2 of sb_inopblock */ |
| 196 | __u8 sb_agblklog; /* log2 of sb_agblocks (rounded up) */ |
| 197 | __u8 sb_rextslog; /* log2 of sb_rextents */ |
| 198 | __u8 sb_inprogress; /* mkfs is in progress, don't mount */ |
| 199 | __u8 sb_imax_pct; /* max % of fs for inode space */ |
| 200 | /* statistics */ |
| 201 | /* |
| 202 | * These fields must remain contiguous. If you really |
| 203 | * want to change their layout, make sure you fix the |
| 204 | * code in xfs_trans_apply_sb_deltas(). |
| 205 | */ |
| 206 | __be64 sb_icount; /* allocated inodes */ |
| 207 | __be64 sb_ifree; /* free inodes */ |
| 208 | __be64 sb_fdblocks; /* free data blocks */ |
| 209 | __be64 sb_frextents; /* free realtime extents */ |
| 210 | /* |
| 211 | * End contiguous fields. |
| 212 | */ |
| 213 | __be64 sb_uquotino; /* user quota inode */ |
| 214 | __be64 sb_gquotino; /* group quota inode */ |
| 215 | __be16 sb_qflags; /* quota flags */ |
| 216 | __u8 sb_flags; /* misc. flags */ |
| 217 | __u8 sb_shared_vn; /* shared version number */ |
| 218 | __be32 sb_inoalignmt; /* inode chunk alignment, fsblocks */ |
| 219 | __be32 sb_unit; /* stripe or raid unit */ |
| 220 | __be32 sb_width; /* stripe or raid width */ |
| 221 | __u8 sb_dirblklog; /* log2 of dir block size (fsbs) */ |
| 222 | __u8 sb_logsectlog; /* log2 of the log sector size */ |
| 223 | __be16 sb_logsectsize; /* sector size for the log, bytes */ |
| 224 | __be32 sb_logsunit; /* stripe unit size for the log */ |
| 225 | __be32 sb_features2; /* additional feature bits */ |
David Chinner | ee1c090 | 2008-03-06 13:45:50 +1100 | [diff] [blame] | 226 | /* |
| 227 | * bad features2 field as a result of failing to pad the sb |
| 228 | * structure to 64 bits. Some machines will be using this field |
| 229 | * for features2 bits. Easiest just to mark it bad and not use |
| 230 | * it for anything else. |
| 231 | */ |
| 232 | __be32 sb_bad_features2; |
| 233 | |
| 234 | /* must be padded to 64 bit alignment */ |
Christoph Hellwig | 2bdf7cd | 2007-08-28 13:58:06 +1000 | [diff] [blame] | 235 | } xfs_dsb_t; |
| 236 | |
| 237 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | * Sequence number values for the fields. |
| 239 | */ |
| 240 | typedef enum { |
| 241 | XFS_SBS_MAGICNUM, XFS_SBS_BLOCKSIZE, XFS_SBS_DBLOCKS, XFS_SBS_RBLOCKS, |
| 242 | XFS_SBS_REXTENTS, XFS_SBS_UUID, XFS_SBS_LOGSTART, XFS_SBS_ROOTINO, |
| 243 | XFS_SBS_RBMINO, XFS_SBS_RSUMINO, XFS_SBS_REXTSIZE, XFS_SBS_AGBLOCKS, |
| 244 | XFS_SBS_AGCOUNT, XFS_SBS_RBMBLOCKS, XFS_SBS_LOGBLOCKS, |
| 245 | XFS_SBS_VERSIONNUM, XFS_SBS_SECTSIZE, XFS_SBS_INODESIZE, |
| 246 | XFS_SBS_INOPBLOCK, XFS_SBS_FNAME, XFS_SBS_BLOCKLOG, |
| 247 | XFS_SBS_SECTLOG, XFS_SBS_INODELOG, XFS_SBS_INOPBLOG, XFS_SBS_AGBLKLOG, |
| 248 | XFS_SBS_REXTSLOG, XFS_SBS_INPROGRESS, XFS_SBS_IMAX_PCT, XFS_SBS_ICOUNT, |
| 249 | XFS_SBS_IFREE, XFS_SBS_FDBLOCKS, XFS_SBS_FREXTENTS, XFS_SBS_UQUOTINO, |
| 250 | XFS_SBS_GQUOTINO, XFS_SBS_QFLAGS, XFS_SBS_FLAGS, XFS_SBS_SHARED_VN, |
| 251 | XFS_SBS_INOALIGNMT, XFS_SBS_UNIT, XFS_SBS_WIDTH, XFS_SBS_DIRBLKLOG, |
| 252 | XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT, |
David Chinner | ee1c090 | 2008-03-06 13:45:50 +1100 | [diff] [blame] | 253 | XFS_SBS_FEATURES2, XFS_SBS_BAD_FEATURES2, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | XFS_SBS_FIELDCOUNT |
| 255 | } xfs_sb_field_t; |
| 256 | |
| 257 | /* |
| 258 | * Mask values, defined based on the xfs_sb_field_t values. |
| 259 | * Only define the ones we're using. |
| 260 | */ |
| 261 | #define XFS_SB_MVAL(x) (1LL << XFS_SBS_ ## x) |
| 262 | #define XFS_SB_UUID XFS_SB_MVAL(UUID) |
| 263 | #define XFS_SB_FNAME XFS_SB_MVAL(FNAME) |
| 264 | #define XFS_SB_ROOTINO XFS_SB_MVAL(ROOTINO) |
| 265 | #define XFS_SB_RBMINO XFS_SB_MVAL(RBMINO) |
| 266 | #define XFS_SB_RSUMINO XFS_SB_MVAL(RSUMINO) |
| 267 | #define XFS_SB_VERSIONNUM XFS_SB_MVAL(VERSIONNUM) |
| 268 | #define XFS_SB_UQUOTINO XFS_SB_MVAL(UQUOTINO) |
| 269 | #define XFS_SB_GQUOTINO XFS_SB_MVAL(GQUOTINO) |
| 270 | #define XFS_SB_QFLAGS XFS_SB_MVAL(QFLAGS) |
| 271 | #define XFS_SB_SHARED_VN XFS_SB_MVAL(SHARED_VN) |
| 272 | #define XFS_SB_UNIT XFS_SB_MVAL(UNIT) |
| 273 | #define XFS_SB_WIDTH XFS_SB_MVAL(WIDTH) |
David Chinner | 92821e2 | 2007-05-24 15:26:31 +1000 | [diff] [blame] | 274 | #define XFS_SB_ICOUNT XFS_SB_MVAL(ICOUNT) |
| 275 | #define XFS_SB_IFREE XFS_SB_MVAL(IFREE) |
| 276 | #define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS) |
Nathan Scott | d8cc890 | 2005-11-02 10:34:53 +1100 | [diff] [blame] | 277 | #define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2) |
David Chinner | ee1c090 | 2008-03-06 13:45:50 +1100 | [diff] [blame] | 278 | #define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 279 | #define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT) |
| 280 | #define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1) |
| 281 | #define XFS_SB_MOD_BITS \ |
| 282 | (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \ |
| 283 | XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \ |
Nathan Scott | d8cc890 | 2005-11-02 10:34:53 +1100 | [diff] [blame] | 284 | XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \ |
David Chinner | ee1c090 | 2008-03-06 13:45:50 +1100 | [diff] [blame] | 285 | XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \ |
| 286 | XFS_SB_BAD_FEATURES2) |
Nathan Scott | d8cc890 | 2005-11-02 10:34:53 +1100 | [diff] [blame] | 287 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | |
| 289 | /* |
| 290 | * Misc. Flags - warning - these will be cleared by xfs_repair unless |
| 291 | * a feature bit is set when the flag is used. |
| 292 | */ |
| 293 | #define XFS_SBF_NOFLAGS 0x00 /* no flags set */ |
| 294 | #define XFS_SBF_READONLY 0x01 /* only read-only mounts allowed */ |
| 295 | |
| 296 | /* |
| 297 | * define max. shared version we can interoperate with |
| 298 | */ |
| 299 | #define XFS_SB_MAX_SHARED_VN 0 |
| 300 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 303 | static inline int xfs_sb_good_version(xfs_sb_t *sbp) |
| 304 | { |
| 305 | /* We always support version 1-3 */ |
| 306 | if (sbp->sb_versionnum >= XFS_SB_VERSION_1 && |
| 307 | sbp->sb_versionnum <= XFS_SB_VERSION_3) |
| 308 | return 1; |
| 309 | |
| 310 | /* We support version 4 if all feature bits are supported */ |
| 311 | if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) { |
| 312 | if ((sbp->sb_versionnum & ~XFS_SB_VERSION_OKREALBITS) || |
| 313 | ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && |
| 314 | (sbp->sb_features2 & ~XFS_SB_VERSION2_OKREALBITS))) |
| 315 | return 0; |
| 316 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | #ifdef __KERNEL__ |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 318 | if (sbp->sb_shared_vn > XFS_SB_MAX_SHARED_VN) |
| 319 | return 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 320 | #else |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 321 | if ((sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT) && |
| 322 | sbp->sb_shared_vn > XFS_SB_MAX_SHARED_VN) |
| 323 | return 0; |
| 324 | #endif |
| 325 | |
| 326 | return 1; |
| 327 | } |
| 328 | |
| 329 | return 0; |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 330 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | |
David Chinner | ee1c090 | 2008-03-06 13:45:50 +1100 | [diff] [blame] | 332 | /* |
Eric Sandeen | e6957ea | 2008-04-10 12:19:34 +1000 | [diff] [blame] | 333 | * Detect a mismatched features2 field. Older kernels read/wrote |
| 334 | * this into the wrong slot, so to be safe we keep them in sync. |
David Chinner | ee1c090 | 2008-03-06 13:45:50 +1100 | [diff] [blame] | 335 | */ |
Eric Sandeen | e6957ea | 2008-04-10 12:19:34 +1000 | [diff] [blame] | 336 | static inline int xfs_sb_has_mismatched_features2(xfs_sb_t *sbp) |
David Chinner | ee1c090 | 2008-03-06 13:45:50 +1100 | [diff] [blame] | 337 | { |
Eric Sandeen | e6957ea | 2008-04-10 12:19:34 +1000 | [diff] [blame] | 338 | return (sbp->sb_bad_features2 != sbp->sb_features2); |
David Chinner | ee1c090 | 2008-03-06 13:45:50 +1100 | [diff] [blame] | 339 | } |
| 340 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 341 | static inline unsigned xfs_sb_version_tonew(unsigned v) |
| 342 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 343 | if (v == XFS_SB_VERSION_1) |
| 344 | return XFS_SB_VERSION_4; |
| 345 | |
| 346 | if (v == XFS_SB_VERSION_2) |
| 347 | return XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT; |
| 348 | |
| 349 | return XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT | |
| 350 | XFS_SB_VERSION_NLINKBIT; |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 351 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 352 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 353 | static inline unsigned xfs_sb_version_toold(unsigned v) |
| 354 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 355 | if (v & (XFS_SB_VERSION_QUOTABIT | XFS_SB_VERSION_ALIGNBIT)) |
| 356 | return 0; |
| 357 | if (v & XFS_SB_VERSION_NLINKBIT) |
| 358 | return XFS_SB_VERSION_3; |
| 359 | if (v & XFS_SB_VERSION_ATTRBIT) |
| 360 | return XFS_SB_VERSION_2; |
| 361 | return XFS_SB_VERSION_1; |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 362 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 364 | static inline int xfs_sb_version_hasattr(xfs_sb_t *sbp) |
| 365 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 366 | return sbp->sb_versionnum == XFS_SB_VERSION_2 || |
| 367 | sbp->sb_versionnum == XFS_SB_VERSION_3 || |
| 368 | (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
| 369 | (sbp->sb_versionnum & XFS_SB_VERSION_ATTRBIT)); |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 370 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 371 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 372 | static inline void xfs_sb_version_addattr(xfs_sb_t *sbp) |
| 373 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 374 | if (sbp->sb_versionnum == XFS_SB_VERSION_1) |
| 375 | sbp->sb_versionnum = XFS_SB_VERSION_2; |
| 376 | else if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) |
| 377 | sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT; |
| 378 | else |
| 379 | sbp->sb_versionnum = XFS_SB_VERSION_4 | XFS_SB_VERSION_ATTRBIT; |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 380 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 381 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 382 | static inline int xfs_sb_version_hasnlink(xfs_sb_t *sbp) |
| 383 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 384 | return sbp->sb_versionnum == XFS_SB_VERSION_3 || |
| 385 | (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
| 386 | (sbp->sb_versionnum & XFS_SB_VERSION_NLINKBIT)); |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 387 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 388 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 389 | static inline void xfs_sb_version_addnlink(xfs_sb_t *sbp) |
| 390 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 391 | if (sbp->sb_versionnum <= XFS_SB_VERSION_2) |
| 392 | sbp->sb_versionnum = XFS_SB_VERSION_3; |
| 393 | else |
| 394 | sbp->sb_versionnum |= XFS_SB_VERSION_NLINKBIT; |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 395 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 397 | static inline int xfs_sb_version_hasquota(xfs_sb_t *sbp) |
| 398 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 399 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
| 400 | (sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT); |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 401 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 403 | static inline void xfs_sb_version_addquota(xfs_sb_t *sbp) |
| 404 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 405 | if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) |
| 406 | sbp->sb_versionnum |= XFS_SB_VERSION_QUOTABIT; |
| 407 | else |
| 408 | sbp->sb_versionnum = xfs_sb_version_tonew(sbp->sb_versionnum) | |
| 409 | XFS_SB_VERSION_QUOTABIT; |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 410 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 412 | static inline int xfs_sb_version_hasalign(xfs_sb_t *sbp) |
| 413 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 414 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
| 415 | (sbp->sb_versionnum & XFS_SB_VERSION_ALIGNBIT); |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 416 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 418 | static inline int xfs_sb_version_hasdalign(xfs_sb_t *sbp) |
| 419 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 420 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
| 421 | (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT); |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 422 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 424 | static inline int xfs_sb_version_hasshared(xfs_sb_t *sbp) |
| 425 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 426 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
| 427 | (sbp->sb_versionnum & XFS_SB_VERSION_SHAREDBIT); |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 428 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 430 | static inline int xfs_sb_version_hasdirv2(xfs_sb_t *sbp) |
| 431 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 432 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
| 433 | (sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT); |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 434 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 435 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 436 | static inline int xfs_sb_version_haslogv2(xfs_sb_t *sbp) |
| 437 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 438 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
| 439 | (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT); |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 440 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 441 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 442 | static inline int xfs_sb_version_hasextflgbit(xfs_sb_t *sbp) |
| 443 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 444 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
| 445 | (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT); |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 446 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 448 | static inline int xfs_sb_version_hassector(xfs_sb_t *sbp) |
| 449 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 450 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
| 451 | (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT); |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 452 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | |
Barry Naujok | 189f4bf | 2008-05-21 16:58:55 +1000 | [diff] [blame] | 454 | static inline int xfs_sb_version_hasasciici(xfs_sb_t *sbp) |
| 455 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 456 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
Barry Naujok | 189f4bf | 2008-05-21 16:58:55 +1000 | [diff] [blame] | 457 | (sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT); |
| 458 | } |
| 459 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 460 | static inline int xfs_sb_version_hasmorebits(xfs_sb_t *sbp) |
| 461 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 462 | return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4 && |
| 463 | (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT); |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 464 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 465 | |
| 466 | /* |
| 467 | * sb_features2 bit version macros. |
| 468 | * |
Nathan Scott | d8cc890 | 2005-11-02 10:34:53 +1100 | [diff] [blame] | 469 | * For example, for a bit defined as XFS_SB_VERSION2_FUNBIT, has a macro: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 470 | * |
Nathan Scott | d8cc890 | 2005-11-02 10:34:53 +1100 | [diff] [blame] | 471 | * SB_VERSION_HASFUNBIT(xfs_sb_t *sbp) |
Eric Sandeen | 6211870 | 2008-03-06 13:44:28 +1100 | [diff] [blame] | 472 | * ((xfs_sb_version_hasmorebits(sbp) && |
Nathan Scott | d8cc890 | 2005-11-02 10:34:53 +1100 | [diff] [blame] | 473 | * ((sbp)->sb_features2 & XFS_SB_VERSION2_FUNBIT) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | */ |
| 475 | |
David Chinner | 92821e2 | 2007-05-24 15:26:31 +1000 | [diff] [blame] | 476 | static inline int xfs_sb_version_haslazysbcount(xfs_sb_t *sbp) |
| 477 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 478 | return xfs_sb_version_hasmorebits(sbp) && |
| 479 | (sbp->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT); |
David Chinner | 92821e2 | 2007-05-24 15:26:31 +1000 | [diff] [blame] | 480 | } |
| 481 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 482 | static inline int xfs_sb_version_hasattr2(xfs_sb_t *sbp) |
| 483 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 484 | return xfs_sb_version_hasmorebits(sbp) && |
| 485 | (sbp->sb_features2 & XFS_SB_VERSION2_ATTR2BIT); |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 486 | } |
| 487 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 488 | static inline void xfs_sb_version_addattr2(xfs_sb_t *sbp) |
| 489 | { |
Christoph Hellwig | 5efcbb8 | 2008-12-03 12:20:31 +0100 | [diff] [blame] | 490 | sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; |
| 491 | sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT; |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 492 | } |
| 493 | |
Tim Shimmin | 7c12f29 | 2008-04-30 18:15:28 +1000 | [diff] [blame] | 494 | static inline void xfs_sb_version_removeattr2(xfs_sb_t *sbp) |
| 495 | { |
| 496 | sbp->sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT; |
| 497 | if (!sbp->sb_features2) |
| 498 | sbp->sb_versionnum &= ~XFS_SB_VERSION_MOREBITSBIT; |
| 499 | } |
| 500 | |
Arkadiusz Mi?kiewicz | 6743099 | 2010-09-26 06:10:18 +0000 | [diff] [blame] | 501 | static inline int xfs_sb_version_hasprojid32bit(xfs_sb_t *sbp) |
| 502 | { |
| 503 | return xfs_sb_version_hasmorebits(sbp) && |
| 504 | (sbp->sb_features2 & XFS_SB_VERSION2_PROJID32BIT); |
| 505 | } |
| 506 | |
Christoph Hellwig | bc02e86 | 2012-11-16 09:20:37 +1100 | [diff] [blame] | 507 | static inline int xfs_sb_version_hascrc(xfs_sb_t *sbp) |
| 508 | { |
| 509 | return (xfs_sb_version_hasmorebits(sbp) && |
| 510 | (sbp->sb_features2 & XFS_SB_VERSION2_CRCBIT)); |
| 511 | } |
| 512 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 513 | /* |
| 514 | * end of superblock version macros |
| 515 | */ |
| 516 | |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 517 | #define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 518 | #define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR) |
Chandra Seetharaman | 6292604 | 2011-07-22 23:40:15 +0000 | [diff] [blame] | 519 | #define XFS_BUF_TO_SBP(bp) ((xfs_dsb_t *)((bp)->b_addr)) |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 520 | |
| 521 | #define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d)) |
| 522 | #define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \ |
Eric Sandeen | b6e3222 | 2009-01-14 23:22:07 -0600 | [diff] [blame] | 523 | xfs_daddr_to_agno(mp,d), xfs_daddr_to_agbno(mp,d)) |
Nathan Scott | a844f45 | 2005-11-02 14:38:42 +1100 | [diff] [blame] | 524 | #define XFS_FSB_TO_DADDR(mp,fsbno) XFS_AGB_TO_DADDR(mp, \ |
| 525 | XFS_FSB_TO_AGNO(mp,fsbno), XFS_FSB_TO_AGBNO(mp,fsbno)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 526 | |
| 527 | /* |
| 528 | * File system sector to basic block conversions. |
| 529 | */ |
| 530 | #define XFS_FSS_TO_BB(mp,sec) ((sec) << (mp)->m_sectbb_log) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 531 | |
| 532 | /* |
| 533 | * File system block to basic block conversions. |
| 534 | */ |
| 535 | #define XFS_FSB_TO_BB(mp,fsbno) ((fsbno) << (mp)->m_blkbb_log) |
| 536 | #define XFS_BB_TO_FSB(mp,bb) \ |
| 537 | (((bb) + (XFS_FSB_TO_BB(mp,1) - 1)) >> (mp)->m_blkbb_log) |
| 538 | #define XFS_BB_TO_FSBT(mp,bb) ((bb) >> (mp)->m_blkbb_log) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 539 | |
| 540 | /* |
| 541 | * File system block to byte conversions. |
| 542 | */ |
| 543 | #define XFS_FSB_TO_B(mp,fsbno) ((xfs_fsize_t)(fsbno) << (mp)->m_sb.sb_blocklog) |
| 544 | #define XFS_B_TO_FSB(mp,b) \ |
| 545 | ((((__uint64_t)(b)) + (mp)->m_blockmask) >> (mp)->m_sb.sb_blocklog) |
| 546 | #define XFS_B_TO_FSBT(mp,b) (((__uint64_t)(b)) >> (mp)->m_sb.sb_blocklog) |
| 547 | #define XFS_B_FSB_OFFSET(mp,b) ((b) & (mp)->m_blockmask) |
| 548 | |
| 549 | #endif /* __XFS_SB_H__ */ |