Re: [PATCH 21/63] xfs: map an inode's offset to an exact physical block
From: Darrick J. Wong <hidden>
Date: 2016-09-30 17:31:03
Also in:
linux-fsdevel
From: Darrick J. Wong <hidden>
Date: 2016-09-30 17:31:03
Also in:
linux-fsdevel
On Fri, Sep 30, 2016 at 12:31:07AM -0700, Christoph Hellwig wrote:
quoted
+ * For a remap operation, just "allocate" an extent at the address that the + * caller passed in, and ensure that the AGFL is the right size. The caller + * will then map the "allocated" extent into the file somewhere. + */ +STATIC int +xfs_bmap_remap_alloc( + struct xfs_bmalloca *ap) +{ + struct xfs_trans *tp = ap->tp; + struct xfs_mount *mp = tp->t_mountp; + xfs_agblock_t bno; + struct xfs_alloc_arg args; + int error; + + /* + * validate that the block number is legal - the enables us to detect + * and handle a silent filesystem corruption rather than crashing. + */ + memset(&args, 0, sizeof(struct xfs_alloc_arg)); + args.tp = ap->tp; + args.mp = ap->tp->t_mountp; + bno = *ap->firstblock; + args.agno = XFS_FSB_TO_AGNO(mp, bno); + ASSERT(args.agno < mp->m_sb.sb_agcount); + args.agbno = XFS_FSB_TO_AGBNO(mp, bno); + ASSERT(args.agbno < mp->m_sb.sb_agblocks);Shouldn't this return -EFSCORRUPED instead? Otherwise the comment above isn't really true.
Hmm, yes. I'll fix that up. --D
Otherwise this looks fine to me: Reviewed-by: Christoph Hellwig <hch@lst.de>