Message ID | 20240423111735.1298851-1-yi.zhang@huaweicloud.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | None | expand |
On Tue, Apr 23, 2024 at 07:17:35PM +0800, Zhang Yi wrote: > + if ((flags & IOMAP_ZERO) && imap.br_startoff <= offset_fsb && > + isnullstartblock(imap.br_startblock)) { > + xfs_fileoff_t eof_fsb = XFS_B_TO_FSB(mp, XFS_ISIZE(ip)); > + > + if (offset_fsb >= eof_fsb) > + goto convert_delay; > + if (end_fsb > eof_fsb) { > + end_fsb = eof_fsb; > + xfs_trim_extent(&imap, offset_fsb, end_fsb - offset_fsb); Nit: overly long line here. I've also tried to to a more comprehensive review, but this depends on the rest of the series, which isn't in my linux-xfs folder for April. I've your're not doing and instant revision it's usually much easier to just review the whole series.
On 2024/4/25 20:22, Christoph Hellwig wrote: > On Tue, Apr 23, 2024 at 07:17:35PM +0800, Zhang Yi wrote: >> + if ((flags & IOMAP_ZERO) && imap.br_startoff <= offset_fsb && >> + isnullstartblock(imap.br_startblock)) { >> + xfs_fileoff_t eof_fsb = XFS_B_TO_FSB(mp, XFS_ISIZE(ip)); >> + >> + if (offset_fsb >= eof_fsb) >> + goto convert_delay; >> + if (end_fsb > eof_fsb) { >> + end_fsb = eof_fsb; >> + xfs_trim_extent(&imap, offset_fsb, end_fsb - offset_fsb); > > Nit: overly long line here. > > I've also tried to to a more comprehensive review, but this depends on > the rest of the series, which isn't in my linux-xfs folder for April. > > I've your're not doing and instant revision it's usually much easier to > just review the whole series. > . > Sure, I will resend the whole series. Thanks, Yi.
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c index 236ee78aa75b..ab398cb3680a 100644 --- a/fs/xfs/xfs_iomap.c +++ b/fs/xfs/xfs_iomap.c @@ -1022,6 +1022,23 @@ xfs_buffered_write_iomap_begin( goto out_unlock; } + /* + * For zeroing, trim a delalloc extent that extends beyond the EOF + * block. If it starts beyond the EOF block, convert it to an + * unwritten extent. + */ + if ((flags & IOMAP_ZERO) && imap.br_startoff <= offset_fsb && + isnullstartblock(imap.br_startblock)) { + xfs_fileoff_t eof_fsb = XFS_B_TO_FSB(mp, XFS_ISIZE(ip)); + + if (offset_fsb >= eof_fsb) + goto convert_delay; + if (end_fsb > eof_fsb) { + end_fsb = eof_fsb; + xfs_trim_extent(&imap, offset_fsb, end_fsb - offset_fsb); + } + } + /* * Search the COW fork extent list even if we did not find a data fork * extent. This serves two purposes: first this implements the @@ -1167,6 +1184,17 @@ xfs_buffered_write_iomap_begin( xfs_iunlock(ip, lockmode); return xfs_bmbt_to_iomap(ip, iomap, &imap, flags, 0, seq); +convert_delay: + xfs_iunlock(ip, lockmode); + truncate_pagecache(inode, offset); + error = xfs_bmapi_convert_delalloc(ip, XFS_DATA_FORK, offset, + iomap, NULL); + if (error) + return error; + + trace_xfs_iomap_alloc(ip, offset, count, XFS_DATA_FORK, &imap); + return 0; + found_cow: seq = xfs_iomap_inode_sequence(ip, 0); if (imap.br_startoff <= offset_fsb) {