Re: [PATCH] xfs: fix the judgment of whether the file already has extents

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

 



On Sun, Oct 27, 2024 at 02:01:16AM +0800, alexjlzheng@xxxxxxxxx wrote:
> From: Jinliang Zheng <alexjlzheng@xxxxxxxxxxx>
> 
> When we call create(), lseek() and write() sequentially, offset != 0
> cannot be used as a judgment condition for whether the file already
> has extents.
> 
> This patch uses prev.br_startoff instead of offset != 0.
> 
> Signed-off-by: Jinliang Zheng <alexjlzheng@xxxxxxxxxxx>
> ---
>  fs/xfs/libxfs/xfs_bmap.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 36dd08d13293..94e7aeed9e95 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -3536,7 +3536,7 @@ xfs_bmap_btalloc_at_eof(
>  	 * or it's the first allocation in a file, just try for a stripe aligned
>  	 * allocation.
>  	 */
> -	if (ap->offset) {
> +	if (ap->prev.br_startoff != NULLFILEOFF) {
>  		xfs_extlen_t	nextminlen = 0;

Makes sense, but the logic is not correct. See xfs_bmap_adjacent()
on how it sets up the ap->blkno target for exact eof bno allocation.

-Dave.
-- 
Dave Chinner
david@xxxxxxxxxxxxx




[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