xfs: make xfs_bmapi_remapi work with attribute forks
Add a new flags argument to xfs_bmapi_remapi so that we can pass BMAPI flags into the function. This enables us to pass in BMAPI_ATTRFORK so that we can remap things into the attribute fork. Eventually the online repair code will use this to rebuild attribute forks, so make it non-static. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com>
This commit is contained in:
parent
9f3a080ef1
commit
7cf199ba5a
2 changed files with 20 additions and 12 deletions
|
@ -4520,30 +4520,34 @@ xfs_bmapi_write(
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
int
|
||||||
xfs_bmapi_remap(
|
xfs_bmapi_remap(
|
||||||
struct xfs_trans *tp,
|
struct xfs_trans *tp,
|
||||||
struct xfs_inode *ip,
|
struct xfs_inode *ip,
|
||||||
xfs_fileoff_t bno,
|
xfs_fileoff_t bno,
|
||||||
xfs_filblks_t len,
|
xfs_filblks_t len,
|
||||||
xfs_fsblock_t startblock,
|
xfs_fsblock_t startblock,
|
||||||
struct xfs_defer_ops *dfops)
|
struct xfs_defer_ops *dfops,
|
||||||
|
int flags)
|
||||||
{
|
{
|
||||||
struct xfs_mount *mp = ip->i_mount;
|
struct xfs_mount *mp = ip->i_mount;
|
||||||
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
|
struct xfs_ifork *ifp;
|
||||||
struct xfs_btree_cur *cur = NULL;
|
struct xfs_btree_cur *cur = NULL;
|
||||||
xfs_fsblock_t firstblock = NULLFSBLOCK;
|
xfs_fsblock_t firstblock = NULLFSBLOCK;
|
||||||
struct xfs_bmbt_irec got;
|
struct xfs_bmbt_irec got;
|
||||||
struct xfs_iext_cursor icur;
|
struct xfs_iext_cursor icur;
|
||||||
|
int whichfork = xfs_bmapi_whichfork(flags);
|
||||||
int logflags = 0, error;
|
int logflags = 0, error;
|
||||||
|
|
||||||
|
ifp = XFS_IFORK_PTR(ip, whichfork);
|
||||||
ASSERT(len > 0);
|
ASSERT(len > 0);
|
||||||
ASSERT(len <= (xfs_filblks_t)MAXEXTLEN);
|
ASSERT(len <= (xfs_filblks_t)MAXEXTLEN);
|
||||||
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
|
ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
|
||||||
|
ASSERT(!(flags & ~(XFS_BMAPI_ATTRFORK)));
|
||||||
|
|
||||||
if (unlikely(XFS_TEST_ERROR(
|
if (unlikely(XFS_TEST_ERROR(
|
||||||
(XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_EXTENTS &&
|
(XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_EXTENTS &&
|
||||||
XFS_IFORK_FORMAT(ip, XFS_DATA_FORK) != XFS_DINODE_FMT_BTREE),
|
XFS_IFORK_FORMAT(ip, whichfork) != XFS_DINODE_FMT_BTREE),
|
||||||
mp, XFS_ERRTAG_BMAPIFORMAT))) {
|
mp, XFS_ERRTAG_BMAPIFORMAT))) {
|
||||||
XFS_ERROR_REPORT("xfs_bmapi_remap", XFS_ERRLEVEL_LOW, mp);
|
XFS_ERROR_REPORT("xfs_bmapi_remap", XFS_ERRLEVEL_LOW, mp);
|
||||||
return -EFSCORRUPTED;
|
return -EFSCORRUPTED;
|
||||||
|
@ -4553,7 +4557,7 @@ xfs_bmapi_remap(
|
||||||
return -EIO;
|
return -EIO;
|
||||||
|
|
||||||
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
|
if (!(ifp->if_flags & XFS_IFEXTENTS)) {
|
||||||
error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK);
|
error = xfs_iread_extents(tp, ip, whichfork);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -4568,7 +4572,7 @@ xfs_bmapi_remap(
|
||||||
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
|
xfs_trans_log_inode(tp, ip, XFS_ILOG_CORE);
|
||||||
|
|
||||||
if (ifp->if_flags & XFS_IFBROOT) {
|
if (ifp->if_flags & XFS_IFBROOT) {
|
||||||
cur = xfs_bmbt_init_cursor(mp, tp, ip, XFS_DATA_FORK);
|
cur = xfs_bmbt_init_cursor(mp, tp, ip, whichfork);
|
||||||
cur->bc_private.b.firstblock = firstblock;
|
cur->bc_private.b.firstblock = firstblock;
|
||||||
cur->bc_private.b.dfops = dfops;
|
cur->bc_private.b.dfops = dfops;
|
||||||
cur->bc_private.b.flags = 0;
|
cur->bc_private.b.flags = 0;
|
||||||
|
@ -4579,16 +4583,16 @@ xfs_bmapi_remap(
|
||||||
got.br_blockcount = len;
|
got.br_blockcount = len;
|
||||||
got.br_state = XFS_EXT_NORM;
|
got.br_state = XFS_EXT_NORM;
|
||||||
|
|
||||||
error = xfs_bmap_add_extent_hole_real(tp, ip, XFS_DATA_FORK, &icur,
|
error = xfs_bmap_add_extent_hole_real(tp, ip, whichfork, &icur,
|
||||||
&cur, &got, &firstblock, dfops, &logflags, 0);
|
&cur, &got, &firstblock, dfops, &logflags, flags);
|
||||||
if (error)
|
if (error)
|
||||||
goto error0;
|
goto error0;
|
||||||
|
|
||||||
if (xfs_bmap_wants_extents(ip, XFS_DATA_FORK)) {
|
if (xfs_bmap_wants_extents(ip, whichfork)) {
|
||||||
int tmp_logflags = 0;
|
int tmp_logflags = 0;
|
||||||
|
|
||||||
error = xfs_bmap_btree_to_extents(tp, ip, cur,
|
error = xfs_bmap_btree_to_extents(tp, ip, cur,
|
||||||
&tmp_logflags, XFS_DATA_FORK);
|
&tmp_logflags, whichfork);
|
||||||
logflags |= tmp_logflags;
|
logflags |= tmp_logflags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6162,7 +6166,7 @@ xfs_bmap_finish_one(
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case XFS_BMAP_MAP:
|
case XFS_BMAP_MAP:
|
||||||
error = xfs_bmapi_remap(tp, ip, startoff, *blockcount,
|
error = xfs_bmapi_remap(tp, ip, startoff, *blockcount,
|
||||||
startblock, dfops);
|
startblock, dfops, 0);
|
||||||
*blockcount = 0;
|
*blockcount = 0;
|
||||||
break;
|
break;
|
||||||
case XFS_BMAP_UNMAP:
|
case XFS_BMAP_UNMAP:
|
||||||
|
|
|
@ -297,4 +297,8 @@ static inline int xfs_bmap_fork_to_state(int whichfork)
|
||||||
xfs_failaddr_t xfs_bmap_validate_extent(struct xfs_inode *ip, int whichfork,
|
xfs_failaddr_t xfs_bmap_validate_extent(struct xfs_inode *ip, int whichfork,
|
||||||
struct xfs_bmbt_irec *irec);
|
struct xfs_bmbt_irec *irec);
|
||||||
|
|
||||||
|
int xfs_bmapi_remap(struct xfs_trans *tp, struct xfs_inode *ip,
|
||||||
|
xfs_fileoff_t bno, xfs_filblks_t len, xfs_fsblock_t startblock,
|
||||||
|
struct xfs_defer_ops *dfops, int flags);
|
||||||
|
|
||||||
#endif /* __XFS_BMAP_H__ */
|
#endif /* __XFS_BMAP_H__ */
|
||||||
|
|
Loading…
Add table
Reference in a new issue