summaryrefslogtreecommitdiff
path: root/fs/xfs/xfs_buf_item.h
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2013-04-03 09:11:30 +0400
committerBen Myers <bpm@sgi.com>2013-04-27 22:01:58 +0400
commit61fe135c1dde112f483bba01d645debd881b5428 (patch)
tree6ec57ed9730f555b29b94aeb6983b4ddbebffe51 /fs/xfs/xfs_buf_item.h
parentd75afeb3d302019527331520a2632b6614425b40 (diff)
downloadlinux-61fe135c1dde112f483bba01d645debd881b5428.tar.xz
xfs: buffer type overruns blf_flags field
The buffer type passed to log recvoery in the buffer log item overruns the blf_flags field. I had assumed that flags field was a 32 bit value, and it turns out it is a unisgned short. Therefore having 19 flags doesn't really work. Convert the buffer type field to numeric value, and use the top 5 bits of the flags field for it. We currently have 17 types of buffers, so using 5 bits gives us plenty of room for expansion in future.... Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Ben Myers <bpm@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_buf_item.h')
-rw-r--r--fs/xfs/xfs_buf_item.h92
1 files changed, 53 insertions, 39 deletions
diff --git a/fs/xfs/xfs_buf_item.h b/fs/xfs/xfs_buf_item.h
index 640adcfa4143..2573d2a75fc8 100644
--- a/fs/xfs/xfs_buf_item.h
+++ b/fs/xfs/xfs_buf_item.h
@@ -39,45 +39,6 @@ extern kmem_zone_t *xfs_buf_item_zone;
#define XFS_BLF_PDQUOT_BUF (1<<3)
#define XFS_BLF_GDQUOT_BUF (1<<4)
-/*
- * all buffers now need flags to tell recovery where the magic number
- * is so that it can verify and calculate the CRCs on the buffer correctly
- * once the changes have been replayed into the buffer.
- */
-#define XFS_BLF_BTREE_BUF (1<<5)
-#define XFS_BLF_AGF_BUF (1<<6)
-#define XFS_BLF_AGFL_BUF (1<<7)
-#define XFS_BLF_AGI_BUF (1<<8)
-#define XFS_BLF_DINO_BUF (1<<9)
-#define XFS_BLF_SYMLINK_BUF (1<<10)
-#define XFS_BLF_DIR_BLOCK_BUF (1<<11)
-#define XFS_BLF_DIR_DATA_BUF (1<<12)
-#define XFS_BLF_DIR_FREE_BUF (1<<13)
-#define XFS_BLF_DIR_LEAF1_BUF (1<<14)
-#define XFS_BLF_DIR_LEAFN_BUF (1<<15)
-#define XFS_BLF_DA_NODE_BUF (1<<16)
-#define XFS_BLF_ATTR_LEAF_BUF (1<<17)
-#define XFS_BLF_ATTR_RMT_BUF (1<<18)
-
-#define XFS_BLF_TYPE_MASK \
- (XFS_BLF_UDQUOT_BUF | \
- XFS_BLF_PDQUOT_BUF | \
- XFS_BLF_GDQUOT_BUF | \
- XFS_BLF_BTREE_BUF | \
- XFS_BLF_AGF_BUF | \
- XFS_BLF_AGFL_BUF | \
- XFS_BLF_AGI_BUF | \
- XFS_BLF_DINO_BUF | \
- XFS_BLF_SYMLINK_BUF | \
- XFS_BLF_DIR_BLOCK_BUF | \
- XFS_BLF_DIR_DATA_BUF | \
- XFS_BLF_DIR_FREE_BUF | \
- XFS_BLF_DIR_LEAF1_BUF | \
- XFS_BLF_DIR_LEAFN_BUF | \
- XFS_BLF_DA_NODE_BUF | \
- XFS_BLF_ATTR_LEAF_BUF | \
- XFS_BLF_ATTR_RMT_BUF)
-
#define XFS_BLF_CHUNK 128
#define XFS_BLF_SHIFT 7
#define BIT_TO_WORD_SHIFT 5
@@ -101,6 +62,55 @@ typedef struct xfs_buf_log_format {
} xfs_buf_log_format_t;
/*
+ * All buffers now need to tell recovery where the magic number
+ * is so that it can verify and calculate the CRCs on the buffer correctly
+ * once the changes have been replayed into the buffer.
+ *
+ * The type value is held in the upper 5 bits of the blf_flags field, which is
+ * an unsigned 16 bit field. Hence we need to shift it 11 bits up and down.
+ */
+#define XFS_BLFT_BITS 5
+#define XFS_BLFT_SHIFT 11
+#define XFS_BLFT_MASK (((1 << XFS_BLFT_BITS) - 1) << XFS_BLFT_SHIFT)
+
+enum xfs_blft {
+ XFS_BLFT_UNKNOWN_BUF = 0,
+ XFS_BLFT_UDQUOT_BUF,
+ XFS_BLFT_PDQUOT_BUF,
+ XFS_BLFT_GDQUOT_BUF,
+ XFS_BLFT_BTREE_BUF,
+ XFS_BLFT_AGF_BUF,
+ XFS_BLFT_AGFL_BUF,
+ XFS_BLFT_AGI_BUF,
+ XFS_BLFT_DINO_BUF,
+ XFS_BLFT_SYMLINK_BUF,
+ XFS_BLFT_DIR_BLOCK_BUF,
+ XFS_BLFT_DIR_DATA_BUF,
+ XFS_BLFT_DIR_FREE_BUF,
+ XFS_BLFT_DIR_LEAF1_BUF,
+ XFS_BLFT_DIR_LEAFN_BUF,
+ XFS_BLFT_DA_NODE_BUF,
+ XFS_BLFT_ATTR_LEAF_BUF,
+ XFS_BLFT_ATTR_RMT_BUF,
+ XFS_BLFT_SB_BUF,
+ XFS_BLFT_MAX_BUF = (1 << XFS_BLFT_BITS),
+};
+
+static inline void
+xfs_blft_to_flags(struct xfs_buf_log_format *blf, enum xfs_blft type)
+{
+ ASSERT(type > XFS_BLFT_UNKNOWN_BUF && type < XFS_BLFT_MAX_BUF);
+ blf->blf_flags &= ~XFS_BLFT_MASK;
+ blf->blf_flags |= ((type << XFS_BLFT_SHIFT) & XFS_BLFT_MASK);
+}
+
+static inline __uint16_t
+xfs_blft_from_flags(struct xfs_buf_log_format *blf)
+{
+ return (blf->blf_flags & XFS_BLFT_MASK) >> XFS_BLFT_SHIFT;
+}
+
+/*
* buf log item flags
*/
#define XFS_BLI_HOLD 0x01
@@ -153,6 +163,10 @@ void xfs_buf_attach_iodone(struct xfs_buf *,
void xfs_buf_iodone_callbacks(struct xfs_buf *);
void xfs_buf_iodone(struct xfs_buf *, struct xfs_log_item *);
+void xfs_trans_buf_set_type(struct xfs_trans *, struct xfs_buf *,
+ enum xfs_blft);
+void xfs_trans_buf_copy_type(struct xfs_buf *dst_bp, struct xfs_buf *src_bp);
+
#endif /* __KERNEL__ */
#endif /* __XFS_BUF_ITEM_H__ */