hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/xfs/libxfs/xfs_da_format.h
....@@ -1,4 +1,4 @@
1
-// SPDX-License-Identifier: GPL-2.0
1
+/* SPDX-License-Identifier: GPL-2.0 */
22 /*
33 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
44 * Copyright (c) 2013 Red Hat, Inc.
....@@ -15,8 +15,8 @@
1515 */
1616 #define XFS_DA_NODE_MAGIC 0xfebe /* magic number: non-leaf blocks */
1717 #define XFS_ATTR_LEAF_MAGIC 0xfbee /* magic number: attribute leaf blks */
18
-#define XFS_DIR2_LEAF1_MAGIC 0xd2f1 /* magic number: v2 dirlf single blks */
19
-#define XFS_DIR2_LEAFN_MAGIC 0xd2ff /* magic number: v2 dirlf multi blks */
18
+#define XFS_DIR2_LEAF1_MAGIC 0xd2f1 /* magic number: v2 dirlf single blks */
19
+#define XFS_DIR2_LEAFN_MAGIC 0xd2ff /* magic number: v2 dirlf multi blks */
2020
2121 typedef struct xfs_da_blkinfo {
2222 __be32 forw; /* previous block in list */
....@@ -35,8 +35,8 @@
3535 */
3636 #define XFS_DA3_NODE_MAGIC 0x3ebe /* magic number: non-leaf blocks */
3737 #define XFS_ATTR3_LEAF_MAGIC 0x3bee /* magic number: attribute leaf blks */
38
-#define XFS_DIR3_LEAF1_MAGIC 0x3df1 /* magic number: v2 dirlf single blks */
39
-#define XFS_DIR3_LEAFN_MAGIC 0x3dff /* magic number: v2 dirlf multi blks */
38
+#define XFS_DIR3_LEAF1_MAGIC 0x3df1 /* magic number: v3 dirlf single blks */
39
+#define XFS_DIR3_LEAFN_MAGIC 0x3dff /* magic number: v3 dirlf multi blks */
4040
4141 struct xfs_da3_blkinfo {
4242 /*
....@@ -61,7 +61,7 @@
6161 * Since we have duplicate keys, use a binary search but always follow
6262 * all match in the block, not just the first match found.
6363 */
64
-#define XFS_DA_NODE_MAXDEPTH 5 /* max depth of Btree */
64
+#define XFS_DA_NODE_MAXDEPTH 5 /* max depth of Btree */
6565
6666 typedef struct xfs_da_node_hdr {
6767 struct xfs_da_blkinfo info; /* block type, links, etc. */
....@@ -91,19 +91,6 @@
9191 struct xfs_da3_intnode {
9292 struct xfs_da3_node_hdr hdr;
9393 struct xfs_da_node_entry __btree[];
94
-};
95
-
96
-/*
97
- * In-core version of the node header to abstract the differences in the v2 and
98
- * v3 disk format of the headers. Callers need to convert to/from disk format as
99
- * appropriate.
100
- */
101
-struct xfs_da3_icnode_hdr {
102
- uint32_t forw;
103
- uint32_t back;
104
- uint16_t magic;
105
- uint16_t count;
106
- uint16_t level;
10794 };
10895
10996 /*
....@@ -230,7 +217,7 @@
230217 * A 64-bit or 32-bit inode number follows here, at a variable offset
231218 * after the name.
232219 */
233
-} xfs_dir2_sf_entry_t;
220
+} __packed xfs_dir2_sf_entry_t;
234221
235222 static inline int xfs_dir2_sf_hdr_size(int i8count)
236223 {
....@@ -434,14 +421,6 @@
434421 __be32 pad; /* 64 bit alignment */
435422 };
436423
437
-struct xfs_dir3_icleaf_hdr {
438
- uint32_t forw;
439
- uint32_t back;
440
- uint16_t magic;
441
- uint16_t count;
442
- uint16_t stale;
443
-};
444
-
445424 /*
446425 * Leaf block entry.
447426 */
....@@ -482,7 +461,7 @@
482461 }
483462
484463 /*
485
- * Free space block defintions for the node format.
464
+ * Free space block definitions for the node format.
486465 */
487466
488467 /*
....@@ -519,19 +498,6 @@
519498 };
520499
521500 #define XFS_DIR3_FREE_CRC_OFF offsetof(struct xfs_dir3_free, hdr.hdr.crc)
522
-
523
-/*
524
- * In core version of the free block header, abstracted away from on-disk format
525
- * differences. Use this in the code, and convert to/from the disk version using
526
- * xfs_dir3_free_hdr_from_disk/xfs_dir3_free_hdr_to_disk.
527
- */
528
-struct xfs_dir3_icfree_hdr {
529
- uint32_t magic;
530
- uint32_t firstdb;
531
- uint32_t nvalid;
532
- uint32_t nused;
533
-
534
-};
535501
536502 /*
537503 * Single block format.
....@@ -613,7 +579,7 @@
613579 /*
614580 * Entries are packed toward the top as tight as possible.
615581 */
616
-typedef struct xfs_attr_shortform {
582
+struct xfs_attr_shortform {
617583 struct xfs_attr_sf_hdr { /* constant-structure header block */
618584 __be16 totsize; /* total bytes in shortform list */
619585 __u8 count; /* count of active entries */
....@@ -623,9 +589,9 @@
623589 uint8_t namelen; /* actual length of name (no NULL) */
624590 uint8_t valuelen; /* actual length of value (no NULL) */
625591 uint8_t flags; /* flags bits (see xfs_attr_leaf.h) */
626
- uint8_t nameval[1]; /* name & value bytes concatenated */
592
+ uint8_t nameval[]; /* name & value bytes concatenated */
627593 } list[1]; /* variable sized array */
628
-} xfs_attr_shortform_t;
594
+};
629595
630596 typedef struct xfs_attr_leaf_map { /* RLE map of free bytes */
631597 __be16 base; /* base of free region */
....@@ -710,29 +676,6 @@
710676 };
711677
712678 /*
713
- * incore, neutral version of the attribute leaf header
714
- */
715
-struct xfs_attr3_icleaf_hdr {
716
- uint32_t forw;
717
- uint32_t back;
718
- uint16_t magic;
719
- uint16_t count;
720
- uint16_t usedbytes;
721
- /*
722
- * firstused is 32-bit here instead of 16-bit like the on-disk variant
723
- * to support maximum fsb size of 64k without overflow issues throughout
724
- * the attr code. Instead, the overflow condition is handled on
725
- * conversion to/from disk.
726
- */
727
- uint32_t firstused;
728
- __u8 holes;
729
- struct {
730
- uint16_t base;
731
- uint16_t size;
732
- } freemap[XFS_ATTR_LEAF_MAPSIZE];
733
-};
734
-
735
-/*
736679 * Special value to represent fs block size in the leaf header firstused field.
737680 * Only used when block size overflows the 2-bytes available on disk.
738681 */
....@@ -740,8 +683,6 @@
740683
741684 /*
742685 * Flags used in the leaf_entry[i].flags field.
743
- * NOTE: the INCOMPLETE bit must not collide with the flags bits specified
744
- * on the system call, they are "or"ed together for various operations.
745686 */
746687 #define XFS_ATTR_LOCAL_BIT 0 /* attr is stored locally */
747688 #define XFS_ATTR_ROOT_BIT 1 /* limit access to trusted attrs */
....@@ -751,19 +692,7 @@
751692 #define XFS_ATTR_ROOT (1 << XFS_ATTR_ROOT_BIT)
752693 #define XFS_ATTR_SECURE (1 << XFS_ATTR_SECURE_BIT)
753694 #define XFS_ATTR_INCOMPLETE (1 << XFS_ATTR_INCOMPLETE_BIT)
754
-
755
-/*
756
- * Conversion macros for converting namespace bits from argument flags
757
- * to ondisk flags.
758
- */
759
-#define XFS_ATTR_NSP_ARGS_MASK (ATTR_ROOT | ATTR_SECURE)
760695 #define XFS_ATTR_NSP_ONDISK_MASK (XFS_ATTR_ROOT | XFS_ATTR_SECURE)
761
-#define XFS_ATTR_NSP_ONDISK(flags) ((flags) & XFS_ATTR_NSP_ONDISK_MASK)
762
-#define XFS_ATTR_NSP_ARGS(flags) ((flags) & XFS_ATTR_NSP_ARGS_MASK)
763
-#define XFS_ATTR_NSP_ARGS_TO_ONDISK(x) (((x) & ATTR_ROOT ? XFS_ATTR_ROOT : 0) |\
764
- ((x) & ATTR_SECURE ? XFS_ATTR_SECURE : 0))
765
-#define XFS_ATTR_NSP_ONDISK_TO_ARGS(x) (((x) & XFS_ATTR_ROOT ? ATTR_ROOT : 0) |\
766
- ((x) & XFS_ATTR_SECURE ? ATTR_SECURE : 0))
767696
768697 /*
769698 * Alignment for namelist and valuelist entries (since they are mixed
....@@ -817,14 +746,14 @@
817746 */
818747 static inline int xfs_attr_leaf_entsize_remote(int nlen)
819748 {
820
- return ((uint)sizeof(xfs_attr_leaf_name_remote_t) - 1 + (nlen) + \
821
- XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
749
+ return round_up(sizeof(struct xfs_attr_leaf_name_remote) - 1 +
750
+ nlen, XFS_ATTR_LEAF_NAME_ALIGN);
822751 }
823752
824753 static inline int xfs_attr_leaf_entsize_local(int nlen, int vlen)
825754 {
826
- return ((uint)sizeof(xfs_attr_leaf_name_local_t) - 1 + (nlen) + (vlen) +
827
- XFS_ATTR_LEAF_NAME_ALIGN - 1) & ~(XFS_ATTR_LEAF_NAME_ALIGN - 1);
755
+ return round_up(sizeof(struct xfs_attr_leaf_name_local) - 1 +
756
+ nlen + vlen, XFS_ATTR_LEAF_NAME_ALIGN);
828757 }
829758
830759 static inline int xfs_attr_leaf_entsize_local_max(int bsize)
....@@ -869,4 +798,7 @@
869798 return 1 << (sbp->sb_blocklog + sbp->sb_dirblklog);
870799 }
871800
801
+xfs_failaddr_t xfs_da3_blkinfo_verify(struct xfs_buf *bp,
802
+ struct xfs_da3_blkinfo *hdr3);
803
+
872804 #endif /* __XFS_DA_FORMAT_H__ */