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

Commit 6044e438 authored by Dave Chinner's avatar Dave Chinner
Browse files

Merge branch 'xfs-misc-fixes-for-3.19-2' into for-next

Conflicts:
	fs/xfs/xfs_iops.c
parents c14fc013 b29c70f5
Loading
Loading
Loading
Loading
+25 −43
Original line number Original line Diff line number Diff line
@@ -5447,13 +5447,11 @@ xfs_bmse_merge(
	struct xfs_btree_cur		*cur,
	struct xfs_btree_cur		*cur,
	int				*logflags)	/* output */
	int				*logflags)	/* output */
{
{
	struct xfs_ifork		*ifp;
	struct xfs_bmbt_irec		got;
	struct xfs_bmbt_irec		got;
	struct xfs_bmbt_irec		left;
	struct xfs_bmbt_irec		left;
	xfs_filblks_t			blockcount;
	xfs_filblks_t			blockcount;
	int				error, i;
	int				error, i;


	ifp = XFS_IFORK_PTR(ip, whichfork);
	xfs_bmbt_get_all(gotp, &got);
	xfs_bmbt_get_all(gotp, &got);
	xfs_bmbt_get_all(leftp, &left);
	xfs_bmbt_get_all(leftp, &left);
	blockcount = left.br_blockcount + got.br_blockcount;
	blockcount = left.br_blockcount + got.br_blockcount;
@@ -5486,32 +5484,25 @@ xfs_bmse_merge(
	error = xfs_bmbt_lookup_eq(cur, got.br_startoff, got.br_startblock,
	error = xfs_bmbt_lookup_eq(cur, got.br_startoff, got.br_startblock,
				   got.br_blockcount, &i);
				   got.br_blockcount, &i);
	if (error)
	if (error)
		goto out_error;
		return error;
	XFS_WANT_CORRUPTED_GOTO(i == 1, out_error);
	XFS_WANT_CORRUPTED_RETURN(i == 1);


	error = xfs_btree_delete(cur, &i);
	error = xfs_btree_delete(cur, &i);
	if (error)
	if (error)
		goto out_error;
		return error;
	XFS_WANT_CORRUPTED_GOTO(i == 1, out_error);
	XFS_WANT_CORRUPTED_RETURN(i == 1);


	/* lookup and update size of the previous extent */
	/* lookup and update size of the previous extent */
	error = xfs_bmbt_lookup_eq(cur, left.br_startoff, left.br_startblock,
	error = xfs_bmbt_lookup_eq(cur, left.br_startoff, left.br_startblock,
				   left.br_blockcount, &i);
				   left.br_blockcount, &i);
	if (error)
	if (error)
		goto out_error;
		return error;
	XFS_WANT_CORRUPTED_GOTO(i == 1, out_error);
	XFS_WANT_CORRUPTED_RETURN(i == 1);


	left.br_blockcount = blockcount;
	left.br_blockcount = blockcount;


	error = xfs_bmbt_update(cur, left.br_startoff, left.br_startblock,
	return xfs_bmbt_update(cur, left.br_startoff, left.br_startblock,
			       left.br_blockcount, left.br_state);
			       left.br_blockcount, left.br_state);
	if (error)
		goto out_error;

	return 0;

out_error:
	return error;
}
}


/*
/*
@@ -5541,20 +5532,13 @@ xfs_bmse_shift_one(
	startoff = got.br_startoff - offset_shift_fsb;
	startoff = got.br_startoff - offset_shift_fsb;


	/* delalloc extents should be prevented by caller */
	/* delalloc extents should be prevented by caller */
	XFS_WANT_CORRUPTED_GOTO(!isnullstartblock(got.br_startblock),
	XFS_WANT_CORRUPTED_RETURN(!isnullstartblock(got.br_startblock));
				out_error);


	/*
	/*
	 * If this is the first extent in the file, make sure there's enough
	 * Check for merge if we've got an extent to the left, otherwise make
	 * room at the start of the file and jump right to the shift as there's
	 * sure there's enough room at the start of the file for the shift.
	 * no left extent to merge.
	 */
	 */
	if (*current_ext == 0) {
	if (*current_ext) {
		if (got.br_startoff < offset_shift_fsb)
			return -EINVAL;
		goto shift_extent;
	}

		/* grab the left extent and check for a large enough hole */
		/* grab the left extent and check for a large enough hole */
		leftp = xfs_iext_get_ext(ifp, *current_ext - 1);
		leftp = xfs_iext_get_ext(ifp, *current_ext - 1);
		xfs_bmbt_get_all(leftp, &left);
		xfs_bmbt_get_all(leftp, &left);
@@ -5563,13 +5547,14 @@ xfs_bmse_shift_one(
			return -EINVAL;
			return -EINVAL;


		/* check whether to merge the extent or shift it down */
		/* check whether to merge the extent or shift it down */
	if (!xfs_bmse_can_merge(&left, &got, offset_shift_fsb))
		if (xfs_bmse_can_merge(&left, &got, offset_shift_fsb)) {
		goto shift_extent;
			return xfs_bmse_merge(ip, whichfork, offset_shift_fsb,

					      *current_ext, gotp, leftp, cur,
	return xfs_bmse_merge(ip, whichfork, offset_shift_fsb, *current_ext,
					      logflags);
			      gotp, leftp, cur, logflags);
		}
	} else if (got.br_startoff < offset_shift_fsb)
		return -EINVAL;


shift_extent:
	/*
	/*
	 * Increment the extent index for the next iteration, update the start
	 * Increment the extent index for the next iteration, update the start
	 * offset of the in-core extent and update the btree if applicable.
	 * offset of the in-core extent and update the btree if applicable.
@@ -5586,14 +5571,11 @@ xfs_bmse_shift_one(
				   got.br_blockcount, &i);
				   got.br_blockcount, &i);
	if (error)
	if (error)
		return error;
		return error;
	XFS_WANT_CORRUPTED_GOTO(i == 1, out_error);
	XFS_WANT_CORRUPTED_RETURN(i == 1);


	got.br_startoff = startoff;
	got.br_startoff = startoff;
	return xfs_bmbt_update(cur, got.br_startoff, got.br_startblock,
	return xfs_bmbt_update(cur, got.br_startoff, got.br_startblock,
				got.br_blockcount, got.br_state);
				got.br_blockcount, got.br_state);

out_error:
	return error;
}
}


/*
/*
+0 −4
Original line number Original line Diff line number Diff line
@@ -512,7 +512,6 @@ xfs_da3_root_split(
	struct xfs_buf		*bp;
	struct xfs_buf		*bp;
	struct xfs_inode	*dp;
	struct xfs_inode	*dp;
	struct xfs_trans	*tp;
	struct xfs_trans	*tp;
	struct xfs_mount	*mp;
	struct xfs_dir2_leaf	*leaf;
	struct xfs_dir2_leaf	*leaf;
	xfs_dablk_t		blkno;
	xfs_dablk_t		blkno;
	int			level;
	int			level;
@@ -532,7 +531,6 @@ xfs_da3_root_split(


	dp = args->dp;
	dp = args->dp;
	tp = args->trans;
	tp = args->trans;
	mp = state->mp;
	error = xfs_da_get_buf(tp, dp, blkno, -1, &bp, args->whichfork);
	error = xfs_da_get_buf(tp, dp, blkno, -1, &bp, args->whichfork);
	if (error)
	if (error)
		return error;
		return error;
@@ -2340,14 +2338,12 @@ xfs_da_shrink_inode(
	xfs_inode_t *dp;
	xfs_inode_t *dp;
	int done, error, w, count;
	int done, error, w, count;
	xfs_trans_t *tp;
	xfs_trans_t *tp;
	xfs_mount_t *mp;


	trace_xfs_da_shrink_inode(args);
	trace_xfs_da_shrink_inode(args);


	dp = args->dp;
	dp = args->dp;
	w = args->whichfork;
	w = args->whichfork;
	tp = args->trans;
	tp = args->trans;
	mp = dp->i_mount;
	count = args->geo->fsbcount;
	count = args->geo->fsbcount;
	for (;;) {
	for (;;) {
		/*
		/*
+16 −0
Original line number Original line Diff line number Diff line
@@ -34,6 +34,22 @@


struct xfs_name xfs_name_dotdot = { (unsigned char *)"..", 2, XFS_DIR3_FT_DIR };
struct xfs_name xfs_name_dotdot = { (unsigned char *)"..", 2, XFS_DIR3_FT_DIR };


/*
 * @mode, if set, indicates that the type field needs to be set up.
 * This uses the transformation from file mode to DT_* as defined in linux/fs.h
 * for file type specification. This will be propagated into the directory
 * structure if appropriate for the given operation and filesystem config.
 */
const unsigned char xfs_mode_to_ftype[S_IFMT >> S_SHIFT] = {
	[0]			= XFS_DIR3_FT_UNKNOWN,
	[S_IFREG >> S_SHIFT]    = XFS_DIR3_FT_REG_FILE,
	[S_IFDIR >> S_SHIFT]    = XFS_DIR3_FT_DIR,
	[S_IFCHR >> S_SHIFT]    = XFS_DIR3_FT_CHRDEV,
	[S_IFBLK >> S_SHIFT]    = XFS_DIR3_FT_BLKDEV,
	[S_IFIFO >> S_SHIFT]    = XFS_DIR3_FT_FIFO,
	[S_IFSOCK >> S_SHIFT]   = XFS_DIR3_FT_SOCK,
	[S_IFLNK >> S_SHIFT]    = XFS_DIR3_FT_SYMLINK,
};


/*
/*
 * ASCII case-insensitive (ie. A-Z) support for directories that was
 * ASCII case-insensitive (ie. A-Z) support for directories that was
+140 −0
Original line number Original line Diff line number Diff line
@@ -31,6 +31,12 @@ struct xfs_dir2_data_unused;


extern struct xfs_name	xfs_name_dotdot;
extern struct xfs_name	xfs_name_dotdot;


/*
 * directory filetype conversion tables.
 */
#define S_SHIFT 12
extern const unsigned char xfs_mode_to_ftype[];

/*
/*
 * directory operations vector for encode/decode routines
 * directory operations vector for encode/decode routines
 */
 */
@@ -177,4 +183,138 @@ extern const struct xfs_buf_ops xfs_dir3_leaf1_buf_ops;
extern const struct xfs_buf_ops xfs_dir3_free_buf_ops;
extern const struct xfs_buf_ops xfs_dir3_free_buf_ops;
extern const struct xfs_buf_ops xfs_dir3_data_buf_ops;
extern const struct xfs_buf_ops xfs_dir3_data_buf_ops;


/*
 * Directory offset/block conversion functions.
 *
 * DB blocks here are logical directory block numbers, not filesystem blocks.
 */

/*
 * Convert dataptr to byte in file space
 */
static inline xfs_dir2_off_t
xfs_dir2_dataptr_to_byte(xfs_dir2_dataptr_t dp)
{
	return (xfs_dir2_off_t)dp << XFS_DIR2_DATA_ALIGN_LOG;
}

/*
 * Convert byte in file space to dataptr.  It had better be aligned.
 */
static inline xfs_dir2_dataptr_t
xfs_dir2_byte_to_dataptr(xfs_dir2_off_t by)
{
	return (xfs_dir2_dataptr_t)(by >> XFS_DIR2_DATA_ALIGN_LOG);
}

/*
 * Convert byte in space to (DB) block
 */
static inline xfs_dir2_db_t
xfs_dir2_byte_to_db(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
{
	return (xfs_dir2_db_t)(by >> geo->blklog);
}

/*
 * Convert dataptr to a block number
 */
static inline xfs_dir2_db_t
xfs_dir2_dataptr_to_db(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp)
{
	return xfs_dir2_byte_to_db(geo, xfs_dir2_dataptr_to_byte(dp));
}

/*
 * Convert byte in space to offset in a block
 */
static inline xfs_dir2_data_aoff_t
xfs_dir2_byte_to_off(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
{
	return (xfs_dir2_data_aoff_t)(by & (geo->blksize - 1));
}

/*
 * Convert dataptr to a byte offset in a block
 */
static inline xfs_dir2_data_aoff_t
xfs_dir2_dataptr_to_off(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp)
{
	return xfs_dir2_byte_to_off(geo, xfs_dir2_dataptr_to_byte(dp));
}

/*
 * Convert block and offset to byte in space
 */
static inline xfs_dir2_off_t
xfs_dir2_db_off_to_byte(struct xfs_da_geometry *geo, xfs_dir2_db_t db,
			xfs_dir2_data_aoff_t o)
{
	return ((xfs_dir2_off_t)db << geo->blklog) + o;
}

/*
 * Convert block (DB) to block (dablk)
 */
static inline xfs_dablk_t
xfs_dir2_db_to_da(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
{
	return (xfs_dablk_t)(db << (geo->blklog - geo->fsblog));
}

/*
 * Convert byte in space to (DA) block
 */
static inline xfs_dablk_t
xfs_dir2_byte_to_da(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
{
	return xfs_dir2_db_to_da(geo, xfs_dir2_byte_to_db(geo, by));
}

/*
 * Convert block and offset to dataptr
 */
static inline xfs_dir2_dataptr_t
xfs_dir2_db_off_to_dataptr(struct xfs_da_geometry *geo, xfs_dir2_db_t db,
			   xfs_dir2_data_aoff_t o)
{
	return xfs_dir2_byte_to_dataptr(xfs_dir2_db_off_to_byte(geo, db, o));
}

/*
 * Convert block (dablk) to block (DB)
 */
static inline xfs_dir2_db_t
xfs_dir2_da_to_db(struct xfs_da_geometry *geo, xfs_dablk_t da)
{
	return (xfs_dir2_db_t)(da >> (geo->blklog - geo->fsblog));
}

/*
 * Convert block (dablk) to byte offset in space
 */
static inline xfs_dir2_off_t
xfs_dir2_da_to_byte(struct xfs_da_geometry *geo, xfs_dablk_t da)
{
	return xfs_dir2_db_off_to_byte(geo, xfs_dir2_da_to_db(geo, da), 0);
}

/*
 * Directory tail pointer accessor functions. Based on block geometry.
 */
static inline struct xfs_dir2_block_tail *
xfs_dir2_block_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_data_hdr *hdr)
{
	return ((struct xfs_dir2_block_tail *)
		((char *)hdr + geo->blksize)) - 1;
}

static inline struct xfs_dir2_leaf_tail *
xfs_dir2_leaf_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_leaf *lp)
{
	return (struct xfs_dir2_leaf_tail *)
		((char *)lp + geo->blksize -
		  sizeof(struct xfs_dir2_leaf_tail));
}

#endif	/* __XFS_DIR2_H__ */
#endif	/* __XFS_DIR2_H__ */
+0 −8
Original line number Original line Diff line number Diff line
@@ -350,7 +350,6 @@ xfs_dir2_block_addname(
	int			low;		/* low index for binary srch */
	int			low;		/* low index for binary srch */
	int			lowstale;	/* low stale index */
	int			lowstale;	/* low stale index */
	int			mid=0;		/* midpoint for binary srch */
	int			mid=0;		/* midpoint for binary srch */
	xfs_mount_t		*mp;		/* filesystem mount point */
	int			needlog;	/* need to log header */
	int			needlog;	/* need to log header */
	int			needscan;	/* need to rescan freespace */
	int			needscan;	/* need to rescan freespace */
	__be16			*tagp;		/* pointer to tag value */
	__be16			*tagp;		/* pointer to tag value */
@@ -360,7 +359,6 @@ xfs_dir2_block_addname(


	dp = args->dp;
	dp = args->dp;
	tp = args->trans;
	tp = args->trans;
	mp = dp->i_mount;


	/* Read the (one and only) directory block into bp. */
	/* Read the (one and only) directory block into bp. */
	error = xfs_dir3_block_read(tp, dp, &bp);
	error = xfs_dir3_block_read(tp, dp, &bp);
@@ -615,7 +613,6 @@ xfs_dir2_block_lookup(
	xfs_inode_t		*dp;		/* incore inode */
	xfs_inode_t		*dp;		/* incore inode */
	int			ent;		/* entry index */
	int			ent;		/* entry index */
	int			error;		/* error return value */
	int			error;		/* error return value */
	xfs_mount_t		*mp;		/* filesystem mount point */


	trace_xfs_dir2_block_lookup(args);
	trace_xfs_dir2_block_lookup(args);


@@ -626,7 +623,6 @@ xfs_dir2_block_lookup(
	if ((error = xfs_dir2_block_lookup_int(args, &bp, &ent)))
	if ((error = xfs_dir2_block_lookup_int(args, &bp, &ent)))
		return error;
		return error;
	dp = args->dp;
	dp = args->dp;
	mp = dp->i_mount;
	hdr = bp->b_addr;
	hdr = bp->b_addr;
	xfs_dir3_data_check(dp, bp);
	xfs_dir3_data_check(dp, bp);
	btp = xfs_dir2_block_tail_p(args->geo, hdr);
	btp = xfs_dir2_block_tail_p(args->geo, hdr);
@@ -767,7 +763,6 @@ xfs_dir2_block_removename(
	xfs_inode_t		*dp;		/* incore inode */
	xfs_inode_t		*dp;		/* incore inode */
	int			ent;		/* block leaf entry index */
	int			ent;		/* block leaf entry index */
	int			error;		/* error return value */
	int			error;		/* error return value */
	xfs_mount_t		*mp;		/* filesystem mount point */
	int			needlog;	/* need to log block header */
	int			needlog;	/* need to log block header */
	int			needscan;	/* need to fixup bestfree */
	int			needscan;	/* need to fixup bestfree */
	xfs_dir2_sf_hdr_t	sfh;		/* shortform header */
	xfs_dir2_sf_hdr_t	sfh;		/* shortform header */
@@ -785,7 +780,6 @@ xfs_dir2_block_removename(
	}
	}
	dp = args->dp;
	dp = args->dp;
	tp = args->trans;
	tp = args->trans;
	mp = dp->i_mount;
	hdr = bp->b_addr;
	hdr = bp->b_addr;
	btp = xfs_dir2_block_tail_p(args->geo, hdr);
	btp = xfs_dir2_block_tail_p(args->geo, hdr);
	blp = xfs_dir2_block_leaf_p(btp);
	blp = xfs_dir2_block_leaf_p(btp);
@@ -849,7 +843,6 @@ xfs_dir2_block_replace(
	xfs_inode_t		*dp;		/* incore inode */
	xfs_inode_t		*dp;		/* incore inode */
	int			ent;		/* leaf entry index */
	int			ent;		/* leaf entry index */
	int			error;		/* error return value */
	int			error;		/* error return value */
	xfs_mount_t		*mp;		/* filesystem mount point */


	trace_xfs_dir2_block_replace(args);
	trace_xfs_dir2_block_replace(args);


@@ -861,7 +854,6 @@ xfs_dir2_block_replace(
		return error;
		return error;
	}
	}
	dp = args->dp;
	dp = args->dp;
	mp = dp->i_mount;
	hdr = bp->b_addr;
	hdr = bp->b_addr;
	btp = xfs_dir2_block_tail_p(args->geo, hdr);
	btp = xfs_dir2_block_tail_p(args->geo, hdr);
	blp = xfs_dir2_block_leaf_p(btp);
	blp = xfs_dir2_block_leaf_p(btp);
Loading