Skip to content

Commit

Permalink
Merge branch 'xfs-misc-fixes-for-3.19-2' into for-next
Browse files Browse the repository at this point in the history
Conflicts:
	fs/xfs/xfs_iops.c
  • Loading branch information
Dave Chinner committed Dec 3, 2014
2 parents c14fc01 + b29c70f commit 6044e43
Show file tree
Hide file tree
Showing 24 changed files with 271 additions and 386 deletions.
68 changes: 25 additions & 43 deletions fs/xfs/libxfs/xfs_bmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -5447,13 +5447,11 @@ xfs_bmse_merge(
struct xfs_btree_cur *cur,
int *logflags) /* output */
{
struct xfs_ifork *ifp;
struct xfs_bmbt_irec got;
struct xfs_bmbt_irec left;
xfs_filblks_t blockcount;
int error, i;

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

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

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

left.br_blockcount = blockcount;

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

return 0;

out_error:
return error;
return xfs_bmbt_update(cur, left.br_startoff, left.br_startblock,
left.br_blockcount, left.br_state);
}

/*
Expand Down Expand Up @@ -5541,35 +5532,29 @@ xfs_bmse_shift_one(
startoff = got.br_startoff - offset_shift_fsb;

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

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

/* grab the left extent and check for a large enough hole */
leftp = xfs_iext_get_ext(ifp, *current_ext - 1);
xfs_bmbt_get_all(leftp, &left);
if (startoff < left.br_startoff + left.br_blockcount)
return -EINVAL;

if (startoff < left.br_startoff + left.br_blockcount)
/* check whether to merge the extent or shift it down */
if (xfs_bmse_can_merge(&left, &got, offset_shift_fsb)) {
return xfs_bmse_merge(ip, whichfork, offset_shift_fsb,
*current_ext, gotp, leftp, cur,
logflags);
}
} else if (got.br_startoff < offset_shift_fsb)
return -EINVAL;

/* check whether to merge the extent or shift it down */
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, logflags);

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

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

out_error:
return error;
}

/*
Expand Down
4 changes: 0 additions & 4 deletions fs/xfs/libxfs/xfs_da_btree.c
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,6 @@ xfs_da3_root_split(
struct xfs_buf *bp;
struct xfs_inode *dp;
struct xfs_trans *tp;
struct xfs_mount *mp;
struct xfs_dir2_leaf *leaf;
xfs_dablk_t blkno;
int level;
Expand All @@ -532,7 +531,6 @@ xfs_da3_root_split(

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

trace_xfs_da_shrink_inode(args);

dp = args->dp;
w = args->whichfork;
tp = args->trans;
mp = dp->i_mount;
count = args->geo->fsbcount;
for (;;) {
/*
Expand Down
16 changes: 16 additions & 0 deletions fs/xfs/libxfs/xfs_dir2.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,22 @@

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
Expand Down
140 changes: 140 additions & 0 deletions fs/xfs/libxfs/xfs_dir2.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ struct xfs_dir2_data_unused;

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
*/
Expand Down Expand Up @@ -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_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__ */
8 changes: 0 additions & 8 deletions fs/xfs/libxfs/xfs_dir2_block.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,6 @@ xfs_dir2_block_addname(
int low; /* low index for binary srch */
int lowstale; /* low stale index */
int mid=0; /* midpoint for binary srch */
xfs_mount_t *mp; /* filesystem mount point */
int needlog; /* need to log header */
int needscan; /* need to rescan freespace */
__be16 *tagp; /* pointer to tag value */
Expand All @@ -360,7 +359,6 @@ xfs_dir2_block_addname(

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

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

trace_xfs_dir2_block_lookup(args);

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

trace_xfs_dir2_block_replace(args);

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

0 comments on commit 6044e43

Please sign in to comment.