2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
3 * Copyright (c) 2013 Red Hat, Inc.
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation.
10 * This program is distributed in the hope that it would be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #ifndef __XFS_DA_FORMAT_H__
20 #define __XFS_DA_FORMAT_H__
22 /*========================================================================
23 * Directory Structure when greater than XFS_LBSIZE(mp) bytes.
24 *========================================================================*/
27 * This structure is common to both leaf nodes and non-leaf nodes in the Btree.
29 * It is used to manage a doubly linked list of all blocks at the same
30 * level in the Btree, and to identify which type of block this is.
32 #define XFS_DA_NODE_MAGIC 0xfebe /* magic number: non-leaf blocks */
33 #define XFS_ATTR_LEAF_MAGIC 0xfbee /* magic number: attribute leaf blks */
34 #define XFS_DIR2_LEAF1_MAGIC 0xd2f1 /* magic number: v2 dirlf single blks */
35 #define XFS_DIR2_LEAFN_MAGIC 0xd2ff /* magic number: v2 dirlf multi blks */
37 typedef struct xfs_da_blkinfo {
38 __be32 forw; /* previous block in list */
39 __be32 back; /* following block in list */
40 __be16 magic; /* validity check on block */
41 __be16 pad; /* unused */
45 * CRC enabled directory structure types
47 * The headers change size for the additional verification information, but
48 * otherwise the tree layouts and contents are unchanged. Hence the da btree
49 * code can use the struct xfs_da_blkinfo for manipulating the tree links and
50 * magic numbers without modification for both v2 and v3 nodes.
52 #define XFS_DA3_NODE_MAGIC 0x3ebe /* magic number: non-leaf blocks */
53 #define XFS_ATTR3_LEAF_MAGIC 0x3bee /* magic number: attribute leaf blks */
54 #define XFS_DIR3_LEAF1_MAGIC 0x3df1 /* magic number: v2 dirlf single blks */
55 #define XFS_DIR3_LEAFN_MAGIC 0x3dff /* magic number: v2 dirlf multi blks */
57 struct xfs_da3_blkinfo {
59 * the node link manipulation code relies on the fact that the first
60 * element of this structure is the struct xfs_da_blkinfo so it can
61 * ignore the differences in the rest of the structures.
63 struct xfs_da_blkinfo hdr;
64 __be32 crc; /* CRC of block */
65 __be64 blkno; /* first block of the buffer */
66 __be64 lsn; /* sequence number of last write */
67 uuid_t uuid; /* filesystem we belong to */
68 __be64 owner; /* inode that owns the block */
72 * This is the structure of the root and intermediate nodes in the Btree.
73 * The leaf nodes are defined above.
75 * Entries are not packed.
77 * Since we have duplicate keys, use a binary search but always follow
78 * all match in the block, not just the first match found.
80 #define XFS_DA_NODE_MAXDEPTH 5 /* max depth of Btree */
82 typedef struct xfs_da_node_hdr {
83 struct xfs_da_blkinfo info; /* block type, links, etc. */
84 __be16 __count; /* count of active entries */
85 __be16 __level; /* level above leaves (leaf == 0) */
88 struct xfs_da3_node_hdr {
89 struct xfs_da3_blkinfo info; /* block type, links, etc. */
90 __be16 __count; /* count of active entries */
91 __be16 __level; /* level above leaves (leaf == 0) */
95 #define XFS_DA3_NODE_CRC_OFF (offsetof(struct xfs_da3_node_hdr, info.crc))
97 typedef struct xfs_da_node_entry {
98 __be32 hashval; /* hash value for this descendant */
99 __be32 before; /* Btree block before this key */
100 } xfs_da_node_entry_t;
102 typedef struct xfs_da_intnode {
103 struct xfs_da_node_hdr hdr;
104 struct xfs_da_node_entry __btree[];
107 struct xfs_da3_intnode {
108 struct xfs_da3_node_hdr hdr;
109 struct xfs_da_node_entry __btree[];
113 * In-core version of the node header to abstract the differences in the v2 and
114 * v3 disk format of the headers. Callers need to convert to/from disk format as
117 struct xfs_da3_icnode_hdr {
125 extern void xfs_da3_node_hdr_from_disk(struct xfs_da3_icnode_hdr *to,
126 struct xfs_da_intnode *from);
127 extern void xfs_da3_node_hdr_to_disk(struct xfs_da_intnode *to,
128 struct xfs_da3_icnode_hdr *from);
131 __xfs_da3_node_hdr_size(bool v3)
134 return sizeof(struct xfs_da3_node_hdr);
135 return sizeof(struct xfs_da_node_hdr);
138 xfs_da3_node_hdr_size(struct xfs_da_intnode *dap)
140 bool v3 = dap->hdr.info.magic == cpu_to_be16(XFS_DA3_NODE_MAGIC);
142 return __xfs_da3_node_hdr_size(v3);
145 static inline struct xfs_da_node_entry *
146 xfs_da3_node_tree_p(struct xfs_da_intnode *dap)
148 if (dap->hdr.info.magic == cpu_to_be16(XFS_DA3_NODE_MAGIC)) {
149 struct xfs_da3_intnode *dap3 = (struct xfs_da3_intnode *)dap;
150 return dap3->__btree;
155 extern void xfs_da3_intnode_from_disk(struct xfs_da3_icnode_hdr *to,
156 struct xfs_da_intnode *from);
157 extern void xfs_da3_intnode_to_disk(struct xfs_da_intnode *to,
158 struct xfs_da3_icnode_hdr *from);
160 #define XFS_LBSIZE(mp) (mp)->m_sb.sb_blocksize
163 * Directory version 2.
165 * There are 4 possible formats:
166 * - shortform - embedded into the inode
167 * - single block - data with embedded leaf at the end
168 * - multiple data blocks, single leaf+freeindex block
169 * - data blocks, node and leaf blocks (btree), freeindex blocks
171 * Note: many node blocks structures and constants are shared with the attr
172 * code and defined in xfs_da_btree.h.
175 #define XFS_DIR2_BLOCK_MAGIC 0x58443242 /* XD2B: single block dirs */
176 #define XFS_DIR2_DATA_MAGIC 0x58443244 /* XD2D: multiblock dirs */
177 #define XFS_DIR2_FREE_MAGIC 0x58443246 /* XD2F: free index blocks */
180 * Directory Version 3 With CRCs.
182 * The tree formats are the same as for version 2 directories. The difference
183 * is in the block header and dirent formats. In many cases the v3 structures
184 * use v2 definitions as they are no different and this makes code sharing much
187 * Also, the xfs_dir3_*() functions handle both v2 and v3 formats - if the
188 * format is v2 then they switch to the existing v2 code, or the format is v3
189 * they implement the v3 functionality. This means the existing dir2 is a mix of
190 * xfs_dir2/xfs_dir3 calls and functions. The xfs_dir3 functions are called
191 * where there is a difference in the formats, otherwise the code is unchanged.
193 * Where it is possible, the code decides what to do based on the magic numbers
194 * in the blocks rather than feature bits in the superblock. This means the code
195 * is as independent of the external XFS code as possible as doesn't require
196 * passing struct xfs_mount pointers into places where it isn't really
199 * Version 3 includes:
201 * - a larger block header for CRC and identification purposes and so the
202 * offsets of all the structures inside the blocks are different.
204 * - new magic numbers to be able to detect the v2/v3 types on the fly.
207 #define XFS_DIR3_BLOCK_MAGIC 0x58444233 /* XDB3: single block dirs */
208 #define XFS_DIR3_DATA_MAGIC 0x58444433 /* XDD3: multiblock dirs */
209 #define XFS_DIR3_FREE_MAGIC 0x58444633 /* XDF3: free index blocks */
212 * Dirents in version 3 directories have a file type field. Additions to this
213 * list are an on-disk format change, requiring feature bits. Valid values
216 #define XFS_DIR3_FT_UNKNOWN 0
217 #define XFS_DIR3_FT_REG_FILE 1
218 #define XFS_DIR3_FT_DIR 2
219 #define XFS_DIR3_FT_CHRDEV 3
220 #define XFS_DIR3_FT_BLKDEV 4
221 #define XFS_DIR3_FT_FIFO 5
222 #define XFS_DIR3_FT_SOCK 6
223 #define XFS_DIR3_FT_SYMLINK 7
224 #define XFS_DIR3_FT_WHT 8
226 #define XFS_DIR3_FT_MAX 9
229 * Byte offset in data block and shortform entry.
231 typedef __uint16_t xfs_dir2_data_off_t;
232 #define NULLDATAOFF 0xffffU
233 typedef uint xfs_dir2_data_aoff_t; /* argument form */
236 * Normalized offset (in a data block) of the entry, really xfs_dir2_data_off_t.
237 * Only need 16 bits, this is the byte offset into the single block form.
239 typedef struct { __uint8_t i[2]; } __arch_pack xfs_dir2_sf_off_t;
242 * Offset in data space of a data entry.
244 typedef __uint32_t xfs_dir2_dataptr_t;
245 #define XFS_DIR2_MAX_DATAPTR ((xfs_dir2_dataptr_t)0xffffffff)
246 #define XFS_DIR2_NULL_DATAPTR ((xfs_dir2_dataptr_t)0)
249 * Byte offset in a directory.
251 typedef xfs_off_t xfs_dir2_off_t;
254 * Directory block number (logical dirblk in file)
256 typedef __uint32_t xfs_dir2_db_t;
259 * Inode number stored as 8 8-bit values.
261 typedef struct { __uint8_t i[8]; } xfs_dir2_ino8_t;
264 * Inode number stored as 4 8-bit values.
265 * Works a lot of the time, when all the inode numbers in a directory
268 typedef struct { __uint8_t i[4]; } xfs_dir2_ino4_t;
274 #define XFS_DIR2_MAX_SHORT_INUM ((xfs_ino_t)0xffffffffULL)
277 * Directory layout when stored internal to an inode.
279 * Small directories are packed as tightly as possible so as to fit into the
280 * literal area of the inode. These "shortform" directories consist of a
281 * single xfs_dir2_sf_hdr header followed by zero or more xfs_dir2_sf_entry
282 * structures. Due the different inode number storage size and the variable
283 * length name field in the xfs_dir2_sf_entry all these structure are
284 * variable length, and the accessors in this file should be used to iterate
287 typedef struct xfs_dir2_sf_hdr {
288 __uint8_t count; /* count of entries */
289 __uint8_t i8count; /* count of 8-byte inode #s */
290 xfs_dir2_inou_t parent; /* parent dir inode number */
291 } __arch_pack xfs_dir2_sf_hdr_t;
293 typedef struct xfs_dir2_sf_entry {
294 __u8 namelen; /* actual name length */
295 xfs_dir2_sf_off_t offset; /* saved offset */
296 __u8 name[]; /* name, variable size */
298 * A single byte containing the file type field follows the inode
299 * number for version 3 directory entries.
301 * A xfs_dir2_ino8_t or xfs_dir2_ino4_t follows here, at a
302 * variable offset after the name.
304 } __arch_pack xfs_dir2_sf_entry_t;
306 static inline int xfs_dir2_sf_hdr_size(int i8count)
308 return sizeof(struct xfs_dir2_sf_hdr) -
310 (sizeof(xfs_dir2_ino8_t) - sizeof(xfs_dir2_ino4_t));
313 static inline xfs_dir2_data_aoff_t
314 xfs_dir2_sf_get_offset(xfs_dir2_sf_entry_t *sfep)
316 return get_unaligned_be16(&sfep->offset.i);
320 xfs_dir2_sf_put_offset(xfs_dir2_sf_entry_t *sfep, xfs_dir2_data_aoff_t off)
322 put_unaligned_be16(off, &sfep->offset.i);
325 static inline struct xfs_dir2_sf_entry *
326 xfs_dir2_sf_firstentry(struct xfs_dir2_sf_hdr *hdr)
328 return (struct xfs_dir2_sf_entry *)
329 ((char *)hdr + xfs_dir2_sf_hdr_size(hdr->i8count));
334 struct xfs_mount *mp,
335 struct xfs_dir2_sf_hdr *hdr,
338 int count = sizeof(struct xfs_dir2_sf_entry); /* namelen + offset */
340 count += len; /* name */
341 count += hdr->i8count ? sizeof(xfs_dir2_ino8_t) :
342 sizeof(xfs_dir2_ino4_t); /* ino # */
343 if (xfs_sb_version_hasftype(&mp->m_sb))
344 count += sizeof(__uint8_t); /* file type */
348 static inline struct xfs_dir2_sf_entry *
349 xfs_dir3_sf_nextentry(
350 struct xfs_mount *mp,
351 struct xfs_dir2_sf_hdr *hdr,
352 struct xfs_dir2_sf_entry *sfep)
354 return (struct xfs_dir2_sf_entry *)
355 ((char *)sfep + xfs_dir3_sf_entsize(mp, hdr, sfep->namelen));
359 * in dir3 shortform directories, the file type field is stored at a variable
360 * offset after the inode number. Because it's only a single byte, endian
361 * conversion is not necessary.
363 static inline __uint8_t *
365 struct xfs_dir2_sf_hdr *hdr,
366 struct xfs_dir2_sf_entry *sfep)
368 return (__uint8_t *)&sfep->name[sfep->namelen];
371 static inline __uint8_t
372 xfs_dir3_sfe_get_ftype(
373 struct xfs_mount *mp,
374 struct xfs_dir2_sf_hdr *hdr,
375 struct xfs_dir2_sf_entry *sfep)
379 if (!xfs_sb_version_hasftype(&mp->m_sb))
380 return XFS_DIR3_FT_UNKNOWN;
382 ftp = xfs_dir3_sfe_ftypep(hdr, sfep);
383 if (*ftp >= XFS_DIR3_FT_MAX)
384 return XFS_DIR3_FT_UNKNOWN;
389 xfs_dir3_sfe_put_ftype(
390 struct xfs_mount *mp,
391 struct xfs_dir2_sf_hdr *hdr,
392 struct xfs_dir2_sf_entry *sfep,
397 ASSERT(ftype < XFS_DIR3_FT_MAX);
399 if (!xfs_sb_version_hasftype(&mp->m_sb))
401 ftp = xfs_dir3_sfe_ftypep(hdr, sfep);
406 * Data block structures.
408 * A pure data block looks like the following drawing on disk:
410 * +-------------------------------------------------+
411 * | xfs_dir2_data_hdr_t |
412 * +-------------------------------------------------+
413 * | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t |
414 * | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t |
415 * | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t |
417 * +-------------------------------------------------+
419 * +-------------------------------------------------+
421 * As all the entries are variable size structures the accessors below should
422 * be used to iterate over them.
424 * In addition to the pure data blocks for the data and node formats,
425 * most structures are also used for the combined data/freespace "block"
429 #define XFS_DIR2_DATA_ALIGN_LOG 3 /* i.e., 8 bytes */
430 #define XFS_DIR2_DATA_ALIGN (1 << XFS_DIR2_DATA_ALIGN_LOG)
431 #define XFS_DIR2_DATA_FREE_TAG 0xffff
432 #define XFS_DIR2_DATA_FD_COUNT 3
435 * Directory address space divided into sections,
436 * spaces separated by 32GB.
438 #define XFS_DIR2_SPACE_SIZE (1ULL << (32 + XFS_DIR2_DATA_ALIGN_LOG))
439 #define XFS_DIR2_DATA_SPACE 0
440 #define XFS_DIR2_DATA_OFFSET (XFS_DIR2_DATA_SPACE * XFS_DIR2_SPACE_SIZE)
441 #define XFS_DIR2_DATA_FIRSTDB(mp) \
442 xfs_dir2_byte_to_db(mp, XFS_DIR2_DATA_OFFSET)
445 * Describe a free area in the data block.
447 * The freespace will be formatted as a xfs_dir2_data_unused_t.
449 typedef struct xfs_dir2_data_free {
450 __be16 offset; /* start of freespace */
451 __be16 length; /* length of freespace */
452 } xfs_dir2_data_free_t;
455 * Header for the data blocks.
457 * The code knows that XFS_DIR2_DATA_FD_COUNT is 3.
459 typedef struct xfs_dir2_data_hdr {
460 __be32 magic; /* XFS_DIR2_DATA_MAGIC or */
461 /* XFS_DIR2_BLOCK_MAGIC */
462 xfs_dir2_data_free_t bestfree[XFS_DIR2_DATA_FD_COUNT];
463 } xfs_dir2_data_hdr_t;
466 * define a structure for all the verification fields we are adding to the
467 * directory block structures. This will be used in several structures.
468 * The magic number must be the first entry to align with all the dir2
469 * structures so we determine how to decode them just by the magic number.
471 struct xfs_dir3_blk_hdr {
472 __be32 magic; /* magic number */
473 __be32 crc; /* CRC of block */
474 __be64 blkno; /* first block of the buffer */
475 __be64 lsn; /* sequence number of last write */
476 uuid_t uuid; /* filesystem we belong to */
477 __be64 owner; /* inode that owns the block */
480 struct xfs_dir3_data_hdr {
481 struct xfs_dir3_blk_hdr hdr;
482 xfs_dir2_data_free_t best_free[XFS_DIR2_DATA_FD_COUNT];
483 __be32 pad; /* 64 bit alignment */
486 #define XFS_DIR3_DATA_CRC_OFF offsetof(struct xfs_dir3_data_hdr, hdr.crc)
488 static inline struct xfs_dir2_data_free *
489 xfs_dir3_data_bestfree_p(struct xfs_dir2_data_hdr *hdr)
491 if (hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) ||
492 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) {
493 struct xfs_dir3_data_hdr *hdr3 = (struct xfs_dir3_data_hdr *)hdr;
494 return hdr3->best_free;
496 return hdr->bestfree;
500 * Active entry in a data block.
502 * Aligned to 8 bytes. After the variable length name field there is a
503 * 2 byte tag field, which can be accessed using xfs_dir3_data_entry_tag_p.
505 * For dir3 structures, there is file type field between the name and the tag.
506 * This can only be manipulated by helper functions. It is packed hard against
507 * the end of the name so any padding for rounding is between the file type and
510 typedef struct xfs_dir2_data_entry {
511 __be64 inumber; /* inode number */
512 __u8 namelen; /* name length */
513 __u8 name[]; /* name bytes, no null */
514 /* __u8 filetype; */ /* type of inode we point to */
515 /* __be16 tag; */ /* starting offset of us */
516 } xfs_dir2_data_entry_t;
519 * Unused entry in a data block.
521 * Aligned to 8 bytes. Tag appears as the last 2 bytes and must be accessed
522 * using xfs_dir2_data_unused_tag_p.
524 typedef struct xfs_dir2_data_unused {
525 __be16 freetag; /* XFS_DIR2_DATA_FREE_TAG */
526 __be16 length; /* total free length */
527 /* variable offset */
528 __be16 tag; /* starting offset of us */
529 } xfs_dir2_data_unused_t;
532 * Size of a data entry.
535 __xfs_dir3_data_entsize(
539 int size = offsetof(struct xfs_dir2_data_entry, name[0]);
542 size += sizeof(xfs_dir2_data_off_t);
544 size += sizeof(__uint8_t);
545 return roundup(size, XFS_DIR2_DATA_ALIGN);
548 xfs_dir3_data_entsize(
549 struct xfs_mount *mp,
552 bool ftype = xfs_sb_version_hasftype(&mp->m_sb) ? true : false;
553 return __xfs_dir3_data_entsize(ftype, n);
556 static inline __uint8_t
557 xfs_dir3_dirent_get_ftype(
558 struct xfs_mount *mp,
559 struct xfs_dir2_data_entry *dep)
561 if (xfs_sb_version_hasftype(&mp->m_sb)) {
562 __uint8_t type = dep->name[dep->namelen];
564 ASSERT(type < XFS_DIR3_FT_MAX);
565 if (type < XFS_DIR3_FT_MAX)
569 return XFS_DIR3_FT_UNKNOWN;
573 xfs_dir3_dirent_put_ftype(
574 struct xfs_mount *mp,
575 struct xfs_dir2_data_entry *dep,
578 ASSERT(type < XFS_DIR3_FT_MAX);
579 ASSERT(dep->namelen != 0);
581 if (xfs_sb_version_hasftype(&mp->m_sb))
582 dep->name[dep->namelen] = type;
586 * Pointer to an entry's tag word.
588 static inline __be16 *
589 xfs_dir3_data_entry_tag_p(
590 struct xfs_mount *mp,
591 struct xfs_dir2_data_entry *dep)
593 return (__be16 *)((char *)dep +
594 xfs_dir3_data_entsize(mp, dep->namelen) - sizeof(__be16));
598 * Pointer to a freespace's tag word.
600 static inline __be16 *
601 xfs_dir2_data_unused_tag_p(struct xfs_dir2_data_unused *dup)
603 return (__be16 *)((char *)dup +
604 be16_to_cpu(dup->length) - sizeof(__be16));
608 xfs_dir3_data_hdr_size(bool dir3)
611 return sizeof(struct xfs_dir3_data_hdr);
612 return sizeof(struct xfs_dir2_data_hdr);
616 xfs_dir3_data_entry_offset(struct xfs_dir2_data_hdr *hdr)
618 bool dir3 = hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) ||
619 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC);
620 return xfs_dir3_data_hdr_size(dir3);
623 static inline struct xfs_dir2_data_entry *
624 xfs_dir3_data_entry_p(struct xfs_dir2_data_hdr *hdr)
626 return (struct xfs_dir2_data_entry *)
627 ((char *)hdr + xfs_dir3_data_entry_offset(hdr));
630 static inline struct xfs_dir2_data_unused *
631 xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr)
633 return (struct xfs_dir2_data_unused *)
634 ((char *)hdr + xfs_dir3_data_entry_offset(hdr));
638 * Offsets of . and .. in data space (always block 0)
640 * XXX: there is scope for significant optimisation of the logic here. Right
641 * now we are checking for "dir3 format" over and over again. Ideally we should
642 * only do it once for each operation.
644 static inline xfs_dir2_data_aoff_t
645 xfs_dir3_data_dot_offset(struct xfs_mount *mp)
647 return xfs_dir3_data_hdr_size(xfs_sb_version_hascrc(&mp->m_sb));
650 static inline xfs_dir2_data_aoff_t
651 xfs_dir3_data_dotdot_offset(struct xfs_mount *mp)
653 return xfs_dir3_data_dot_offset(mp) +
654 xfs_dir3_data_entsize(mp, 1);
657 static inline xfs_dir2_data_aoff_t
658 xfs_dir3_data_first_offset(struct xfs_mount *mp)
660 return xfs_dir3_data_dotdot_offset(mp) +
661 xfs_dir3_data_entsize(mp, 2);
665 * location of . and .. in data space (always block 0)
667 static inline struct xfs_dir2_data_entry *
668 xfs_dir3_data_dot_entry_p(
669 struct xfs_mount *mp,
670 struct xfs_dir2_data_hdr *hdr)
672 return (struct xfs_dir2_data_entry *)
673 ((char *)hdr + xfs_dir3_data_dot_offset(mp));
676 static inline struct xfs_dir2_data_entry *
677 xfs_dir3_data_dotdot_entry_p(
678 struct xfs_mount *mp,
679 struct xfs_dir2_data_hdr *hdr)
681 return (struct xfs_dir2_data_entry *)
682 ((char *)hdr + xfs_dir3_data_dotdot_offset(mp));
685 static inline struct xfs_dir2_data_entry *
686 xfs_dir3_data_first_entry_p(
687 struct xfs_mount *mp,
688 struct xfs_dir2_data_hdr *hdr)
690 return (struct xfs_dir2_data_entry *)
691 ((char *)hdr + xfs_dir3_data_first_offset(mp));
695 * Leaf block structures.
697 * A pure leaf block looks like the following drawing on disk:
699 * +---------------------------+
700 * | xfs_dir2_leaf_hdr_t |
701 * +---------------------------+
702 * | xfs_dir2_leaf_entry_t |
703 * | xfs_dir2_leaf_entry_t |
704 * | xfs_dir2_leaf_entry_t |
705 * | xfs_dir2_leaf_entry_t |
707 * +---------------------------+
708 * | xfs_dir2_data_off_t |
709 * | xfs_dir2_data_off_t |
710 * | xfs_dir2_data_off_t |
712 * +---------------------------+
713 * | xfs_dir2_leaf_tail_t |
714 * +---------------------------+
716 * The xfs_dir2_data_off_t members (bests) and tail are at the end of the block
717 * for single-leaf (magic = XFS_DIR2_LEAF1_MAGIC) blocks only, but not present
718 * for directories with separate leaf nodes and free space blocks
719 * (magic = XFS_DIR2_LEAFN_MAGIC).
721 * As all the entries are variable size structures the accessors below should
722 * be used to iterate over them.
726 * Offset of the leaf/node space. First block in this space
729 #define XFS_DIR2_LEAF_SPACE 1
730 #define XFS_DIR2_LEAF_OFFSET (XFS_DIR2_LEAF_SPACE * XFS_DIR2_SPACE_SIZE)
731 #define XFS_DIR2_LEAF_FIRSTDB(mp) \
732 xfs_dir2_byte_to_db(mp, XFS_DIR2_LEAF_OFFSET)
737 typedef struct xfs_dir2_leaf_hdr {
738 xfs_da_blkinfo_t info; /* header for da routines */
739 __be16 count; /* count of entries */
740 __be16 stale; /* count of stale entries */
741 } xfs_dir2_leaf_hdr_t;
743 struct xfs_dir3_leaf_hdr {
744 struct xfs_da3_blkinfo info; /* header for da routines */
745 __be16 count; /* count of entries */
746 __be16 stale; /* count of stale entries */
747 __be32 pad; /* 64 bit alignment */
750 struct xfs_dir3_icleaf_hdr {
761 typedef struct xfs_dir2_leaf_entry {
762 __be32 hashval; /* hash value of name */
763 __be32 address; /* address of data entry */
764 } xfs_dir2_leaf_entry_t;
769 typedef struct xfs_dir2_leaf_tail {
771 } xfs_dir2_leaf_tail_t;
776 typedef struct xfs_dir2_leaf {
777 xfs_dir2_leaf_hdr_t hdr; /* leaf header */
778 xfs_dir2_leaf_entry_t __ents[]; /* entries */
781 struct xfs_dir3_leaf {
782 struct xfs_dir3_leaf_hdr hdr; /* leaf header */
783 struct xfs_dir2_leaf_entry __ents[]; /* entries */
786 #define XFS_DIR3_LEAF_CRC_OFF offsetof(struct xfs_dir3_leaf_hdr, info.crc)
788 extern void xfs_dir3_leaf_hdr_from_disk(struct xfs_dir3_icleaf_hdr *to,
789 struct xfs_dir2_leaf *from);
792 xfs_dir3_leaf_hdr_size(struct xfs_dir2_leaf *lp)
794 if (lp->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC) ||
795 lp->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC))
796 return sizeof(struct xfs_dir3_leaf_hdr);
797 return sizeof(struct xfs_dir2_leaf_hdr);
801 xfs_dir3_max_leaf_ents(struct xfs_mount *mp, struct xfs_dir2_leaf *lp)
803 return (mp->m_dirblksize - xfs_dir3_leaf_hdr_size(lp)) /
804 (uint)sizeof(struct xfs_dir2_leaf_entry);
808 * Get address of the bestcount field in the single-leaf block.
810 static inline struct xfs_dir2_leaf_entry *
811 xfs_dir3_leaf_ents_p(struct xfs_dir2_leaf *lp)
813 if (lp->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC) ||
814 lp->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)) {
815 struct xfs_dir3_leaf *lp3 = (struct xfs_dir3_leaf *)lp;
822 * Get address of the bestcount field in the single-leaf block.
824 static inline struct xfs_dir2_leaf_tail *
825 xfs_dir2_leaf_tail_p(struct xfs_mount *mp, struct xfs_dir2_leaf *lp)
827 return (struct xfs_dir2_leaf_tail *)
828 ((char *)lp + mp->m_dirblksize -
829 sizeof(struct xfs_dir2_leaf_tail));
833 * Get address of the bests array in the single-leaf block.
835 static inline __be16 *
836 xfs_dir2_leaf_bests_p(struct xfs_dir2_leaf_tail *ltp)
838 return (__be16 *)ltp - be32_to_cpu(ltp->bestcount);
842 * DB blocks here are logical directory block numbers, not filesystem blocks.
846 * Convert dataptr to byte in file space
848 static inline xfs_dir2_off_t
849 xfs_dir2_dataptr_to_byte(struct xfs_mount *mp, xfs_dir2_dataptr_t dp)
851 return (xfs_dir2_off_t)dp << XFS_DIR2_DATA_ALIGN_LOG;
855 * Convert byte in file space to dataptr. It had better be aligned.
857 static inline xfs_dir2_dataptr_t
858 xfs_dir2_byte_to_dataptr(struct xfs_mount *mp, xfs_dir2_off_t by)
860 return (xfs_dir2_dataptr_t)(by >> XFS_DIR2_DATA_ALIGN_LOG);
864 * Convert byte in space to (DB) block
866 static inline xfs_dir2_db_t
867 xfs_dir2_byte_to_db(struct xfs_mount *mp, xfs_dir2_off_t by)
869 return (xfs_dir2_db_t)
870 (by >> (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog));
874 * Convert dataptr to a block number
876 static inline xfs_dir2_db_t
877 xfs_dir2_dataptr_to_db(struct xfs_mount *mp, xfs_dir2_dataptr_t dp)
879 return xfs_dir2_byte_to_db(mp, xfs_dir2_dataptr_to_byte(mp, dp));
883 * Convert byte in space to offset in a block
885 static inline xfs_dir2_data_aoff_t
886 xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by)
888 return (xfs_dir2_data_aoff_t)(by &
889 ((1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) - 1));
893 * Convert dataptr to a byte offset in a block
895 static inline xfs_dir2_data_aoff_t
896 xfs_dir2_dataptr_to_off(struct xfs_mount *mp, xfs_dir2_dataptr_t dp)
898 return xfs_dir2_byte_to_off(mp, xfs_dir2_dataptr_to_byte(mp, dp));
902 * Convert block and offset to byte in space
904 static inline xfs_dir2_off_t
905 xfs_dir2_db_off_to_byte(struct xfs_mount *mp, xfs_dir2_db_t db,
906 xfs_dir2_data_aoff_t o)
908 return ((xfs_dir2_off_t)db <<
909 (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) + o;
913 * Convert block (DB) to block (dablk)
915 static inline xfs_dablk_t
916 xfs_dir2_db_to_da(struct xfs_mount *mp, xfs_dir2_db_t db)
918 return (xfs_dablk_t)(db << mp->m_sb.sb_dirblklog);
922 * Convert byte in space to (DA) block
924 static inline xfs_dablk_t
925 xfs_dir2_byte_to_da(struct xfs_mount *mp, xfs_dir2_off_t by)
927 return xfs_dir2_db_to_da(mp, xfs_dir2_byte_to_db(mp, by));
931 * Convert block and offset to dataptr
933 static inline xfs_dir2_dataptr_t
934 xfs_dir2_db_off_to_dataptr(struct xfs_mount *mp, xfs_dir2_db_t db,
935 xfs_dir2_data_aoff_t o)
937 return xfs_dir2_byte_to_dataptr(mp, xfs_dir2_db_off_to_byte(mp, db, o));
941 * Convert block (dablk) to block (DB)
943 static inline xfs_dir2_db_t
944 xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da)
946 return (xfs_dir2_db_t)(da >> mp->m_sb.sb_dirblklog);
950 * Convert block (dablk) to byte offset in space
952 static inline xfs_dir2_off_t
953 xfs_dir2_da_to_byte(struct xfs_mount *mp, xfs_dablk_t da)
955 return xfs_dir2_db_off_to_byte(mp, xfs_dir2_da_to_db(mp, da), 0);
959 * Free space block defintions for the node format.
963 * Offset of the freespace index.
965 #define XFS_DIR2_FREE_SPACE 2
966 #define XFS_DIR2_FREE_OFFSET (XFS_DIR2_FREE_SPACE * XFS_DIR2_SPACE_SIZE)
967 #define XFS_DIR2_FREE_FIRSTDB(mp) \
968 xfs_dir2_byte_to_db(mp, XFS_DIR2_FREE_OFFSET)
970 typedef struct xfs_dir2_free_hdr {
971 __be32 magic; /* XFS_DIR2_FREE_MAGIC */
972 __be32 firstdb; /* db of first entry */
973 __be32 nvalid; /* count of valid entries */
974 __be32 nused; /* count of used entries */
975 } xfs_dir2_free_hdr_t;
977 typedef struct xfs_dir2_free {
978 xfs_dir2_free_hdr_t hdr; /* block header */
979 __be16 bests[]; /* best free counts */
980 /* unused entries are -1 */
983 struct xfs_dir3_free_hdr {
984 struct xfs_dir3_blk_hdr hdr;
985 __be32 firstdb; /* db of first entry */
986 __be32 nvalid; /* count of valid entries */
987 __be32 nused; /* count of used entries */
988 __be32 pad; /* 64 bit alignment */
991 struct xfs_dir3_free {
992 struct xfs_dir3_free_hdr hdr;
993 __be16 bests[]; /* best free counts */
994 /* unused entries are -1 */
997 #define XFS_DIR3_FREE_CRC_OFF offsetof(struct xfs_dir3_free, hdr.hdr.crc)
1000 * In core version of the free block header, abstracted away from on-disk format
1001 * differences. Use this in the code, and convert to/from the disk version using
1002 * xfs_dir3_free_hdr_from_disk/xfs_dir3_free_hdr_to_disk.
1004 struct xfs_dir3_icfree_hdr {
1012 void xfs_dir3_free_hdr_from_disk(struct xfs_dir3_icfree_hdr *to,
1013 struct xfs_dir2_free *from);
1016 xfs_dir3_free_hdr_size(struct xfs_mount *mp)
1018 if (xfs_sb_version_hascrc(&mp->m_sb))
1019 return sizeof(struct xfs_dir3_free_hdr);
1020 return sizeof(struct xfs_dir2_free_hdr);
1024 xfs_dir3_free_max_bests(struct xfs_mount *mp)
1026 return (mp->m_dirblksize - xfs_dir3_free_hdr_size(mp)) /
1027 sizeof(xfs_dir2_data_off_t);
1030 static inline __be16 *
1031 xfs_dir3_free_bests_p(struct xfs_mount *mp, struct xfs_dir2_free *free)
1033 return (__be16 *)((char *)free + xfs_dir3_free_hdr_size(mp));
1037 * Convert data space db to the corresponding free db.
1039 static inline xfs_dir2_db_t
1040 xfs_dir2_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db)
1042 return XFS_DIR2_FREE_FIRSTDB(mp) + db / xfs_dir3_free_max_bests(mp);
1046 * Convert data space db to the corresponding index in a free db.
1049 xfs_dir2_db_to_fdindex(struct xfs_mount *mp, xfs_dir2_db_t db)
1051 return db % xfs_dir3_free_max_bests(mp);
1055 * Single block format.
1057 * The single block format looks like the following drawing on disk:
1059 * +-------------------------------------------------+
1060 * | xfs_dir2_data_hdr_t |
1061 * +-------------------------------------------------+
1062 * | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t |
1063 * | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t |
1064 * | xfs_dir2_data_entry_t OR xfs_dir2_data_unused_t :
1066 * +-------------------------------------------------+
1068 * +-------------------------------------------------+
1070 * | xfs_dir2_leaf_entry_t |
1071 * | xfs_dir2_leaf_entry_t |
1072 * +-------------------------------------------------+
1073 * | xfs_dir2_block_tail_t |
1074 * +-------------------------------------------------+
1076 * As all the entries are variable size structures the accessors below should
1077 * be used to iterate over them.
1080 typedef struct xfs_dir2_block_tail {
1081 __be32 count; /* count of leaf entries */
1082 __be32 stale; /* count of stale lf entries */
1083 } xfs_dir2_block_tail_t;
1086 * Pointer to the leaf header embedded in a data block (1-block format)
1088 static inline struct xfs_dir2_block_tail *
1089 xfs_dir2_block_tail_p(struct xfs_mount *mp, struct xfs_dir2_data_hdr *hdr)
1091 return ((struct xfs_dir2_block_tail *)
1092 ((char *)hdr + mp->m_dirblksize)) - 1;
1096 * Pointer to the leaf entries embedded in a data block (1-block format)
1098 static inline struct xfs_dir2_leaf_entry *
1099 xfs_dir2_block_leaf_p(struct xfs_dir2_block_tail *btp)
1101 return ((struct xfs_dir2_leaf_entry *)btp) - be32_to_cpu(btp->count);
1106 * Attribute storage layout
1108 * Attribute lists are structured around Btrees where all the data
1109 * elements are in the leaf nodes. Attribute names are hashed into an int,
1110 * then that int is used as the index into the Btree. Since the hashval
1111 * of an attribute name may not be unique, we may have duplicate keys. The
1112 * internal links in the Btree are logical block offsets into the file.
1114 *========================================================================
1115 * Attribute structure when equal to XFS_LBSIZE(mp) bytes.
1116 *========================================================================
1118 * Struct leaf_entry's are packed from the top. Name/values grow from the
1119 * bottom but are not packed. The freemap contains run-length-encoded entries
1120 * for the free bytes after the leaf_entry's, but only the N largest such,
1121 * smaller runs are dropped. When the freemap doesn't show enough space
1122 * for an allocation, we compact the name/value area and try again. If we
1123 * still don't have enough space, then we have to split the block. The
1124 * name/value structs (both local and remote versions) must be 32bit aligned.
1126 * Since we have duplicate hash keys, for each key that matches, compare
1127 * the actual name string. The root and intermediate node search always
1128 * takes the first-in-the-block key match found, so we should only have
1129 * to work "forw"ard. If none matches, continue with the "forw"ard leaf
1130 * nodes until the hash key changes or the attribute name is found.
1132 * We store the fact that an attribute is a ROOT/USER/SECURE attribute in
1133 * the leaf_entry. The namespaces are independent only because we also look
1134 * at the namespace bit when we are looking for a matching attribute name.
1136 * We also store an "incomplete" bit in the leaf_entry. It shows that an
1137 * attribute is in the middle of being created and should not be shown to
1138 * the user if we crash during the time that the bit is set. We clear the
1139 * bit when we have finished setting up the attribute. We do this because
1140 * we cannot create some large attributes inside a single transaction, and we
1141 * need some indication that we weren't finished if we crash in the middle.
1143 #define XFS_ATTR_LEAF_MAPSIZE 3 /* how many freespace slots */
1145 typedef struct xfs_attr_leaf_map { /* RLE map of free bytes */
1146 __be16 base; /* base of free region */
1147 __be16 size; /* length of free region */
1148 } xfs_attr_leaf_map_t;
1150 typedef struct xfs_attr_leaf_hdr { /* constant-structure header block */
1151 xfs_da_blkinfo_t info; /* block type, links, etc. */
1152 __be16 count; /* count of active leaf_entry's */
1153 __be16 usedbytes; /* num bytes of names/values stored */
1154 __be16 firstused; /* first used byte in name area */
1155 __u8 holes; /* != 0 if blk needs compaction */
1157 xfs_attr_leaf_map_t freemap[XFS_ATTR_LEAF_MAPSIZE];
1158 /* N largest free regions */
1159 } xfs_attr_leaf_hdr_t;
1161 typedef struct xfs_attr_leaf_entry { /* sorted on key, not name */
1162 __be32 hashval; /* hash value of name */
1163 __be16 nameidx; /* index into buffer of name/value */
1164 __u8 flags; /* LOCAL/ROOT/SECURE/INCOMPLETE flag */
1165 __u8 pad2; /* unused pad byte */
1166 } xfs_attr_leaf_entry_t;
1168 typedef struct xfs_attr_leaf_name_local {
1169 __be16 valuelen; /* number of bytes in value */
1170 __u8 namelen; /* length of name bytes */
1171 __u8 nameval[1]; /* name/value bytes */
1172 } xfs_attr_leaf_name_local_t;
1174 typedef struct xfs_attr_leaf_name_remote {
1175 __be32 valueblk; /* block number of value bytes */
1176 __be32 valuelen; /* number of bytes in value */
1177 __u8 namelen; /* length of name bytes */
1178 __u8 name[1]; /* name bytes */
1179 } xfs_attr_leaf_name_remote_t;
1181 typedef struct xfs_attr_leafblock {
1182 xfs_attr_leaf_hdr_t hdr; /* constant-structure header block */
1183 xfs_attr_leaf_entry_t entries[1]; /* sorted on key, not name */
1184 xfs_attr_leaf_name_local_t namelist; /* grows from bottom of buf */
1185 xfs_attr_leaf_name_remote_t valuelist; /* grows from bottom of buf */
1186 } xfs_attr_leafblock_t;
1189 * CRC enabled leaf structures. Called "version 3" structures to match the
1190 * version number of the directory and dablk structures for this feature, and
1191 * attr2 is already taken by the variable inode attribute fork size feature.
1193 struct xfs_attr3_leaf_hdr {
1194 struct xfs_da3_blkinfo info;
1200 struct xfs_attr_leaf_map freemap[XFS_ATTR_LEAF_MAPSIZE];
1201 __be32 pad2; /* 64 bit alignment */
1204 #define XFS_ATTR3_LEAF_CRC_OFF (offsetof(struct xfs_attr3_leaf_hdr, info.crc))
1206 struct xfs_attr3_leafblock {
1207 struct xfs_attr3_leaf_hdr hdr;
1208 struct xfs_attr_leaf_entry entries[1];
1211 * The rest of the block contains the following structures after the
1212 * leaf entries, growing from the bottom up. The variables are never
1213 * referenced, the locations accessed purely from helper functions.
1215 * struct xfs_attr_leaf_name_local
1216 * struct xfs_attr_leaf_name_remote
1221 * incore, neutral version of the attribute leaf header
1223 struct xfs_attr3_icleaf_hdr {
1228 __uint16_t usedbytes;
1229 __uint16_t firstused;
1234 } freemap[XFS_ATTR_LEAF_MAPSIZE];
1238 * Flags used in the leaf_entry[i].flags field.
1239 * NOTE: the INCOMPLETE bit must not collide with the flags bits specified
1240 * on the system call, they are "or"ed together for various operations.
1242 #define XFS_ATTR_LOCAL_BIT 0 /* attr is stored locally */
1243 #define XFS_ATTR_ROOT_BIT 1 /* limit access to trusted attrs */
1244 #define XFS_ATTR_SECURE_BIT 2 /* limit access to secure attrs */
1245 #define XFS_ATTR_INCOMPLETE_BIT 7 /* attr in middle of create/delete */
1246 #define XFS_ATTR_LOCAL (1 << XFS_ATTR_LOCAL_BIT)
1247 #define XFS_ATTR_ROOT (1 << XFS_ATTR_ROOT_BIT)
1248 #define XFS_ATTR_SECURE (1 << XFS_ATTR_SECURE_BIT)
1249 #define XFS_ATTR_INCOMPLETE (1 << XFS_ATTR_INCOMPLETE_BIT)
1252 * Conversion macros for converting namespace bits from argument flags
1255 #define XFS_ATTR_NSP_ARGS_MASK (ATTR_ROOT | ATTR_SECURE)
1256 #define XFS_ATTR_NSP_ONDISK_MASK (XFS_ATTR_ROOT | XFS_ATTR_SECURE)
1257 #define XFS_ATTR_NSP_ONDISK(flags) ((flags) & XFS_ATTR_NSP_ONDISK_MASK)
1258 #define XFS_ATTR_NSP_ARGS(flags) ((flags) & XFS_ATTR_NSP_ARGS_MASK)
1259 #define XFS_ATTR_NSP_ARGS_TO_ONDISK(x) (((x) & ATTR_ROOT ? XFS_ATTR_ROOT : 0) |\
1260 ((x) & ATTR_SECURE ? XFS_ATTR_SECURE : 0))
1261 #define XFS_ATTR_NSP_ONDISK_TO_ARGS(x) (((x) & XFS_ATTR_ROOT ? ATTR_ROOT : 0) |\
1262 ((x) & XFS_ATTR_SECURE ? ATTR_SECURE : 0))
1265 * Alignment for namelist and valuelist entries (since they are mixed
1266 * there can be only one alignment value)
1268 #define XFS_ATTR_LEAF_NAME_ALIGN ((uint)sizeof(xfs_dablk_t))
1271 xfs_attr3_leaf_hdr_size(struct xfs_attr_leafblock *leafp)
1273 if (leafp->hdr.info.magic == cpu_to_be16(XFS_ATTR3_LEAF_MAGIC))
1274 return sizeof(struct xfs_attr3_leaf_hdr);
1275 return sizeof(struct xfs_attr_leaf_hdr);
1278 static inline struct xfs_attr_leaf_entry *
1279 xfs_attr3_leaf_entryp(xfs_attr_leafblock_t *leafp)
1281 if (leafp->hdr.info.magic == cpu_to_be16(XFS_ATTR3_LEAF_MAGIC))
1282 return &((struct xfs_attr3_leafblock *)leafp)->entries[0];
1283 return &leafp->entries[0];
1287 * Cast typed pointers for "local" and "remote" name/value structs.
1289 static inline char *
1290 xfs_attr3_leaf_name(xfs_attr_leafblock_t *leafp, int idx)
1292 struct xfs_attr_leaf_entry *entries = xfs_attr3_leaf_entryp(leafp);
1294 return &((char *)leafp)[be16_to_cpu(entries[idx].nameidx)];
1297 static inline xfs_attr_leaf_name_remote_t *
1298 xfs_attr3_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx)
1300 return (xfs_attr_leaf_name_remote_t *)xfs_attr3_leaf_name(leafp, idx);
1303 static inline xfs_attr_leaf_name_local_t *
1304 xfs_attr3_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx)
1306 return (xfs_attr_leaf_name_local_t *)xfs_attr3_leaf_name(leafp, idx);
1310 * Calculate total bytes used (including trailing pad for alignment) for
1311 * a "local" name/value structure, a "remote" name/value structure, and
1312 * a pointer which might be either.
1314 static inline int xfs_attr_leaf_entsize_remote(int nlen)
1316 return ((uint)sizeof(xfs_attr_leaf_name_remote_t) - 1 + (nlen) + \
1317 XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
1320 static inline int xfs_attr_leaf_entsize_local(int nlen, int vlen)
1322 return ((uint)sizeof(xfs_attr_leaf_name_local_t) - 1 + (nlen) + (vlen) +
1323 XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
1326 static inline int xfs_attr_leaf_entsize_local_max(int bsize)
1328 return (((bsize) >> 1) + ((bsize) >> 2));
1334 * Remote attribute block format definition
1336 * There is one of these headers per filesystem block in a remote attribute.
1337 * This is done to ensure there is a 1:1 mapping between the attribute value
1338 * length and the number of blocks needed to store the attribute. This makes the
1339 * verification of a buffer a little more complex, but greatly simplifies the
1340 * allocation, reading and writing of these attributes as we don't have to guess
1341 * the number of blocks needed to store the attribute data.
1343 #define XFS_ATTR3_RMT_MAGIC 0x5841524d /* XARM */
1345 struct xfs_attr3_rmt_hdr {
1356 #define XFS_ATTR3_RMT_CRC_OFF offsetof(struct xfs_attr3_rmt_hdr, rm_crc)
1358 #define XFS_ATTR3_RMT_BUF_SPACE(mp, bufsize) \
1359 ((bufsize) - (xfs_sb_version_hascrc(&(mp)->m_sb) ? \
1360 sizeof(struct xfs_attr3_rmt_hdr) : 0))
1362 #endif /* __XFS_DA_FORMAT_H__ */