Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'xfs-for-linus-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs

Pull xfs update from Dave Chinner:
"There's relatively little change in this update; it is mainly bug
fixes, cleanups and more of the on-going libxfs restructuring and
on-disk format header consolidation work.

Details:
- more on-disk format header consolidation
- move some structures shared with userspace to libxfs
- new per-mount workqueue to fix for deadlocks between nested loop
mounted filesystems
- various bug fixes for ENOSPC, stats, quota off and preallocation
- a bunch of compiler warning fixes for set-but-unused variables
- various code cleanups"

* tag 'xfs-for-linus-3.19-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/dgc/linux-xfs: (24 commits)
xfs: split metadata and log buffer completion to separate workqueues
xfs: fix set-but-unused warnings
xfs: move type conversion functions to xfs_dir.h
xfs: move ftype conversion functions to libxfs
xfs: lobotomise xfs_trans_read_buf_map()
xfs: active inodes stat is broken
xfs: cleanup xfs_bmse_merge returns
xfs: cleanup xfs_bmse_shift_one goto mess
xfs: fix premature enospc on inode allocation
xfs: overflow in xfs_iomap_eof_align_last_fsb
xfs: fix simple_return.cocci warning in xfs_bmse_shift_one
xfs: fix simple_return.cocci warning in xfs_file_readdir
libxfs: fix simple_return.cocci warnings
xfs: remove unnecessary null checks
xfs: merge xfs_inum.h into xfs_format.h
xfs: move most of xfs_sb.h to xfs_format.h
xfs: merge xfs_ag.h into xfs_format.h
xfs: move acl structures to xfs_format.h
xfs: merge xfs_dinode.h into xfs_format.h
xfs: catch invalid negative blknos in _xfs_buf_find()
...

+1466 -1834
-281
fs/xfs/libxfs/xfs_ag.h
··· 1 - /* 2 - * Copyright (c) 2000-2003,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_AG_H__ 19 - #define __XFS_AG_H__ 20 - 21 - /* 22 - * Allocation group header 23 - * This is divided into three structures, placed in sequential 512-byte 24 - * buffers after a copy of the superblock (also in a 512-byte buffer). 25 - */ 26 - 27 - struct xfs_buf; 28 - struct xfs_mount; 29 - struct xfs_trans; 30 - 31 - #define XFS_AGF_MAGIC 0x58414746 /* 'XAGF' */ 32 - #define XFS_AGI_MAGIC 0x58414749 /* 'XAGI' */ 33 - #define XFS_AGFL_MAGIC 0x5841464c /* 'XAFL' */ 34 - #define XFS_AGF_VERSION 1 35 - #define XFS_AGI_VERSION 1 36 - 37 - #define XFS_AGF_GOOD_VERSION(v) ((v) == XFS_AGF_VERSION) 38 - #define XFS_AGI_GOOD_VERSION(v) ((v) == XFS_AGI_VERSION) 39 - 40 - /* 41 - * Btree number 0 is bno, 1 is cnt. This value gives the size of the 42 - * arrays below. 43 - */ 44 - #define XFS_BTNUM_AGF ((int)XFS_BTNUM_CNTi + 1) 45 - 46 - /* 47 - * The second word of agf_levels in the first a.g. overlaps the EFS 48 - * superblock's magic number. Since the magic numbers valid for EFS 49 - * are > 64k, our value cannot be confused for an EFS superblock's. 50 - */ 51 - 52 - typedef struct xfs_agf { 53 - /* 54 - * Common allocation group header information 55 - */ 56 - __be32 agf_magicnum; /* magic number == XFS_AGF_MAGIC */ 57 - __be32 agf_versionnum; /* header version == XFS_AGF_VERSION */ 58 - __be32 agf_seqno; /* sequence # starting from 0 */ 59 - __be32 agf_length; /* size in blocks of a.g. */ 60 - /* 61 - * Freespace information 62 - */ 63 - __be32 agf_roots[XFS_BTNUM_AGF]; /* root blocks */ 64 - __be32 agf_spare0; /* spare field */ 65 - __be32 agf_levels[XFS_BTNUM_AGF]; /* btree levels */ 66 - __be32 agf_spare1; /* spare field */ 67 - 68 - __be32 agf_flfirst; /* first freelist block's index */ 69 - __be32 agf_fllast; /* last freelist block's index */ 70 - __be32 agf_flcount; /* count of blocks in freelist */ 71 - __be32 agf_freeblks; /* total free blocks */ 72 - 73 - __be32 agf_longest; /* longest free space */ 74 - __be32 agf_btreeblks; /* # of blocks held in AGF btrees */ 75 - uuid_t agf_uuid; /* uuid of filesystem */ 76 - 77 - /* 78 - * reserve some contiguous space for future logged fields before we add 79 - * the unlogged fields. This makes the range logging via flags and 80 - * structure offsets much simpler. 81 - */ 82 - __be64 agf_spare64[16]; 83 - 84 - /* unlogged fields, written during buffer writeback. */ 85 - __be64 agf_lsn; /* last write sequence */ 86 - __be32 agf_crc; /* crc of agf sector */ 87 - __be32 agf_spare2; 88 - 89 - /* structure must be padded to 64 bit alignment */ 90 - } xfs_agf_t; 91 - 92 - #define XFS_AGF_CRC_OFF offsetof(struct xfs_agf, agf_crc) 93 - 94 - #define XFS_AGF_MAGICNUM 0x00000001 95 - #define XFS_AGF_VERSIONNUM 0x00000002 96 - #define XFS_AGF_SEQNO 0x00000004 97 - #define XFS_AGF_LENGTH 0x00000008 98 - #define XFS_AGF_ROOTS 0x00000010 99 - #define XFS_AGF_LEVELS 0x00000020 100 - #define XFS_AGF_FLFIRST 0x00000040 101 - #define XFS_AGF_FLLAST 0x00000080 102 - #define XFS_AGF_FLCOUNT 0x00000100 103 - #define XFS_AGF_FREEBLKS 0x00000200 104 - #define XFS_AGF_LONGEST 0x00000400 105 - #define XFS_AGF_BTREEBLKS 0x00000800 106 - #define XFS_AGF_UUID 0x00001000 107 - #define XFS_AGF_NUM_BITS 13 108 - #define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1) 109 - 110 - #define XFS_AGF_FLAGS \ 111 - { XFS_AGF_MAGICNUM, "MAGICNUM" }, \ 112 - { XFS_AGF_VERSIONNUM, "VERSIONNUM" }, \ 113 - { XFS_AGF_SEQNO, "SEQNO" }, \ 114 - { XFS_AGF_LENGTH, "LENGTH" }, \ 115 - { XFS_AGF_ROOTS, "ROOTS" }, \ 116 - { XFS_AGF_LEVELS, "LEVELS" }, \ 117 - { XFS_AGF_FLFIRST, "FLFIRST" }, \ 118 - { XFS_AGF_FLLAST, "FLLAST" }, \ 119 - { XFS_AGF_FLCOUNT, "FLCOUNT" }, \ 120 - { XFS_AGF_FREEBLKS, "FREEBLKS" }, \ 121 - { XFS_AGF_LONGEST, "LONGEST" }, \ 122 - { XFS_AGF_BTREEBLKS, "BTREEBLKS" }, \ 123 - { XFS_AGF_UUID, "UUID" } 124 - 125 - /* disk block (xfs_daddr_t) in the AG */ 126 - #define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) 127 - #define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp)) 128 - #define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)((bp)->b_addr)) 129 - 130 - extern int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp, 131 - xfs_agnumber_t agno, int flags, struct xfs_buf **bpp); 132 - 133 - /* 134 - * Size of the unlinked inode hash table in the agi. 135 - */ 136 - #define XFS_AGI_UNLINKED_BUCKETS 64 137 - 138 - typedef struct xfs_agi { 139 - /* 140 - * Common allocation group header information 141 - */ 142 - __be32 agi_magicnum; /* magic number == XFS_AGI_MAGIC */ 143 - __be32 agi_versionnum; /* header version == XFS_AGI_VERSION */ 144 - __be32 agi_seqno; /* sequence # starting from 0 */ 145 - __be32 agi_length; /* size in blocks of a.g. */ 146 - /* 147 - * Inode information 148 - * Inodes are mapped by interpreting the inode number, so no 149 - * mapping data is needed here. 150 - */ 151 - __be32 agi_count; /* count of allocated inodes */ 152 - __be32 agi_root; /* root of inode btree */ 153 - __be32 agi_level; /* levels in inode btree */ 154 - __be32 agi_freecount; /* number of free inodes */ 155 - 156 - __be32 agi_newino; /* new inode just allocated */ 157 - __be32 agi_dirino; /* last directory inode chunk */ 158 - /* 159 - * Hash table of inodes which have been unlinked but are 160 - * still being referenced. 161 - */ 162 - __be32 agi_unlinked[XFS_AGI_UNLINKED_BUCKETS]; 163 - /* 164 - * This marks the end of logging region 1 and start of logging region 2. 165 - */ 166 - uuid_t agi_uuid; /* uuid of filesystem */ 167 - __be32 agi_crc; /* crc of agi sector */ 168 - __be32 agi_pad32; 169 - __be64 agi_lsn; /* last write sequence */ 170 - 171 - __be32 agi_free_root; /* root of the free inode btree */ 172 - __be32 agi_free_level;/* levels in free inode btree */ 173 - 174 - /* structure must be padded to 64 bit alignment */ 175 - } xfs_agi_t; 176 - 177 - #define XFS_AGI_CRC_OFF offsetof(struct xfs_agi, agi_crc) 178 - 179 - #define XFS_AGI_MAGICNUM (1 << 0) 180 - #define XFS_AGI_VERSIONNUM (1 << 1) 181 - #define XFS_AGI_SEQNO (1 << 2) 182 - #define XFS_AGI_LENGTH (1 << 3) 183 - #define XFS_AGI_COUNT (1 << 4) 184 - #define XFS_AGI_ROOT (1 << 5) 185 - #define XFS_AGI_LEVEL (1 << 6) 186 - #define XFS_AGI_FREECOUNT (1 << 7) 187 - #define XFS_AGI_NEWINO (1 << 8) 188 - #define XFS_AGI_DIRINO (1 << 9) 189 - #define XFS_AGI_UNLINKED (1 << 10) 190 - #define XFS_AGI_NUM_BITS_R1 11 /* end of the 1st agi logging region */ 191 - #define XFS_AGI_ALL_BITS_R1 ((1 << XFS_AGI_NUM_BITS_R1) - 1) 192 - #define XFS_AGI_FREE_ROOT (1 << 11) 193 - #define XFS_AGI_FREE_LEVEL (1 << 12) 194 - #define XFS_AGI_NUM_BITS_R2 13 195 - 196 - /* disk block (xfs_daddr_t) in the AG */ 197 - #define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log)) 198 - #define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp)) 199 - #define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)((bp)->b_addr)) 200 - 201 - extern int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp, 202 - xfs_agnumber_t agno, struct xfs_buf **bpp); 203 - 204 - /* 205 - * The third a.g. block contains the a.g. freelist, an array 206 - * of block pointers to blocks owned by the allocation btree code. 207 - */ 208 - #define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log)) 209 - #define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp)) 210 - #define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)((bp)->b_addr)) 211 - 212 - #define XFS_BUF_TO_AGFL_BNO(mp, bp) \ 213 - (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ 214 - &(XFS_BUF_TO_AGFL(bp)->agfl_bno[0]) : \ 215 - (__be32 *)(bp)->b_addr) 216 - 217 - /* 218 - * Size of the AGFL. For CRC-enabled filesystes we steal a couple of 219 - * slots in the beginning of the block for a proper header with the 220 - * location information and CRC. 221 - */ 222 - #define XFS_AGFL_SIZE(mp) \ 223 - (((mp)->m_sb.sb_sectsize - \ 224 - (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ 225 - sizeof(struct xfs_agfl) : 0)) / \ 226 - sizeof(xfs_agblock_t)) 227 - 228 - typedef struct xfs_agfl { 229 - __be32 agfl_magicnum; 230 - __be32 agfl_seqno; 231 - uuid_t agfl_uuid; 232 - __be64 agfl_lsn; 233 - __be32 agfl_crc; 234 - __be32 agfl_bno[]; /* actually XFS_AGFL_SIZE(mp) */ 235 - } xfs_agfl_t; 236 - 237 - #define XFS_AGFL_CRC_OFF offsetof(struct xfs_agfl, agfl_crc) 238 - 239 - /* 240 - * tags for inode radix tree 241 - */ 242 - #define XFS_ICI_NO_TAG (-1) /* special flag for an untagged lookup 243 - in xfs_inode_ag_iterator */ 244 - #define XFS_ICI_RECLAIM_TAG 0 /* inode is to be reclaimed */ 245 - #define XFS_ICI_EOFBLOCKS_TAG 1 /* inode has blocks beyond EOF */ 246 - 247 - #define XFS_AG_MAXLEVELS(mp) ((mp)->m_ag_maxlevels) 248 - #define XFS_MIN_FREELIST_RAW(bl,cl,mp) \ 249 - (MIN(bl + 1, XFS_AG_MAXLEVELS(mp)) + MIN(cl + 1, XFS_AG_MAXLEVELS(mp))) 250 - #define XFS_MIN_FREELIST(a,mp) \ 251 - (XFS_MIN_FREELIST_RAW( \ 252 - be32_to_cpu((a)->agf_levels[XFS_BTNUM_BNOi]), \ 253 - be32_to_cpu((a)->agf_levels[XFS_BTNUM_CNTi]), mp)) 254 - #define XFS_MIN_FREELIST_PAG(pag,mp) \ 255 - (XFS_MIN_FREELIST_RAW( \ 256 - (unsigned int)(pag)->pagf_levels[XFS_BTNUM_BNOi], \ 257 - (unsigned int)(pag)->pagf_levels[XFS_BTNUM_CNTi], mp)) 258 - 259 - #define XFS_AGB_TO_FSB(mp,agno,agbno) \ 260 - (((xfs_fsblock_t)(agno) << (mp)->m_sb.sb_agblklog) | (agbno)) 261 - #define XFS_FSB_TO_AGNO(mp,fsbno) \ 262 - ((xfs_agnumber_t)((fsbno) >> (mp)->m_sb.sb_agblklog)) 263 - #define XFS_FSB_TO_AGBNO(mp,fsbno) \ 264 - ((xfs_agblock_t)((fsbno) & xfs_mask32lo((mp)->m_sb.sb_agblklog))) 265 - #define XFS_AGB_TO_DADDR(mp,agno,agbno) \ 266 - ((xfs_daddr_t)XFS_FSB_TO_BB(mp, \ 267 - (xfs_fsblock_t)(agno) * (mp)->m_sb.sb_agblocks + (agbno))) 268 - #define XFS_AG_DADDR(mp,agno,d) (XFS_AGB_TO_DADDR(mp, agno, 0) + (d)) 269 - 270 - /* 271 - * For checking for bad ranges of xfs_daddr_t's, covering multiple 272 - * allocation groups or a single xfs_daddr_t that's a superblock copy. 273 - */ 274 - #define XFS_AG_CHECK_DADDR(mp,d,len) \ 275 - ((len) == 1 ? \ 276 - ASSERT((d) == XFS_SB_DADDR || \ 277 - xfs_daddr_to_agbno(mp, d) != XFS_SB_DADDR) : \ 278 - ASSERT(xfs_daddr_to_agno(mp, d) == \ 279 - xfs_daddr_to_agno(mp, (d) + (len) - 1))) 280 - 281 - #endif /* __XFS_AG_H__ */
-1
fs/xfs/libxfs/xfs_alloc.c
··· 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_bit.h" 25 25 #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 26 #include "xfs_mount.h" 28 27 #include "xfs_inode.h" 29 28 #include "xfs_btree.h"
+3
fs/xfs/libxfs/xfs_alloc.h
··· 231 231 xfs_extlen_t *len, /* output: length of extent */ 232 232 int *stat); /* output: success/failure */ 233 233 234 + int xfs_read_agf(struct xfs_mount *mp, struct xfs_trans *tp, 235 + xfs_agnumber_t agno, int flags, struct xfs_buf **bpp); 236 + 234 237 #endif /* __XFS_ALLOC_H__ */
-1
fs/xfs/libxfs/xfs_alloc_btree.c
··· 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 25 #include "xfs_mount.h" 27 26 #include "xfs_btree.h" 28 27 #include "xfs_alloc_btree.h"
-3
fs/xfs/libxfs/xfs_attr.c
··· 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_bit.h" 25 - #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 25 #include "xfs_mount.h" 28 26 #include "xfs_da_format.h" 29 27 #include "xfs_da_btree.h" ··· 40 42 #include "xfs_quota.h" 41 43 #include "xfs_trans_space.h" 42 44 #include "xfs_trace.h" 43 - #include "xfs_dinode.h" 44 45 45 46 /* 46 47 * xfs_attr.c
-2
fs/xfs/libxfs/xfs_attr_leaf.c
··· 24 24 #include "xfs_trans_resv.h" 25 25 #include "xfs_bit.h" 26 26 #include "xfs_sb.h" 27 - #include "xfs_ag.h" 28 27 #include "xfs_mount.h" 29 28 #include "xfs_da_format.h" 30 29 #include "xfs_da_btree.h" ··· 40 41 #include "xfs_trace.h" 41 42 #include "xfs_buf_item.h" 42 43 #include "xfs_cksum.h" 43 - #include "xfs_dinode.h" 44 44 #include "xfs_dir2.h" 45 45 46 46
-2
fs/xfs/libxfs/xfs_attr_remote.c
··· 23 23 #include "xfs_log_format.h" 24 24 #include "xfs_trans_resv.h" 25 25 #include "xfs_bit.h" 26 - #include "xfs_sb.h" 27 - #include "xfs_ag.h" 28 26 #include "xfs_mount.h" 29 27 #include "xfs_da_format.h" 30 28 #include "xfs_da_btree.h"
+26 -51
fs/xfs/libxfs/xfs_bmap.c
··· 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_bit.h" 25 - #include "xfs_inum.h" 26 25 #include "xfs_sb.h" 27 - #include "xfs_ag.h" 28 26 #include "xfs_mount.h" 29 27 #include "xfs_da_format.h" 30 28 #include "xfs_da_btree.h" ··· 44 46 #include "xfs_trace.h" 45 47 #include "xfs_symlink.h" 46 48 #include "xfs_attr_leaf.h" 47 - #include "xfs_dinode.h" 48 49 #include "xfs_filestream.h" 49 50 50 51 ··· 5447 5450 struct xfs_btree_cur *cur, 5448 5451 int *logflags) /* output */ 5449 5452 { 5450 - struct xfs_ifork *ifp; 5451 5453 struct xfs_bmbt_irec got; 5452 5454 struct xfs_bmbt_irec left; 5453 5455 xfs_filblks_t blockcount; 5454 5456 int error, i; 5455 5457 5456 - ifp = XFS_IFORK_PTR(ip, whichfork); 5457 5458 xfs_bmbt_get_all(gotp, &got); 5458 5459 xfs_bmbt_get_all(leftp, &left); 5459 5460 blockcount = left.br_blockcount + got.br_blockcount; ··· 5484 5489 error = xfs_bmbt_lookup_eq(cur, got.br_startoff, got.br_startblock, 5485 5490 got.br_blockcount, &i); 5486 5491 if (error) 5487 - goto out_error; 5488 - XFS_WANT_CORRUPTED_GOTO(i == 1, out_error); 5492 + return error; 5493 + XFS_WANT_CORRUPTED_RETURN(i == 1); 5489 5494 5490 5495 error = xfs_btree_delete(cur, &i); 5491 5496 if (error) 5492 - goto out_error; 5493 - XFS_WANT_CORRUPTED_GOTO(i == 1, out_error); 5497 + return error; 5498 + XFS_WANT_CORRUPTED_RETURN(i == 1); 5494 5499 5495 5500 /* lookup and update size of the previous extent */ 5496 5501 error = xfs_bmbt_lookup_eq(cur, left.br_startoff, left.br_startblock, 5497 5502 left.br_blockcount, &i); 5498 5503 if (error) 5499 - goto out_error; 5500 - XFS_WANT_CORRUPTED_GOTO(i == 1, out_error); 5504 + return error; 5505 + XFS_WANT_CORRUPTED_RETURN(i == 1); 5501 5506 5502 5507 left.br_blockcount = blockcount; 5503 5508 5504 - error = xfs_bmbt_update(cur, left.br_startoff, left.br_startblock, 5505 - left.br_blockcount, left.br_state); 5506 - if (error) 5507 - goto out_error; 5508 - 5509 - return 0; 5510 - 5511 - out_error: 5512 - return error; 5509 + return xfs_bmbt_update(cur, left.br_startoff, left.br_startblock, 5510 + left.br_blockcount, left.br_state); 5513 5511 } 5514 5512 5515 5513 /* ··· 5532 5544 startoff = got.br_startoff - offset_shift_fsb; 5533 5545 5534 5546 /* delalloc extents should be prevented by caller */ 5535 - XFS_WANT_CORRUPTED_GOTO(!isnullstartblock(got.br_startblock), 5536 - out_error); 5547 + XFS_WANT_CORRUPTED_RETURN(!isnullstartblock(got.br_startblock)); 5537 5548 5538 5549 /* 5539 - * If this is the first extent in the file, make sure there's enough 5540 - * room at the start of the file and jump right to the shift as there's 5541 - * no left extent to merge. 5550 + * Check for merge if we've got an extent to the left, otherwise make 5551 + * sure there's enough room at the start of the file for the shift. 5542 5552 */ 5543 - if (*current_ext == 0) { 5544 - if (got.br_startoff < offset_shift_fsb) 5553 + if (*current_ext) { 5554 + /* grab the left extent and check for a large enough hole */ 5555 + leftp = xfs_iext_get_ext(ifp, *current_ext - 1); 5556 + xfs_bmbt_get_all(leftp, &left); 5557 + 5558 + if (startoff < left.br_startoff + left.br_blockcount) 5545 5559 return -EINVAL; 5546 - goto shift_extent; 5547 - } 5548 5560 5549 - /* grab the left extent and check for a large enough hole */ 5550 - leftp = xfs_iext_get_ext(ifp, *current_ext - 1); 5551 - xfs_bmbt_get_all(leftp, &left); 5552 - 5553 - if (startoff < left.br_startoff + left.br_blockcount) 5561 + /* check whether to merge the extent or shift it down */ 5562 + if (xfs_bmse_can_merge(&left, &got, offset_shift_fsb)) { 5563 + return xfs_bmse_merge(ip, whichfork, offset_shift_fsb, 5564 + *current_ext, gotp, leftp, cur, 5565 + logflags); 5566 + } 5567 + } else if (got.br_startoff < offset_shift_fsb) 5554 5568 return -EINVAL; 5555 5569 5556 - /* check whether to merge the extent or shift it down */ 5557 - if (!xfs_bmse_can_merge(&left, &got, offset_shift_fsb)) 5558 - goto shift_extent; 5559 - 5560 - return xfs_bmse_merge(ip, whichfork, offset_shift_fsb, *current_ext, 5561 - gotp, leftp, cur, logflags); 5562 - 5563 - shift_extent: 5564 5570 /* 5565 5571 * Increment the extent index for the next iteration, update the start 5566 5572 * offset of the in-core extent and update the btree if applicable. ··· 5571 5589 got.br_blockcount, &i); 5572 5590 if (error) 5573 5591 return error; 5574 - XFS_WANT_CORRUPTED_GOTO(i == 1, out_error); 5592 + XFS_WANT_CORRUPTED_RETURN(i == 1); 5575 5593 5576 5594 got.br_startoff = startoff; 5577 - error = xfs_bmbt_update(cur, got.br_startoff, got.br_startblock, 5595 + return xfs_bmbt_update(cur, got.br_startoff, got.br_startblock, 5578 5596 got.br_blockcount, got.br_state); 5579 - if (error) 5580 - return error; 5581 - 5582 - return 0; 5583 - 5584 - out_error: 5585 - return error; 5586 5597 } 5587 5598 5588 5599 /*
-3
fs/xfs/libxfs/xfs_bmap_btree.c
··· 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_bit.h" 25 - #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 25 #include "xfs_mount.h" 28 26 #include "xfs_inode.h" 29 27 #include "xfs_trans.h" ··· 34 36 #include "xfs_quota.h" 35 37 #include "xfs_trace.h" 36 38 #include "xfs_cksum.h" 37 - #include "xfs_dinode.h" 38 39 39 40 /* 40 41 * Determine the extent state.
-2
fs/xfs/libxfs/xfs_btree.c
··· 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_bit.h" 25 - #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 25 #include "xfs_mount.h" 28 26 #include "xfs_inode.h" 29 27 #include "xfs_trans.h"
-6
fs/xfs/libxfs/xfs_da_btree.c
··· 23 23 #include "xfs_log_format.h" 24 24 #include "xfs_trans_resv.h" 25 25 #include "xfs_bit.h" 26 - #include "xfs_sb.h" 27 - #include "xfs_ag.h" 28 26 #include "xfs_mount.h" 29 27 #include "xfs_da_format.h" 30 28 #include "xfs_da_btree.h" ··· 512 514 struct xfs_buf *bp; 513 515 struct xfs_inode *dp; 514 516 struct xfs_trans *tp; 515 - struct xfs_mount *mp; 516 517 struct xfs_dir2_leaf *leaf; 517 518 xfs_dablk_t blkno; 518 519 int level; ··· 531 534 532 535 dp = args->dp; 533 536 tp = args->trans; 534 - mp = state->mp; 535 537 error = xfs_da_get_buf(tp, dp, blkno, -1, &bp, args->whichfork); 536 538 if (error) 537 539 return error; ··· 2338 2342 xfs_inode_t *dp; 2339 2343 int done, error, w, count; 2340 2344 xfs_trans_t *tp; 2341 - xfs_mount_t *mp; 2342 2345 2343 2346 trace_xfs_da_shrink_inode(args); 2344 2347 2345 2348 dp = args->dp; 2346 2349 w = args->whichfork; 2347 2350 tp = args->trans; 2348 - mp = dp->i_mount; 2349 2351 count = args->geo->fsbcount; 2350 2352 for (;;) { 2351 2353 /*
-2
fs/xfs/libxfs/xfs_da_format.c
··· 22 22 #include "xfs_format.h" 23 23 #include "xfs_log_format.h" 24 24 #include "xfs_trans_resv.h" 25 - #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 25 #include "xfs_mount.h" 28 26 #include "xfs_da_format.h" 29 27 #include "xfs_da_btree.h"
-243
fs/xfs/libxfs/xfs_dinode.h
··· 1 - /* 2 - * Copyright (c) 2000,2002,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_DINODE_H__ 19 - #define __XFS_DINODE_H__ 20 - 21 - #define XFS_DINODE_MAGIC 0x494e /* 'IN' */ 22 - #define XFS_DINODE_GOOD_VERSION(v) ((v) >= 1 && (v) <= 3) 23 - 24 - typedef struct xfs_timestamp { 25 - __be32 t_sec; /* timestamp seconds */ 26 - __be32 t_nsec; /* timestamp nanoseconds */ 27 - } xfs_timestamp_t; 28 - 29 - /* 30 - * On-disk inode structure. 31 - * 32 - * This is just the header or "dinode core", the inode is expanded to fill a 33 - * variable size the leftover area split into a data and an attribute fork. 34 - * The format of the data and attribute fork depends on the format of the 35 - * inode as indicated by di_format and di_aformat. To access the data and 36 - * attribute use the XFS_DFORK_DPTR, XFS_DFORK_APTR, and XFS_DFORK_PTR macros 37 - * below. 38 - * 39 - * There is a very similar struct icdinode in xfs_inode which matches the 40 - * layout of the first 96 bytes of this structure, but is kept in native 41 - * format instead of big endian. 42 - * 43 - * Note: di_flushiter is only used by v1/2 inodes - it's effectively a zeroed 44 - * padding field for v3 inodes. 45 - */ 46 - typedef struct xfs_dinode { 47 - __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */ 48 - __be16 di_mode; /* mode and type of file */ 49 - __u8 di_version; /* inode version */ 50 - __u8 di_format; /* format of di_c data */ 51 - __be16 di_onlink; /* old number of links to file */ 52 - __be32 di_uid; /* owner's user id */ 53 - __be32 di_gid; /* owner's group id */ 54 - __be32 di_nlink; /* number of links to file */ 55 - __be16 di_projid_lo; /* lower part of owner's project id */ 56 - __be16 di_projid_hi; /* higher part owner's project id */ 57 - __u8 di_pad[6]; /* unused, zeroed space */ 58 - __be16 di_flushiter; /* incremented on flush */ 59 - xfs_timestamp_t di_atime; /* time last accessed */ 60 - xfs_timestamp_t di_mtime; /* time last modified */ 61 - xfs_timestamp_t di_ctime; /* time created/inode modified */ 62 - __be64 di_size; /* number of bytes in file */ 63 - __be64 di_nblocks; /* # of direct & btree blocks used */ 64 - __be32 di_extsize; /* basic/minimum extent size for file */ 65 - __be32 di_nextents; /* number of extents in data fork */ 66 - __be16 di_anextents; /* number of extents in attribute fork*/ 67 - __u8 di_forkoff; /* attr fork offs, <<3 for 64b align */ 68 - __s8 di_aformat; /* format of attr fork's data */ 69 - __be32 di_dmevmask; /* DMIG event mask */ 70 - __be16 di_dmstate; /* DMIG state info */ 71 - __be16 di_flags; /* random flags, XFS_DIFLAG_... */ 72 - __be32 di_gen; /* generation number */ 73 - 74 - /* di_next_unlinked is the only non-core field in the old dinode */ 75 - __be32 di_next_unlinked;/* agi unlinked list ptr */ 76 - 77 - /* start of the extended dinode, writable fields */ 78 - __le32 di_crc; /* CRC of the inode */ 79 - __be64 di_changecount; /* number of attribute changes */ 80 - __be64 di_lsn; /* flush sequence */ 81 - __be64 di_flags2; /* more random flags */ 82 - __u8 di_pad2[16]; /* more padding for future expansion */ 83 - 84 - /* fields only written to during inode creation */ 85 - xfs_timestamp_t di_crtime; /* time created */ 86 - __be64 di_ino; /* inode number */ 87 - uuid_t di_uuid; /* UUID of the filesystem */ 88 - 89 - /* structure must be padded to 64 bit alignment */ 90 - } xfs_dinode_t; 91 - 92 - #define XFS_DINODE_CRC_OFF offsetof(struct xfs_dinode, di_crc) 93 - 94 - #define DI_MAX_FLUSH 0xffff 95 - 96 - /* 97 - * Size of the core inode on disk. Version 1 and 2 inodes have 98 - * the same size, but version 3 has grown a few additional fields. 99 - */ 100 - static inline uint xfs_dinode_size(int version) 101 - { 102 - if (version == 3) 103 - return sizeof(struct xfs_dinode); 104 - return offsetof(struct xfs_dinode, di_crc); 105 - } 106 - 107 - /* 108 - * The 32 bit link count in the inode theoretically maxes out at UINT_MAX. 109 - * Since the pathconf interface is signed, we use 2^31 - 1 instead. 110 - * The old inode format had a 16 bit link count, so its maximum is USHRT_MAX. 111 - */ 112 - #define XFS_MAXLINK ((1U << 31) - 1U) 113 - #define XFS_MAXLINK_1 65535U 114 - 115 - /* 116 - * Values for di_format 117 - */ 118 - typedef enum xfs_dinode_fmt { 119 - XFS_DINODE_FMT_DEV, /* xfs_dev_t */ 120 - XFS_DINODE_FMT_LOCAL, /* bulk data */ 121 - XFS_DINODE_FMT_EXTENTS, /* struct xfs_bmbt_rec */ 122 - XFS_DINODE_FMT_BTREE, /* struct xfs_bmdr_block */ 123 - XFS_DINODE_FMT_UUID /* uuid_t */ 124 - } xfs_dinode_fmt_t; 125 - 126 - /* 127 - * Inode minimum and maximum sizes. 128 - */ 129 - #define XFS_DINODE_MIN_LOG 8 130 - #define XFS_DINODE_MAX_LOG 11 131 - #define XFS_DINODE_MIN_SIZE (1 << XFS_DINODE_MIN_LOG) 132 - #define XFS_DINODE_MAX_SIZE (1 << XFS_DINODE_MAX_LOG) 133 - 134 - /* 135 - * Inode size for given fs. 136 - */ 137 - #define XFS_LITINO(mp, version) \ 138 - ((int)(((mp)->m_sb.sb_inodesize) - xfs_dinode_size(version))) 139 - 140 - /* 141 - * Inode data & attribute fork sizes, per inode. 142 - */ 143 - #define XFS_DFORK_Q(dip) ((dip)->di_forkoff != 0) 144 - #define XFS_DFORK_BOFF(dip) ((int)((dip)->di_forkoff << 3)) 145 - 146 - #define XFS_DFORK_DSIZE(dip,mp) \ 147 - (XFS_DFORK_Q(dip) ? \ 148 - XFS_DFORK_BOFF(dip) : \ 149 - XFS_LITINO(mp, (dip)->di_version)) 150 - #define XFS_DFORK_ASIZE(dip,mp) \ 151 - (XFS_DFORK_Q(dip) ? \ 152 - XFS_LITINO(mp, (dip)->di_version) - XFS_DFORK_BOFF(dip) : \ 153 - 0) 154 - #define XFS_DFORK_SIZE(dip,mp,w) \ 155 - ((w) == XFS_DATA_FORK ? \ 156 - XFS_DFORK_DSIZE(dip, mp) : \ 157 - XFS_DFORK_ASIZE(dip, mp)) 158 - 159 - /* 160 - * Return pointers to the data or attribute forks. 161 - */ 162 - #define XFS_DFORK_DPTR(dip) \ 163 - ((char *)dip + xfs_dinode_size(dip->di_version)) 164 - #define XFS_DFORK_APTR(dip) \ 165 - (XFS_DFORK_DPTR(dip) + XFS_DFORK_BOFF(dip)) 166 - #define XFS_DFORK_PTR(dip,w) \ 167 - ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip)) 168 - 169 - #define XFS_DFORK_FORMAT(dip,w) \ 170 - ((w) == XFS_DATA_FORK ? \ 171 - (dip)->di_format : \ 172 - (dip)->di_aformat) 173 - #define XFS_DFORK_NEXTENTS(dip,w) \ 174 - ((w) == XFS_DATA_FORK ? \ 175 - be32_to_cpu((dip)->di_nextents) : \ 176 - be16_to_cpu((dip)->di_anextents)) 177 - 178 - #define XFS_BUF_TO_DINODE(bp) ((xfs_dinode_t *)((bp)->b_addr)) 179 - 180 - /* 181 - * For block and character special files the 32bit dev_t is stored at the 182 - * beginning of the data fork. 183 - */ 184 - static inline xfs_dev_t xfs_dinode_get_rdev(struct xfs_dinode *dip) 185 - { 186 - return be32_to_cpu(*(__be32 *)XFS_DFORK_DPTR(dip)); 187 - } 188 - 189 - static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) 190 - { 191 - *(__be32 *)XFS_DFORK_DPTR(dip) = cpu_to_be32(rdev); 192 - } 193 - 194 - /* 195 - * Values for di_flags 196 - * There should be a one-to-one correspondence between these flags and the 197 - * XFS_XFLAG_s. 198 - */ 199 - #define XFS_DIFLAG_REALTIME_BIT 0 /* file's blocks come from rt area */ 200 - #define XFS_DIFLAG_PREALLOC_BIT 1 /* file space has been preallocated */ 201 - #define XFS_DIFLAG_NEWRTBM_BIT 2 /* for rtbitmap inode, new format */ 202 - #define XFS_DIFLAG_IMMUTABLE_BIT 3 /* inode is immutable */ 203 - #define XFS_DIFLAG_APPEND_BIT 4 /* inode is append-only */ 204 - #define XFS_DIFLAG_SYNC_BIT 5 /* inode is written synchronously */ 205 - #define XFS_DIFLAG_NOATIME_BIT 6 /* do not update atime */ 206 - #define XFS_DIFLAG_NODUMP_BIT 7 /* do not dump */ 207 - #define XFS_DIFLAG_RTINHERIT_BIT 8 /* create with realtime bit set */ 208 - #define XFS_DIFLAG_PROJINHERIT_BIT 9 /* create with parents projid */ 209 - #define XFS_DIFLAG_NOSYMLINKS_BIT 10 /* disallow symlink creation */ 210 - #define XFS_DIFLAG_EXTSIZE_BIT 11 /* inode extent size allocator hint */ 211 - #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */ 212 - #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */ 213 - #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */ 214 - #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT) 215 - #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT) 216 - #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT) 217 - #define XFS_DIFLAG_IMMUTABLE (1 << XFS_DIFLAG_IMMUTABLE_BIT) 218 - #define XFS_DIFLAG_APPEND (1 << XFS_DIFLAG_APPEND_BIT) 219 - #define XFS_DIFLAG_SYNC (1 << XFS_DIFLAG_SYNC_BIT) 220 - #define XFS_DIFLAG_NOATIME (1 << XFS_DIFLAG_NOATIME_BIT) 221 - #define XFS_DIFLAG_NODUMP (1 << XFS_DIFLAG_NODUMP_BIT) 222 - #define XFS_DIFLAG_RTINHERIT (1 << XFS_DIFLAG_RTINHERIT_BIT) 223 - #define XFS_DIFLAG_PROJINHERIT (1 << XFS_DIFLAG_PROJINHERIT_BIT) 224 - #define XFS_DIFLAG_NOSYMLINKS (1 << XFS_DIFLAG_NOSYMLINKS_BIT) 225 - #define XFS_DIFLAG_EXTSIZE (1 << XFS_DIFLAG_EXTSIZE_BIT) 226 - #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT) 227 - #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT) 228 - #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT) 229 - 230 - #ifdef CONFIG_XFS_RT 231 - #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) 232 - #else 233 - #define XFS_IS_REALTIME_INODE(ip) (0) 234 - #endif 235 - 236 - #define XFS_DIFLAG_ANY \ 237 - (XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \ 238 - XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \ 239 - XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \ 240 - XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \ 241 - XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM) 242 - 243 - #endif /* __XFS_DINODE_H__ */
+16 -4
fs/xfs/libxfs/xfs_dir2.c
··· 20 20 #include "xfs_format.h" 21 21 #include "xfs_log_format.h" 22 22 #include "xfs_trans_resv.h" 23 - #include "xfs_inum.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 23 #include "xfs_mount.h" 27 24 #include "xfs_da_format.h" 28 25 #include "xfs_da_btree.h" ··· 31 34 #include "xfs_dir2_priv.h" 32 35 #include "xfs_error.h" 33 36 #include "xfs_trace.h" 34 - #include "xfs_dinode.h" 35 37 36 38 struct xfs_name xfs_name_dotdot = { (unsigned char *)"..", 2, XFS_DIR3_FT_DIR }; 37 39 40 + /* 41 + * @mode, if set, indicates that the type field needs to be set up. 42 + * This uses the transformation from file mode to DT_* as defined in linux/fs.h 43 + * for file type specification. This will be propagated into the directory 44 + * structure if appropriate for the given operation and filesystem config. 45 + */ 46 + const unsigned char xfs_mode_to_ftype[S_IFMT >> S_SHIFT] = { 47 + [0] = XFS_DIR3_FT_UNKNOWN, 48 + [S_IFREG >> S_SHIFT] = XFS_DIR3_FT_REG_FILE, 49 + [S_IFDIR >> S_SHIFT] = XFS_DIR3_FT_DIR, 50 + [S_IFCHR >> S_SHIFT] = XFS_DIR3_FT_CHRDEV, 51 + [S_IFBLK >> S_SHIFT] = XFS_DIR3_FT_BLKDEV, 52 + [S_IFIFO >> S_SHIFT] = XFS_DIR3_FT_FIFO, 53 + [S_IFSOCK >> S_SHIFT] = XFS_DIR3_FT_SOCK, 54 + [S_IFLNK >> S_SHIFT] = XFS_DIR3_FT_SYMLINK, 55 + }; 38 56 39 57 /* 40 58 * ASCII case-insensitive (ie. A-Z) support for directories that was
+140
fs/xfs/libxfs/xfs_dir2.h
··· 32 32 extern struct xfs_name xfs_name_dotdot; 33 33 34 34 /* 35 + * directory filetype conversion tables. 36 + */ 37 + #define S_SHIFT 12 38 + extern const unsigned char xfs_mode_to_ftype[]; 39 + 40 + /* 35 41 * directory operations vector for encode/decode routines 36 42 */ 37 43 struct xfs_dir_ops { ··· 182 176 extern const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops; 183 177 extern const struct xfs_buf_ops xfs_dir3_free_buf_ops; 184 178 extern const struct xfs_buf_ops xfs_dir3_data_buf_ops; 179 + 180 + /* 181 + * Directory offset/block conversion functions. 182 + * 183 + * DB blocks here are logical directory block numbers, not filesystem blocks. 184 + */ 185 + 186 + /* 187 + * Convert dataptr to byte in file space 188 + */ 189 + static inline xfs_dir2_off_t 190 + xfs_dir2_dataptr_to_byte(xfs_dir2_dataptr_t dp) 191 + { 192 + return (xfs_dir2_off_t)dp << XFS_DIR2_DATA_ALIGN_LOG; 193 + } 194 + 195 + /* 196 + * Convert byte in file space to dataptr. It had better be aligned. 197 + */ 198 + static inline xfs_dir2_dataptr_t 199 + xfs_dir2_byte_to_dataptr(xfs_dir2_off_t by) 200 + { 201 + return (xfs_dir2_dataptr_t)(by >> XFS_DIR2_DATA_ALIGN_LOG); 202 + } 203 + 204 + /* 205 + * Convert byte in space to (DB) block 206 + */ 207 + static inline xfs_dir2_db_t 208 + xfs_dir2_byte_to_db(struct xfs_da_geometry *geo, xfs_dir2_off_t by) 209 + { 210 + return (xfs_dir2_db_t)(by >> geo->blklog); 211 + } 212 + 213 + /* 214 + * Convert dataptr to a block number 215 + */ 216 + static inline xfs_dir2_db_t 217 + xfs_dir2_dataptr_to_db(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp) 218 + { 219 + return xfs_dir2_byte_to_db(geo, xfs_dir2_dataptr_to_byte(dp)); 220 + } 221 + 222 + /* 223 + * Convert byte in space to offset in a block 224 + */ 225 + static inline xfs_dir2_data_aoff_t 226 + xfs_dir2_byte_to_off(struct xfs_da_geometry *geo, xfs_dir2_off_t by) 227 + { 228 + return (xfs_dir2_data_aoff_t)(by & (geo->blksize - 1)); 229 + } 230 + 231 + /* 232 + * Convert dataptr to a byte offset in a block 233 + */ 234 + static inline xfs_dir2_data_aoff_t 235 + xfs_dir2_dataptr_to_off(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp) 236 + { 237 + return xfs_dir2_byte_to_off(geo, xfs_dir2_dataptr_to_byte(dp)); 238 + } 239 + 240 + /* 241 + * Convert block and offset to byte in space 242 + */ 243 + static inline xfs_dir2_off_t 244 + xfs_dir2_db_off_to_byte(struct xfs_da_geometry *geo, xfs_dir2_db_t db, 245 + xfs_dir2_data_aoff_t o) 246 + { 247 + return ((xfs_dir2_off_t)db << geo->blklog) + o; 248 + } 249 + 250 + /* 251 + * Convert block (DB) to block (dablk) 252 + */ 253 + static inline xfs_dablk_t 254 + xfs_dir2_db_to_da(struct xfs_da_geometry *geo, xfs_dir2_db_t db) 255 + { 256 + return (xfs_dablk_t)(db << (geo->blklog - geo->fsblog)); 257 + } 258 + 259 + /* 260 + * Convert byte in space to (DA) block 261 + */ 262 + static inline xfs_dablk_t 263 + xfs_dir2_byte_to_da(struct xfs_da_geometry *geo, xfs_dir2_off_t by) 264 + { 265 + return xfs_dir2_db_to_da(geo, xfs_dir2_byte_to_db(geo, by)); 266 + } 267 + 268 + /* 269 + * Convert block and offset to dataptr 270 + */ 271 + static inline xfs_dir2_dataptr_t 272 + xfs_dir2_db_off_to_dataptr(struct xfs_da_geometry *geo, xfs_dir2_db_t db, 273 + xfs_dir2_data_aoff_t o) 274 + { 275 + return xfs_dir2_byte_to_dataptr(xfs_dir2_db_off_to_byte(geo, db, o)); 276 + } 277 + 278 + /* 279 + * Convert block (dablk) to block (DB) 280 + */ 281 + static inline xfs_dir2_db_t 282 + xfs_dir2_da_to_db(struct xfs_da_geometry *geo, xfs_dablk_t da) 283 + { 284 + return (xfs_dir2_db_t)(da >> (geo->blklog - geo->fsblog)); 285 + } 286 + 287 + /* 288 + * Convert block (dablk) to byte offset in space 289 + */ 290 + static inline xfs_dir2_off_t 291 + xfs_dir2_da_to_byte(struct xfs_da_geometry *geo, xfs_dablk_t da) 292 + { 293 + return xfs_dir2_db_off_to_byte(geo, xfs_dir2_da_to_db(geo, da), 0); 294 + } 295 + 296 + /* 297 + * Directory tail pointer accessor functions. Based on block geometry. 298 + */ 299 + static inline struct xfs_dir2_block_tail * 300 + xfs_dir2_block_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_data_hdr *hdr) 301 + { 302 + return ((struct xfs_dir2_block_tail *) 303 + ((char *)hdr + geo->blksize)) - 1; 304 + } 305 + 306 + static inline struct xfs_dir2_leaf_tail * 307 + xfs_dir2_leaf_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_leaf *lp) 308 + { 309 + return (struct xfs_dir2_leaf_tail *) 310 + ((char *)lp + geo->blksize - 311 + sizeof(struct xfs_dir2_leaf_tail)); 312 + } 185 313 186 314 #endif /* __XFS_DIR2_H__ */
-11
fs/xfs/libxfs/xfs_dir2_block.c
··· 21 21 #include "xfs_format.h" 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 24 #include "xfs_mount.h" 27 25 #include "xfs_da_format.h" 28 26 #include "xfs_da_btree.h" ··· 34 36 #include "xfs_error.h" 35 37 #include "xfs_trace.h" 36 38 #include "xfs_cksum.h" 37 - #include "xfs_dinode.h" 38 39 39 40 /* 40 41 * Local function prototypes. ··· 350 353 int low; /* low index for binary srch */ 351 354 int lowstale; /* low stale index */ 352 355 int mid=0; /* midpoint for binary srch */ 353 - xfs_mount_t *mp; /* filesystem mount point */ 354 356 int needlog; /* need to log header */ 355 357 int needscan; /* need to rescan freespace */ 356 358 __be16 *tagp; /* pointer to tag value */ ··· 359 363 360 364 dp = args->dp; 361 365 tp = args->trans; 362 - mp = dp->i_mount; 363 366 364 367 /* Read the (one and only) directory block into bp. */ 365 368 error = xfs_dir3_block_read(tp, dp, &bp); ··· 613 618 xfs_inode_t *dp; /* incore inode */ 614 619 int ent; /* entry index */ 615 620 int error; /* error return value */ 616 - xfs_mount_t *mp; /* filesystem mount point */ 617 621 618 622 trace_xfs_dir2_block_lookup(args); 619 623 ··· 623 629 if ((error = xfs_dir2_block_lookup_int(args, &bp, &ent))) 624 630 return error; 625 631 dp = args->dp; 626 - mp = dp->i_mount; 627 632 hdr = bp->b_addr; 628 633 xfs_dir3_data_check(dp, bp); 629 634 btp = xfs_dir2_block_tail_p(args->geo, hdr); ··· 763 770 xfs_inode_t *dp; /* incore inode */ 764 771 int ent; /* block leaf entry index */ 765 772 int error; /* error return value */ 766 - xfs_mount_t *mp; /* filesystem mount point */ 767 773 int needlog; /* need to log block header */ 768 774 int needscan; /* need to fixup bestfree */ 769 775 xfs_dir2_sf_hdr_t sfh; /* shortform header */ ··· 780 788 } 781 789 dp = args->dp; 782 790 tp = args->trans; 783 - mp = dp->i_mount; 784 791 hdr = bp->b_addr; 785 792 btp = xfs_dir2_block_tail_p(args->geo, hdr); 786 793 blp = xfs_dir2_block_leaf_p(btp); ··· 843 852 xfs_inode_t *dp; /* incore inode */ 844 853 int ent; /* leaf entry index */ 845 854 int error; /* error return value */ 846 - xfs_mount_t *mp; /* filesystem mount point */ 847 855 848 856 trace_xfs_dir2_block_replace(args); 849 857 ··· 854 864 return error; 855 865 } 856 866 dp = args->dp; 857 - mp = dp->i_mount; 858 867 hdr = bp->b_addr; 859 868 btp = xfs_dir2_block_tail_p(args->geo, hdr); 860 869 blp = xfs_dir2_block_leaf_p(btp);
-2
fs/xfs/libxfs/xfs_dir2_data.c
··· 21 21 #include "xfs_format.h" 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 24 #include "xfs_mount.h" 27 25 #include "xfs_da_format.h" 28 26 #include "xfs_da_btree.h"
-12
fs/xfs/libxfs/xfs_dir2_leaf.c
··· 21 21 #include "xfs_format.h" 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 24 #include "xfs_mount.h" 27 25 #include "xfs_da_format.h" 28 26 #include "xfs_da_btree.h" ··· 382 384 xfs_dir2_db_t ldb; /* leaf block's bno */ 383 385 xfs_dir2_leaf_t *leaf; /* leaf structure */ 384 386 xfs_dir2_leaf_tail_t *ltp; /* leaf's tail */ 385 - xfs_mount_t *mp; /* filesystem mount point */ 386 387 int needlog; /* need to log block header */ 387 388 int needscan; /* need to rescan bestfree */ 388 389 xfs_trans_t *tp; /* transaction pointer */ ··· 392 395 trace_xfs_dir2_block_to_leaf(args); 393 396 394 397 dp = args->dp; 395 - mp = dp->i_mount; 396 398 tp = args->trans; 397 399 /* 398 400 * Add the leaf block to the inode. ··· 622 626 int lfloghigh; /* high leaf logging index */ 623 627 int lowstale; /* index of prev stale leaf */ 624 628 xfs_dir2_leaf_tail_t *ltp; /* leaf tail pointer */ 625 - xfs_mount_t *mp; /* filesystem mount point */ 626 629 int needbytes; /* leaf block bytes needed */ 627 630 int needlog; /* need to log data header */ 628 631 int needscan; /* need to rescan data free */ ··· 636 641 637 642 dp = args->dp; 638 643 tp = args->trans; 639 - mp = dp->i_mount; 640 644 641 645 error = xfs_dir3_leaf_read(tp, dp, args->geo->leafblk, -1, &lbp); 642 646 if (error) ··· 1350 1356 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1351 1357 xfs_dir2_leaf_entry_t *lep; /* leaf entry */ 1352 1358 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ 1353 - xfs_mount_t *mp; /* filesystem mount point */ 1354 1359 int needlog; /* need to log data header */ 1355 1360 int needscan; /* need to rescan data frees */ 1356 1361 xfs_dir2_data_off_t oldbest; /* old value of best free */ 1357 - xfs_trans_t *tp; /* transaction pointer */ 1358 1362 struct xfs_dir2_data_free *bf; /* bestfree table */ 1359 1363 struct xfs_dir2_leaf_entry *ents; 1360 1364 struct xfs_dir3_icleaf_hdr leafhdr; ··· 1366 1374 return error; 1367 1375 } 1368 1376 dp = args->dp; 1369 - tp = args->trans; 1370 - mp = dp->i_mount; 1371 1377 leaf = lbp->b_addr; 1372 1378 hdr = dbp->b_addr; 1373 1379 xfs_dir3_data_check(dp, dbp); ··· 1597 1607 int error; /* error return value */ 1598 1608 xfs_dir2_leaf_t *leaf; /* leaf structure */ 1599 1609 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ 1600 - xfs_mount_t *mp; /* filesystem mount point */ 1601 1610 xfs_trans_t *tp; /* transaction pointer */ 1602 1611 1603 1612 dp = args->dp; 1604 - mp = dp->i_mount; 1605 1613 tp = args->trans; 1606 1614 /* 1607 1615 * Read the offending data block. We need its buffer.
-14
fs/xfs/libxfs/xfs_dir2_node.c
··· 21 21 #include "xfs_format.h" 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 24 #include "xfs_mount.h" 27 25 #include "xfs_da_format.h" 28 26 #include "xfs_da_btree.h" ··· 295 297 int i; /* leaf freespace index */ 296 298 xfs_dir2_leaf_t *leaf; /* leaf structure */ 297 299 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ 298 - xfs_mount_t *mp; /* filesystem mount point */ 299 300 int n; /* count of live freespc ents */ 300 301 xfs_dir2_data_off_t off; /* freespace entry value */ 301 302 __be16 *to; /* pointer to freespace entry */ ··· 304 307 trace_xfs_dir2_leaf_to_node(args); 305 308 306 309 dp = args->dp; 307 - mp = dp->i_mount; 308 310 tp = args->trans; 309 311 /* 310 312 * Add a freespace block to the directory. ··· 383 387 int lfloghigh; /* high leaf entry logging */ 384 388 int lfloglow; /* low leaf entry logging */ 385 389 int lowstale; /* previous stale entry */ 386 - xfs_mount_t *mp; /* filesystem mount point */ 387 - xfs_trans_t *tp; /* transaction pointer */ 388 390 struct xfs_dir3_icleaf_hdr leafhdr; 389 391 struct xfs_dir2_leaf_entry *ents; 390 392 391 393 trace_xfs_dir2_leafn_add(args, index); 392 394 393 395 dp = args->dp; 394 - mp = dp->i_mount; 395 - tp = args->trans; 396 396 leaf = bp->b_addr; 397 397 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf); 398 398 ents = dp->d_ops->leaf_ents_p(leaf); ··· 1162 1170 xfs_dir2_leaf_entry_t *lep; /* leaf entry */ 1163 1171 int longest; /* longest data free entry */ 1164 1172 int off; /* data block entry offset */ 1165 - xfs_mount_t *mp; /* filesystem mount point */ 1166 1173 int needlog; /* need to log data header */ 1167 1174 int needscan; /* need to rescan data frees */ 1168 1175 xfs_trans_t *tp; /* transaction pointer */ ··· 1173 1182 1174 1183 dp = args->dp; 1175 1184 tp = args->trans; 1176 - mp = dp->i_mount; 1177 1185 leaf = bp->b_addr; 1178 1186 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf); 1179 1187 ents = dp->d_ops->leaf_ents_p(leaf); ··· 1313 1323 xfs_da_args_t *args; /* operation arguments */ 1314 1324 xfs_dablk_t blkno; /* new leaf block number */ 1315 1325 int error; /* error return value */ 1316 - xfs_mount_t *mp; /* filesystem mount point */ 1317 1326 struct xfs_inode *dp; 1318 1327 1319 1328 /* ··· 1320 1331 */ 1321 1332 args = state->args; 1322 1333 dp = args->dp; 1323 - mp = dp->i_mount; 1324 1334 ASSERT(oldblk->magic == XFS_DIR2_LEAFN_MAGIC); 1325 1335 error = xfs_da_grow_inode(args, &blkno); 1326 1336 if (error) { ··· 2219 2231 xfs_inode_t *dp; /* incore directory inode */ 2220 2232 int error; /* error return code */ 2221 2233 xfs_dir2_free_t *free; /* freespace structure */ 2222 - xfs_mount_t *mp; /* filesystem mount point */ 2223 2234 xfs_trans_t *tp; /* transaction pointer */ 2224 2235 struct xfs_dir3_icfree_hdr freehdr; 2225 2236 2226 2237 dp = args->dp; 2227 - mp = dp->i_mount; 2228 2238 tp = args->trans; 2229 2239 /* 2230 2240 * Read the freespace block.
-140
fs/xfs/libxfs/xfs_dir2_priv.h
··· 20 20 21 21 struct dir_context; 22 22 23 - /* 24 - * Directory offset/block conversion functions. 25 - * 26 - * DB blocks here are logical directory block numbers, not filesystem blocks. 27 - */ 28 - 29 - /* 30 - * Convert dataptr to byte in file space 31 - */ 32 - static inline xfs_dir2_off_t 33 - xfs_dir2_dataptr_to_byte(xfs_dir2_dataptr_t dp) 34 - { 35 - return (xfs_dir2_off_t)dp << XFS_DIR2_DATA_ALIGN_LOG; 36 - } 37 - 38 - /* 39 - * Convert byte in file space to dataptr. It had better be aligned. 40 - */ 41 - static inline xfs_dir2_dataptr_t 42 - xfs_dir2_byte_to_dataptr(xfs_dir2_off_t by) 43 - { 44 - return (xfs_dir2_dataptr_t)(by >> XFS_DIR2_DATA_ALIGN_LOG); 45 - } 46 - 47 - /* 48 - * Convert byte in space to (DB) block 49 - */ 50 - static inline xfs_dir2_db_t 51 - xfs_dir2_byte_to_db(struct xfs_da_geometry *geo, xfs_dir2_off_t by) 52 - { 53 - return (xfs_dir2_db_t)(by >> geo->blklog); 54 - } 55 - 56 - /* 57 - * Convert dataptr to a block number 58 - */ 59 - static inline xfs_dir2_db_t 60 - xfs_dir2_dataptr_to_db(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp) 61 - { 62 - return xfs_dir2_byte_to_db(geo, xfs_dir2_dataptr_to_byte(dp)); 63 - } 64 - 65 - /* 66 - * Convert byte in space to offset in a block 67 - */ 68 - static inline xfs_dir2_data_aoff_t 69 - xfs_dir2_byte_to_off(struct xfs_da_geometry *geo, xfs_dir2_off_t by) 70 - { 71 - return (xfs_dir2_data_aoff_t)(by & (geo->blksize - 1)); 72 - } 73 - 74 - /* 75 - * Convert dataptr to a byte offset in a block 76 - */ 77 - static inline xfs_dir2_data_aoff_t 78 - xfs_dir2_dataptr_to_off(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp) 79 - { 80 - return xfs_dir2_byte_to_off(geo, xfs_dir2_dataptr_to_byte(dp)); 81 - } 82 - 83 - /* 84 - * Convert block and offset to byte in space 85 - */ 86 - static inline xfs_dir2_off_t 87 - xfs_dir2_db_off_to_byte(struct xfs_da_geometry *geo, xfs_dir2_db_t db, 88 - xfs_dir2_data_aoff_t o) 89 - { 90 - return ((xfs_dir2_off_t)db << geo->blklog) + o; 91 - } 92 - 93 - /* 94 - * Convert block (DB) to block (dablk) 95 - */ 96 - static inline xfs_dablk_t 97 - xfs_dir2_db_to_da(struct xfs_da_geometry *geo, xfs_dir2_db_t db) 98 - { 99 - return (xfs_dablk_t)(db << (geo->blklog - geo->fsblog)); 100 - } 101 - 102 - /* 103 - * Convert byte in space to (DA) block 104 - */ 105 - static inline xfs_dablk_t 106 - xfs_dir2_byte_to_da(struct xfs_da_geometry *geo, xfs_dir2_off_t by) 107 - { 108 - return xfs_dir2_db_to_da(geo, xfs_dir2_byte_to_db(geo, by)); 109 - } 110 - 111 - /* 112 - * Convert block and offset to dataptr 113 - */ 114 - static inline xfs_dir2_dataptr_t 115 - xfs_dir2_db_off_to_dataptr(struct xfs_da_geometry *geo, xfs_dir2_db_t db, 116 - xfs_dir2_data_aoff_t o) 117 - { 118 - return xfs_dir2_byte_to_dataptr(xfs_dir2_db_off_to_byte(geo, db, o)); 119 - } 120 - 121 - /* 122 - * Convert block (dablk) to block (DB) 123 - */ 124 - static inline xfs_dir2_db_t 125 - xfs_dir2_da_to_db(struct xfs_da_geometry *geo, xfs_dablk_t da) 126 - { 127 - return (xfs_dir2_db_t)(da >> (geo->blklog - geo->fsblog)); 128 - } 129 - 130 - /* 131 - * Convert block (dablk) to byte offset in space 132 - */ 133 - static inline xfs_dir2_off_t 134 - xfs_dir2_da_to_byte(struct xfs_da_geometry *geo, xfs_dablk_t da) 135 - { 136 - return xfs_dir2_db_off_to_byte(geo, xfs_dir2_da_to_db(geo, da), 0); 137 - } 138 - 139 - /* 140 - * Directory tail pointer accessor functions. Based on block geometry. 141 - */ 142 - static inline struct xfs_dir2_block_tail * 143 - xfs_dir2_block_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_data_hdr *hdr) 144 - { 145 - return ((struct xfs_dir2_block_tail *) 146 - ((char *)hdr + geo->blksize)) - 1; 147 - } 148 - 149 - static inline struct xfs_dir2_leaf_tail * 150 - xfs_dir2_leaf_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_leaf *lp) 151 - { 152 - return (struct xfs_dir2_leaf_tail *) 153 - ((char *)lp + geo->blksize - 154 - sizeof(struct xfs_dir2_leaf_tail)); 155 - } 156 - 157 23 /* xfs_dir2.c */ 158 24 extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino); 159 25 extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, 160 26 xfs_dir2_db_t *dbp); 161 27 extern int xfs_dir_cilookup_result(struct xfs_da_args *args, 162 28 const unsigned char *name, int len); 163 - 164 - #define S_SHIFT 12 165 - extern const unsigned char xfs_mode_to_ftype[]; 166 - 167 - extern unsigned char xfs_dir3_get_dtype(struct xfs_mount *mp, 168 - __uint8_t filetype); 169 29 170 30 171 31 /* xfs_dir2_block.c */
-13
fs/xfs/libxfs/xfs_dir2_sf.c
··· 20 20 #include "xfs_format.h" 21 21 #include "xfs_log_format.h" 22 22 #include "xfs_trans_resv.h" 23 - #include "xfs_sb.h" 24 - #include "xfs_ag.h" 25 23 #include "xfs_mount.h" 26 24 #include "xfs_da_format.h" 27 25 #include "xfs_da_btree.h" ··· 30 32 #include "xfs_dir2.h" 31 33 #include "xfs_dir2_priv.h" 32 34 #include "xfs_trace.h" 33 - #include "xfs_dinode.h" 34 35 35 36 /* 36 37 * Prototypes for internal functions. ··· 452 455 xfs_dir2_sf_hdr_t *oldsfp; /* original shortform dir */ 453 456 xfs_dir2_sf_entry_t *sfep; /* entry in new dir */ 454 457 xfs_dir2_sf_hdr_t *sfp; /* new shortform dir */ 455 - struct xfs_mount *mp; 456 458 457 459 /* 458 460 * Copy the old directory to the stack buffer. 459 461 */ 460 462 dp = args->dp; 461 - mp = dp->i_mount; 462 463 463 464 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; 464 465 old_isize = (int)dp->i_d.di_size; ··· 537 542 xfs_inode_t *dp; /* incore directory inode */ 538 543 int holefit; /* found hole it will fit in */ 539 544 int i; /* entry number */ 540 - xfs_mount_t *mp; /* filesystem mount point */ 541 545 xfs_dir2_data_aoff_t offset; /* data block offset */ 542 546 xfs_dir2_sf_entry_t *sfep; /* shortform entry */ 543 547 xfs_dir2_sf_hdr_t *sfp; /* shortform structure */ ··· 544 550 int used; /* data bytes used */ 545 551 546 552 dp = args->dp; 547 - mp = dp->i_mount; 548 553 549 554 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; 550 555 size = dp->d_ops->data_entsize(args->namelen); ··· 609 616 int offset; /* data offset */ 610 617 xfs_dir2_sf_entry_t *sfep; /* shortform dir entry */ 611 618 xfs_dir2_sf_hdr_t *sfp; /* shortform structure */ 612 - struct xfs_mount *mp; 613 619 614 620 dp = args->dp; 615 - mp = dp->i_mount; 616 621 617 622 sfp = (xfs_dir2_sf_hdr_t *)dp->i_df.if_u1.if_data; 618 623 offset = dp->d_ops->data_first_offset; ··· 1007 1016 int oldsize; /* old inode size */ 1008 1017 xfs_dir2_sf_entry_t *sfep; /* new sf entry */ 1009 1018 xfs_dir2_sf_hdr_t *sfp; /* new sf directory */ 1010 - struct xfs_mount *mp; 1011 1019 1012 1020 trace_xfs_dir2_sf_toino4(args); 1013 1021 1014 1022 dp = args->dp; 1015 - mp = dp->i_mount; 1016 1023 1017 1024 /* 1018 1025 * Copy the old directory to the buffer. ··· 1083 1094 int oldsize; /* old inode size */ 1084 1095 xfs_dir2_sf_entry_t *sfep; /* new sf entry */ 1085 1096 xfs_dir2_sf_hdr_t *sfp; /* new sf directory */ 1086 - struct xfs_mount *mp; 1087 1097 1088 1098 trace_xfs_dir2_sf_toino8(args); 1089 1099 1090 1100 dp = args->dp; 1091 - mp = dp->i_mount; 1092 1101 1093 1102 /* 1094 1103 * Copy the old directory to the buffer.
-2
fs/xfs/libxfs/xfs_dquot_buf.c
··· 22 22 #include "xfs_format.h" 23 23 #include "xfs_log_format.h" 24 24 #include "xfs_trans_resv.h" 25 - #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 25 #include "xfs_mount.h" 28 26 #include "xfs_inode.h" 29 27 #include "xfs_quota.h"
+1107
fs/xfs/libxfs/xfs_format.h
··· 34 34 struct xfs_ifork; 35 35 36 36 /* 37 + * Super block 38 + * Fits into a sector-sized buffer at address 0 of each allocation group. 39 + * Only the first of these is ever updated except during growfs. 40 + */ 41 + #define XFS_SB_MAGIC 0x58465342 /* 'XFSB' */ 42 + #define XFS_SB_VERSION_1 1 /* 5.3, 6.0.1, 6.1 */ 43 + #define XFS_SB_VERSION_2 2 /* 6.2 - attributes */ 44 + #define XFS_SB_VERSION_3 3 /* 6.2 - new inode version */ 45 + #define XFS_SB_VERSION_4 4 /* 6.2+ - bitmask version */ 46 + #define XFS_SB_VERSION_5 5 /* CRC enabled filesystem */ 47 + #define XFS_SB_VERSION_NUMBITS 0x000f 48 + #define XFS_SB_VERSION_ALLFBITS 0xfff0 49 + #define XFS_SB_VERSION_ATTRBIT 0x0010 50 + #define XFS_SB_VERSION_NLINKBIT 0x0020 51 + #define XFS_SB_VERSION_QUOTABIT 0x0040 52 + #define XFS_SB_VERSION_ALIGNBIT 0x0080 53 + #define XFS_SB_VERSION_DALIGNBIT 0x0100 54 + #define XFS_SB_VERSION_SHAREDBIT 0x0200 55 + #define XFS_SB_VERSION_LOGV2BIT 0x0400 56 + #define XFS_SB_VERSION_SECTORBIT 0x0800 57 + #define XFS_SB_VERSION_EXTFLGBIT 0x1000 58 + #define XFS_SB_VERSION_DIRV2BIT 0x2000 59 + #define XFS_SB_VERSION_BORGBIT 0x4000 /* ASCII only case-insens. */ 60 + #define XFS_SB_VERSION_MOREBITSBIT 0x8000 61 + 62 + /* 63 + * Supported feature bit list is just all bits in the versionnum field because 64 + * we've used them all up and understand them all. Except, of course, for the 65 + * shared superblock bit, which nobody knows what it does and so is unsupported. 66 + */ 67 + #define XFS_SB_VERSION_OKBITS \ 68 + ((XFS_SB_VERSION_NUMBITS | XFS_SB_VERSION_ALLFBITS) & \ 69 + ~XFS_SB_VERSION_SHAREDBIT) 70 + 71 + /* 72 + * There are two words to hold XFS "feature" bits: the original 73 + * word, sb_versionnum, and sb_features2. Whenever a bit is set in 74 + * sb_features2, the feature bit XFS_SB_VERSION_MOREBITSBIT must be set. 75 + * 76 + * These defines represent bits in sb_features2. 77 + */ 78 + #define XFS_SB_VERSION2_RESERVED1BIT 0x00000001 79 + #define XFS_SB_VERSION2_LAZYSBCOUNTBIT 0x00000002 /* Superblk counters */ 80 + #define XFS_SB_VERSION2_RESERVED4BIT 0x00000004 81 + #define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */ 82 + #define XFS_SB_VERSION2_PARENTBIT 0x00000010 /* parent pointers */ 83 + #define XFS_SB_VERSION2_PROJID32BIT 0x00000080 /* 32 bit project id */ 84 + #define XFS_SB_VERSION2_CRCBIT 0x00000100 /* metadata CRCs */ 85 + #define XFS_SB_VERSION2_FTYPE 0x00000200 /* inode type in dir */ 86 + 87 + #define XFS_SB_VERSION2_OKBITS \ 88 + (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \ 89 + XFS_SB_VERSION2_ATTR2BIT | \ 90 + XFS_SB_VERSION2_PROJID32BIT | \ 91 + XFS_SB_VERSION2_FTYPE) 92 + 93 + /* 94 + * Superblock - in core version. Must match the ondisk version below. 95 + * Must be padded to 64 bit alignment. 96 + */ 97 + typedef struct xfs_sb { 98 + __uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */ 99 + __uint32_t sb_blocksize; /* logical block size, bytes */ 100 + xfs_rfsblock_t sb_dblocks; /* number of data blocks */ 101 + xfs_rfsblock_t sb_rblocks; /* number of realtime blocks */ 102 + xfs_rtblock_t sb_rextents; /* number of realtime extents */ 103 + uuid_t sb_uuid; /* file system unique id */ 104 + xfs_fsblock_t sb_logstart; /* starting block of log if internal */ 105 + xfs_ino_t sb_rootino; /* root inode number */ 106 + xfs_ino_t sb_rbmino; /* bitmap inode for realtime extents */ 107 + xfs_ino_t sb_rsumino; /* summary inode for rt bitmap */ 108 + xfs_agblock_t sb_rextsize; /* realtime extent size, blocks */ 109 + xfs_agblock_t sb_agblocks; /* size of an allocation group */ 110 + xfs_agnumber_t sb_agcount; /* number of allocation groups */ 111 + xfs_extlen_t sb_rbmblocks; /* number of rt bitmap blocks */ 112 + xfs_extlen_t sb_logblocks; /* number of log blocks */ 113 + __uint16_t sb_versionnum; /* header version == XFS_SB_VERSION */ 114 + __uint16_t sb_sectsize; /* volume sector size, bytes */ 115 + __uint16_t sb_inodesize; /* inode size, bytes */ 116 + __uint16_t sb_inopblock; /* inodes per block */ 117 + char sb_fname[12]; /* file system name */ 118 + __uint8_t sb_blocklog; /* log2 of sb_blocksize */ 119 + __uint8_t sb_sectlog; /* log2 of sb_sectsize */ 120 + __uint8_t sb_inodelog; /* log2 of sb_inodesize */ 121 + __uint8_t sb_inopblog; /* log2 of sb_inopblock */ 122 + __uint8_t sb_agblklog; /* log2 of sb_agblocks (rounded up) */ 123 + __uint8_t sb_rextslog; /* log2 of sb_rextents */ 124 + __uint8_t sb_inprogress; /* mkfs is in progress, don't mount */ 125 + __uint8_t sb_imax_pct; /* max % of fs for inode space */ 126 + /* statistics */ 127 + /* 128 + * These fields must remain contiguous. If you really 129 + * want to change their layout, make sure you fix the 130 + * code in xfs_trans_apply_sb_deltas(). 131 + */ 132 + __uint64_t sb_icount; /* allocated inodes */ 133 + __uint64_t sb_ifree; /* free inodes */ 134 + __uint64_t sb_fdblocks; /* free data blocks */ 135 + __uint64_t sb_frextents; /* free realtime extents */ 136 + /* 137 + * End contiguous fields. 138 + */ 139 + xfs_ino_t sb_uquotino; /* user quota inode */ 140 + xfs_ino_t sb_gquotino; /* group quota inode */ 141 + __uint16_t sb_qflags; /* quota flags */ 142 + __uint8_t sb_flags; /* misc. flags */ 143 + __uint8_t sb_shared_vn; /* shared version number */ 144 + xfs_extlen_t sb_inoalignmt; /* inode chunk alignment, fsblocks */ 145 + __uint32_t sb_unit; /* stripe or raid unit */ 146 + __uint32_t sb_width; /* stripe or raid width */ 147 + __uint8_t sb_dirblklog; /* log2 of dir block size (fsbs) */ 148 + __uint8_t sb_logsectlog; /* log2 of the log sector size */ 149 + __uint16_t sb_logsectsize; /* sector size for the log, bytes */ 150 + __uint32_t sb_logsunit; /* stripe unit size for the log */ 151 + __uint32_t sb_features2; /* additional feature bits */ 152 + 153 + /* 154 + * bad features2 field as a result of failing to pad the sb 155 + * structure to 64 bits. Some machines will be using this field 156 + * for features2 bits. Easiest just to mark it bad and not use 157 + * it for anything else. 158 + */ 159 + __uint32_t sb_bad_features2; 160 + 161 + /* version 5 superblock fields start here */ 162 + 163 + /* feature masks */ 164 + __uint32_t sb_features_compat; 165 + __uint32_t sb_features_ro_compat; 166 + __uint32_t sb_features_incompat; 167 + __uint32_t sb_features_log_incompat; 168 + 169 + __uint32_t sb_crc; /* superblock crc */ 170 + __uint32_t sb_pad; 171 + 172 + xfs_ino_t sb_pquotino; /* project quota inode */ 173 + xfs_lsn_t sb_lsn; /* last write sequence */ 174 + 175 + /* must be padded to 64 bit alignment */ 176 + } xfs_sb_t; 177 + 178 + #define XFS_SB_CRC_OFF offsetof(struct xfs_sb, sb_crc) 179 + 180 + /* 181 + * Superblock - on disk version. Must match the in core version above. 182 + * Must be padded to 64 bit alignment. 183 + */ 184 + typedef struct xfs_dsb { 185 + __be32 sb_magicnum; /* magic number == XFS_SB_MAGIC */ 186 + __be32 sb_blocksize; /* logical block size, bytes */ 187 + __be64 sb_dblocks; /* number of data blocks */ 188 + __be64 sb_rblocks; /* number of realtime blocks */ 189 + __be64 sb_rextents; /* number of realtime extents */ 190 + uuid_t sb_uuid; /* file system unique id */ 191 + __be64 sb_logstart; /* starting block of log if internal */ 192 + __be64 sb_rootino; /* root inode number */ 193 + __be64 sb_rbmino; /* bitmap inode for realtime extents */ 194 + __be64 sb_rsumino; /* summary inode for rt bitmap */ 195 + __be32 sb_rextsize; /* realtime extent size, blocks */ 196 + __be32 sb_agblocks; /* size of an allocation group */ 197 + __be32 sb_agcount; /* number of allocation groups */ 198 + __be32 sb_rbmblocks; /* number of rt bitmap blocks */ 199 + __be32 sb_logblocks; /* number of log blocks */ 200 + __be16 sb_versionnum; /* header version == XFS_SB_VERSION */ 201 + __be16 sb_sectsize; /* volume sector size, bytes */ 202 + __be16 sb_inodesize; /* inode size, bytes */ 203 + __be16 sb_inopblock; /* inodes per block */ 204 + char sb_fname[12]; /* file system name */ 205 + __u8 sb_blocklog; /* log2 of sb_blocksize */ 206 + __u8 sb_sectlog; /* log2 of sb_sectsize */ 207 + __u8 sb_inodelog; /* log2 of sb_inodesize */ 208 + __u8 sb_inopblog; /* log2 of sb_inopblock */ 209 + __u8 sb_agblklog; /* log2 of sb_agblocks (rounded up) */ 210 + __u8 sb_rextslog; /* log2 of sb_rextents */ 211 + __u8 sb_inprogress; /* mkfs is in progress, don't mount */ 212 + __u8 sb_imax_pct; /* max % of fs for inode space */ 213 + /* statistics */ 214 + /* 215 + * These fields must remain contiguous. If you really 216 + * want to change their layout, make sure you fix the 217 + * code in xfs_trans_apply_sb_deltas(). 218 + */ 219 + __be64 sb_icount; /* allocated inodes */ 220 + __be64 sb_ifree; /* free inodes */ 221 + __be64 sb_fdblocks; /* free data blocks */ 222 + __be64 sb_frextents; /* free realtime extents */ 223 + /* 224 + * End contiguous fields. 225 + */ 226 + __be64 sb_uquotino; /* user quota inode */ 227 + __be64 sb_gquotino; /* group quota inode */ 228 + __be16 sb_qflags; /* quota flags */ 229 + __u8 sb_flags; /* misc. flags */ 230 + __u8 sb_shared_vn; /* shared version number */ 231 + __be32 sb_inoalignmt; /* inode chunk alignment, fsblocks */ 232 + __be32 sb_unit; /* stripe or raid unit */ 233 + __be32 sb_width; /* stripe or raid width */ 234 + __u8 sb_dirblklog; /* log2 of dir block size (fsbs) */ 235 + __u8 sb_logsectlog; /* log2 of the log sector size */ 236 + __be16 sb_logsectsize; /* sector size for the log, bytes */ 237 + __be32 sb_logsunit; /* stripe unit size for the log */ 238 + __be32 sb_features2; /* additional feature bits */ 239 + /* 240 + * bad features2 field as a result of failing to pad the sb 241 + * structure to 64 bits. Some machines will be using this field 242 + * for features2 bits. Easiest just to mark it bad and not use 243 + * it for anything else. 244 + */ 245 + __be32 sb_bad_features2; 246 + 247 + /* version 5 superblock fields start here */ 248 + 249 + /* feature masks */ 250 + __be32 sb_features_compat; 251 + __be32 sb_features_ro_compat; 252 + __be32 sb_features_incompat; 253 + __be32 sb_features_log_incompat; 254 + 255 + __le32 sb_crc; /* superblock crc */ 256 + __be32 sb_pad; 257 + 258 + __be64 sb_pquotino; /* project quota inode */ 259 + __be64 sb_lsn; /* last write sequence */ 260 + 261 + /* must be padded to 64 bit alignment */ 262 + } xfs_dsb_t; 263 + 264 + /* 265 + * Sequence number values for the fields. 266 + */ 267 + typedef enum { 268 + XFS_SBS_MAGICNUM, XFS_SBS_BLOCKSIZE, XFS_SBS_DBLOCKS, XFS_SBS_RBLOCKS, 269 + XFS_SBS_REXTENTS, XFS_SBS_UUID, XFS_SBS_LOGSTART, XFS_SBS_ROOTINO, 270 + XFS_SBS_RBMINO, XFS_SBS_RSUMINO, XFS_SBS_REXTSIZE, XFS_SBS_AGBLOCKS, 271 + XFS_SBS_AGCOUNT, XFS_SBS_RBMBLOCKS, XFS_SBS_LOGBLOCKS, 272 + XFS_SBS_VERSIONNUM, XFS_SBS_SECTSIZE, XFS_SBS_INODESIZE, 273 + XFS_SBS_INOPBLOCK, XFS_SBS_FNAME, XFS_SBS_BLOCKLOG, 274 + XFS_SBS_SECTLOG, XFS_SBS_INODELOG, XFS_SBS_INOPBLOG, XFS_SBS_AGBLKLOG, 275 + XFS_SBS_REXTSLOG, XFS_SBS_INPROGRESS, XFS_SBS_IMAX_PCT, XFS_SBS_ICOUNT, 276 + XFS_SBS_IFREE, XFS_SBS_FDBLOCKS, XFS_SBS_FREXTENTS, XFS_SBS_UQUOTINO, 277 + XFS_SBS_GQUOTINO, XFS_SBS_QFLAGS, XFS_SBS_FLAGS, XFS_SBS_SHARED_VN, 278 + XFS_SBS_INOALIGNMT, XFS_SBS_UNIT, XFS_SBS_WIDTH, XFS_SBS_DIRBLKLOG, 279 + XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT, 280 + XFS_SBS_FEATURES2, XFS_SBS_BAD_FEATURES2, XFS_SBS_FEATURES_COMPAT, 281 + XFS_SBS_FEATURES_RO_COMPAT, XFS_SBS_FEATURES_INCOMPAT, 282 + XFS_SBS_FEATURES_LOG_INCOMPAT, XFS_SBS_CRC, XFS_SBS_PAD, 283 + XFS_SBS_PQUOTINO, XFS_SBS_LSN, 284 + XFS_SBS_FIELDCOUNT 285 + } xfs_sb_field_t; 286 + 287 + /* 288 + * Mask values, defined based on the xfs_sb_field_t values. 289 + * Only define the ones we're using. 290 + */ 291 + #define XFS_SB_MVAL(x) (1LL << XFS_SBS_ ## x) 292 + #define XFS_SB_UUID XFS_SB_MVAL(UUID) 293 + #define XFS_SB_FNAME XFS_SB_MVAL(FNAME) 294 + #define XFS_SB_ROOTINO XFS_SB_MVAL(ROOTINO) 295 + #define XFS_SB_RBMINO XFS_SB_MVAL(RBMINO) 296 + #define XFS_SB_RSUMINO XFS_SB_MVAL(RSUMINO) 297 + #define XFS_SB_VERSIONNUM XFS_SB_MVAL(VERSIONNUM) 298 + #define XFS_SB_UQUOTINO XFS_SB_MVAL(UQUOTINO) 299 + #define XFS_SB_GQUOTINO XFS_SB_MVAL(GQUOTINO) 300 + #define XFS_SB_QFLAGS XFS_SB_MVAL(QFLAGS) 301 + #define XFS_SB_SHARED_VN XFS_SB_MVAL(SHARED_VN) 302 + #define XFS_SB_UNIT XFS_SB_MVAL(UNIT) 303 + #define XFS_SB_WIDTH XFS_SB_MVAL(WIDTH) 304 + #define XFS_SB_ICOUNT XFS_SB_MVAL(ICOUNT) 305 + #define XFS_SB_IFREE XFS_SB_MVAL(IFREE) 306 + #define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS) 307 + #define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2) 308 + #define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2) 309 + #define XFS_SB_FEATURES_COMPAT XFS_SB_MVAL(FEATURES_COMPAT) 310 + #define XFS_SB_FEATURES_RO_COMPAT XFS_SB_MVAL(FEATURES_RO_COMPAT) 311 + #define XFS_SB_FEATURES_INCOMPAT XFS_SB_MVAL(FEATURES_INCOMPAT) 312 + #define XFS_SB_FEATURES_LOG_INCOMPAT XFS_SB_MVAL(FEATURES_LOG_INCOMPAT) 313 + #define XFS_SB_CRC XFS_SB_MVAL(CRC) 314 + #define XFS_SB_PQUOTINO XFS_SB_MVAL(PQUOTINO) 315 + #define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT) 316 + #define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1) 317 + #define XFS_SB_MOD_BITS \ 318 + (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \ 319 + XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \ 320 + 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 | \ 322 + XFS_SB_BAD_FEATURES2 | XFS_SB_FEATURES_COMPAT | \ 323 + XFS_SB_FEATURES_RO_COMPAT | XFS_SB_FEATURES_INCOMPAT | \ 324 + XFS_SB_FEATURES_LOG_INCOMPAT | XFS_SB_PQUOTINO) 325 + 326 + 327 + /* 328 + * Misc. Flags - warning - these will be cleared by xfs_repair unless 329 + * a feature bit is set when the flag is used. 330 + */ 331 + #define XFS_SBF_NOFLAGS 0x00 /* no flags set */ 332 + #define XFS_SBF_READONLY 0x01 /* only read-only mounts allowed */ 333 + 334 + /* 335 + * define max. shared version we can interoperate with 336 + */ 337 + #define XFS_SB_MAX_SHARED_VN 0 338 + 339 + #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) 340 + 341 + /* 342 + * The first XFS version we support is a v4 superblock with V2 directories. 343 + */ 344 + static inline bool xfs_sb_good_v4_features(struct xfs_sb *sbp) 345 + { 346 + if (!(sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT)) 347 + return false; 348 + 349 + /* check for unknown features in the fs */ 350 + if ((sbp->sb_versionnum & ~XFS_SB_VERSION_OKBITS) || 351 + ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && 352 + (sbp->sb_features2 & ~XFS_SB_VERSION2_OKBITS))) 353 + return false; 354 + 355 + return true; 356 + } 357 + 358 + static inline bool xfs_sb_good_version(struct xfs_sb *sbp) 359 + { 360 + if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) 361 + return true; 362 + if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) 363 + return xfs_sb_good_v4_features(sbp); 364 + return false; 365 + } 366 + 367 + /* 368 + * Detect a mismatched features2 field. Older kernels read/wrote 369 + * this into the wrong slot, so to be safe we keep them in sync. 370 + */ 371 + static inline bool xfs_sb_has_mismatched_features2(struct xfs_sb *sbp) 372 + { 373 + return sbp->sb_bad_features2 != sbp->sb_features2; 374 + } 375 + 376 + static inline bool xfs_sb_version_hasattr(struct xfs_sb *sbp) 377 + { 378 + return (sbp->sb_versionnum & XFS_SB_VERSION_ATTRBIT); 379 + } 380 + 381 + static inline void xfs_sb_version_addattr(struct xfs_sb *sbp) 382 + { 383 + sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT; 384 + } 385 + 386 + static inline bool xfs_sb_version_hasquota(struct xfs_sb *sbp) 387 + { 388 + return (sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT); 389 + } 390 + 391 + static inline void xfs_sb_version_addquota(struct xfs_sb *sbp) 392 + { 393 + sbp->sb_versionnum |= XFS_SB_VERSION_QUOTABIT; 394 + } 395 + 396 + static inline bool xfs_sb_version_hasalign(struct xfs_sb *sbp) 397 + { 398 + return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || 399 + (sbp->sb_versionnum & XFS_SB_VERSION_ALIGNBIT)); 400 + } 401 + 402 + static inline bool xfs_sb_version_hasdalign(struct xfs_sb *sbp) 403 + { 404 + return (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT); 405 + } 406 + 407 + static inline bool xfs_sb_version_haslogv2(struct xfs_sb *sbp) 408 + { 409 + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || 410 + (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT); 411 + } 412 + 413 + static inline bool xfs_sb_version_hasextflgbit(struct xfs_sb *sbp) 414 + { 415 + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || 416 + (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT); 417 + } 418 + 419 + static inline bool xfs_sb_version_hassector(struct xfs_sb *sbp) 420 + { 421 + return (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT); 422 + } 423 + 424 + static inline bool xfs_sb_version_hasasciici(struct xfs_sb *sbp) 425 + { 426 + return (sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT); 427 + } 428 + 429 + static inline bool xfs_sb_version_hasmorebits(struct xfs_sb *sbp) 430 + { 431 + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || 432 + (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT); 433 + } 434 + 435 + /* 436 + * sb_features2 bit version macros. 437 + */ 438 + static inline bool xfs_sb_version_haslazysbcount(struct xfs_sb *sbp) 439 + { 440 + return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || 441 + (xfs_sb_version_hasmorebits(sbp) && 442 + (sbp->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT)); 443 + } 444 + 445 + static inline bool xfs_sb_version_hasattr2(struct xfs_sb *sbp) 446 + { 447 + return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || 448 + (xfs_sb_version_hasmorebits(sbp) && 449 + (sbp->sb_features2 & XFS_SB_VERSION2_ATTR2BIT)); 450 + } 451 + 452 + static inline void xfs_sb_version_addattr2(struct xfs_sb *sbp) 453 + { 454 + sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; 455 + sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT; 456 + sbp->sb_bad_features2 |= XFS_SB_VERSION2_ATTR2BIT; 457 + } 458 + 459 + static inline void xfs_sb_version_removeattr2(struct xfs_sb *sbp) 460 + { 461 + sbp->sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT; 462 + sbp->sb_bad_features2 &= ~XFS_SB_VERSION2_ATTR2BIT; 463 + if (!sbp->sb_features2) 464 + sbp->sb_versionnum &= ~XFS_SB_VERSION_MOREBITSBIT; 465 + } 466 + 467 + static inline bool xfs_sb_version_hasprojid32bit(struct xfs_sb *sbp) 468 + { 469 + return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || 470 + (xfs_sb_version_hasmorebits(sbp) && 471 + (sbp->sb_features2 & XFS_SB_VERSION2_PROJID32BIT)); 472 + } 473 + 474 + static inline void xfs_sb_version_addprojid32bit(struct xfs_sb *sbp) 475 + { 476 + sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; 477 + sbp->sb_features2 |= XFS_SB_VERSION2_PROJID32BIT; 478 + sbp->sb_bad_features2 |= XFS_SB_VERSION2_PROJID32BIT; 479 + } 480 + 481 + /* 482 + * Extended v5 superblock feature masks. These are to be used for new v5 483 + * superblock features only. 484 + * 485 + * Compat features are new features that old kernels will not notice or affect 486 + * and so can mount read-write without issues. 487 + * 488 + * RO-Compat (read only) are features that old kernels can read but will break 489 + * if they write. Hence only read-only mounts of such filesystems are allowed on 490 + * kernels that don't support the feature bit. 491 + * 492 + * InCompat features are features which old kernels will not understand and so 493 + * must not mount. 494 + * 495 + * Log-InCompat features are for changes to log formats or new transactions that 496 + * can't be replayed on older kernels. The fields are set when the filesystem is 497 + * mounted, and a clean unmount clears the fields. 498 + */ 499 + #define XFS_SB_FEAT_COMPAT_ALL 0 500 + #define XFS_SB_FEAT_COMPAT_UNKNOWN ~XFS_SB_FEAT_COMPAT_ALL 501 + static inline bool 502 + xfs_sb_has_compat_feature( 503 + struct xfs_sb *sbp, 504 + __uint32_t feature) 505 + { 506 + return (sbp->sb_features_compat & feature) != 0; 507 + } 508 + 509 + #define XFS_SB_FEAT_RO_COMPAT_FINOBT (1 << 0) /* free inode btree */ 510 + #define XFS_SB_FEAT_RO_COMPAT_ALL \ 511 + (XFS_SB_FEAT_RO_COMPAT_FINOBT) 512 + #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL 513 + static inline bool 514 + xfs_sb_has_ro_compat_feature( 515 + struct xfs_sb *sbp, 516 + __uint32_t feature) 517 + { 518 + return (sbp->sb_features_ro_compat & feature) != 0; 519 + } 520 + 521 + #define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */ 522 + #define XFS_SB_FEAT_INCOMPAT_ALL \ 523 + (XFS_SB_FEAT_INCOMPAT_FTYPE) 524 + 525 + #define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL 526 + static inline bool 527 + xfs_sb_has_incompat_feature( 528 + struct xfs_sb *sbp, 529 + __uint32_t feature) 530 + { 531 + return (sbp->sb_features_incompat & feature) != 0; 532 + } 533 + 534 + #define XFS_SB_FEAT_INCOMPAT_LOG_ALL 0 535 + #define XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_LOG_ALL 536 + static inline bool 537 + xfs_sb_has_incompat_log_feature( 538 + struct xfs_sb *sbp, 539 + __uint32_t feature) 540 + { 541 + return (sbp->sb_features_log_incompat & feature) != 0; 542 + } 543 + 544 + /* 545 + * V5 superblock specific feature checks 546 + */ 547 + static inline int xfs_sb_version_hascrc(struct xfs_sb *sbp) 548 + { 549 + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; 550 + } 551 + 552 + static inline int xfs_sb_version_has_pquotino(struct xfs_sb *sbp) 553 + { 554 + return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; 555 + } 556 + 557 + static inline int xfs_sb_version_hasftype(struct xfs_sb *sbp) 558 + { 559 + return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && 560 + xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_FTYPE)) || 561 + (xfs_sb_version_hasmorebits(sbp) && 562 + (sbp->sb_features2 & XFS_SB_VERSION2_FTYPE)); 563 + } 564 + 565 + static inline int xfs_sb_version_hasfinobt(xfs_sb_t *sbp) 566 + { 567 + return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) && 568 + (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_FINOBT); 569 + } 570 + 571 + /* 572 + * end of superblock version macros 573 + */ 574 + 575 + static inline bool 576 + xfs_is_quota_inode(struct xfs_sb *sbp, xfs_ino_t ino) 577 + { 578 + return (ino == sbp->sb_uquotino || 579 + ino == sbp->sb_gquotino || 580 + ino == sbp->sb_pquotino); 581 + } 582 + 583 + #define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */ 584 + #define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR) 585 + #define XFS_BUF_TO_SBP(bp) ((xfs_dsb_t *)((bp)->b_addr)) 586 + 587 + #define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d)) 588 + #define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \ 589 + xfs_daddr_to_agno(mp,d), xfs_daddr_to_agbno(mp,d)) 590 + #define XFS_FSB_TO_DADDR(mp,fsbno) XFS_AGB_TO_DADDR(mp, \ 591 + XFS_FSB_TO_AGNO(mp,fsbno), XFS_FSB_TO_AGBNO(mp,fsbno)) 592 + 593 + /* 594 + * File system sector to basic block conversions. 595 + */ 596 + #define XFS_FSS_TO_BB(mp,sec) ((sec) << (mp)->m_sectbb_log) 597 + 598 + /* 599 + * File system block to basic block conversions. 600 + */ 601 + #define XFS_FSB_TO_BB(mp,fsbno) ((fsbno) << (mp)->m_blkbb_log) 602 + #define XFS_BB_TO_FSB(mp,bb) \ 603 + (((bb) + (XFS_FSB_TO_BB(mp,1) - 1)) >> (mp)->m_blkbb_log) 604 + #define XFS_BB_TO_FSBT(mp,bb) ((bb) >> (mp)->m_blkbb_log) 605 + 606 + /* 607 + * File system block to byte conversions. 608 + */ 609 + #define XFS_FSB_TO_B(mp,fsbno) ((xfs_fsize_t)(fsbno) << (mp)->m_sb.sb_blocklog) 610 + #define XFS_B_TO_FSB(mp,b) \ 611 + ((((__uint64_t)(b)) + (mp)->m_blockmask) >> (mp)->m_sb.sb_blocklog) 612 + #define XFS_B_TO_FSBT(mp,b) (((__uint64_t)(b)) >> (mp)->m_sb.sb_blocklog) 613 + #define XFS_B_FSB_OFFSET(mp,b) ((b) & (mp)->m_blockmask) 614 + 615 + /* 616 + * Allocation group header 617 + * 618 + * This is divided into three structures, placed in sequential 512-byte 619 + * buffers after a copy of the superblock (also in a 512-byte buffer). 620 + */ 621 + #define XFS_AGF_MAGIC 0x58414746 /* 'XAGF' */ 622 + #define XFS_AGI_MAGIC 0x58414749 /* 'XAGI' */ 623 + #define XFS_AGFL_MAGIC 0x5841464c /* 'XAFL' */ 624 + #define XFS_AGF_VERSION 1 625 + #define XFS_AGI_VERSION 1 626 + 627 + #define XFS_AGF_GOOD_VERSION(v) ((v) == XFS_AGF_VERSION) 628 + #define XFS_AGI_GOOD_VERSION(v) ((v) == XFS_AGI_VERSION) 629 + 630 + /* 631 + * Btree number 0 is bno, 1 is cnt. This value gives the size of the 632 + * arrays below. 633 + */ 634 + #define XFS_BTNUM_AGF ((int)XFS_BTNUM_CNTi + 1) 635 + 636 + /* 637 + * The second word of agf_levels in the first a.g. overlaps the EFS 638 + * superblock's magic number. Since the magic numbers valid for EFS 639 + * are > 64k, our value cannot be confused for an EFS superblock's. 640 + */ 641 + 642 + typedef struct xfs_agf { 643 + /* 644 + * Common allocation group header information 645 + */ 646 + __be32 agf_magicnum; /* magic number == XFS_AGF_MAGIC */ 647 + __be32 agf_versionnum; /* header version == XFS_AGF_VERSION */ 648 + __be32 agf_seqno; /* sequence # starting from 0 */ 649 + __be32 agf_length; /* size in blocks of a.g. */ 650 + /* 651 + * Freespace information 652 + */ 653 + __be32 agf_roots[XFS_BTNUM_AGF]; /* root blocks */ 654 + __be32 agf_spare0; /* spare field */ 655 + __be32 agf_levels[XFS_BTNUM_AGF]; /* btree levels */ 656 + __be32 agf_spare1; /* spare field */ 657 + 658 + __be32 agf_flfirst; /* first freelist block's index */ 659 + __be32 agf_fllast; /* last freelist block's index */ 660 + __be32 agf_flcount; /* count of blocks in freelist */ 661 + __be32 agf_freeblks; /* total free blocks */ 662 + 663 + __be32 agf_longest; /* longest free space */ 664 + __be32 agf_btreeblks; /* # of blocks held in AGF btrees */ 665 + uuid_t agf_uuid; /* uuid of filesystem */ 666 + 667 + /* 668 + * reserve some contiguous space for future logged fields before we add 669 + * the unlogged fields. This makes the range logging via flags and 670 + * structure offsets much simpler. 671 + */ 672 + __be64 agf_spare64[16]; 673 + 674 + /* unlogged fields, written during buffer writeback. */ 675 + __be64 agf_lsn; /* last write sequence */ 676 + __be32 agf_crc; /* crc of agf sector */ 677 + __be32 agf_spare2; 678 + 679 + /* structure must be padded to 64 bit alignment */ 680 + } xfs_agf_t; 681 + 682 + #define XFS_AGF_CRC_OFF offsetof(struct xfs_agf, agf_crc) 683 + 684 + #define XFS_AGF_MAGICNUM 0x00000001 685 + #define XFS_AGF_VERSIONNUM 0x00000002 686 + #define XFS_AGF_SEQNO 0x00000004 687 + #define XFS_AGF_LENGTH 0x00000008 688 + #define XFS_AGF_ROOTS 0x00000010 689 + #define XFS_AGF_LEVELS 0x00000020 690 + #define XFS_AGF_FLFIRST 0x00000040 691 + #define XFS_AGF_FLLAST 0x00000080 692 + #define XFS_AGF_FLCOUNT 0x00000100 693 + #define XFS_AGF_FREEBLKS 0x00000200 694 + #define XFS_AGF_LONGEST 0x00000400 695 + #define XFS_AGF_BTREEBLKS 0x00000800 696 + #define XFS_AGF_UUID 0x00001000 697 + #define XFS_AGF_NUM_BITS 13 698 + #define XFS_AGF_ALL_BITS ((1 << XFS_AGF_NUM_BITS) - 1) 699 + 700 + #define XFS_AGF_FLAGS \ 701 + { XFS_AGF_MAGICNUM, "MAGICNUM" }, \ 702 + { XFS_AGF_VERSIONNUM, "VERSIONNUM" }, \ 703 + { XFS_AGF_SEQNO, "SEQNO" }, \ 704 + { XFS_AGF_LENGTH, "LENGTH" }, \ 705 + { XFS_AGF_ROOTS, "ROOTS" }, \ 706 + { XFS_AGF_LEVELS, "LEVELS" }, \ 707 + { XFS_AGF_FLFIRST, "FLFIRST" }, \ 708 + { XFS_AGF_FLLAST, "FLLAST" }, \ 709 + { XFS_AGF_FLCOUNT, "FLCOUNT" }, \ 710 + { XFS_AGF_FREEBLKS, "FREEBLKS" }, \ 711 + { XFS_AGF_LONGEST, "LONGEST" }, \ 712 + { XFS_AGF_BTREEBLKS, "BTREEBLKS" }, \ 713 + { XFS_AGF_UUID, "UUID" } 714 + 715 + /* disk block (xfs_daddr_t) in the AG */ 716 + #define XFS_AGF_DADDR(mp) ((xfs_daddr_t)(1 << (mp)->m_sectbb_log)) 717 + #define XFS_AGF_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGF_DADDR(mp)) 718 + #define XFS_BUF_TO_AGF(bp) ((xfs_agf_t *)((bp)->b_addr)) 719 + 720 + /* 721 + * Size of the unlinked inode hash table in the agi. 722 + */ 723 + #define XFS_AGI_UNLINKED_BUCKETS 64 724 + 725 + typedef struct xfs_agi { 726 + /* 727 + * Common allocation group header information 728 + */ 729 + __be32 agi_magicnum; /* magic number == XFS_AGI_MAGIC */ 730 + __be32 agi_versionnum; /* header version == XFS_AGI_VERSION */ 731 + __be32 agi_seqno; /* sequence # starting from 0 */ 732 + __be32 agi_length; /* size in blocks of a.g. */ 733 + /* 734 + * Inode information 735 + * Inodes are mapped by interpreting the inode number, so no 736 + * mapping data is needed here. 737 + */ 738 + __be32 agi_count; /* count of allocated inodes */ 739 + __be32 agi_root; /* root of inode btree */ 740 + __be32 agi_level; /* levels in inode btree */ 741 + __be32 agi_freecount; /* number of free inodes */ 742 + 743 + __be32 agi_newino; /* new inode just allocated */ 744 + __be32 agi_dirino; /* last directory inode chunk */ 745 + /* 746 + * Hash table of inodes which have been unlinked but are 747 + * still being referenced. 748 + */ 749 + __be32 agi_unlinked[XFS_AGI_UNLINKED_BUCKETS]; 750 + /* 751 + * This marks the end of logging region 1 and start of logging region 2. 752 + */ 753 + uuid_t agi_uuid; /* uuid of filesystem */ 754 + __be32 agi_crc; /* crc of agi sector */ 755 + __be32 agi_pad32; 756 + __be64 agi_lsn; /* last write sequence */ 757 + 758 + __be32 agi_free_root; /* root of the free inode btree */ 759 + __be32 agi_free_level;/* levels in free inode btree */ 760 + 761 + /* structure must be padded to 64 bit alignment */ 762 + } xfs_agi_t; 763 + 764 + #define XFS_AGI_CRC_OFF offsetof(struct xfs_agi, agi_crc) 765 + 766 + #define XFS_AGI_MAGICNUM (1 << 0) 767 + #define XFS_AGI_VERSIONNUM (1 << 1) 768 + #define XFS_AGI_SEQNO (1 << 2) 769 + #define XFS_AGI_LENGTH (1 << 3) 770 + #define XFS_AGI_COUNT (1 << 4) 771 + #define XFS_AGI_ROOT (1 << 5) 772 + #define XFS_AGI_LEVEL (1 << 6) 773 + #define XFS_AGI_FREECOUNT (1 << 7) 774 + #define XFS_AGI_NEWINO (1 << 8) 775 + #define XFS_AGI_DIRINO (1 << 9) 776 + #define XFS_AGI_UNLINKED (1 << 10) 777 + #define XFS_AGI_NUM_BITS_R1 11 /* end of the 1st agi logging region */ 778 + #define XFS_AGI_ALL_BITS_R1 ((1 << XFS_AGI_NUM_BITS_R1) - 1) 779 + #define XFS_AGI_FREE_ROOT (1 << 11) 780 + #define XFS_AGI_FREE_LEVEL (1 << 12) 781 + #define XFS_AGI_NUM_BITS_R2 13 782 + 783 + /* disk block (xfs_daddr_t) in the AG */ 784 + #define XFS_AGI_DADDR(mp) ((xfs_daddr_t)(2 << (mp)->m_sectbb_log)) 785 + #define XFS_AGI_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGI_DADDR(mp)) 786 + #define XFS_BUF_TO_AGI(bp) ((xfs_agi_t *)((bp)->b_addr)) 787 + 788 + /* 789 + * The third a.g. block contains the a.g. freelist, an array 790 + * of block pointers to blocks owned by the allocation btree code. 791 + */ 792 + #define XFS_AGFL_DADDR(mp) ((xfs_daddr_t)(3 << (mp)->m_sectbb_log)) 793 + #define XFS_AGFL_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_AGFL_DADDR(mp)) 794 + #define XFS_BUF_TO_AGFL(bp) ((xfs_agfl_t *)((bp)->b_addr)) 795 + 796 + #define XFS_BUF_TO_AGFL_BNO(mp, bp) \ 797 + (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ 798 + &(XFS_BUF_TO_AGFL(bp)->agfl_bno[0]) : \ 799 + (__be32 *)(bp)->b_addr) 800 + 801 + /* 802 + * Size of the AGFL. For CRC-enabled filesystes we steal a couple of 803 + * slots in the beginning of the block for a proper header with the 804 + * location information and CRC. 805 + */ 806 + #define XFS_AGFL_SIZE(mp) \ 807 + (((mp)->m_sb.sb_sectsize - \ 808 + (xfs_sb_version_hascrc(&((mp)->m_sb)) ? \ 809 + sizeof(struct xfs_agfl) : 0)) / \ 810 + sizeof(xfs_agblock_t)) 811 + 812 + typedef struct xfs_agfl { 813 + __be32 agfl_magicnum; 814 + __be32 agfl_seqno; 815 + uuid_t agfl_uuid; 816 + __be64 agfl_lsn; 817 + __be32 agfl_crc; 818 + __be32 agfl_bno[]; /* actually XFS_AGFL_SIZE(mp) */ 819 + } xfs_agfl_t; 820 + 821 + #define XFS_AGFL_CRC_OFF offsetof(struct xfs_agfl, agfl_crc) 822 + 823 + 824 + #define XFS_AG_MAXLEVELS(mp) ((mp)->m_ag_maxlevels) 825 + #define XFS_MIN_FREELIST_RAW(bl,cl,mp) \ 826 + (MIN(bl + 1, XFS_AG_MAXLEVELS(mp)) + MIN(cl + 1, XFS_AG_MAXLEVELS(mp))) 827 + #define XFS_MIN_FREELIST(a,mp) \ 828 + (XFS_MIN_FREELIST_RAW( \ 829 + be32_to_cpu((a)->agf_levels[XFS_BTNUM_BNOi]), \ 830 + be32_to_cpu((a)->agf_levels[XFS_BTNUM_CNTi]), mp)) 831 + #define XFS_MIN_FREELIST_PAG(pag,mp) \ 832 + (XFS_MIN_FREELIST_RAW( \ 833 + (unsigned int)(pag)->pagf_levels[XFS_BTNUM_BNOi], \ 834 + (unsigned int)(pag)->pagf_levels[XFS_BTNUM_CNTi], mp)) 835 + 836 + #define XFS_AGB_TO_FSB(mp,agno,agbno) \ 837 + (((xfs_fsblock_t)(agno) << (mp)->m_sb.sb_agblklog) | (agbno)) 838 + #define XFS_FSB_TO_AGNO(mp,fsbno) \ 839 + ((xfs_agnumber_t)((fsbno) >> (mp)->m_sb.sb_agblklog)) 840 + #define XFS_FSB_TO_AGBNO(mp,fsbno) \ 841 + ((xfs_agblock_t)((fsbno) & xfs_mask32lo((mp)->m_sb.sb_agblklog))) 842 + #define XFS_AGB_TO_DADDR(mp,agno,agbno) \ 843 + ((xfs_daddr_t)XFS_FSB_TO_BB(mp, \ 844 + (xfs_fsblock_t)(agno) * (mp)->m_sb.sb_agblocks + (agbno))) 845 + #define XFS_AG_DADDR(mp,agno,d) (XFS_AGB_TO_DADDR(mp, agno, 0) + (d)) 846 + 847 + /* 848 + * For checking for bad ranges of xfs_daddr_t's, covering multiple 849 + * allocation groups or a single xfs_daddr_t that's a superblock copy. 850 + */ 851 + #define XFS_AG_CHECK_DADDR(mp,d,len) \ 852 + ((len) == 1 ? \ 853 + ASSERT((d) == XFS_SB_DADDR || \ 854 + xfs_daddr_to_agbno(mp, d) != XFS_SB_DADDR) : \ 855 + ASSERT(xfs_daddr_to_agno(mp, d) == \ 856 + xfs_daddr_to_agno(mp, (d) + (len) - 1))) 857 + 858 + typedef struct xfs_timestamp { 859 + __be32 t_sec; /* timestamp seconds */ 860 + __be32 t_nsec; /* timestamp nanoseconds */ 861 + } xfs_timestamp_t; 862 + 863 + /* 864 + * On-disk inode structure. 865 + * 866 + * This is just the header or "dinode core", the inode is expanded to fill a 867 + * variable size the leftover area split into a data and an attribute fork. 868 + * The format of the data and attribute fork depends on the format of the 869 + * inode as indicated by di_format and di_aformat. To access the data and 870 + * attribute use the XFS_DFORK_DPTR, XFS_DFORK_APTR, and XFS_DFORK_PTR macros 871 + * below. 872 + * 873 + * There is a very similar struct icdinode in xfs_inode which matches the 874 + * layout of the first 96 bytes of this structure, but is kept in native 875 + * format instead of big endian. 876 + * 877 + * Note: di_flushiter is only used by v1/2 inodes - it's effectively a zeroed 878 + * padding field for v3 inodes. 879 + */ 880 + #define XFS_DINODE_MAGIC 0x494e /* 'IN' */ 881 + #define XFS_DINODE_GOOD_VERSION(v) ((v) >= 1 && (v) <= 3) 882 + typedef struct xfs_dinode { 883 + __be16 di_magic; /* inode magic # = XFS_DINODE_MAGIC */ 884 + __be16 di_mode; /* mode and type of file */ 885 + __u8 di_version; /* inode version */ 886 + __u8 di_format; /* format of di_c data */ 887 + __be16 di_onlink; /* old number of links to file */ 888 + __be32 di_uid; /* owner's user id */ 889 + __be32 di_gid; /* owner's group id */ 890 + __be32 di_nlink; /* number of links to file */ 891 + __be16 di_projid_lo; /* lower part of owner's project id */ 892 + __be16 di_projid_hi; /* higher part owner's project id */ 893 + __u8 di_pad[6]; /* unused, zeroed space */ 894 + __be16 di_flushiter; /* incremented on flush */ 895 + xfs_timestamp_t di_atime; /* time last accessed */ 896 + xfs_timestamp_t di_mtime; /* time last modified */ 897 + xfs_timestamp_t di_ctime; /* time created/inode modified */ 898 + __be64 di_size; /* number of bytes in file */ 899 + __be64 di_nblocks; /* # of direct & btree blocks used */ 900 + __be32 di_extsize; /* basic/minimum extent size for file */ 901 + __be32 di_nextents; /* number of extents in data fork */ 902 + __be16 di_anextents; /* number of extents in attribute fork*/ 903 + __u8 di_forkoff; /* attr fork offs, <<3 for 64b align */ 904 + __s8 di_aformat; /* format of attr fork's data */ 905 + __be32 di_dmevmask; /* DMIG event mask */ 906 + __be16 di_dmstate; /* DMIG state info */ 907 + __be16 di_flags; /* random flags, XFS_DIFLAG_... */ 908 + __be32 di_gen; /* generation number */ 909 + 910 + /* di_next_unlinked is the only non-core field in the old dinode */ 911 + __be32 di_next_unlinked;/* agi unlinked list ptr */ 912 + 913 + /* start of the extended dinode, writable fields */ 914 + __le32 di_crc; /* CRC of the inode */ 915 + __be64 di_changecount; /* number of attribute changes */ 916 + __be64 di_lsn; /* flush sequence */ 917 + __be64 di_flags2; /* more random flags */ 918 + __u8 di_pad2[16]; /* more padding for future expansion */ 919 + 920 + /* fields only written to during inode creation */ 921 + xfs_timestamp_t di_crtime; /* time created */ 922 + __be64 di_ino; /* inode number */ 923 + uuid_t di_uuid; /* UUID of the filesystem */ 924 + 925 + /* structure must be padded to 64 bit alignment */ 926 + } xfs_dinode_t; 927 + 928 + #define XFS_DINODE_CRC_OFF offsetof(struct xfs_dinode, di_crc) 929 + 930 + #define DI_MAX_FLUSH 0xffff 931 + 932 + /* 933 + * Size of the core inode on disk. Version 1 and 2 inodes have 934 + * the same size, but version 3 has grown a few additional fields. 935 + */ 936 + static inline uint xfs_dinode_size(int version) 937 + { 938 + if (version == 3) 939 + return sizeof(struct xfs_dinode); 940 + return offsetof(struct xfs_dinode, di_crc); 941 + } 942 + 943 + /* 944 + * The 32 bit link count in the inode theoretically maxes out at UINT_MAX. 945 + * Since the pathconf interface is signed, we use 2^31 - 1 instead. 946 + * The old inode format had a 16 bit link count, so its maximum is USHRT_MAX. 947 + */ 948 + #define XFS_MAXLINK ((1U << 31) - 1U) 949 + #define XFS_MAXLINK_1 65535U 950 + 951 + /* 952 + * Values for di_format 953 + */ 954 + typedef enum xfs_dinode_fmt { 955 + XFS_DINODE_FMT_DEV, /* xfs_dev_t */ 956 + XFS_DINODE_FMT_LOCAL, /* bulk data */ 957 + XFS_DINODE_FMT_EXTENTS, /* struct xfs_bmbt_rec */ 958 + XFS_DINODE_FMT_BTREE, /* struct xfs_bmdr_block */ 959 + XFS_DINODE_FMT_UUID /* uuid_t */ 960 + } xfs_dinode_fmt_t; 961 + 962 + /* 963 + * Inode minimum and maximum sizes. 964 + */ 965 + #define XFS_DINODE_MIN_LOG 8 966 + #define XFS_DINODE_MAX_LOG 11 967 + #define XFS_DINODE_MIN_SIZE (1 << XFS_DINODE_MIN_LOG) 968 + #define XFS_DINODE_MAX_SIZE (1 << XFS_DINODE_MAX_LOG) 969 + 970 + /* 971 + * Inode size for given fs. 972 + */ 973 + #define XFS_LITINO(mp, version) \ 974 + ((int)(((mp)->m_sb.sb_inodesize) - xfs_dinode_size(version))) 975 + 976 + /* 977 + * Inode data & attribute fork sizes, per inode. 978 + */ 979 + #define XFS_DFORK_Q(dip) ((dip)->di_forkoff != 0) 980 + #define XFS_DFORK_BOFF(dip) ((int)((dip)->di_forkoff << 3)) 981 + 982 + #define XFS_DFORK_DSIZE(dip,mp) \ 983 + (XFS_DFORK_Q(dip) ? \ 984 + XFS_DFORK_BOFF(dip) : \ 985 + XFS_LITINO(mp, (dip)->di_version)) 986 + #define XFS_DFORK_ASIZE(dip,mp) \ 987 + (XFS_DFORK_Q(dip) ? \ 988 + XFS_LITINO(mp, (dip)->di_version) - XFS_DFORK_BOFF(dip) : \ 989 + 0) 990 + #define XFS_DFORK_SIZE(dip,mp,w) \ 991 + ((w) == XFS_DATA_FORK ? \ 992 + XFS_DFORK_DSIZE(dip, mp) : \ 993 + XFS_DFORK_ASIZE(dip, mp)) 994 + 995 + /* 996 + * Return pointers to the data or attribute forks. 997 + */ 998 + #define XFS_DFORK_DPTR(dip) \ 999 + ((char *)dip + xfs_dinode_size(dip->di_version)) 1000 + #define XFS_DFORK_APTR(dip) \ 1001 + (XFS_DFORK_DPTR(dip) + XFS_DFORK_BOFF(dip)) 1002 + #define XFS_DFORK_PTR(dip,w) \ 1003 + ((w) == XFS_DATA_FORK ? XFS_DFORK_DPTR(dip) : XFS_DFORK_APTR(dip)) 1004 + 1005 + #define XFS_DFORK_FORMAT(dip,w) \ 1006 + ((w) == XFS_DATA_FORK ? \ 1007 + (dip)->di_format : \ 1008 + (dip)->di_aformat) 1009 + #define XFS_DFORK_NEXTENTS(dip,w) \ 1010 + ((w) == XFS_DATA_FORK ? \ 1011 + be32_to_cpu((dip)->di_nextents) : \ 1012 + be16_to_cpu((dip)->di_anextents)) 1013 + 1014 + /* 1015 + * For block and character special files the 32bit dev_t is stored at the 1016 + * beginning of the data fork. 1017 + */ 1018 + static inline xfs_dev_t xfs_dinode_get_rdev(struct xfs_dinode *dip) 1019 + { 1020 + return be32_to_cpu(*(__be32 *)XFS_DFORK_DPTR(dip)); 1021 + } 1022 + 1023 + static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev) 1024 + { 1025 + *(__be32 *)XFS_DFORK_DPTR(dip) = cpu_to_be32(rdev); 1026 + } 1027 + 1028 + /* 1029 + * Values for di_flags 1030 + * There should be a one-to-one correspondence between these flags and the 1031 + * XFS_XFLAG_s. 1032 + */ 1033 + #define XFS_DIFLAG_REALTIME_BIT 0 /* file's blocks come from rt area */ 1034 + #define XFS_DIFLAG_PREALLOC_BIT 1 /* file space has been preallocated */ 1035 + #define XFS_DIFLAG_NEWRTBM_BIT 2 /* for rtbitmap inode, new format */ 1036 + #define XFS_DIFLAG_IMMUTABLE_BIT 3 /* inode is immutable */ 1037 + #define XFS_DIFLAG_APPEND_BIT 4 /* inode is append-only */ 1038 + #define XFS_DIFLAG_SYNC_BIT 5 /* inode is written synchronously */ 1039 + #define XFS_DIFLAG_NOATIME_BIT 6 /* do not update atime */ 1040 + #define XFS_DIFLAG_NODUMP_BIT 7 /* do not dump */ 1041 + #define XFS_DIFLAG_RTINHERIT_BIT 8 /* create with realtime bit set */ 1042 + #define XFS_DIFLAG_PROJINHERIT_BIT 9 /* create with parents projid */ 1043 + #define XFS_DIFLAG_NOSYMLINKS_BIT 10 /* disallow symlink creation */ 1044 + #define XFS_DIFLAG_EXTSIZE_BIT 11 /* inode extent size allocator hint */ 1045 + #define XFS_DIFLAG_EXTSZINHERIT_BIT 12 /* inherit inode extent size */ 1046 + #define XFS_DIFLAG_NODEFRAG_BIT 13 /* do not reorganize/defragment */ 1047 + #define XFS_DIFLAG_FILESTREAM_BIT 14 /* use filestream allocator */ 1048 + #define XFS_DIFLAG_REALTIME (1 << XFS_DIFLAG_REALTIME_BIT) 1049 + #define XFS_DIFLAG_PREALLOC (1 << XFS_DIFLAG_PREALLOC_BIT) 1050 + #define XFS_DIFLAG_NEWRTBM (1 << XFS_DIFLAG_NEWRTBM_BIT) 1051 + #define XFS_DIFLAG_IMMUTABLE (1 << XFS_DIFLAG_IMMUTABLE_BIT) 1052 + #define XFS_DIFLAG_APPEND (1 << XFS_DIFLAG_APPEND_BIT) 1053 + #define XFS_DIFLAG_SYNC (1 << XFS_DIFLAG_SYNC_BIT) 1054 + #define XFS_DIFLAG_NOATIME (1 << XFS_DIFLAG_NOATIME_BIT) 1055 + #define XFS_DIFLAG_NODUMP (1 << XFS_DIFLAG_NODUMP_BIT) 1056 + #define XFS_DIFLAG_RTINHERIT (1 << XFS_DIFLAG_RTINHERIT_BIT) 1057 + #define XFS_DIFLAG_PROJINHERIT (1 << XFS_DIFLAG_PROJINHERIT_BIT) 1058 + #define XFS_DIFLAG_NOSYMLINKS (1 << XFS_DIFLAG_NOSYMLINKS_BIT) 1059 + #define XFS_DIFLAG_EXTSIZE (1 << XFS_DIFLAG_EXTSIZE_BIT) 1060 + #define XFS_DIFLAG_EXTSZINHERIT (1 << XFS_DIFLAG_EXTSZINHERIT_BIT) 1061 + #define XFS_DIFLAG_NODEFRAG (1 << XFS_DIFLAG_NODEFRAG_BIT) 1062 + #define XFS_DIFLAG_FILESTREAM (1 << XFS_DIFLAG_FILESTREAM_BIT) 1063 + 1064 + #define XFS_DIFLAG_ANY \ 1065 + (XFS_DIFLAG_REALTIME | XFS_DIFLAG_PREALLOC | XFS_DIFLAG_NEWRTBM | \ 1066 + XFS_DIFLAG_IMMUTABLE | XFS_DIFLAG_APPEND | XFS_DIFLAG_SYNC | \ 1067 + XFS_DIFLAG_NOATIME | XFS_DIFLAG_NODUMP | XFS_DIFLAG_RTINHERIT | \ 1068 + XFS_DIFLAG_PROJINHERIT | XFS_DIFLAG_NOSYMLINKS | XFS_DIFLAG_EXTSIZE | \ 1069 + XFS_DIFLAG_EXTSZINHERIT | XFS_DIFLAG_NODEFRAG | XFS_DIFLAG_FILESTREAM) 1070 + 1071 + /* 1072 + * Inode number format: 1073 + * low inopblog bits - offset in block 1074 + * next agblklog bits - block number in ag 1075 + * next agno_log bits - ag number 1076 + * high agno_log-agblklog-inopblog bits - 0 1077 + */ 1078 + #define XFS_INO_MASK(k) (__uint32_t)((1ULL << (k)) - 1) 1079 + #define XFS_INO_OFFSET_BITS(mp) (mp)->m_sb.sb_inopblog 1080 + #define XFS_INO_AGBNO_BITS(mp) (mp)->m_sb.sb_agblklog 1081 + #define XFS_INO_AGINO_BITS(mp) (mp)->m_agino_log 1082 + #define XFS_INO_AGNO_BITS(mp) (mp)->m_agno_log 1083 + #define XFS_INO_BITS(mp) \ 1084 + XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp) 1085 + #define XFS_INO_TO_AGNO(mp,i) \ 1086 + ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp))) 1087 + #define XFS_INO_TO_AGINO(mp,i) \ 1088 + ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp))) 1089 + #define XFS_INO_TO_AGBNO(mp,i) \ 1090 + (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \ 1091 + XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp))) 1092 + #define XFS_INO_TO_OFFSET(mp,i) \ 1093 + ((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) 1094 + #define XFS_INO_TO_FSB(mp,i) \ 1095 + XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i)) 1096 + #define XFS_AGINO_TO_INO(mp,a,i) \ 1097 + (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i)) 1098 + #define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp)) 1099 + #define XFS_AGINO_TO_OFFSET(mp,i) \ 1100 + ((i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) 1101 + #define XFS_OFFBNO_TO_AGINO(mp,b,o) \ 1102 + ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o))) 1103 + 1104 + #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL)) 1105 + #define XFS_MAXINUMBER_32 ((xfs_ino_t)((1ULL << 32) - 1ULL)) 1106 + 1107 + /* 37 1108 * RealTime Device format definitions 38 1109 */ 39 1110 ··· 1483 412 offsetof(struct xfs_btree_block, bb_u.s.bb_crc) 1484 413 #define XFS_BTREE_LBLOCK_CRC_OFF \ 1485 414 offsetof(struct xfs_btree_block, bb_u.l.bb_crc) 415 + 416 + /* 417 + * On-disk XFS access control list structure. 418 + */ 419 + struct xfs_acl_entry { 420 + __be32 ae_tag; 421 + __be32 ae_id; 422 + __be16 ae_perm; 423 + __be16 ae_pad; /* fill the implicit hole in the structure */ 424 + }; 425 + 426 + struct xfs_acl { 427 + __be32 acl_cnt; 428 + struct xfs_acl_entry acl_entry[0]; 429 + }; 430 + 431 + /* 432 + * The number of ACL entries allowed is defined by the on-disk format. 433 + * For v4 superblocks, that is limited to 25 entries. For v5 superblocks, it is 434 + * limited only by the maximum size of the xattr that stores the information. 435 + */ 436 + #define XFS_ACL_MAX_ENTRIES(mp) \ 437 + (xfs_sb_version_hascrc(&mp->m_sb) \ 438 + ? (XATTR_SIZE_MAX - sizeof(struct xfs_acl)) / \ 439 + sizeof(struct xfs_acl_entry) \ 440 + : 25) 441 + 442 + #define XFS_ACL_MAX_SIZE(mp) \ 443 + (sizeof(struct xfs_acl) + \ 444 + sizeof(struct xfs_acl_entry) * XFS_ACL_MAX_ENTRIES((mp))) 445 + 446 + /* On-disk XFS extended attribute names */ 447 + #define SGI_ACL_FILE (unsigned char *)"SGI_ACL_FILE" 448 + #define SGI_ACL_DEFAULT (unsigned char *)"SGI_ACL_DEFAULT" 449 + #define SGI_ACL_FILE_SIZE (sizeof(SGI_ACL_FILE)-1) 450 + #define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1) 1486 451 1487 452 #endif /* __XFS_FORMAT_H__ */
+25 -18
fs/xfs/libxfs/xfs_ialloc.c
··· 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_bit.h" 25 - #include "xfs_inum.h" 26 25 #include "xfs_sb.h" 27 - #include "xfs_ag.h" 28 26 #include "xfs_mount.h" 29 27 #include "xfs_inode.h" 30 28 #include "xfs_btree.h" ··· 37 39 #include "xfs_buf_item.h" 38 40 #include "xfs_icreate_item.h" 39 41 #include "xfs_icache.h" 40 - #include "xfs_dinode.h" 41 42 #include "xfs_trace.h" 42 43 43 44 ··· 45 48 */ 46 49 static inline int 47 50 xfs_ialloc_cluster_alignment( 48 - xfs_alloc_arg_t *args) 51 + struct xfs_mount *mp) 49 52 { 50 - if (xfs_sb_version_hasalign(&args->mp->m_sb) && 51 - args->mp->m_sb.sb_inoalignmt >= 52 - XFS_B_TO_FSBT(args->mp, args->mp->m_inode_cluster_size)) 53 - return args->mp->m_sb.sb_inoalignmt; 53 + if (xfs_sb_version_hasalign(&mp->m_sb) && 54 + mp->m_sb.sb_inoalignmt >= 55 + XFS_B_TO_FSBT(mp, mp->m_inode_cluster_size)) 56 + return mp->m_sb.sb_inoalignmt; 54 57 return 1; 55 58 } 56 59 ··· 409 412 * but not to use them in the actual exact allocation. 410 413 */ 411 414 args.alignment = 1; 412 - args.minalignslop = xfs_ialloc_cluster_alignment(&args) - 1; 415 + args.minalignslop = xfs_ialloc_cluster_alignment(args.mp) - 1; 413 416 414 417 /* Allow space for the inode btree to split. */ 415 418 args.minleft = args.mp->m_in_maxlevels - 1; ··· 445 448 args.alignment = args.mp->m_dalign; 446 449 isaligned = 1; 447 450 } else 448 - args.alignment = xfs_ialloc_cluster_alignment(&args); 451 + args.alignment = xfs_ialloc_cluster_alignment(args.mp); 449 452 /* 450 453 * Need to figure out where to allocate the inode blocks. 451 454 * Ideally they should be spaced out through the a.g. ··· 474 477 args.type = XFS_ALLOCTYPE_NEAR_BNO; 475 478 args.agbno = be32_to_cpu(agi->agi_root); 476 479 args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno); 477 - args.alignment = xfs_ialloc_cluster_alignment(&args); 480 + args.alignment = xfs_ialloc_cluster_alignment(args.mp); 478 481 if ((error = xfs_alloc_vextent(&args))) 479 482 return error; 480 483 } ··· 629 632 } 630 633 631 634 /* 632 - * Is there enough free space for the file plus a block of 633 - * inodes? (if we need to allocate some)? 635 + * Check that there is enough free space for the file plus a 636 + * chunk of inodes if we need to allocate some. If this is the 637 + * first pass across the AGs, take into account the potential 638 + * space needed for alignment of inode chunks when checking the 639 + * longest contiguous free space in the AG - this prevents us 640 + * from getting ENOSPC because we have free space larger than 641 + * m_ialloc_blks but alignment constraints prevent us from using 642 + * it. 643 + * 644 + * If we can't find an AG with space for full alignment slack to 645 + * be taken into account, we must be near ENOSPC in all AGs. 646 + * Hence we don't include alignment for the second pass and so 647 + * if we fail allocation due to alignment issues then it is most 648 + * likely a real ENOSPC condition. 634 649 */ 635 650 ineed = mp->m_ialloc_blks; 651 + if (flags && ineed > 1) 652 + ineed += xfs_ialloc_cluster_alignment(mp); 636 653 longest = pag->pagf_longest; 637 654 if (!longest) 638 655 longest = pag->pagf_flcount > 0; ··· 1148 1137 XFS_WANT_CORRUPTED_RETURN((rec.ir_free == frec->ir_free) && 1149 1138 (rec.ir_freecount == frec->ir_freecount)); 1150 1139 1151 - error = xfs_inobt_update(cur, &rec); 1152 - if (error) 1153 - return error; 1154 - 1155 - return 0; 1140 + return xfs_inobt_update(cur, &rec); 1156 1141 } 1157 1142 1158 1143 /*
+4
fs/xfs/libxfs/xfs_ialloc.h
··· 160 160 xfs_agnumber_t agno, xfs_agblock_t agbno, 161 161 xfs_agblock_t length, unsigned int gen); 162 162 163 + int xfs_read_agi(struct xfs_mount *mp, struct xfs_trans *tp, 164 + xfs_agnumber_t agno, struct xfs_buf **bpp); 165 + 166 + 163 167 #endif /* __XFS_IALLOC_H__ */
-2
fs/xfs/libxfs/xfs_ialloc_btree.c
··· 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_bit.h" 25 - #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 25 #include "xfs_mount.h" 28 26 #include "xfs_inode.h" 29 27 #include "xfs_btree.h"
-3
fs/xfs/libxfs/xfs_inode_buf.c
··· 21 21 #include "xfs_format.h" 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 24 #include "xfs_mount.h" 27 25 #include "xfs_inode.h" 28 26 #include "xfs_error.h" ··· 28 30 #include "xfs_icache.h" 29 31 #include "xfs_trans.h" 30 32 #include "xfs_ialloc.h" 31 - #include "xfs_dinode.h" 32 33 33 34 /* 34 35 * Check that none of the inode's in the buffer have a next
-4
fs/xfs/libxfs/xfs_inode_fork.c
··· 22 22 #include "xfs_format.h" 23 23 #include "xfs_log_format.h" 24 24 #include "xfs_trans_resv.h" 25 - #include "xfs_inum.h" 26 - #include "xfs_sb.h" 27 - #include "xfs_ag.h" 28 25 #include "xfs_mount.h" 29 26 #include "xfs_inode.h" 30 27 #include "xfs_trans.h" ··· 31 34 #include "xfs_error.h" 32 35 #include "xfs_trace.h" 33 36 #include "xfs_attr_sf.h" 34 - #include "xfs_dinode.h" 35 37 36 38 kmem_zone_t *xfs_ifork_zone; 37 39
-60
fs/xfs/libxfs/xfs_inum.h
··· 1 - /* 2 - * Copyright (c) 2000-2003,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_INUM_H__ 19 - #define __XFS_INUM_H__ 20 - 21 - /* 22 - * Inode number format: 23 - * low inopblog bits - offset in block 24 - * next agblklog bits - block number in ag 25 - * next agno_log bits - ag number 26 - * high agno_log-agblklog-inopblog bits - 0 27 - */ 28 - 29 - struct xfs_mount; 30 - 31 - #define XFS_INO_MASK(k) (__uint32_t)((1ULL << (k)) - 1) 32 - #define XFS_INO_OFFSET_BITS(mp) (mp)->m_sb.sb_inopblog 33 - #define XFS_INO_AGBNO_BITS(mp) (mp)->m_sb.sb_agblklog 34 - #define XFS_INO_AGINO_BITS(mp) (mp)->m_agino_log 35 - #define XFS_INO_AGNO_BITS(mp) (mp)->m_agno_log 36 - #define XFS_INO_BITS(mp) \ 37 - XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp) 38 - #define XFS_INO_TO_AGNO(mp,i) \ 39 - ((xfs_agnumber_t)((i) >> XFS_INO_AGINO_BITS(mp))) 40 - #define XFS_INO_TO_AGINO(mp,i) \ 41 - ((xfs_agino_t)(i) & XFS_INO_MASK(XFS_INO_AGINO_BITS(mp))) 42 - #define XFS_INO_TO_AGBNO(mp,i) \ 43 - (((xfs_agblock_t)(i) >> XFS_INO_OFFSET_BITS(mp)) & \ 44 - XFS_INO_MASK(XFS_INO_AGBNO_BITS(mp))) 45 - #define XFS_INO_TO_OFFSET(mp,i) \ 46 - ((int)(i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) 47 - #define XFS_INO_TO_FSB(mp,i) \ 48 - XFS_AGB_TO_FSB(mp, XFS_INO_TO_AGNO(mp,i), XFS_INO_TO_AGBNO(mp,i)) 49 - #define XFS_AGINO_TO_INO(mp,a,i) \ 50 - (((xfs_ino_t)(a) << XFS_INO_AGINO_BITS(mp)) | (i)) 51 - #define XFS_AGINO_TO_AGBNO(mp,i) ((i) >> XFS_INO_OFFSET_BITS(mp)) 52 - #define XFS_AGINO_TO_OFFSET(mp,i) \ 53 - ((i) & XFS_INO_MASK(XFS_INO_OFFSET_BITS(mp))) 54 - #define XFS_OFFBNO_TO_AGINO(mp,b,o) \ 55 - ((xfs_agino_t)(((b) << XFS_INO_OFFSET_BITS(mp)) | (o))) 56 - 57 - #define XFS_MAXINUMBER ((xfs_ino_t)((1ULL << 56) - 1ULL)) 58 - #define XFS_MAXINUMBER_32 ((xfs_ino_t)((1ULL << 32) - 1ULL)) 59 - 60 - #endif /* __XFS_INUM_H__ */
+1 -1
fs/xfs/libxfs/xfs_log_format.h
··· 361 361 362 362 /* 363 363 * NOTE: This structure must be kept identical to struct xfs_dinode 364 - * in xfs_dinode.h except for the endianness annotations. 364 + * except for the endianness annotations. 365 365 */ 366 366 typedef struct xfs_icdinode { 367 367 __uint16_t di_magic; /* inode magic # = XFS_DINODE_MAGIC */
-2
fs/xfs/libxfs/xfs_log_rlimit.c
··· 21 21 #include "xfs_format.h" 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 - #include "xfs_ag.h" 25 - #include "xfs_sb.h" 26 24 #include "xfs_mount.h" 27 25 #include "xfs_da_format.h" 28 26 #include "xfs_trans_space.h"
-3
fs/xfs/libxfs/xfs_rtbitmap.c
··· 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_bit.h" 25 - #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 25 #include "xfs_mount.h" 28 26 #include "xfs_inode.h" 29 27 #include "xfs_bmap.h" ··· 34 36 #include "xfs_trace.h" 35 37 #include "xfs_buf.h" 36 38 #include "xfs_icache.h" 37 - #include "xfs_dinode.h" 38 39 #include "xfs_rtalloc.h" 39 40 40 41
-2
fs/xfs/libxfs/xfs_sb.c
··· 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_bit.h" 25 25 #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 26 #include "xfs_mount.h" 28 27 #include "xfs_inode.h" 29 28 #include "xfs_ialloc.h" ··· 32 33 #include "xfs_cksum.h" 33 34 #include "xfs_trans.h" 34 35 #include "xfs_buf_item.h" 35 - #include "xfs_dinode.h" 36 36 #include "xfs_bmap_btree.h" 37 37 #include "xfs_alloc_btree.h" 38 38 #include "xfs_ialloc_btree.h"
-584
fs/xfs/libxfs/xfs_sb.h
··· 19 19 #define __XFS_SB_H__ 20 20 21 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 - struct xfs_trans; 30 - 31 - #define XFS_SB_MAGIC 0x58465342 /* 'XFSB' */ 32 - #define XFS_SB_VERSION_1 1 /* 5.3, 6.0.1, 6.1 */ 33 - #define XFS_SB_VERSION_2 2 /* 6.2 - attributes */ 34 - #define XFS_SB_VERSION_3 3 /* 6.2 - new inode version */ 35 - #define XFS_SB_VERSION_4 4 /* 6.2+ - bitmask version */ 36 - #define XFS_SB_VERSION_5 5 /* CRC enabled filesystem */ 37 - #define XFS_SB_VERSION_NUMBITS 0x000f 38 - #define XFS_SB_VERSION_ALLFBITS 0xfff0 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 49 - #define XFS_SB_VERSION_BORGBIT 0x4000 /* ASCII only case-insens. */ 50 - #define XFS_SB_VERSION_MOREBITSBIT 0x8000 51 - 52 - /* 53 - * Supported feature bit list is just all bits in the versionnum field because 54 - * we've used them all up and understand them all. Except, of course, for the 55 - * shared superblock bit, which nobody knows what it does and so is unsupported. 56 - */ 57 - #define XFS_SB_VERSION_OKBITS \ 58 - ((XFS_SB_VERSION_NUMBITS | XFS_SB_VERSION_ALLFBITS) & \ 59 - ~XFS_SB_VERSION_SHAREDBIT) 60 - 61 - /* 62 - * There are two words to hold XFS "feature" bits: the original 63 - * word, sb_versionnum, and sb_features2. Whenever a bit is set in 64 - * sb_features2, the feature bit XFS_SB_VERSION_MOREBITSBIT must be set. 65 - * 66 - * These defines represent bits in sb_features2. 67 - */ 68 - #define XFS_SB_VERSION2_RESERVED1BIT 0x00000001 69 - #define XFS_SB_VERSION2_LAZYSBCOUNTBIT 0x00000002 /* Superblk counters */ 70 - #define XFS_SB_VERSION2_RESERVED4BIT 0x00000004 71 - #define XFS_SB_VERSION2_ATTR2BIT 0x00000008 /* Inline attr rework */ 72 - #define XFS_SB_VERSION2_PARENTBIT 0x00000010 /* parent pointers */ 73 - #define XFS_SB_VERSION2_PROJID32BIT 0x00000080 /* 32 bit project id */ 74 - #define XFS_SB_VERSION2_CRCBIT 0x00000100 /* metadata CRCs */ 75 - #define XFS_SB_VERSION2_FTYPE 0x00000200 /* inode type in dir */ 76 - 77 - #define XFS_SB_VERSION2_OKBITS \ 78 - (XFS_SB_VERSION2_LAZYSBCOUNTBIT | \ 79 - XFS_SB_VERSION2_ATTR2BIT | \ 80 - XFS_SB_VERSION2_PROJID32BIT | \ 81 - XFS_SB_VERSION2_FTYPE) 82 - 83 - /* 84 - * Superblock - in core version. Must match the ondisk version below. 85 - * Must be padded to 64 bit alignment. 86 - */ 87 - typedef struct xfs_sb { 88 - __uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */ 89 - __uint32_t sb_blocksize; /* logical block size, bytes */ 90 - xfs_rfsblock_t sb_dblocks; /* number of data blocks */ 91 - xfs_rfsblock_t sb_rblocks; /* number of realtime blocks */ 92 - xfs_rtblock_t sb_rextents; /* number of realtime extents */ 93 - uuid_t sb_uuid; /* file system unique id */ 94 - xfs_fsblock_t sb_logstart; /* starting block of log if internal */ 95 - xfs_ino_t sb_rootino; /* root inode number */ 96 - xfs_ino_t sb_rbmino; /* bitmap inode for realtime extents */ 97 - xfs_ino_t sb_rsumino; /* summary inode for rt bitmap */ 98 - xfs_agblock_t sb_rextsize; /* realtime extent size, blocks */ 99 - xfs_agblock_t sb_agblocks; /* size of an allocation group */ 100 - xfs_agnumber_t sb_agcount; /* number of allocation groups */ 101 - xfs_extlen_t sb_rbmblocks; /* number of rt bitmap blocks */ 102 - xfs_extlen_t sb_logblocks; /* number of log blocks */ 103 - __uint16_t sb_versionnum; /* header version == XFS_SB_VERSION */ 104 - __uint16_t sb_sectsize; /* volume sector size, bytes */ 105 - __uint16_t sb_inodesize; /* inode size, bytes */ 106 - __uint16_t sb_inopblock; /* inodes per block */ 107 - char sb_fname[12]; /* file system name */ 108 - __uint8_t sb_blocklog; /* log2 of sb_blocksize */ 109 - __uint8_t sb_sectlog; /* log2 of sb_sectsize */ 110 - __uint8_t sb_inodelog; /* log2 of sb_inodesize */ 111 - __uint8_t sb_inopblog; /* log2 of sb_inopblock */ 112 - __uint8_t sb_agblklog; /* log2 of sb_agblocks (rounded up) */ 113 - __uint8_t sb_rextslog; /* log2 of sb_rextents */ 114 - __uint8_t sb_inprogress; /* mkfs is in progress, don't mount */ 115 - __uint8_t sb_imax_pct; /* max % of fs for inode space */ 116 - /* statistics */ 117 - /* 118 - * These fields must remain contiguous. If you really 119 - * want to change their layout, make sure you fix the 120 - * code in xfs_trans_apply_sb_deltas(). 121 - */ 122 - __uint64_t sb_icount; /* allocated inodes */ 123 - __uint64_t sb_ifree; /* free inodes */ 124 - __uint64_t sb_fdblocks; /* free data blocks */ 125 - __uint64_t sb_frextents; /* free realtime extents */ 126 - /* 127 - * End contiguous fields. 128 - */ 129 - xfs_ino_t sb_uquotino; /* user quota inode */ 130 - xfs_ino_t sb_gquotino; /* group quota inode */ 131 - __uint16_t sb_qflags; /* quota flags */ 132 - __uint8_t sb_flags; /* misc. flags */ 133 - __uint8_t sb_shared_vn; /* shared version number */ 134 - xfs_extlen_t sb_inoalignmt; /* inode chunk alignment, fsblocks */ 135 - __uint32_t sb_unit; /* stripe or raid unit */ 136 - __uint32_t sb_width; /* stripe or raid width */ 137 - __uint8_t sb_dirblklog; /* log2 of dir block size (fsbs) */ 138 - __uint8_t sb_logsectlog; /* log2 of the log sector size */ 139 - __uint16_t sb_logsectsize; /* sector size for the log, bytes */ 140 - __uint32_t sb_logsunit; /* stripe unit size for the log */ 141 - __uint32_t sb_features2; /* additional feature bits */ 142 - 143 - /* 144 - * bad features2 field as a result of failing to pad the sb 145 - * structure to 64 bits. Some machines will be using this field 146 - * for features2 bits. Easiest just to mark it bad and not use 147 - * it for anything else. 148 - */ 149 - __uint32_t sb_bad_features2; 150 - 151 - /* version 5 superblock fields start here */ 152 - 153 - /* feature masks */ 154 - __uint32_t sb_features_compat; 155 - __uint32_t sb_features_ro_compat; 156 - __uint32_t sb_features_incompat; 157 - __uint32_t sb_features_log_incompat; 158 - 159 - __uint32_t sb_crc; /* superblock crc */ 160 - __uint32_t sb_pad; 161 - 162 - xfs_ino_t sb_pquotino; /* project quota inode */ 163 - xfs_lsn_t sb_lsn; /* last write sequence */ 164 - 165 - /* must be padded to 64 bit alignment */ 166 - } xfs_sb_t; 167 - 168 - #define XFS_SB_CRC_OFF offsetof(struct xfs_sb, sb_crc) 169 - 170 - /* 171 - * Superblock - on disk version. Must match the in core version above. 172 - * Must be padded to 64 bit alignment. 173 - */ 174 - typedef struct xfs_dsb { 175 - __be32 sb_magicnum; /* magic number == XFS_SB_MAGIC */ 176 - __be32 sb_blocksize; /* logical block size, bytes */ 177 - __be64 sb_dblocks; /* number of data blocks */ 178 - __be64 sb_rblocks; /* number of realtime blocks */ 179 - __be64 sb_rextents; /* number of realtime extents */ 180 - uuid_t sb_uuid; /* file system unique id */ 181 - __be64 sb_logstart; /* starting block of log if internal */ 182 - __be64 sb_rootino; /* root inode number */ 183 - __be64 sb_rbmino; /* bitmap inode for realtime extents */ 184 - __be64 sb_rsumino; /* summary inode for rt bitmap */ 185 - __be32 sb_rextsize; /* realtime extent size, blocks */ 186 - __be32 sb_agblocks; /* size of an allocation group */ 187 - __be32 sb_agcount; /* number of allocation groups */ 188 - __be32 sb_rbmblocks; /* number of rt bitmap blocks */ 189 - __be32 sb_logblocks; /* number of log blocks */ 190 - __be16 sb_versionnum; /* header version == XFS_SB_VERSION */ 191 - __be16 sb_sectsize; /* volume sector size, bytes */ 192 - __be16 sb_inodesize; /* inode size, bytes */ 193 - __be16 sb_inopblock; /* inodes per block */ 194 - char sb_fname[12]; /* file system name */ 195 - __u8 sb_blocklog; /* log2 of sb_blocksize */ 196 - __u8 sb_sectlog; /* log2 of sb_sectsize */ 197 - __u8 sb_inodelog; /* log2 of sb_inodesize */ 198 - __u8 sb_inopblog; /* log2 of sb_inopblock */ 199 - __u8 sb_agblklog; /* log2 of sb_agblocks (rounded up) */ 200 - __u8 sb_rextslog; /* log2 of sb_rextents */ 201 - __u8 sb_inprogress; /* mkfs is in progress, don't mount */ 202 - __u8 sb_imax_pct; /* max % of fs for inode space */ 203 - /* statistics */ 204 - /* 205 - * These fields must remain contiguous. If you really 206 - * want to change their layout, make sure you fix the 207 - * code in xfs_trans_apply_sb_deltas(). 208 - */ 209 - __be64 sb_icount; /* allocated inodes */ 210 - __be64 sb_ifree; /* free inodes */ 211 - __be64 sb_fdblocks; /* free data blocks */ 212 - __be64 sb_frextents; /* free realtime extents */ 213 - /* 214 - * End contiguous fields. 215 - */ 216 - __be64 sb_uquotino; /* user quota inode */ 217 - __be64 sb_gquotino; /* group quota inode */ 218 - __be16 sb_qflags; /* quota flags */ 219 - __u8 sb_flags; /* misc. flags */ 220 - __u8 sb_shared_vn; /* shared version number */ 221 - __be32 sb_inoalignmt; /* inode chunk alignment, fsblocks */ 222 - __be32 sb_unit; /* stripe or raid unit */ 223 - __be32 sb_width; /* stripe or raid width */ 224 - __u8 sb_dirblklog; /* log2 of dir block size (fsbs) */ 225 - __u8 sb_logsectlog; /* log2 of the log sector size */ 226 - __be16 sb_logsectsize; /* sector size for the log, bytes */ 227 - __be32 sb_logsunit; /* stripe unit size for the log */ 228 - __be32 sb_features2; /* additional feature bits */ 229 - /* 230 - * bad features2 field as a result of failing to pad the sb 231 - * structure to 64 bits. Some machines will be using this field 232 - * for features2 bits. Easiest just to mark it bad and not use 233 - * it for anything else. 234 - */ 235 - __be32 sb_bad_features2; 236 - 237 - /* version 5 superblock fields start here */ 238 - 239 - /* feature masks */ 240 - __be32 sb_features_compat; 241 - __be32 sb_features_ro_compat; 242 - __be32 sb_features_incompat; 243 - __be32 sb_features_log_incompat; 244 - 245 - __le32 sb_crc; /* superblock crc */ 246 - __be32 sb_pad; 247 - 248 - __be64 sb_pquotino; /* project quota inode */ 249 - __be64 sb_lsn; /* last write sequence */ 250 - 251 - /* must be padded to 64 bit alignment */ 252 - } xfs_dsb_t; 253 - 254 - /* 255 - * Sequence number values for the fields. 256 - */ 257 - typedef enum { 258 - XFS_SBS_MAGICNUM, XFS_SBS_BLOCKSIZE, XFS_SBS_DBLOCKS, XFS_SBS_RBLOCKS, 259 - XFS_SBS_REXTENTS, XFS_SBS_UUID, XFS_SBS_LOGSTART, XFS_SBS_ROOTINO, 260 - XFS_SBS_RBMINO, XFS_SBS_RSUMINO, XFS_SBS_REXTSIZE, XFS_SBS_AGBLOCKS, 261 - XFS_SBS_AGCOUNT, XFS_SBS_RBMBLOCKS, XFS_SBS_LOGBLOCKS, 262 - XFS_SBS_VERSIONNUM, XFS_SBS_SECTSIZE, XFS_SBS_INODESIZE, 263 - XFS_SBS_INOPBLOCK, XFS_SBS_FNAME, XFS_SBS_BLOCKLOG, 264 - XFS_SBS_SECTLOG, XFS_SBS_INODELOG, XFS_SBS_INOPBLOG, XFS_SBS_AGBLKLOG, 265 - XFS_SBS_REXTSLOG, XFS_SBS_INPROGRESS, XFS_SBS_IMAX_PCT, XFS_SBS_ICOUNT, 266 - XFS_SBS_IFREE, XFS_SBS_FDBLOCKS, XFS_SBS_FREXTENTS, XFS_SBS_UQUOTINO, 267 - XFS_SBS_GQUOTINO, XFS_SBS_QFLAGS, XFS_SBS_FLAGS, XFS_SBS_SHARED_VN, 268 - XFS_SBS_INOALIGNMT, XFS_SBS_UNIT, XFS_SBS_WIDTH, XFS_SBS_DIRBLKLOG, 269 - XFS_SBS_LOGSECTLOG, XFS_SBS_LOGSECTSIZE, XFS_SBS_LOGSUNIT, 270 - XFS_SBS_FEATURES2, XFS_SBS_BAD_FEATURES2, XFS_SBS_FEATURES_COMPAT, 271 - XFS_SBS_FEATURES_RO_COMPAT, XFS_SBS_FEATURES_INCOMPAT, 272 - XFS_SBS_FEATURES_LOG_INCOMPAT, XFS_SBS_CRC, XFS_SBS_PAD, 273 - XFS_SBS_PQUOTINO, XFS_SBS_LSN, 274 - XFS_SBS_FIELDCOUNT 275 - } xfs_sb_field_t; 276 - 277 - /* 278 - * Mask values, defined based on the xfs_sb_field_t values. 279 - * Only define the ones we're using. 280 - */ 281 - #define XFS_SB_MVAL(x) (1LL << XFS_SBS_ ## x) 282 - #define XFS_SB_UUID XFS_SB_MVAL(UUID) 283 - #define XFS_SB_FNAME XFS_SB_MVAL(FNAME) 284 - #define XFS_SB_ROOTINO XFS_SB_MVAL(ROOTINO) 285 - #define XFS_SB_RBMINO XFS_SB_MVAL(RBMINO) 286 - #define XFS_SB_RSUMINO XFS_SB_MVAL(RSUMINO) 287 - #define XFS_SB_VERSIONNUM XFS_SB_MVAL(VERSIONNUM) 288 - #define XFS_SB_UQUOTINO XFS_SB_MVAL(UQUOTINO) 289 - #define XFS_SB_GQUOTINO XFS_SB_MVAL(GQUOTINO) 290 - #define XFS_SB_QFLAGS XFS_SB_MVAL(QFLAGS) 291 - #define XFS_SB_SHARED_VN XFS_SB_MVAL(SHARED_VN) 292 - #define XFS_SB_UNIT XFS_SB_MVAL(UNIT) 293 - #define XFS_SB_WIDTH XFS_SB_MVAL(WIDTH) 294 - #define XFS_SB_ICOUNT XFS_SB_MVAL(ICOUNT) 295 - #define XFS_SB_IFREE XFS_SB_MVAL(IFREE) 296 - #define XFS_SB_FDBLOCKS XFS_SB_MVAL(FDBLOCKS) 297 - #define XFS_SB_FEATURES2 XFS_SB_MVAL(FEATURES2) 298 - #define XFS_SB_BAD_FEATURES2 XFS_SB_MVAL(BAD_FEATURES2) 299 - #define XFS_SB_FEATURES_COMPAT XFS_SB_MVAL(FEATURES_COMPAT) 300 - #define XFS_SB_FEATURES_RO_COMPAT XFS_SB_MVAL(FEATURES_RO_COMPAT) 301 - #define XFS_SB_FEATURES_INCOMPAT XFS_SB_MVAL(FEATURES_INCOMPAT) 302 - #define XFS_SB_FEATURES_LOG_INCOMPAT XFS_SB_MVAL(FEATURES_LOG_INCOMPAT) 303 - #define XFS_SB_CRC XFS_SB_MVAL(CRC) 304 - #define XFS_SB_PQUOTINO XFS_SB_MVAL(PQUOTINO) 305 - #define XFS_SB_NUM_BITS ((int)XFS_SBS_FIELDCOUNT) 306 - #define XFS_SB_ALL_BITS ((1LL << XFS_SB_NUM_BITS) - 1) 307 - #define XFS_SB_MOD_BITS \ 308 - (XFS_SB_UUID | XFS_SB_ROOTINO | XFS_SB_RBMINO | XFS_SB_RSUMINO | \ 309 - XFS_SB_VERSIONNUM | XFS_SB_UQUOTINO | XFS_SB_GQUOTINO | \ 310 - XFS_SB_QFLAGS | XFS_SB_SHARED_VN | XFS_SB_UNIT | XFS_SB_WIDTH | \ 311 - XFS_SB_ICOUNT | XFS_SB_IFREE | XFS_SB_FDBLOCKS | XFS_SB_FEATURES2 | \ 312 - XFS_SB_BAD_FEATURES2 | XFS_SB_FEATURES_COMPAT | \ 313 - XFS_SB_FEATURES_RO_COMPAT | XFS_SB_FEATURES_INCOMPAT | \ 314 - XFS_SB_FEATURES_LOG_INCOMPAT | XFS_SB_PQUOTINO) 315 - 316 - 317 - /* 318 - * Misc. Flags - warning - these will be cleared by xfs_repair unless 319 - * a feature bit is set when the flag is used. 320 - */ 321 - #define XFS_SBF_NOFLAGS 0x00 /* no flags set */ 322 - #define XFS_SBF_READONLY 0x01 /* only read-only mounts allowed */ 323 - 324 - /* 325 - * define max. shared version we can interoperate with 326 - */ 327 - #define XFS_SB_MAX_SHARED_VN 0 328 - 329 - #define XFS_SB_VERSION_NUM(sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) 330 - 331 - /* 332 - * The first XFS version we support is a v4 superblock with V2 directories. 333 - */ 334 - static inline bool xfs_sb_good_v4_features(struct xfs_sb *sbp) 335 - { 336 - if (!(sbp->sb_versionnum & XFS_SB_VERSION_DIRV2BIT)) 337 - return false; 338 - 339 - /* check for unknown features in the fs */ 340 - if ((sbp->sb_versionnum & ~XFS_SB_VERSION_OKBITS) || 341 - ((sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT) && 342 - (sbp->sb_features2 & ~XFS_SB_VERSION2_OKBITS))) 343 - return false; 344 - 345 - return true; 346 - } 347 - 348 - static inline bool xfs_sb_good_version(struct xfs_sb *sbp) 349 - { 350 - if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) 351 - return true; 352 - if (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_4) 353 - return xfs_sb_good_v4_features(sbp); 354 - return false; 355 - } 356 - 357 - /* 358 - * Detect a mismatched features2 field. Older kernels read/wrote 359 - * this into the wrong slot, so to be safe we keep them in sync. 360 - */ 361 - static inline bool xfs_sb_has_mismatched_features2(struct xfs_sb *sbp) 362 - { 363 - return sbp->sb_bad_features2 != sbp->sb_features2; 364 - } 365 - 366 - static inline bool xfs_sb_version_hasattr(struct xfs_sb *sbp) 367 - { 368 - return (sbp->sb_versionnum & XFS_SB_VERSION_ATTRBIT); 369 - } 370 - 371 - static inline void xfs_sb_version_addattr(struct xfs_sb *sbp) 372 - { 373 - sbp->sb_versionnum |= XFS_SB_VERSION_ATTRBIT; 374 - } 375 - 376 - static inline bool xfs_sb_version_hasquota(struct xfs_sb *sbp) 377 - { 378 - return (sbp->sb_versionnum & XFS_SB_VERSION_QUOTABIT); 379 - } 380 - 381 - static inline void xfs_sb_version_addquota(struct xfs_sb *sbp) 382 - { 383 - sbp->sb_versionnum |= XFS_SB_VERSION_QUOTABIT; 384 - } 385 - 386 - static inline bool xfs_sb_version_hasalign(struct xfs_sb *sbp) 387 - { 388 - return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || 389 - (sbp->sb_versionnum & XFS_SB_VERSION_ALIGNBIT)); 390 - } 391 - 392 - static inline bool xfs_sb_version_hasdalign(struct xfs_sb *sbp) 393 - { 394 - return (sbp->sb_versionnum & XFS_SB_VERSION_DALIGNBIT); 395 - } 396 - 397 - static inline bool xfs_sb_version_haslogv2(struct xfs_sb *sbp) 398 - { 399 - return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || 400 - (sbp->sb_versionnum & XFS_SB_VERSION_LOGV2BIT); 401 - } 402 - 403 - static inline bool xfs_sb_version_hasextflgbit(struct xfs_sb *sbp) 404 - { 405 - return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || 406 - (sbp->sb_versionnum & XFS_SB_VERSION_EXTFLGBIT); 407 - } 408 - 409 - static inline bool xfs_sb_version_hassector(struct xfs_sb *sbp) 410 - { 411 - return (sbp->sb_versionnum & XFS_SB_VERSION_SECTORBIT); 412 - } 413 - 414 - static inline bool xfs_sb_version_hasasciici(struct xfs_sb *sbp) 415 - { 416 - return (sbp->sb_versionnum & XFS_SB_VERSION_BORGBIT); 417 - } 418 - 419 - static inline bool xfs_sb_version_hasmorebits(struct xfs_sb *sbp) 420 - { 421 - return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 || 422 - (sbp->sb_versionnum & XFS_SB_VERSION_MOREBITSBIT); 423 - } 424 - 425 - /* 426 - * sb_features2 bit version macros. 427 - */ 428 - static inline bool xfs_sb_version_haslazysbcount(struct xfs_sb *sbp) 429 - { 430 - return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || 431 - (xfs_sb_version_hasmorebits(sbp) && 432 - (sbp->sb_features2 & XFS_SB_VERSION2_LAZYSBCOUNTBIT)); 433 - } 434 - 435 - static inline bool xfs_sb_version_hasattr2(struct xfs_sb *sbp) 436 - { 437 - return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || 438 - (xfs_sb_version_hasmorebits(sbp) && 439 - (sbp->sb_features2 & XFS_SB_VERSION2_ATTR2BIT)); 440 - } 441 - 442 - static inline void xfs_sb_version_addattr2(struct xfs_sb *sbp) 443 - { 444 - sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; 445 - sbp->sb_features2 |= XFS_SB_VERSION2_ATTR2BIT; 446 - sbp->sb_bad_features2 |= XFS_SB_VERSION2_ATTR2BIT; 447 - } 448 - 449 - static inline void xfs_sb_version_removeattr2(struct xfs_sb *sbp) 450 - { 451 - sbp->sb_features2 &= ~XFS_SB_VERSION2_ATTR2BIT; 452 - sbp->sb_bad_features2 &= ~XFS_SB_VERSION2_ATTR2BIT; 453 - if (!sbp->sb_features2) 454 - sbp->sb_versionnum &= ~XFS_SB_VERSION_MOREBITSBIT; 455 - } 456 - 457 - static inline bool xfs_sb_version_hasprojid32bit(struct xfs_sb *sbp) 458 - { 459 - return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) || 460 - (xfs_sb_version_hasmorebits(sbp) && 461 - (sbp->sb_features2 & XFS_SB_VERSION2_PROJID32BIT)); 462 - } 463 - 464 - static inline void xfs_sb_version_addprojid32bit(struct xfs_sb *sbp) 465 - { 466 - sbp->sb_versionnum |= XFS_SB_VERSION_MOREBITSBIT; 467 - sbp->sb_features2 |= XFS_SB_VERSION2_PROJID32BIT; 468 - sbp->sb_bad_features2 |= XFS_SB_VERSION2_PROJID32BIT; 469 - } 470 - 471 - /* 472 - * Extended v5 superblock feature masks. These are to be used for new v5 473 - * superblock features only. 474 - * 475 - * Compat features are new features that old kernels will not notice or affect 476 - * and so can mount read-write without issues. 477 - * 478 - * RO-Compat (read only) are features that old kernels can read but will break 479 - * if they write. Hence only read-only mounts of such filesystems are allowed on 480 - * kernels that don't support the feature bit. 481 - * 482 - * InCompat features are features which old kernels will not understand and so 483 - * must not mount. 484 - * 485 - * Log-InCompat features are for changes to log formats or new transactions that 486 - * can't be replayed on older kernels. The fields are set when the filesystem is 487 - * mounted, and a clean unmount clears the fields. 488 - */ 489 - #define XFS_SB_FEAT_COMPAT_ALL 0 490 - #define XFS_SB_FEAT_COMPAT_UNKNOWN ~XFS_SB_FEAT_COMPAT_ALL 491 - static inline bool 492 - xfs_sb_has_compat_feature( 493 - struct xfs_sb *sbp, 494 - __uint32_t feature) 495 - { 496 - return (sbp->sb_features_compat & feature) != 0; 497 - } 498 - 499 - #define XFS_SB_FEAT_RO_COMPAT_FINOBT (1 << 0) /* free inode btree */ 500 - #define XFS_SB_FEAT_RO_COMPAT_ALL \ 501 - (XFS_SB_FEAT_RO_COMPAT_FINOBT) 502 - #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL 503 - static inline bool 504 - xfs_sb_has_ro_compat_feature( 505 - struct xfs_sb *sbp, 506 - __uint32_t feature) 507 - { 508 - return (sbp->sb_features_ro_compat & feature) != 0; 509 - } 510 - 511 - #define XFS_SB_FEAT_INCOMPAT_FTYPE (1 << 0) /* filetype in dirent */ 512 - #define XFS_SB_FEAT_INCOMPAT_ALL \ 513 - (XFS_SB_FEAT_INCOMPAT_FTYPE) 514 - 515 - #define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL 516 - static inline bool 517 - xfs_sb_has_incompat_feature( 518 - struct xfs_sb *sbp, 519 - __uint32_t feature) 520 - { 521 - return (sbp->sb_features_incompat & feature) != 0; 522 - } 523 - 524 - #define XFS_SB_FEAT_INCOMPAT_LOG_ALL 0 525 - #define XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_LOG_ALL 526 - static inline bool 527 - xfs_sb_has_incompat_log_feature( 528 - struct xfs_sb *sbp, 529 - __uint32_t feature) 530 - { 531 - return (sbp->sb_features_log_incompat & feature) != 0; 532 - } 533 - 534 - /* 535 - * V5 superblock specific feature checks 536 - */ 537 - static inline int xfs_sb_version_hascrc(struct xfs_sb *sbp) 538 - { 539 - return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; 540 - } 541 - 542 - static inline int xfs_sb_version_has_pquotino(struct xfs_sb *sbp) 543 - { 544 - return XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5; 545 - } 546 - 547 - static inline int xfs_sb_version_hasftype(struct xfs_sb *sbp) 548 - { 549 - return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 && 550 - xfs_sb_has_incompat_feature(sbp, XFS_SB_FEAT_INCOMPAT_FTYPE)) || 551 - (xfs_sb_version_hasmorebits(sbp) && 552 - (sbp->sb_features2 & XFS_SB_VERSION2_FTYPE)); 553 - } 554 - 555 - static inline int xfs_sb_version_hasfinobt(xfs_sb_t *sbp) 556 - { 557 - return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) && 558 - (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_FINOBT); 559 - } 560 - 561 - /* 562 - * end of superblock version macros 563 - */ 564 - 565 - static inline bool 566 - xfs_is_quota_inode(struct xfs_sb *sbp, xfs_ino_t ino) 567 - { 568 - return (ino == sbp->sb_uquotino || 569 - ino == sbp->sb_gquotino || 570 - ino == sbp->sb_pquotino); 571 - } 572 - 573 - #define XFS_SB_DADDR ((xfs_daddr_t)0) /* daddr in filesystem/ag */ 574 - #define XFS_SB_BLOCK(mp) XFS_HDR_BLOCK(mp, XFS_SB_DADDR) 575 - #define XFS_BUF_TO_SBP(bp) ((xfs_dsb_t *)((bp)->b_addr)) 576 - 577 - #define XFS_HDR_BLOCK(mp,d) ((xfs_agblock_t)XFS_BB_TO_FSBT(mp,d)) 578 - #define XFS_DADDR_TO_FSB(mp,d) XFS_AGB_TO_FSB(mp, \ 579 - xfs_daddr_to_agno(mp,d), xfs_daddr_to_agbno(mp,d)) 580 - #define XFS_FSB_TO_DADDR(mp,fsbno) XFS_AGB_TO_DADDR(mp, \ 581 - XFS_FSB_TO_AGNO(mp,fsbno), XFS_FSB_TO_AGBNO(mp,fsbno)) 582 - 583 - /* 584 - * File system sector to basic block conversions. 585 - */ 586 - #define XFS_FSS_TO_BB(mp,sec) ((sec) << (mp)->m_sectbb_log) 587 - 588 - /* 589 - * File system block to basic block conversions. 590 - */ 591 - #define XFS_FSB_TO_BB(mp,fsbno) ((fsbno) << (mp)->m_blkbb_log) 592 - #define XFS_BB_TO_FSB(mp,bb) \ 593 - (((bb) + (XFS_FSB_TO_BB(mp,1) - 1)) >> (mp)->m_blkbb_log) 594 - #define XFS_BB_TO_FSBT(mp,bb) ((bb) >> (mp)->m_blkbb_log) 595 - 596 - /* 597 - * File system block to byte conversions. 598 - */ 599 - #define XFS_FSB_TO_B(mp,fsbno) ((xfs_fsize_t)(fsbno) << (mp)->m_sb.sb_blocklog) 600 - #define XFS_B_TO_FSB(mp,b) \ 601 - ((((__uint64_t)(b)) + (mp)->m_blockmask) >> (mp)->m_sb.sb_blocklog) 602 - #define XFS_B_TO_FSBT(mp,b) (((__uint64_t)(b)) >> (mp)->m_sb.sb_blocklog) 603 - #define XFS_B_FSB_OFFSET(mp,b) ((b) & (mp)->m_blockmask) 604 - 605 - /* 606 22 * perag get/put wrappers for ref counting 607 23 */ 608 24 extern struct xfs_perag *xfs_perag_get(struct xfs_mount *, xfs_agnumber_t);
-2
fs/xfs/libxfs/xfs_trans_resv.c
··· 22 22 #include "xfs_format.h" 23 23 #include "xfs_log_format.h" 24 24 #include "xfs_trans_resv.h" 25 - #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 25 #include "xfs_mount.h" 28 26 #include "xfs_da_format.h" 29 27 #include "xfs_da_btree.h"
-2
fs/xfs/xfs_acl.c
··· 19 19 #include "xfs_format.h" 20 20 #include "xfs_log_format.h" 21 21 #include "xfs_trans_resv.h" 22 - #include "xfs_ag.h" 23 - #include "xfs_sb.h" 24 22 #include "xfs_mount.h" 25 23 #include "xfs_inode.h" 26 24 #include "xfs_acl.h"
-36
fs/xfs/xfs_acl.h
··· 22 22 struct posix_acl; 23 23 struct xfs_inode; 24 24 25 - #define XFS_ACL_NOT_PRESENT (-1) 26 - 27 - /* On-disk XFS access control list structure */ 28 - struct xfs_acl_entry { 29 - __be32 ae_tag; 30 - __be32 ae_id; 31 - __be16 ae_perm; 32 - __be16 ae_pad; /* fill the implicit hole in the structure */ 33 - }; 34 - 35 - struct xfs_acl { 36 - __be32 acl_cnt; 37 - struct xfs_acl_entry acl_entry[0]; 38 - }; 39 - 40 - /* 41 - * The number of ACL entries allowed is defined by the on-disk format. 42 - * For v4 superblocks, that is limited to 25 entries. For v5 superblocks, it is 43 - * limited only by the maximum size of the xattr that stores the information. 44 - */ 45 - #define XFS_ACL_MAX_ENTRIES(mp) \ 46 - (xfs_sb_version_hascrc(&mp->m_sb) \ 47 - ? (XATTR_SIZE_MAX - sizeof(struct xfs_acl)) / \ 48 - sizeof(struct xfs_acl_entry) \ 49 - : 25) 50 - 51 - #define XFS_ACL_MAX_SIZE(mp) \ 52 - (sizeof(struct xfs_acl) + \ 53 - sizeof(struct xfs_acl_entry) * XFS_ACL_MAX_ENTRIES((mp))) 54 - 55 - /* On-disk XFS extended attribute names */ 56 - #define SGI_ACL_FILE (unsigned char *)"SGI_ACL_FILE" 57 - #define SGI_ACL_DEFAULT (unsigned char *)"SGI_ACL_DEFAULT" 58 - #define SGI_ACL_FILE_SIZE (sizeof(SGI_ACL_FILE)-1) 59 - #define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1) 60 - 61 25 #ifdef CONFIG_XFS_POSIX_ACL 62 26 extern struct posix_acl *xfs_get_acl(struct inode *inode, int type); 63 27 extern int xfs_set_acl(struct inode *inode, struct posix_acl *acl, int type);
-3
fs/xfs/xfs_aops.c
··· 20 20 #include "xfs_format.h" 21 21 #include "xfs_log_format.h" 22 22 #include "xfs_trans_resv.h" 23 - #include "xfs_sb.h" 24 - #include "xfs_ag.h" 25 23 #include "xfs_mount.h" 26 24 #include "xfs_inode.h" 27 25 #include "xfs_trans.h" ··· 31 33 #include "xfs_bmap.h" 32 34 #include "xfs_bmap_util.h" 33 35 #include "xfs_bmap_btree.h" 34 - #include "xfs_dinode.h" 35 36 #include <linux/aio.h> 36 37 #include <linux/gfp.h> 37 38 #include <linux/mpage.h>
-3
fs/xfs/xfs_attr_inactive.c
··· 23 23 #include "xfs_log_format.h" 24 24 #include "xfs_trans_resv.h" 25 25 #include "xfs_bit.h" 26 - #include "xfs_sb.h" 27 - #include "xfs_ag.h" 28 26 #include "xfs_mount.h" 29 27 #include "xfs_da_format.h" 30 28 #include "xfs_da_btree.h" ··· 37 39 #include "xfs_error.h" 38 40 #include "xfs_quota.h" 39 41 #include "xfs_trace.h" 40 - #include "xfs_dinode.h" 41 42 #include "xfs_dir2.h" 42 43 43 44 /*
-3
fs/xfs/xfs_attr_list.c
··· 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_bit.h" 25 - #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 25 #include "xfs_mount.h" 28 26 #include "xfs_da_format.h" 29 27 #include "xfs_da_btree.h" ··· 37 39 #include "xfs_trace.h" 38 40 #include "xfs_buf_item.h" 39 41 #include "xfs_cksum.h" 40 - #include "xfs_dinode.h" 41 42 #include "xfs_dir2.h" 42 43 43 44 STATIC int
-3
fs/xfs/xfs_bmap_util.c
··· 23 23 #include "xfs_log_format.h" 24 24 #include "xfs_trans_resv.h" 25 25 #include "xfs_bit.h" 26 - #include "xfs_sb.h" 27 - #include "xfs_ag.h" 28 26 #include "xfs_mount.h" 29 27 #include "xfs_da_format.h" 30 28 #include "xfs_inode.h" ··· 40 42 #include "xfs_trace.h" 41 43 #include "xfs_icache.h" 42 44 #include "xfs_log.h" 43 - #include "xfs_dinode.h" 44 45 45 46 /* Kernel only BMAP related definitions and functions */ 46 47
+12 -15
fs/xfs/xfs_buf.c
··· 34 34 #include <linux/backing-dev.h> 35 35 #include <linux/freezer.h> 36 36 37 + #include "xfs_format.h" 37 38 #include "xfs_log_format.h" 38 39 #include "xfs_trans_resv.h" 39 40 #include "xfs_sb.h" 40 - #include "xfs_ag.h" 41 41 #include "xfs_mount.h" 42 42 #include "xfs_trace.h" 43 43 #include "xfs_log.h" 44 44 45 45 static kmem_zone_t *xfs_buf_zone; 46 - 47 - static struct workqueue_struct *xfslogd_workqueue; 48 46 49 47 #ifdef XFS_BUF_LOCK_TRACKING 50 48 # define XB_SET_OWNER(bp) ((bp)->b_last_holder = current->pid) ··· 461 463 * have to check that the buffer falls within the filesystem bounds. 462 464 */ 463 465 eofs = XFS_FSB_TO_BB(btp->bt_mount, btp->bt_mount->m_sb.sb_dblocks); 464 - if (blkno >= eofs) { 466 + if (blkno < 0 || blkno >= eofs) { 465 467 /* 466 468 * XXX (dgc): we should really be returning -EFSCORRUPTED here, 467 469 * but none of the higher level infrastructure supports ··· 1041 1043 struct work_struct *work) 1042 1044 { 1043 1045 struct xfs_buf *bp = 1044 - container_of(work, xfs_buf_t, b_iodone_work); 1046 + container_of(work, xfs_buf_t, b_ioend_work); 1045 1047 1046 1048 xfs_buf_ioend(bp); 1047 1049 } ··· 1050 1052 xfs_buf_ioend_async( 1051 1053 struct xfs_buf *bp) 1052 1054 { 1053 - INIT_WORK(&bp->b_iodone_work, xfs_buf_ioend_work); 1054 - queue_work(xfslogd_workqueue, &bp->b_iodone_work); 1055 + INIT_WORK(&bp->b_ioend_work, xfs_buf_ioend_work); 1056 + queue_work(bp->b_ioend_wq, &bp->b_ioend_work); 1055 1057 } 1056 1058 1057 1059 void ··· 1219 1221 * left over from previous use of the buffer (e.g. failed readahead). 1220 1222 */ 1221 1223 bp->b_error = 0; 1224 + 1225 + /* 1226 + * Initialize the I/O completion workqueue if we haven't yet or the 1227 + * submitter has not opted to specify a custom one. 1228 + */ 1229 + if (!bp->b_ioend_wq) 1230 + bp->b_ioend_wq = bp->b_target->bt_mount->m_buf_workqueue; 1222 1231 1223 1232 if (bp->b_flags & XBF_WRITE) { 1224 1233 if (bp->b_flags & XBF_SYNCIO) ··· 1887 1882 if (!xfs_buf_zone) 1888 1883 goto out; 1889 1884 1890 - xfslogd_workqueue = alloc_workqueue("xfslogd", 1891 - WQ_MEM_RECLAIM | WQ_HIGHPRI | WQ_FREEZABLE, 1); 1892 - if (!xfslogd_workqueue) 1893 - goto out_free_buf_zone; 1894 - 1895 1885 return 0; 1896 1886 1897 - out_free_buf_zone: 1898 - kmem_zone_destroy(xfs_buf_zone); 1899 1887 out: 1900 1888 return -ENOMEM; 1901 1889 } ··· 1896 1898 void 1897 1899 xfs_buf_terminate(void) 1898 1900 { 1899 - destroy_workqueue(xfslogd_workqueue); 1900 1901 kmem_zone_destroy(xfs_buf_zone); 1901 1902 }
+2 -1
fs/xfs/xfs_buf.h
··· 164 164 struct xfs_perag *b_pag; /* contains rbtree root */ 165 165 xfs_buftarg_t *b_target; /* buffer target (device) */ 166 166 void *b_addr; /* virtual address of buffer */ 167 - struct work_struct b_iodone_work; 167 + struct work_struct b_ioend_work; 168 + struct workqueue_struct *b_ioend_wq; /* I/O completion wq */ 168 169 xfs_buf_iodone_t b_iodone; /* I/O completion function */ 169 170 struct completion b_iowait; /* queue for I/O waiters */ 170 171 void *b_fspriv;
+1 -1
fs/xfs/xfs_buf_item.c
··· 17 17 */ 18 18 #include "xfs.h" 19 19 #include "xfs_fs.h" 20 + #include "xfs_format.h" 20 21 #include "xfs_log_format.h" 21 22 #include "xfs_trans_resv.h" 22 23 #include "xfs_bit.h" 23 24 #include "xfs_sb.h" 24 - #include "xfs_ag.h" 25 25 #include "xfs_mount.h" 26 26 #include "xfs_trans.h" 27 27 #include "xfs_buf_item.h"
+1 -20
fs/xfs/xfs_dir2_readdir.c
··· 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_bit.h" 25 - #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 25 #include "xfs_mount.h" 28 26 #include "xfs_da_format.h" 29 27 #include "xfs_da_btree.h" ··· 32 34 #include "xfs_trace.h" 33 35 #include "xfs_bmap.h" 34 36 #include "xfs_trans.h" 35 - #include "xfs_dinode.h" 36 37 37 38 /* 38 39 * Directory file type support functions ··· 41 44 DT_FIFO, DT_SOCK, DT_LNK, DT_WHT, 42 45 }; 43 46 44 - unsigned char 47 + static unsigned char 45 48 xfs_dir3_get_dtype( 46 49 struct xfs_mount *mp, 47 50 __uint8_t filetype) ··· 54 57 55 58 return xfs_dir3_filetype_table[filetype]; 56 59 } 57 - /* 58 - * @mode, if set, indicates that the type field needs to be set up. 59 - * This uses the transformation from file mode to DT_* as defined in linux/fs.h 60 - * for file type specification. This will be propagated into the directory 61 - * structure if appropriate for the given operation and filesystem config. 62 - */ 63 - const unsigned char xfs_mode_to_ftype[S_IFMT >> S_SHIFT] = { 64 - [0] = XFS_DIR3_FT_UNKNOWN, 65 - [S_IFREG >> S_SHIFT] = XFS_DIR3_FT_REG_FILE, 66 - [S_IFDIR >> S_SHIFT] = XFS_DIR3_FT_DIR, 67 - [S_IFCHR >> S_SHIFT] = XFS_DIR3_FT_CHRDEV, 68 - [S_IFBLK >> S_SHIFT] = XFS_DIR3_FT_BLKDEV, 69 - [S_IFIFO >> S_SHIFT] = XFS_DIR3_FT_FIFO, 70 - [S_IFSOCK >> S_SHIFT] = XFS_DIR3_FT_SOCK, 71 - [S_IFLNK >> S_SHIFT] = XFS_DIR3_FT_SYMLINK, 72 - }; 73 60 74 61 STATIC int 75 62 xfs_dir2_sf_getdents(
-1
fs/xfs/xfs_discard.c
··· 20 20 #include "xfs_log_format.h" 21 21 #include "xfs_trans_resv.h" 22 22 #include "xfs_sb.h" 23 - #include "xfs_ag.h" 24 23 #include "xfs_mount.h" 25 24 #include "xfs_quota.h" 26 25 #include "xfs_inode.h"
-2
fs/xfs/xfs_dquot.c
··· 22 22 #include "xfs_shared.h" 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_bit.h" 25 - #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 25 #include "xfs_mount.h" 28 26 #include "xfs_inode.h" 29 27 #include "xfs_bmap.h"
-2
fs/xfs/xfs_dquot_item.c
··· 20 20 #include "xfs_format.h" 21 21 #include "xfs_log_format.h" 22 22 #include "xfs_trans_resv.h" 23 - #include "xfs_sb.h" 24 - #include "xfs_ag.h" 25 23 #include "xfs_mount.h" 26 24 #include "xfs_inode.h" 27 25 #include "xfs_quota.h"
-2
fs/xfs/xfs_error.c
··· 20 20 #include "xfs_fs.h" 21 21 #include "xfs_log_format.h" 22 22 #include "xfs_trans_resv.h" 23 - #include "xfs_sb.h" 24 - #include "xfs_ag.h" 25 23 #include "xfs_mount.h" 26 24 #include "xfs_error.h" 27 25
+1 -2
fs/xfs/xfs_export.c
··· 19 19 #include "xfs_format.h" 20 20 #include "xfs_log_format.h" 21 21 #include "xfs_trans_resv.h" 22 - #include "xfs_sb.h" 23 - #include "xfs_ag.h" 24 22 #include "xfs_mount.h" 25 23 #include "xfs_da_format.h" 24 + #include "xfs_da_btree.h" 26 25 #include "xfs_dir2.h" 27 26 #include "xfs_export.h" 28 27 #include "xfs_inode.h"
-1
fs/xfs/xfs_extent_busy.c
··· 24 24 #include "xfs_shared.h" 25 25 #include "xfs_trans_resv.h" 26 26 #include "xfs_sb.h" 27 - #include "xfs_ag.h" 28 27 #include "xfs_mount.h" 29 28 #include "xfs_alloc.h" 30 29 #include "xfs_extent_busy.h"
+1 -2
fs/xfs/xfs_extfree_item.c
··· 17 17 */ 18 18 #include "xfs.h" 19 19 #include "xfs_fs.h" 20 + #include "xfs_format.h" 20 21 #include "xfs_log_format.h" 21 22 #include "xfs_trans_resv.h" 22 - #include "xfs_sb.h" 23 - #include "xfs_ag.h" 24 23 #include "xfs_mount.h" 25 24 #include "xfs_trans.h" 26 25 #include "xfs_trans_priv.h"
+1 -8
fs/xfs/xfs_file.c
··· 21 21 #include "xfs_format.h" 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 24 #include "xfs_mount.h" 27 25 #include "xfs_da_format.h" 28 26 #include "xfs_da_btree.h" ··· 35 37 #include "xfs_ioctl.h" 36 38 #include "xfs_trace.h" 37 39 #include "xfs_log.h" 38 - #include "xfs_dinode.h" 39 40 #include "xfs_icache.h" 40 41 41 42 #include <linux/aio.h> ··· 930 933 { 931 934 struct inode *inode = file_inode(file); 932 935 xfs_inode_t *ip = XFS_I(inode); 933 - int error; 934 936 size_t bufsize; 935 937 936 938 /* ··· 946 950 */ 947 951 bufsize = (size_t)min_t(loff_t, 32768, ip->i_d.di_size); 948 952 949 - error = xfs_readdir(ip, ctx, bufsize); 950 - if (error) 951 - return error; 952 - return 0; 953 + return xfs_readdir(ip, ctx, bufsize); 953 954 } 954 955 955 956 STATIC int
-3
fs/xfs/xfs_filestream.c
··· 20 20 #include "xfs_format.h" 21 21 #include "xfs_log_format.h" 22 22 #include "xfs_trans_resv.h" 23 - #include "xfs_ag.h" 24 23 #include "xfs_sb.h" 25 24 #include "xfs_mount.h" 26 - #include "xfs_inum.h" 27 25 #include "xfs_inode.h" 28 26 #include "xfs_bmap.h" 29 27 #include "xfs_bmap_util.h" 30 28 #include "xfs_alloc.h" 31 29 #include "xfs_mru_cache.h" 32 - #include "xfs_dinode.h" 33 30 #include "xfs_filestream.h" 34 31 #include "xfs_trace.h" 35 32
-2
fs/xfs/xfs_fsops.c
··· 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 25 #include "xfs_mount.h" 27 26 #include "xfs_da_format.h" 28 27 #include "xfs_da_btree.h" ··· 39 40 #include "xfs_rtalloc.h" 40 41 #include "xfs_trace.h" 41 42 #include "xfs_log.h" 42 - #include "xfs_dinode.h" 43 43 #include "xfs_filestream.h" 44 44 45 45 /*
+2 -2
fs/xfs/xfs_icache.c
··· 20 20 #include "xfs_format.h" 21 21 #include "xfs_log_format.h" 22 22 #include "xfs_trans_resv.h" 23 - #include "xfs_inum.h" 24 23 #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 24 #include "xfs_mount.h" 27 25 #include "xfs_inode.h" 28 26 #include "xfs_error.h" ··· 63 65 return NULL; 64 66 } 65 67 68 + XFS_STATS_INC(vn_active); 66 69 ASSERT(atomic_read(&ip->i_pincount) == 0); 67 70 ASSERT(!spin_is_locked(&ip->i_flags_lock)); 68 71 ASSERT(!xfs_isiflocked(ip)); ··· 129 130 /* asserts to verify all state is correct here */ 130 131 ASSERT(atomic_read(&ip->i_pincount) == 0); 131 132 ASSERT(!xfs_isiflocked(ip)); 133 + XFS_STATS_DEC(vn_active); 132 134 133 135 call_rcu(&VFS_I(ip)->i_rcu, xfs_inode_free_callback); 134 136 }
+8
fs/xfs/xfs_icache.h
··· 34 34 #define SYNC_TRYLOCK 0x0002 /* only try to lock inodes */ 35 35 36 36 /* 37 + * tags for inode radix tree 38 + */ 39 + #define XFS_ICI_NO_TAG (-1) /* special flag for an untagged lookup 40 + in xfs_inode_ag_iterator */ 41 + #define XFS_ICI_RECLAIM_TAG 0 /* inode is to be reclaimed */ 42 + #define XFS_ICI_EOFBLOCKS_TAG 1 /* inode has blocks beyond EOF */ 43 + 44 + /* 37 45 * Flags for xfs_iget() 38 46 */ 39 47 #define XFS_IGET_CREATE 0x1
+1 -2
fs/xfs/xfs_icreate_item.c
··· 18 18 #include "xfs.h" 19 19 #include "xfs_fs.h" 20 20 #include "xfs_shared.h" 21 + #include "xfs_format.h" 21 22 #include "xfs_log_format.h" 22 23 #include "xfs_trans_resv.h" 23 24 #include "xfs_bit.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 25 #include "xfs_mount.h" 27 26 #include "xfs_trans.h" 28 27 #include "xfs_trans_priv.h"
+8 -21
fs/xfs/xfs_inode.c
··· 23 23 #include "xfs_format.h" 24 24 #include "xfs_log_format.h" 25 25 #include "xfs_trans_resv.h" 26 - #include "xfs_inum.h" 27 26 #include "xfs_sb.h" 28 - #include "xfs_ag.h" 29 27 #include "xfs_mount.h" 30 28 #include "xfs_inode.h" 31 29 #include "xfs_da_format.h" ··· 1080 1082 struct xfs_dquot *udqp = NULL; 1081 1083 struct xfs_dquot *gdqp = NULL; 1082 1084 struct xfs_dquot *pdqp = NULL; 1083 - struct xfs_trans_res tres; 1085 + struct xfs_trans_res *tres; 1084 1086 uint resblks; 1085 1087 1086 1088 trace_xfs_create(dp, name); ··· 1103 1105 if (is_dir) { 1104 1106 rdev = 0; 1105 1107 resblks = XFS_MKDIR_SPACE_RES(mp, name->len); 1106 - tres.tr_logres = M_RES(mp)->tr_mkdir.tr_logres; 1107 - tres.tr_logcount = XFS_MKDIR_LOG_COUNT; 1108 + tres = &M_RES(mp)->tr_mkdir; 1108 1109 tp = xfs_trans_alloc(mp, XFS_TRANS_MKDIR); 1109 1110 } else { 1110 1111 resblks = XFS_CREATE_SPACE_RES(mp, name->len); 1111 - tres.tr_logres = M_RES(mp)->tr_create.tr_logres; 1112 - tres.tr_logcount = XFS_CREATE_LOG_COUNT; 1112 + tres = &M_RES(mp)->tr_create; 1113 1113 tp = xfs_trans_alloc(mp, XFS_TRANS_CREATE); 1114 1114 } 1115 1115 ··· 1119 1123 * the case we'll drop the one we have and get a more 1120 1124 * appropriate transaction later. 1121 1125 */ 1122 - tres.tr_logflags = XFS_TRANS_PERM_LOG_RES; 1123 - error = xfs_trans_reserve(tp, &tres, resblks, 0); 1126 + error = xfs_trans_reserve(tp, tres, resblks, 0); 1124 1127 if (error == -ENOSPC) { 1125 1128 /* flush outstanding delalloc blocks and retry */ 1126 1129 xfs_flush_inodes(mp); 1127 - error = xfs_trans_reserve(tp, &tres, resblks, 0); 1130 + error = xfs_trans_reserve(tp, tres, resblks, 0); 1128 1131 } 1129 1132 if (error == -ENOSPC) { 1130 1133 /* No space at all so try a "no-allocation" reservation */ 1131 1134 resblks = 0; 1132 - error = xfs_trans_reserve(tp, &tres, 0, 0); 1135 + error = xfs_trans_reserve(tp, tres, 0, 0); 1133 1136 } 1134 1137 if (error) { 1135 1138 cancel_flags = 0; ··· 2483 2488 xfs_fsblock_t first_block; 2484 2489 int cancel_flags; 2485 2490 int committed; 2486 - int link_zero; 2487 2491 uint resblks; 2488 - uint log_count; 2489 2492 2490 2493 trace_xfs_remove(dp, name); 2491 2494 ··· 2498 2505 if (error) 2499 2506 goto std_return; 2500 2507 2501 - if (is_dir) { 2508 + if (is_dir) 2502 2509 tp = xfs_trans_alloc(mp, XFS_TRANS_RMDIR); 2503 - log_count = XFS_DEFAULT_LOG_COUNT; 2504 - } else { 2510 + else 2505 2511 tp = xfs_trans_alloc(mp, XFS_TRANS_REMOVE); 2506 - log_count = XFS_REMOVE_LOG_COUNT; 2507 - } 2508 2512 cancel_flags = XFS_TRANS_RELEASE_LOG_RES; 2509 2513 2510 2514 /* ··· 2568 2578 error = xfs_droplink(tp, ip); 2569 2579 if (error) 2570 2580 goto out_trans_cancel; 2571 - 2572 - /* Determine if this is the last link while the inode is locked */ 2573 - link_zero = (ip->i_d.di_nlink == 0); 2574 2581 2575 2582 xfs_bmap_init(&free_list, &first_block); 2576 2583 error = xfs_dir_removename(tp, dp, name, ip->i_ino,
-2
fs/xfs/xfs_inode.h
··· 20 20 21 21 #include "xfs_inode_buf.h" 22 22 #include "xfs_inode_fork.h" 23 - #include "xfs_dinode.h" 24 23 25 24 /* 26 25 * Kernel only inode definitions ··· 322 323 #define XFS_INHERIT_GID(pip) \ 323 324 (((pip)->i_mount->m_flags & XFS_MOUNT_GRPID) || \ 324 325 ((pip)->i_d.di_mode & S_ISGID)) 325 - 326 326 327 327 int xfs_release(struct xfs_inode *ip); 328 328 void xfs_inactive(struct xfs_inode *ip);
-3
fs/xfs/xfs_inode_item.c
··· 20 20 #include "xfs_format.h" 21 21 #include "xfs_log_format.h" 22 22 #include "xfs_trans_resv.h" 23 - #include "xfs_sb.h" 24 - #include "xfs_ag.h" 25 23 #include "xfs_mount.h" 26 24 #include "xfs_inode.h" 27 25 #include "xfs_trans.h" ··· 27 29 #include "xfs_error.h" 28 30 #include "xfs_trace.h" 29 31 #include "xfs_trans_priv.h" 30 - #include "xfs_dinode.h" 31 32 #include "xfs_log.h" 32 33 33 34
-3
fs/xfs/xfs_ioctl.c
··· 21 21 #include "xfs_format.h" 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 24 #include "xfs_mount.h" 27 25 #include "xfs_inode.h" 28 26 #include "xfs_ioctl.h" ··· 38 40 #include "xfs_trace.h" 39 41 #include "xfs_icache.h" 40 42 #include "xfs_symlink.h" 41 - #include "xfs_dinode.h" 42 43 #include "xfs_trans.h" 43 44 44 45 #include <linux/capability.h>
-2
fs/xfs/xfs_ioctl32.c
··· 25 25 #include "xfs_format.h" 26 26 #include "xfs_log_format.h" 27 27 #include "xfs_trans_resv.h" 28 - #include "xfs_sb.h" 29 - #include "xfs_ag.h" 30 28 #include "xfs_mount.h" 31 29 #include "xfs_inode.h" 32 30 #include "xfs_itable.h"
+6 -12
fs/xfs/xfs_iomap.c
··· 21 21 #include "xfs_format.h" 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 24 #include "xfs_mount.h" 27 25 #include "xfs_inode.h" 28 26 #include "xfs_btree.h" ··· 36 38 #include "xfs_quota.h" 37 39 #include "xfs_dquot_item.h" 38 40 #include "xfs_dquot.h" 39 - #include "xfs_dinode.h" 40 41 41 42 42 43 #define XFS_WRITEIO_ALIGN(mp,off) (((off) >> mp->m_writeio_log) \ ··· 49 52 xfs_extlen_t extsize, 50 53 xfs_fileoff_t *last_fsb) 51 54 { 52 - xfs_fileoff_t new_last_fsb = 0; 53 55 xfs_extlen_t align = 0; 54 56 int eof, error; 55 57 ··· 66 70 else if (mp->m_dalign) 67 71 align = mp->m_dalign; 68 72 69 - if (align && XFS_ISIZE(ip) >= XFS_FSB_TO_B(mp, align)) 70 - new_last_fsb = roundup_64(*last_fsb, align); 73 + if (align && XFS_ISIZE(ip) < XFS_FSB_TO_B(mp, align)) 74 + align = 0; 71 75 } 72 76 73 77 /* ··· 75 79 * (when file on a real-time subvolume or has di_extsize hint). 76 80 */ 77 81 if (extsize) { 78 - if (new_last_fsb) 79 - align = roundup_64(new_last_fsb, extsize); 82 + if (align) 83 + align = roundup_64(align, extsize); 80 84 else 81 85 align = extsize; 82 - new_last_fsb = roundup_64(*last_fsb, align); 83 86 } 84 87 85 - if (new_last_fsb) { 88 + if (align) { 89 + xfs_fileoff_t new_last_fsb = roundup_64(*last_fsb, align); 86 90 error = xfs_bmap_eof(ip, new_last_fsb, XFS_DATA_FORK, &eof); 87 91 if (error) 88 92 return error; ··· 260 264 { 261 265 xfs_fileoff_t start_fsb; 262 266 xfs_filblks_t count_fsb; 263 - xfs_fsblock_t firstblock; 264 267 int n, error, imaps; 265 268 int found_delalloc = 0; 266 269 ··· 284 289 count_fsb = XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes); 285 290 while (count_fsb > 0) { 286 291 imaps = nimaps; 287 - firstblock = NULLFSBLOCK; 288 292 error = xfs_bmapi_read(ip, start_fsb, count_fsb, imap, &imaps, 289 293 0); 290 294 if (error)
+1 -4
fs/xfs/xfs_iops.c
··· 21 21 #include "xfs_format.h" 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 24 #include "xfs_mount.h" 27 25 #include "xfs_da_format.h" 28 26 #include "xfs_inode.h" ··· 35 37 #include "xfs_icache.h" 36 38 #include "xfs_symlink.h" 37 39 #include "xfs_da_btree.h" 38 - #include "xfs_dir2_priv.h" 39 - #include "xfs_dinode.h" 40 + #include "xfs_dir2.h" 40 41 #include "xfs_trans_space.h" 41 42 42 43 #include <linux/capability.h>
-6
fs/xfs/xfs_itable.c
··· 21 21 #include "xfs_format.h" 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 - #include "xfs_inum.h" 25 - #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 24 #include "xfs_mount.h" 28 25 #include "xfs_inode.h" 29 26 #include "xfs_btree.h" ··· 30 33 #include "xfs_error.h" 31 34 #include "xfs_trace.h" 32 35 #include "xfs_icache.h" 33 - #include "xfs_dinode.h" 34 36 35 37 STATIC int 36 38 xfs_internal_inum( ··· 348 352 int *done) /* 1 if there are more stats to get */ 349 353 { 350 354 xfs_buf_t *agbp; /* agi header buffer */ 351 - xfs_agi_t *agi; /* agi header data */ 352 355 xfs_agino_t agino; /* inode # in allocation group */ 353 356 xfs_agnumber_t agno; /* allocation group number */ 354 357 xfs_btree_cur_t *cur; /* btree cursor for ialloc btree */ ··· 398 403 error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp); 399 404 if (error) 400 405 break; 401 - agi = XFS_BUF_TO_AGI(agbp); 402 406 /* 403 407 * Allocate and initialize a btree cursor for ialloc btree. 404 408 */
+6
fs/xfs/xfs_linux.h
··· 384 384 #endif /* XFS_WARN */ 385 385 #endif /* DEBUG */ 386 386 387 + #ifdef CONFIG_XFS_RT 388 + #define XFS_IS_REALTIME_INODE(ip) ((ip)->i_d.di_flags & XFS_DIFLAG_REALTIME) 389 + #else 390 + #define XFS_IS_REALTIME_INODE(ip) (0) 391 + #endif 392 + 387 393 #endif /* __XFS_LINUX__ */
+5 -3
fs/xfs/xfs_log.c
··· 21 21 #include "xfs_format.h" 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 24 #include "xfs_mount.h" 27 25 #include "xfs_error.h" 28 26 #include "xfs_trans.h" ··· 1029 1031 struct xlog *log = mp->m_log; 1030 1032 int needed = 0; 1031 1033 1032 - if (!xfs_fs_writable(mp)) 1034 + if (!xfs_fs_writable(mp, SB_FREEZE_WRITE)) 1033 1035 return 0; 1034 1036 1035 1037 if (!xlog_cil_empty(log)) ··· 1806 1808 XFS_BUF_ZEROFLAGS(bp); 1807 1809 XFS_BUF_ASYNC(bp); 1808 1810 bp->b_flags |= XBF_SYNCIO; 1811 + /* use high priority completion wq */ 1812 + bp->b_ioend_wq = log->l_mp->m_log_workqueue; 1809 1813 1810 1814 if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) { 1811 1815 bp->b_flags |= XBF_FUA; ··· 1856 1856 bp->b_flags |= XBF_SYNCIO; 1857 1857 if (log->l_mp->m_flags & XFS_MOUNT_BARRIER) 1858 1858 bp->b_flags |= XBF_FUA; 1859 + /* use high priority completion wq */ 1860 + bp->b_ioend_wq = log->l_mp->m_log_workqueue; 1859 1861 1860 1862 ASSERT(XFS_BUF_ADDR(bp) <= log->l_logBBsize-1); 1861 1863 ASSERT(XFS_BUF_ADDR(bp) + BTOBB(count) <= log->l_logBBsize);
+1 -2
fs/xfs/xfs_log_cil.c
··· 17 17 18 18 #include "xfs.h" 19 19 #include "xfs_fs.h" 20 + #include "xfs_format.h" 20 21 #include "xfs_log_format.h" 21 22 #include "xfs_shared.h" 22 23 #include "xfs_trans_resv.h" 23 - #include "xfs_sb.h" 24 - #include "xfs_ag.h" 25 24 #include "xfs_mount.h" 26 25 #include "xfs_error.h" 27 26 #include "xfs_alloc.h"
+1 -3
fs/xfs/xfs_log_recover.c
··· 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_bit.h" 25 - #include "xfs_inum.h" 26 25 #include "xfs_sb.h" 27 - #include "xfs_ag.h" 28 26 #include "xfs_mount.h" 29 27 #include "xfs_da_format.h" 28 + #include "xfs_da_btree.h" 30 29 #include "xfs_inode.h" 31 30 #include "xfs_trans.h" 32 31 #include "xfs_log.h" ··· 41 42 #include "xfs_trace.h" 42 43 #include "xfs_icache.h" 43 44 #include "xfs_bmap_btree.h" 44 - #include "xfs_dinode.h" 45 45 #include "xfs_error.h" 46 46 #include "xfs_dir2.h" 47 47
+1 -2
fs/xfs/xfs_message.c
··· 17 17 18 18 #include "xfs.h" 19 19 #include "xfs_fs.h" 20 + #include "xfs_format.h" 20 21 #include "xfs_log_format.h" 21 22 #include "xfs_trans_resv.h" 22 - #include "xfs_sb.h" 23 - #include "xfs_ag.h" 24 23 #include "xfs_mount.h" 25 24 26 25 /*
+22 -11
fs/xfs/xfs_mount.c
··· 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_bit.h" 25 - #include "xfs_inum.h" 26 25 #include "xfs_sb.h" 27 - #include "xfs_ag.h" 28 26 #include "xfs_mount.h" 29 27 #include "xfs_da_format.h" 28 + #include "xfs_da_btree.h" 30 29 #include "xfs_inode.h" 31 30 #include "xfs_dir2.h" 32 31 #include "xfs_ialloc.h" ··· 40 41 #include "xfs_fsops.h" 41 42 #include "xfs_trace.h" 42 43 #include "xfs_icache.h" 43 - #include "xfs_dinode.h" 44 44 #include "xfs_sysfs.h" 45 45 46 46 ··· 1072 1074 xfs_sysfs_del(&mp->m_kobj); 1073 1075 } 1074 1076 1075 - int 1076 - xfs_fs_writable(xfs_mount_t *mp) 1077 + /* 1078 + * Determine whether modifications can proceed. The caller specifies the minimum 1079 + * freeze level for which modifications should not be allowed. This allows 1080 + * certain operations to proceed while the freeze sequence is in progress, if 1081 + * necessary. 1082 + */ 1083 + bool 1084 + xfs_fs_writable( 1085 + struct xfs_mount *mp, 1086 + int level) 1077 1087 { 1078 - return !(mp->m_super->s_writers.frozen || XFS_FORCED_SHUTDOWN(mp) || 1079 - (mp->m_flags & XFS_MOUNT_RDONLY)); 1088 + ASSERT(level > SB_UNFROZEN); 1089 + if ((mp->m_super->s_writers.frozen >= level) || 1090 + XFS_FORCED_SHUTDOWN(mp) || (mp->m_flags & XFS_MOUNT_RDONLY)) 1091 + return false; 1092 + 1093 + return true; 1080 1094 } 1081 1095 1082 1096 /* ··· 1096 1086 * 1097 1087 * Sync the superblock counters to disk. 1098 1088 * 1099 - * Note this code can be called during the process of freezing, so 1100 - * we may need to use the transaction allocator which does not 1101 - * block when the transaction subsystem is in its frozen state. 1089 + * Note this code can be called during the process of freezing, so we use the 1090 + * transaction allocator that does not block when the transaction subsystem is 1091 + * in its frozen state. 1102 1092 */ 1103 1093 int 1104 1094 xfs_log_sbcount(xfs_mount_t *mp) ··· 1106 1096 xfs_trans_t *tp; 1107 1097 int error; 1108 1098 1109 - if (!xfs_fs_writable(mp)) 1099 + /* allow this to proceed during the freeze sequence... */ 1100 + if (!xfs_fs_writable(mp, SB_FREEZE_COMPLETE)) 1110 1101 return 0; 1111 1102 1112 1103 xfs_icsb_sync_counters(mp, 0);
+3 -5
fs/xfs/xfs_mount.h
··· 168 168 /* low free space thresholds */ 169 169 struct xfs_kobj m_kobj; 170 170 171 + struct workqueue_struct *m_buf_workqueue; 171 172 struct workqueue_struct *m_data_workqueue; 172 173 struct workqueue_struct *m_unwritten_workqueue; 173 174 struct workqueue_struct *m_cil_workqueue; ··· 321 320 322 321 /* 323 322 * Per-ag incore structure, copies of information in agf and agi, to improve the 324 - * performance of allocation group selection. This is defined for the kernel 325 - * only, and hence is defined here instead of in xfs_ag.h. You need the struct 326 - * xfs_mount to be defined to look up a xfs_perag anyway (via mp->m_perag_tree), 327 - * so this doesn't introduce any strange header file dependencies. 323 + * performance of allocation group selection. 328 324 */ 329 325 typedef struct xfs_perag { 330 326 struct xfs_mount *pag_mount; /* owner filesystem */ ··· 382 384 extern struct xfs_buf *xfs_getsb(xfs_mount_t *, int); 383 385 extern int xfs_readsb(xfs_mount_t *, int); 384 386 extern void xfs_freesb(xfs_mount_t *); 385 - extern int xfs_fs_writable(xfs_mount_t *); 387 + extern bool xfs_fs_writable(struct xfs_mount *mp, int level); 386 388 extern int xfs_sb_validate_fsb_count(struct xfs_sb *, __uint64_t); 387 389 388 390 extern int xfs_dev_is_read_only(struct xfs_mount *, char *);
+5 -9
fs/xfs/xfs_qm.c
··· 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_bit.h" 25 25 #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 26 #include "xfs_mount.h" 28 27 #include "xfs_inode.h" 29 28 #include "xfs_ialloc.h" ··· 37 38 #include "xfs_trace.h" 38 39 #include "xfs_icache.h" 39 40 #include "xfs_cksum.h" 40 - #include "xfs_dinode.h" 41 41 42 42 /* 43 43 * The global quota manager. There is only one of these for the entire ··· 1747 1749 xfs_iunlock(ip, lockflags); 1748 1750 if (O_udqpp) 1749 1751 *O_udqpp = uq; 1750 - else if (uq) 1752 + else 1751 1753 xfs_qm_dqrele(uq); 1752 1754 if (O_gdqpp) 1753 1755 *O_gdqpp = gq; 1754 - else if (gq) 1756 + else 1755 1757 xfs_qm_dqrele(gq); 1756 1758 if (O_pdqpp) 1757 1759 *O_pdqpp = pq; 1758 - else if (pq) 1760 + else 1759 1761 xfs_qm_dqrele(pq); 1760 1762 return 0; 1761 1763 1762 1764 error_rele: 1763 - if (gq) 1764 - xfs_qm_dqrele(gq); 1765 - if (uq) 1766 - xfs_qm_dqrele(uq); 1765 + xfs_qm_dqrele(gq); 1766 + xfs_qm_dqrele(uq); 1767 1767 return error; 1768 1768 } 1769 1769
-2
fs/xfs/xfs_qm_bhv.c
··· 20 20 #include "xfs_format.h" 21 21 #include "xfs_log_format.h" 22 22 #include "xfs_trans_resv.h" 23 - #include "xfs_sb.h" 24 - #include "xfs_ag.h" 25 23 #include "xfs_quota.h" 26 24 #include "xfs_mount.h" 27 25 #include "xfs_inode.h"
+10 -17
fs/xfs/xfs_qm_syscalls.c
··· 26 26 #include "xfs_trans_resv.h" 27 27 #include "xfs_bit.h" 28 28 #include "xfs_sb.h" 29 - #include "xfs_ag.h" 30 29 #include "xfs_mount.h" 31 30 #include "xfs_inode.h" 32 31 #include "xfs_trans.h" ··· 783 784 { 784 785 xfs_trans_t *tp; 785 786 int error; 786 - xfs_qoff_logitem_t *qoffi=NULL; 787 - uint oldsbqflag=0; 787 + xfs_qoff_logitem_t *qoffi; 788 + 789 + *qoffstartp = NULL; 788 790 789 791 tp = xfs_trans_alloc(mp, XFS_TRANS_QM_QUOTAOFF); 790 792 error = xfs_trans_reserve(tp, &M_RES(mp)->tr_qm_quotaoff, 0, 0); 791 - if (error) 792 - goto error0; 793 + if (error) { 794 + xfs_trans_cancel(tp, 0); 795 + goto out; 796 + } 793 797 794 798 qoffi = xfs_trans_get_qoff_item(tp, NULL, flags & XFS_ALL_QUOTA_ACCT); 795 799 xfs_trans_log_quotaoff_item(tp, qoffi); 796 800 797 801 spin_lock(&mp->m_sb_lock); 798 - oldsbqflag = mp->m_sb.sb_qflags; 799 802 mp->m_sb.sb_qflags = (mp->m_qflags & ~(flags)) & XFS_MOUNT_QUOTA_ALL; 800 803 spin_unlock(&mp->m_sb_lock); 801 804 ··· 810 809 */ 811 810 xfs_trans_set_sync(tp); 812 811 error = xfs_trans_commit(tp, 0); 812 + if (error) 813 + goto out; 813 814 814 - error0: 815 - if (error) { 816 - xfs_trans_cancel(tp, 0); 817 - /* 818 - * No one else is modifying sb_qflags, so this is OK. 819 - * We still hold the quotaofflock. 820 - */ 821 - spin_lock(&mp->m_sb_lock); 822 - mp->m_sb.sb_qflags = oldsbqflag; 823 - spin_unlock(&mp->m_sb_lock); 824 - } 825 815 *qoffstartp = qoffi; 816 + out: 826 817 return error; 827 818 } 828 819
-2
fs/xfs/xfs_quotaops.c
··· 19 19 #include "xfs_format.h" 20 20 #include "xfs_log_format.h" 21 21 #include "xfs_trans_resv.h" 22 - #include "xfs_sb.h" 23 - #include "xfs_ag.h" 24 22 #include "xfs_mount.h" 25 23 #include "xfs_inode.h" 26 24 #include "xfs_quota.h"
-3
fs/xfs/xfs_rtalloc.c
··· 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 24 #include "xfs_bit.h" 25 - #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 25 #include "xfs_mount.h" 28 26 #include "xfs_inode.h" 29 27 #include "xfs_bmap.h" ··· 34 36 #include "xfs_trace.h" 35 37 #include "xfs_buf.h" 36 38 #include "xfs_icache.h" 37 - #include "xfs_dinode.h" 38 39 #include "xfs_rtalloc.h" 39 40 40 41
+11 -8
fs/xfs/xfs_super.c
··· 21 21 #include "xfs_format.h" 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 - #include "xfs_inum.h" 25 24 #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 25 #include "xfs_mount.h" 28 26 #include "xfs_da_format.h" 29 27 #include "xfs_inode.h" ··· 42 44 #include "xfs_icache.h" 43 45 #include "xfs_trace.h" 44 46 #include "xfs_icreate_item.h" 45 - #include "xfs_dinode.h" 46 47 #include "xfs_filestream.h" 47 48 #include "xfs_quota.h" 48 49 #include "xfs_sysfs.h" ··· 793 796 out_free_ddev_targ: 794 797 xfs_free_buftarg(mp, mp->m_ddev_targp); 795 798 out_close_rtdev: 796 - if (rtdev) 797 - xfs_blkdev_put(rtdev); 799 + xfs_blkdev_put(rtdev); 798 800 out_close_logdev: 799 801 if (logdev && logdev != ddev) 800 802 xfs_blkdev_put(logdev); ··· 838 842 xfs_init_mount_workqueues( 839 843 struct xfs_mount *mp) 840 844 { 845 + mp->m_buf_workqueue = alloc_workqueue("xfs-buf/%s", 846 + WQ_MEM_RECLAIM|WQ_FREEZABLE, 1, mp->m_fsname); 847 + if (!mp->m_buf_workqueue) 848 + goto out; 849 + 841 850 mp->m_data_workqueue = alloc_workqueue("xfs-data/%s", 842 851 WQ_MEM_RECLAIM|WQ_FREEZABLE, 0, mp->m_fsname); 843 852 if (!mp->m_data_workqueue) 844 - goto out; 853 + goto out_destroy_buf; 845 854 846 855 mp->m_unwritten_workqueue = alloc_workqueue("xfs-conv/%s", 847 856 WQ_MEM_RECLAIM|WQ_FREEZABLE, 0, mp->m_fsname); ··· 864 863 goto out_destroy_cil; 865 864 866 865 mp->m_log_workqueue = alloc_workqueue("xfs-log/%s", 867 - WQ_FREEZABLE, 0, mp->m_fsname); 866 + WQ_FREEZABLE|WQ_HIGHPRI, 0, mp->m_fsname); 868 867 if (!mp->m_log_workqueue) 869 868 goto out_destroy_reclaim; 870 869 ··· 885 884 destroy_workqueue(mp->m_unwritten_workqueue); 886 885 out_destroy_data_iodone_queue: 887 886 destroy_workqueue(mp->m_data_workqueue); 887 + out_destroy_buf: 888 + destroy_workqueue(mp->m_buf_workqueue); 888 889 out: 889 890 return -ENOMEM; 890 891 } ··· 901 898 destroy_workqueue(mp->m_cil_workqueue); 902 899 destroy_workqueue(mp->m_data_workqueue); 903 900 destroy_workqueue(mp->m_unwritten_workqueue); 901 + destroy_workqueue(mp->m_buf_workqueue); 904 902 } 905 903 906 904 /* ··· 1004 1000 clear_inode(inode); 1005 1001 XFS_STATS_INC(vn_rele); 1006 1002 XFS_STATS_INC(vn_remove); 1007 - XFS_STATS_DEC(vn_active); 1008 1003 1009 1004 xfs_inactive(ip); 1010 1005 }
-3
fs/xfs/xfs_symlink.c
··· 23 23 #include "xfs_log_format.h" 24 24 #include "xfs_trans_resv.h" 25 25 #include "xfs_bit.h" 26 - #include "xfs_sb.h" 27 - #include "xfs_ag.h" 28 26 #include "xfs_mount.h" 29 27 #include "xfs_da_format.h" 30 28 #include "xfs_da_btree.h" ··· 40 42 #include "xfs_symlink.h" 41 43 #include "xfs_trans.h" 42 44 #include "xfs_log.h" 43 - #include "xfs_dinode.h" 44 45 45 46 /* ----- Kernel only functions below ----- */ 46 47 STATIC int
-2
fs/xfs/xfs_trace.c
··· 21 21 #include "xfs_format.h" 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 24 #include "xfs_mount.h" 27 25 #include "xfs_da_format.h" 28 26 #include "xfs_inode.h"
-2
fs/xfs/xfs_trans.c
··· 22 22 #include "xfs_format.h" 23 23 #include "xfs_log_format.h" 24 24 #include "xfs_trans_resv.h" 25 - #include "xfs_sb.h" 26 - #include "xfs_ag.h" 27 25 #include "xfs_mount.h" 28 26 #include "xfs_inode.h" 29 27 #include "xfs_extent_busy.h"
+1 -2
fs/xfs/xfs_trans_ail.c
··· 18 18 */ 19 19 #include "xfs.h" 20 20 #include "xfs_fs.h" 21 + #include "xfs_format.h" 21 22 #include "xfs_log_format.h" 22 23 #include "xfs_trans_resv.h" 23 - #include "xfs_sb.h" 24 - #include "xfs_ag.h" 25 24 #include "xfs_mount.h" 26 25 #include "xfs_trans.h" 27 26 #include "xfs_trans_priv.h"
+32 -103
fs/xfs/xfs_trans_buf.c
··· 21 21 #include "xfs_format.h" 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 24 #include "xfs_mount.h" 27 25 #include "xfs_inode.h" 28 26 #include "xfs_trans.h" ··· 227 229 return bp; 228 230 } 229 231 230 - #ifdef DEBUG 231 - xfs_buftarg_t *xfs_error_target; 232 - int xfs_do_error; 233 - int xfs_req_num; 234 - int xfs_error_mod = 33; 235 - #endif 236 - 237 232 /* 238 233 * Get and lock the buffer for the caller if it is not already 239 234 * locked within the given transaction. If it has not yet been ··· 248 257 struct xfs_buf **bpp, 249 258 const struct xfs_buf_ops *ops) 250 259 { 251 - xfs_buf_t *bp; 252 - xfs_buf_log_item_t *bip; 260 + struct xfs_buf *bp = NULL; 261 + struct xfs_buf_log_item *bip; 253 262 int error; 254 263 255 264 *bpp = NULL; 256 - if (!tp) { 257 - bp = xfs_buf_read_map(target, map, nmaps, flags, ops); 258 - if (!bp) 259 - return (flags & XBF_TRYLOCK) ? 260 - -EAGAIN : -ENOMEM; 261 - 262 - if (bp->b_error) { 263 - error = bp->b_error; 264 - xfs_buf_ioerror_alert(bp, __func__); 265 - XFS_BUF_UNDONE(bp); 266 - xfs_buf_stale(bp); 267 - xfs_buf_relse(bp); 268 - 269 - /* bad CRC means corrupted metadata */ 270 - if (error == -EFSBADCRC) 271 - error = -EFSCORRUPTED; 272 - return error; 273 - } 274 - #ifdef DEBUG 275 - if (xfs_do_error) { 276 - if (xfs_error_target == target) { 277 - if (((xfs_req_num++) % xfs_error_mod) == 0) { 278 - xfs_buf_relse(bp); 279 - xfs_debug(mp, "Returning error!"); 280 - return -EIO; 281 - } 282 - } 283 - } 284 - #endif 285 - if (XFS_FORCED_SHUTDOWN(mp)) 286 - goto shutdown_abort; 287 - *bpp = bp; 288 - return 0; 289 - } 290 - 291 265 /* 292 266 * If we find the buffer in the cache with this transaction 293 267 * pointer in its b_fsprivate2 field, then we know we already ··· 261 305 * If the buffer is not yet read in, then we read it in, increment 262 306 * the lock recursion count, and return it to the caller. 263 307 */ 264 - bp = xfs_trans_buf_item_match(tp, target, map, nmaps); 265 - if (bp != NULL) { 308 + if (tp) 309 + bp = xfs_trans_buf_item_match(tp, target, map, nmaps); 310 + if (bp) { 266 311 ASSERT(xfs_buf_islocked(bp)); 267 312 ASSERT(bp->b_transp == tp); 268 313 ASSERT(bp->b_fspriv != NULL); 269 314 ASSERT(!bp->b_error); 270 - if (!(XFS_BUF_ISDONE(bp))) { 271 - trace_xfs_trans_read_buf_io(bp, _RET_IP_); 272 - ASSERT(!XFS_BUF_ISASYNC(bp)); 273 - ASSERT(bp->b_iodone == NULL); 274 - XFS_BUF_READ(bp); 275 - bp->b_ops = ops; 315 + ASSERT(bp->b_flags & XBF_DONE); 276 316 277 - error = xfs_buf_submit_wait(bp); 278 - if (error) { 279 - if (!XFS_FORCED_SHUTDOWN(mp)) 280 - xfs_buf_ioerror_alert(bp, __func__); 281 - xfs_buf_relse(bp); 282 - /* 283 - * We can gracefully recover from most read 284 - * errors. Ones we can't are those that happen 285 - * after the transaction's already dirty. 286 - */ 287 - if (tp->t_flags & XFS_TRANS_DIRTY) 288 - xfs_force_shutdown(tp->t_mountp, 289 - SHUTDOWN_META_IO_ERROR); 290 - /* bad CRC means corrupted metadata */ 291 - if (error == -EFSBADCRC) 292 - error = -EFSCORRUPTED; 293 - return error; 294 - } 295 - } 296 317 /* 297 318 * We never locked this buf ourselves, so we shouldn't 298 319 * brelse it either. Just get out. 299 320 */ 300 321 if (XFS_FORCED_SHUTDOWN(mp)) { 301 322 trace_xfs_trans_read_buf_shut(bp, _RET_IP_); 302 - *bpp = NULL; 303 323 return -EIO; 304 324 } 305 - 306 325 307 326 bip = bp->b_fspriv; 308 327 bip->bli_recur++; ··· 289 358 } 290 359 291 360 bp = xfs_buf_read_map(target, map, nmaps, flags, ops); 292 - if (bp == NULL) { 293 - *bpp = NULL; 294 - return (flags & XBF_TRYLOCK) ? 295 - 0 : -ENOMEM; 361 + if (!bp) { 362 + if (!(flags & XBF_TRYLOCK)) 363 + return -ENOMEM; 364 + return tp ? 0 : -EAGAIN; 296 365 } 366 + 367 + /* 368 + * If we've had a read error, then the contents of the buffer are 369 + * invalid and should not be used. To ensure that a followup read tries 370 + * to pull the buffer from disk again, we clear the XBF_DONE flag and 371 + * mark the buffer stale. This ensures that anyone who has a current 372 + * reference to the buffer will interpret it's contents correctly and 373 + * future cache lookups will also treat it as an empty, uninitialised 374 + * buffer. 375 + */ 297 376 if (bp->b_error) { 298 377 error = bp->b_error; 378 + if (!XFS_FORCED_SHUTDOWN(mp)) 379 + xfs_buf_ioerror_alert(bp, __func__); 380 + bp->b_flags &= ~XBF_DONE; 299 381 xfs_buf_stale(bp); 300 - XFS_BUF_DONE(bp); 301 - xfs_buf_ioerror_alert(bp, __func__); 302 - if (tp->t_flags & XFS_TRANS_DIRTY) 382 + 383 + if (tp && (tp->t_flags & XFS_TRANS_DIRTY)) 303 384 xfs_force_shutdown(tp->t_mountp, SHUTDOWN_META_IO_ERROR); 304 385 xfs_buf_relse(bp); 305 386 ··· 320 377 error = -EFSCORRUPTED; 321 378 return error; 322 379 } 323 - #ifdef DEBUG 324 - if (xfs_do_error && !(tp->t_flags & XFS_TRANS_DIRTY)) { 325 - if (xfs_error_target == target) { 326 - if (((xfs_req_num++) % xfs_error_mod) == 0) { 327 - xfs_force_shutdown(tp->t_mountp, 328 - SHUTDOWN_META_IO_ERROR); 329 - xfs_buf_relse(bp); 330 - xfs_debug(mp, "Returning trans error!"); 331 - return -EIO; 332 - } 333 - } 380 + 381 + if (XFS_FORCED_SHUTDOWN(mp)) { 382 + xfs_buf_relse(bp); 383 + trace_xfs_trans_read_buf_shut(bp, _RET_IP_); 384 + return -EIO; 334 385 } 335 - #endif 336 - if (XFS_FORCED_SHUTDOWN(mp)) 337 - goto shutdown_abort; 338 386 339 - _xfs_trans_bjoin(tp, bp, 1); 387 + if (tp) 388 + _xfs_trans_bjoin(tp, bp, 1); 340 389 trace_xfs_trans_read_buf(bp->b_fspriv); 341 - 342 390 *bpp = bp; 343 391 return 0; 344 392 345 - shutdown_abort: 346 - trace_xfs_trans_read_buf_shut(bp, _RET_IP_); 347 - xfs_buf_relse(bp); 348 - *bpp = NULL; 349 - return -EIO; 350 393 } 351 394 352 395 /*
-2
fs/xfs/xfs_trans_dquot.c
··· 21 21 #include "xfs_format.h" 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 24 #include "xfs_mount.h" 27 25 #include "xfs_inode.h" 28 26 #include "xfs_error.h"
+1 -2
fs/xfs/xfs_trans_extfree.c
··· 18 18 #include "xfs.h" 19 19 #include "xfs_fs.h" 20 20 #include "xfs_shared.h" 21 + #include "xfs_format.h" 21 22 #include "xfs_log_format.h" 22 23 #include "xfs_trans_resv.h" 23 - #include "xfs_sb.h" 24 - #include "xfs_ag.h" 25 24 #include "xfs_mount.h" 26 25 #include "xfs_trans.h" 27 26 #include "xfs_trans_priv.h"
-2
fs/xfs/xfs_trans_inode.c
··· 21 21 #include "xfs_format.h" 22 22 #include "xfs_log_format.h" 23 23 #include "xfs_trans_resv.h" 24 - #include "xfs_sb.h" 25 - #include "xfs_ag.h" 26 24 #include "xfs_mount.h" 27 25 #include "xfs_inode.h" 28 26 #include "xfs_trans.h"
-2
fs/xfs/xfs_xattr.c
··· 20 20 #include "xfs_format.h" 21 21 #include "xfs_log_format.h" 22 22 #include "xfs_trans_resv.h" 23 - #include "xfs_sb.h" 24 - #include "xfs_ag.h" 25 23 #include "xfs_mount.h" 26 24 #include "xfs_da_format.h" 27 25 #include "xfs_inode.h"