diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2016-08-03 12:09:48 +1000 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2016-08-03 12:09:48 +1000 |
commit | 9e88b5d86703bb836d33dcd0c70eb59e049c80c7 (patch) | |
tree | 123f5b81adf8a7da7cb4d3e0a18f1de2afd5b4c0 /fs/xfs/xfs_rmap_item.c | |
parent | 5880f2d78ff17c6ee7c7f6d4071bfd13090c264c (diff) | |
download | linux-stable-9e88b5d86703bb836d33dcd0c70eb59e049c80c7.tar.gz linux-stable-9e88b5d86703bb836d33dcd0c70eb59e049c80c7.tar.bz2 linux-stable-9e88b5d86703bb836d33dcd0c70eb59e049c80c7.zip |
xfs: log rmap intent items
Provide a mechanism for higher levels to create RUI/RUD items, submit
them to the log, and a stub function to deal with recovered RUI items.
These parts will be connected to the rmapbt in a later patch.
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_rmap_item.c')
-rw-r--r-- | fs/xfs/xfs_rmap_item.c | 60 |
1 files changed, 60 insertions, 0 deletions
diff --git a/fs/xfs/xfs_rmap_item.c b/fs/xfs/xfs_rmap_item.c index 5398b8478f02..fecd1e4d688d 100644 --- a/fs/xfs/xfs_rmap_item.c +++ b/fs/xfs/xfs_rmap_item.c @@ -22,6 +22,7 @@ #include "xfs_format.h" #include "xfs_log_format.h" #include "xfs_trans_resv.h" +#include "xfs_bit.h" #include "xfs_mount.h" #include "xfs_trans.h" #include "xfs_trans_priv.h" @@ -457,3 +458,62 @@ xfs_rud_init( return rudp; } + +/* + * Process an rmap update intent item that was recovered from the log. + * We need to update the rmapbt. + */ +int +xfs_rui_recover( + struct xfs_mount *mp, + struct xfs_rui_log_item *ruip) +{ + int i; + int error = 0; + struct xfs_map_extent *rmap; + xfs_fsblock_t startblock_fsb; + bool op_ok; + + ASSERT(!test_bit(XFS_RUI_RECOVERED, &ruip->rui_flags)); + + /* + * First check the validity of the extents described by the + * RUI. If any are bad, then assume that all are bad and + * just toss the RUI. + */ + for (i = 0; i < ruip->rui_format.rui_nextents; i++) { + rmap = &(ruip->rui_format.rui_extents[i]); + startblock_fsb = XFS_BB_TO_FSB(mp, + XFS_FSB_TO_DADDR(mp, rmap->me_startblock)); + switch (rmap->me_flags & XFS_RMAP_EXTENT_TYPE_MASK) { + case XFS_RMAP_EXTENT_MAP: + case XFS_RMAP_EXTENT_UNMAP: + case XFS_RMAP_EXTENT_CONVERT: + case XFS_RMAP_EXTENT_ALLOC: + case XFS_RMAP_EXTENT_FREE: + op_ok = true; + break; + default: + op_ok = false; + break; + } + if (!op_ok || (startblock_fsb == 0) || + (rmap->me_len == 0) || + (startblock_fsb >= mp->m_sb.sb_dblocks) || + (rmap->me_len >= mp->m_sb.sb_agblocks) || + (rmap->me_flags & ~XFS_RMAP_EXTENT_FLAGS)) { + /* + * This will pull the RUI from the AIL and + * free the memory associated with it. + */ + set_bit(XFS_RUI_RECOVERED, &ruip->rui_flags); + xfs_rui_release(ruip); + return -EIO; + } + } + + /* XXX: do nothing for now */ + set_bit(XFS_RUI_RECOVERED, &ruip->rui_flags); + xfs_rui_release(ruip); + return error; +} |