Commit 17a85dc6 authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: use the xfs_da_args owner field to set new dir/attr block owner



When we're creating leaf, data, freespace, or dabtree blocks for
directories and xattrs, use the explicit owner field (instead of the
xfs_inode) to set the owner field.  This will enable online repair to
construct replacement data structures in a temporary file without having
to change the owner fields prior to swapping the new and old structures.

Signed-off-by: default avatarDarrick J. Wong <djwong@kernel.org>
Reviewed-by: default avatarChristoph Hellwig <hch@lst.de>
parent 9eef772f
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1239,7 +1239,7 @@ xfs_attr3_leaf_create(
		ichdr.magic = XFS_ATTR3_LEAF_MAGIC;

		hdr3->blkno = cpu_to_be64(xfs_buf_daddr(bp));
		hdr3->owner = cpu_to_be64(dp->i_ino);
		hdr3->owner = cpu_to_be64(args->owner);
		uuid_copy(&hdr3->uuid, &mp->m_sb.sb_meta_uuid);

		ichdr.freemap[0].base = sizeof(struct xfs_attr3_leaf_hdr);
+2 −2
Original line number Diff line number Diff line
@@ -522,8 +522,8 @@ xfs_attr_rmtval_set_value(
			return error;
		bp->b_ops = &xfs_attr3_rmt_buf_ops;

		xfs_attr_rmtval_copyin(mp, bp, args->dp->i_ino, &offset,
				       &valuelen, &src);
		xfs_attr_rmtval_copyin(mp, bp, args->owner, &offset, &valuelen,
				&src);

		error = xfs_bwrite(bp);	/* GROT: NOTE: synchronous write */
		xfs_buf_relse(bp);
+1 −1
Original line number Diff line number Diff line
@@ -486,7 +486,7 @@ xfs_da3_node_create(
		memset(hdr3, 0, sizeof(struct xfs_da3_node_hdr));
		ichdr.magic = XFS_DA3_NODE_MAGIC;
		hdr3->info.blkno = cpu_to_be64(xfs_buf_daddr(bp));
		hdr3->info.owner = cpu_to_be64(args->dp->i_ino);
		hdr3->info.owner = cpu_to_be64(args->owner);
		uuid_copy(&hdr3->info.uuid, &mp->m_sb.sb_meta_uuid);
	} else {
		ichdr.magic = XFS_DA_NODE_MAGIC;
+10 −9
Original line number Diff line number Diff line
@@ -163,11 +163,12 @@ xfs_dir3_block_read(

static void
xfs_dir3_block_init(
	struct xfs_mount	*mp,
	struct xfs_trans	*tp,
	struct xfs_buf		*bp,
	struct xfs_inode	*dp)
	struct xfs_da_args	*args,
	struct xfs_buf		*bp)
{
	struct xfs_trans	*tp = args->trans;
	struct xfs_inode	*dp = args->dp;
	struct xfs_mount	*mp = dp->i_mount;
	struct xfs_dir3_blk_hdr	*hdr3 = bp->b_addr;

	bp->b_ops = &xfs_dir3_block_buf_ops;
@@ -177,7 +178,7 @@ xfs_dir3_block_init(
		memset(hdr3, 0, sizeof(*hdr3));
		hdr3->magic = cpu_to_be32(XFS_DIR3_BLOCK_MAGIC);
		hdr3->blkno = cpu_to_be64(xfs_buf_daddr(bp));
		hdr3->owner = cpu_to_be64(dp->i_ino);
		hdr3->owner = cpu_to_be64(args->owner);
		uuid_copy(&hdr3->uuid, &mp->m_sb.sb_meta_uuid);
		return;

@@ -1009,7 +1010,7 @@ xfs_dir2_leaf_to_block(
	/*
	 * Start converting it to block form.
	 */
	xfs_dir3_block_init(mp, tp, dbp, dp);
	xfs_dir3_block_init(args, dbp);

	needlog = 1;
	needscan = 0;
@@ -1129,7 +1130,7 @@ xfs_dir2_sf_to_block(
	error = xfs_dir3_data_init(args, blkno, &bp);
	if (error)
		goto out_free;
	xfs_dir3_block_init(mp, tp, bp, dp);
	xfs_dir3_block_init(args, bp);
	hdr = bp->b_addr;

	/*
@@ -1169,7 +1170,7 @@ xfs_dir2_sf_to_block(
	 * Create entry for .
	 */
	dep = bp->b_addr + offset;
	dep->inumber = cpu_to_be64(dp->i_ino);
	dep->inumber = cpu_to_be64(args->owner);
	dep->namelen = 1;
	dep->name[0] = '.';
	xfs_dir2_data_put_ftype(mp, dep, XFS_DIR3_FT_DIR);
+1 −1
Original line number Diff line number Diff line
@@ -725,7 +725,7 @@ xfs_dir3_data_init(
		memset(hdr3, 0, sizeof(*hdr3));
		hdr3->magic = cpu_to_be32(XFS_DIR3_DATA_MAGIC);
		hdr3->blkno = cpu_to_be64(xfs_buf_daddr(bp));
		hdr3->owner = cpu_to_be64(dp->i_ino);
		hdr3->owner = cpu_to_be64(args->owner);
		uuid_copy(&hdr3->uuid, &mp->m_sb.sb_meta_uuid);

	} else
Loading