On Tue, Jan 06, 2015 at 05:28:39PM +0100, Christoph Hellwig wrote:
> Current xfs_bmapi_write always allocates blocks when it encounters a
> hole. But for unwritten extent conversions we do not have the proper
> transaction reservations to do that, and should error out instead.
>
> Currently this doesn't matter too much because the writeback path
> ensures that all blocks are properly allocated, but the pNFS block
> server code will accept unwritten extent conversions from clients,
> and in case of recovery from a crashed server we might get conversion
> requests for blocks whose allocation transaction hasn't made it to
> disk before the crash. Also in general it is a good idea to be
> defensive here, especially for client initiated requests.
>
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> ---
> fs/xfs/libxfs/xfs_bmap.c | 15 +++++++++++++++
> fs/xfs/xfs_iomap.c | 17 ++++++-----------
> 2 files changed, 21 insertions(+), 11 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index b5eb474..be08671 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -4580,6 +4580,20 @@ xfs_bmapi_write(
> * that we found, if any.
> */
> if (inhole || wasdelay) {
> + if ((flags & (XFS_BMAPI_CONVERT|XFS_BMAPI_PREALLOC)) ==
> + XFS_BMAPI_CONVERT) {
> + xfs_filblks_t count;
> +
> + if (eof)
> + bma.got.br_startoff = end;
> +
> + count = XFS_FILBLKS_MIN(len,
> + bma.got.br_startoff - bno);
> + bno += count;
> + len -= count;
> + goto next;
> + }
Please add a comment to the code explaining why this check is needed.
Cheers,
Dave.
--
Dave Chinner
david@xxxxxxxxxxxxx
|