Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d75afeb3 authored by Dave Chinner's avatar Dave Chinner Committed by Ben Myers
Browse files

xfs: add buffer types to directory and attribute buffers



Add buffer types to the buffer log items so that log recovery can
validate the buffers and calculate CRCs correctly after the buffers
are recovered.

Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarBen Myers <bpm@sgi.com>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent d2e448d5
Loading
Loading
Loading
Loading
+8 −1
Original line number Diff line number Diff line
@@ -271,8 +271,13 @@ xfs_attr3_leaf_read(
	xfs_daddr_t		mappedbno,
	struct xfs_buf		**bpp)
{
	return xfs_da_read_buf(tp, dp, bno, mappedbno, bpp,
	int			err;

	err = xfs_da_read_buf(tp, dp, bno, mappedbno, bpp,
				XFS_ATTR_FORK, &xfs_attr3_leaf_buf_ops);
	if (!err && tp)
		xfs_trans_buf_set_type(tp, *bpp, XFS_BLF_ATTR_LEAF_BUF);
	return err;
}

/*========================================================================
@@ -1078,6 +1083,7 @@ xfs_attr3_leaf_to_node(
		goto out;

	/* copy leaf to new buffer, update identifiers */
	xfs_trans_buf_set_type(args->trans, bp2, XFS_BLF_ATTR_LEAF_BUF);
	bp2->b_ops = bp1->b_ops;
	memcpy(bp2->b_addr, bp1->b_addr, XFS_LBSIZE(mp));
	if (xfs_sb_version_hascrc(&mp->m_sb)) {
@@ -1140,6 +1146,7 @@ xfs_attr3_leaf_create(
	if (error)
		return error;
	bp->b_ops = &xfs_attr3_leaf_buf_ops;
	xfs_trans_buf_set_type(args->trans, bp, XFS_BLF_ATTR_LEAF_BUF);
	leaf = bp->b_addr;
	memset(leaf, 0, XFS_LBSIZE(mp));

+2 −0
Original line number Diff line number Diff line
@@ -37,6 +37,8 @@ struct xfs_attr3_rmt_hdr {
	((bufsize) - (xfs_sb_version_hascrc(&(mp)->m_sb) ? \
			sizeof(struct xfs_attr3_rmt_hdr) : 0))

extern const struct xfs_buf_ops xfs_attr3_rmt_buf_ops;

int xfs_attr_rmtval_get(struct xfs_da_args *args);
int xfs_attr_rmtval_set(struct xfs_da_args *args);
int xfs_attr_rmtval_remove(struct xfs_da_args *args);
+17 −1
Original line number Diff line number Diff line
@@ -50,6 +50,14 @@ extern kmem_zone_t *xfs_buf_item_zone;
#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 | \
@@ -60,7 +68,15 @@ extern kmem_zone_t *xfs_buf_item_zone;
		 XFS_BLF_AGFL_BUF | \
		 XFS_BLF_AGI_BUF | \
		 XFS_BLF_DINO_BUF | \
		 XFS_BLF_SYMLINK_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
+43 −3
Original line number Diff line number Diff line
@@ -292,7 +292,6 @@ const struct xfs_buf_ops xfs_da3_node_buf_ops = {
	.verify_write = xfs_da3_node_write_verify,
};


int
xfs_da3_node_read(
	struct xfs_trans	*tp,
@@ -302,8 +301,35 @@ xfs_da3_node_read(
	struct xfs_buf		**bpp,
	int			which_fork)
{
	return xfs_da_read_buf(tp, dp, bno, mappedbno, bpp,
	int			err;

	err = xfs_da_read_buf(tp, dp, bno, mappedbno, bpp,
					which_fork, &xfs_da3_node_buf_ops);
	if (!err && tp) {
		struct xfs_da_blkinfo	*info = (*bpp)->b_addr;
		int			type;

		switch (be16_to_cpu(info->magic)) {
		case XFS_DA3_NODE_MAGIC:
		case XFS_DA_NODE_MAGIC:
			type = XFS_BLF_DA_NODE_BUF;
			break;
		case XFS_ATTR_LEAF_MAGIC:
		case XFS_ATTR3_LEAF_MAGIC:
			type = XFS_BLF_ATTR_LEAF_BUF;
			break;
		case XFS_DIR2_LEAFN_MAGIC:
		case XFS_DIR3_LEAFN_MAGIC:
			type = XFS_BLF_DIR_LEAFN_BUF;
			break;
		default:
			type = 0;
			ASSERT(0);
			break;
		}
		xfs_trans_buf_set_type(tp, *bpp, type);
	}
	return err;
}

/*========================================================================
@@ -334,6 +360,8 @@ xfs_da3_node_create(
	error = xfs_da_get_buf(tp, args->dp, blkno, -1, &bp, whichfork);
	if (error)
		return(error);
	bp->b_ops = &xfs_da3_node_buf_ops;
	xfs_trans_buf_set_type(tp, bp, XFS_BLF_DA_NODE_BUF);
	node = bp->b_addr;

	if (xfs_sb_version_hascrc(&mp->m_sb)) {
@@ -352,7 +380,6 @@ xfs_da3_node_create(
	xfs_trans_log_buf(tp, bp,
		XFS_DA_LOGRANGE(node, &node->hdr, xfs_da3_node_hdr_size(node)));

	bp->b_ops = &xfs_da3_node_buf_ops;
	*bpp = bp;
	return(0);
}
@@ -565,6 +592,12 @@ xfs_da3_root_split(
		btree = xfs_da3_node_tree_p(oldroot);
		size = (int)((char *)&btree[nodehdr.count] - (char *)oldroot);
		level = nodehdr.level;

		/*
		 * we are about to copy oldroot to bp, so set up the type
		 * of bp while we know exactly what it will be.
		 */
		xfs_trans_buf_set_type(tp, bp, XFS_BLF_DA_NODE_BUF);
	} else {
		struct xfs_dir3_icleaf_hdr leafhdr;
		struct xfs_dir2_leaf_entry *ents;
@@ -577,6 +610,12 @@ xfs_da3_root_split(
		       leafhdr.magic == XFS_DIR3_LEAFN_MAGIC);
		size = (int)((char *)&ents[leafhdr.count] - (char *)leaf);
		level = 0;

		/*
		 * we are about to copy oldroot to bp, so set up the type
		 * of bp while we know exactly what it will be.
		 */
		xfs_trans_buf_set_type(tp, bp, XFS_BLF_DIR_LEAFN_BUF);
	}

	/*
@@ -1092,6 +1131,7 @@ xfs_da3_root_join(
	 */
	memcpy(root_blk->bp->b_addr, bp->b_addr, state->blocksize);
	root_blk->bp->b_ops = bp->b_ops;
	xfs_trans_buf_copy_type(root_blk->bp, bp);
	if (oldroothdr.magic == XFS_DA3_NODE_MAGIC) {
		struct xfs_da3_blkinfo *da3 = root_blk->bp->b_addr;
		da3->blkno = cpu_to_be64(root_blk->bp->b_bn);
+2 −0
Original line number Diff line number Diff line
@@ -301,6 +301,8 @@ int xfs_da3_node_read(struct xfs_trans *tp, struct xfs_inode *dp,
			 xfs_dablk_t bno, xfs_daddr_t mappedbno,
			 struct xfs_buf **bpp, int which_fork);

extern const struct xfs_buf_ops xfs_da3_node_buf_ops;

/*
 * Utility routines.
 */
Loading