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

Commit 8f66193c authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner
Browse files

xfs: convert m_dirblksize to xfs_da_geometry

parent d6cf1305
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -2169,8 +2169,8 @@ xfs_da3_swap_lastblock(
	/*
	 * Copy the last block into the dead buffer and log it.
	 */
	memcpy(dead_buf->b_addr, last_buf->b_addr, mp->m_dirblksize);
	xfs_trans_log_buf(tp, dead_buf, 0, mp->m_dirblksize - 1);
	memcpy(dead_buf->b_addr, last_buf->b_addr, args->geo->blksize);
	xfs_trans_log_buf(tp, dead_buf, 0, args->geo->blksize - 1);
	dead_info = dead_buf->b_addr;
	/*
	 * Get values from the moved block.
+18 −18
Original line number Diff line number Diff line
@@ -427,9 +427,9 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr)
 * Directory Leaf block operations
 */
static int
xfs_dir2_max_leaf_ents(struct xfs_mount *mp)
xfs_dir2_max_leaf_ents(struct xfs_da_geometry *geo)
{
	return (mp->m_dirblksize - sizeof(struct xfs_dir2_leaf_hdr)) /
	return (geo->blksize - sizeof(struct xfs_dir2_leaf_hdr)) /
		(uint)sizeof(struct xfs_dir2_leaf_entry);
}

@@ -440,9 +440,9 @@ xfs_dir2_leaf_ents_p(struct xfs_dir2_leaf *lp)
}

static int
xfs_dir3_max_leaf_ents(struct xfs_mount *mp)
xfs_dir3_max_leaf_ents(struct xfs_da_geometry *geo)
{
	return (mp->m_dirblksize - sizeof(struct xfs_dir3_leaf_hdr)) /
	return (geo->blksize - sizeof(struct xfs_dir3_leaf_hdr)) /
		(uint)sizeof(struct xfs_dir2_leaf_entry);
}

@@ -593,9 +593,9 @@ xfs_da3_node_hdr_to_disk(
 * Directory free space block operations
 */
static int
xfs_dir2_free_max_bests(struct xfs_mount *mp)
xfs_dir2_free_max_bests(struct xfs_da_geometry *geo)
{
	return (mp->m_dirblksize - sizeof(struct xfs_dir2_free_hdr)) /
	return (geo->blksize - sizeof(struct xfs_dir2_free_hdr)) /
		sizeof(xfs_dir2_data_off_t);
}

@@ -609,25 +609,25 @@ xfs_dir2_free_bests_p(struct xfs_dir2_free *free)
 * Convert data space db to the corresponding free db.
 */
static xfs_dir2_db_t
xfs_dir2_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db)
xfs_dir2_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
{
	return xfs_dir2_byte_to_db(mp->m_dir_geo, XFS_DIR2_FREE_OFFSET) +
			(db / xfs_dir2_free_max_bests(mp));
	return xfs_dir2_byte_to_db(geo, XFS_DIR2_FREE_OFFSET) +
			(db / xfs_dir2_free_max_bests(geo));
}

/*
 * Convert data space db to the corresponding index in a free db.
 */
static int
xfs_dir2_db_to_fdindex(struct xfs_mount *mp, xfs_dir2_db_t db)
xfs_dir2_db_to_fdindex(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
{
	return db % xfs_dir2_free_max_bests(mp);
	return db % xfs_dir2_free_max_bests(geo);
}

static int
xfs_dir3_free_max_bests(struct xfs_mount *mp)
xfs_dir3_free_max_bests(struct xfs_da_geometry *geo)
{
	return (mp->m_dirblksize - sizeof(struct xfs_dir3_free_hdr)) /
	return (geo->blksize - sizeof(struct xfs_dir3_free_hdr)) /
		sizeof(xfs_dir2_data_off_t);
}

@@ -641,19 +641,19 @@ xfs_dir3_free_bests_p(struct xfs_dir2_free *free)
 * Convert data space db to the corresponding free db.
 */
static xfs_dir2_db_t
xfs_dir3_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db)
xfs_dir3_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
{
	return xfs_dir2_byte_to_db(mp->m_dir_geo, XFS_DIR2_FREE_OFFSET) +
			(db / xfs_dir3_free_max_bests(mp));
	return xfs_dir2_byte_to_db(geo, XFS_DIR2_FREE_OFFSET) +
			(db / xfs_dir3_free_max_bests(geo));
}

/*
 * Convert data space db to the corresponding index in a free db.
 */
static int
xfs_dir3_db_to_fdindex(struct xfs_mount *mp, xfs_dir2_db_t db)
xfs_dir3_db_to_fdindex(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
{
	return db % xfs_dir3_free_max_bests(mp);
	return db % xfs_dir3_free_max_bests(geo);
}

static void
+2 −3
Original line number Diff line number Diff line
@@ -145,7 +145,6 @@ xfs_da_mount(
		mp->m_dirnameops = &xfs_default_nameops;

	/* XXX: these are to be removed as code is converted to use geo */
	mp->m_dirblksize = mp->m_dir_geo->blksize;
	mp->m_dir_node_ents = mp->m_dir_geo->node_ents;
	mp->m_dir_magicpct = mp->m_dir_geo->magicpct;
	mp->m_attr_node_ents = mp->m_attr_geo->node_ents;
@@ -665,8 +664,8 @@ xfs_dir2_isblock(
	mp = dp->i_mount;
	if ((rval = xfs_bmap_last_offset(dp, &last, XFS_DATA_FORK)))
		return rval;
	rval = XFS_FSB_TO_B(mp, last) == mp->m_dirblksize;
	ASSERT(rval == 0 || dp->i_d.di_size == mp->m_dirblksize);
	rval = XFS_FSB_TO_B(mp, last) == mp->m_dir_geo->blksize;
	ASSERT(rval == 0 || dp->i_d.di_size == mp->m_dir_geo->blksize);
	*vp = rval;
	return 0;
}
+6 −4
Original line number Diff line number Diff line
@@ -80,7 +80,7 @@ struct xfs_dir_ops {
				    struct xfs_dir3_icleaf_hdr *from);
	void	(*leaf_hdr_from_disk)(struct xfs_dir3_icleaf_hdr *to,
				      struct xfs_dir2_leaf *from);
	int	(*leaf_max_ents)(struct xfs_mount *mp);
	int	(*leaf_max_ents)(struct xfs_da_geometry *geo);
	struct xfs_dir2_leaf_entry *
		(*leaf_ents_p)(struct xfs_dir2_leaf *lp);

@@ -97,10 +97,12 @@ struct xfs_dir_ops {
				    struct xfs_dir3_icfree_hdr *from);
	void	(*free_hdr_from_disk)(struct xfs_dir3_icfree_hdr *to,
				      struct xfs_dir2_free *from);
	int	(*free_max_bests)(struct xfs_mount *mp);
	int	(*free_max_bests)(struct xfs_da_geometry *geo);
	__be16 * (*free_bests_p)(struct xfs_dir2_free *free);
	xfs_dir2_db_t (*db_to_fdb)(struct xfs_mount *mp, xfs_dir2_db_t db);
	int	(*db_to_fdindex)(struct xfs_mount *mp, xfs_dir2_db_t db);
	xfs_dir2_db_t (*db_to_fdb)(struct xfs_da_geometry *geo,
				   xfs_dir2_db_t db);
	int	(*db_to_fdindex)(struct xfs_da_geometry *geo,
				 xfs_dir2_db_t db);
};

extern const struct xfs_dir_ops *
+16 −16
Original line number Diff line number Diff line
@@ -377,7 +377,7 @@ xfs_dir2_block_addname(
	 * Set up pointers to parts of the block.
	 */
	hdr = bp->b_addr;
	btp = xfs_dir2_block_tail_p(mp, hdr);
	btp = xfs_dir2_block_tail_p(args->geo, hdr);
	blp = xfs_dir2_block_leaf_p(btp);

	/*
@@ -581,7 +581,7 @@ xfs_dir2_block_log_leaf(
	xfs_dir2_leaf_entry_t	*blp;
	xfs_dir2_block_tail_t	*btp;

	btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr);
	btp = xfs_dir2_block_tail_p(tp->t_mountp->m_dir_geo, hdr);
	blp = xfs_dir2_block_leaf_p(btp);
	xfs_trans_log_buf(tp, bp, (uint)((char *)&blp[first] - (char *)hdr),
		(uint)((char *)&blp[last + 1] - (char *)hdr - 1));
@@ -598,7 +598,7 @@ xfs_dir2_block_log_tail(
	xfs_dir2_data_hdr_t	*hdr = bp->b_addr;
	xfs_dir2_block_tail_t	*btp;

	btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr);
	btp = xfs_dir2_block_tail_p(tp->t_mountp->m_dir_geo, hdr);
	xfs_trans_log_buf(tp, bp, (uint)((char *)btp - (char *)hdr),
		(uint)((char *)(btp + 1) - (char *)hdr - 1));
}
@@ -633,7 +633,7 @@ xfs_dir2_block_lookup(
	mp = dp->i_mount;
	hdr = bp->b_addr;
	xfs_dir3_data_check(dp, bp);
	btp = xfs_dir2_block_tail_p(mp, hdr);
	btp = xfs_dir2_block_tail_p(args->geo, hdr);
	blp = xfs_dir2_block_leaf_p(btp);
	/*
	 * Get the offset from the leaf entry, to point to the data.
@@ -686,7 +686,7 @@ xfs_dir2_block_lookup_int(

	hdr = bp->b_addr;
	xfs_dir3_data_check(dp, bp);
	btp = xfs_dir2_block_tail_p(mp, hdr);
	btp = xfs_dir2_block_tail_p(args->geo, hdr);
	blp = xfs_dir2_block_leaf_p(btp);
	/*
	 * Loop doing a binary search for our hash value.
@@ -791,7 +791,7 @@ xfs_dir2_block_removename(
	tp = args->trans;
	mp = dp->i_mount;
	hdr = bp->b_addr;
	btp = xfs_dir2_block_tail_p(mp, hdr);
	btp = xfs_dir2_block_tail_p(args->geo, hdr);
	blp = xfs_dir2_block_leaf_p(btp);
	/*
	 * Point to the data entry using the leaf entry.
@@ -867,7 +867,7 @@ xfs_dir2_block_replace(
	dp = args->dp;
	mp = dp->i_mount;
	hdr = bp->b_addr;
	btp = xfs_dir2_block_tail_p(mp, hdr);
	btp = xfs_dir2_block_tail_p(args->geo, hdr);
	blp = xfs_dir2_block_leaf_p(btp);
	/*
	 * Point to the data entry we need to change.
@@ -941,7 +941,7 @@ xfs_dir2_leaf_to_block(
	leaf = lbp->b_addr;
	dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
	ents = dp->d_ops->leaf_ents_p(leaf);
	ltp = xfs_dir2_leaf_tail_p(mp, leaf);
	ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);

	ASSERT(leafhdr.magic == XFS_DIR2_LEAF1_MAGIC ||
	       leafhdr.magic == XFS_DIR3_LEAF1_MAGIC);
@@ -951,13 +951,13 @@ xfs_dir2_leaf_to_block(
	 * been left behind during no-space-reservation operations.
	 * These will show up in the leaf bests table.
	 */
	while (dp->i_d.di_size > mp->m_dirblksize) {
	while (dp->i_d.di_size > args->geo->blksize) {
		int hdrsz;

		hdrsz = dp->d_ops->data_entry_offset;
		bestsp = xfs_dir2_leaf_bests_p(ltp);
		if (be16_to_cpu(bestsp[be32_to_cpu(ltp->bestcount) - 1]) ==
					    mp->m_dirblksize - hdrsz) {
					    args->geo->blksize - hdrsz) {
			if ((error =
			    xfs_dir2_leaf_trim_data(args, lbp,
				    (xfs_dir2_db_t)(be32_to_cpu(ltp->bestcount) - 1))))
@@ -985,7 +985,7 @@ xfs_dir2_leaf_to_block(
	/*
	 * Look at the last data entry.
	 */
	tagp = (__be16 *)((char *)hdr + mp->m_dirblksize) - 1;
	tagp = (__be16 *)((char *)hdr + args->geo->blksize) - 1;
	dup = (xfs_dir2_data_unused_t *)((char *)hdr + be16_to_cpu(*tagp));
	/*
	 * If it's not free or is too short we can't do it.
@@ -1004,12 +1004,12 @@ xfs_dir2_leaf_to_block(
	/*
	 * Use up the space at the end of the block (blp/btp).
	 */
	xfs_dir2_data_use_free(tp, dp, dbp, dup, mp->m_dirblksize - size, size,
	xfs_dir2_data_use_free(tp, dp, dbp, dup, args->geo->blksize - size, size,
		&needlog, &needscan);
	/*
	 * Initialize the block tail.
	 */
	btp = xfs_dir2_block_tail_p(mp, hdr);
	btp = xfs_dir2_block_tail_p(args->geo, hdr);
	btp->count = cpu_to_be32(leafhdr.count - leafhdr.stale);
	btp->stale = 0;
	xfs_dir2_block_log_tail(tp, dbp);
@@ -1143,13 +1143,13 @@ xfs_dir2_sf_to_block(
	 */
	dup = dp->d_ops->data_unused_p(hdr);
	needlog = needscan = 0;
	xfs_dir2_data_use_free(tp, dp, bp, dup, mp->m_dirblksize - i, i, &needlog,
		&needscan);
	xfs_dir2_data_use_free(tp, dp, bp, dup, args->geo->blksize - i,
			       i, &needlog, &needscan);
	ASSERT(needscan == 0);
	/*
	 * Fill in the tail.
	 */
	btp = xfs_dir2_block_tail_p(mp, hdr);
	btp = xfs_dir2_block_tail_p(args->geo, hdr);
	btp->count = cpu_to_be32(sfp->count + 2);	/* ., .. */
	btp->stale = 0;
	blp = xfs_dir2_block_leaf_p(btp);
Loading