Re: [PATCH V3 06/10] xfs: Check for extent overflow when writing to unwritten extent

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Aug 20, 2020 at 11:13:45AM +0530, Chandan Babu R wrote:
> A write to a sub-interval of an existing unwritten extent causes
> the original extent to be split into 3 extents
> i.e. | Unwritten | Real | Unwritten |
> Hence extent count can increase by 2.
> 
> Signed-off-by: Chandan Babu R <chandanrlinux@xxxxxxxxx>

Seems fine to me,
Reviewed-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>

--D

> ---
>  fs/xfs/libxfs/xfs_inode_fork.h | 7 +++++++
>  fs/xfs/xfs_iomap.c             | 5 +++++
>  2 files changed, 12 insertions(+)
> 
> diff --git a/fs/xfs/libxfs/xfs_inode_fork.h b/fs/xfs/libxfs/xfs_inode_fork.h
> index f686c7418d2b..83ff90e2a5fe 100644
> --- a/fs/xfs/libxfs/xfs_inode_fork.h
> +++ b/fs/xfs/libxfs/xfs_inode_fork.h
> @@ -66,6 +66,13 @@ struct xfs_ifork {
>   */
>  #define XFS_IEXT_DIR_MANIP_CNT(mp) \
>  	((XFS_DA_NODE_MAXDEPTH + 1 + 1) * (mp)->m_dir_geo->fsbcount)
> +/*
> + * A write to a sub-interval of an existing unwritten extent causes the original
> + * extent to be split into 3 extents
> + * i.e. | Unwritten | Real | Unwritten |
> + * Hence extent count can increase by 2.
> + */
> +#define XFS_IEXT_WRITE_UNWRITTEN_CNT	(2)
>  
>  /*
>   * Fork handling.
> diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
> index 37b0c743c116..694b25fbb4a3 100644
> --- a/fs/xfs/xfs_iomap.c
> +++ b/fs/xfs/xfs_iomap.c
> @@ -566,6 +566,11 @@ xfs_iomap_write_unwritten(
>  		if (error)
>  			goto error_on_bmapi_transaction;
>  
> +		error = xfs_iext_count_may_overflow(ip, XFS_DATA_FORK,
> +				XFS_IEXT_WRITE_UNWRITTEN_CNT);
> +		if (error)
> +			goto error_on_bmapi_transaction;
> +
>  		/*
>  		 * Modify the unwritten extent state of the buffer.
>  		 */
> -- 
> 2.28.0
> 



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux