Commit 0335402b authored by John Garry's avatar John Garry Committed by Long Li
Browse files

xfs: Don't revert allocated offset for forcealign

maillist inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I9VTE3
CVE: NA

Reference: https://lore.kernel.org/linux-xfs/20240705162450.3481169-1-john.g.garry@oracle.com



--------------------------------

In xfs_bmap_process_allocated_extent(), for when we found that we could not
provide the requested length completely, the mapping is moved so that we
can provide as much as possible for the original request.

For forcealign, this would mean ignoring alignment guaranteed, so don't do
this.

Fixes: 63f4d844 ("fs: xfs: Make file data allocations observe the 'forcealign' flag")
Reviewed-by: default avatar"Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: default avatarJohn Garry <john.g.garry@oracle.com>
Signed-off-by: default avatarLong Li <leo.lilong@huawei.com>
parent 936d7de5
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -3686,10 +3686,12 @@ xfs_bmap_btalloc(
		 * very fragmented so we're unlikely to be able to satisfy the
		 * hints anyway.
		 */
		if (!(xfs_inode_forcealign(ap->ip) && align)) {
			if (ap->length <= orig_length)
				ap->offset = orig_offset;
			else if (ap->offset + ap->length < orig_offset + orig_length)
				ap->offset = orig_offset + orig_length - ap->length;
		}
		xfs_bmap_btalloc_accounting(ap, &args);
	} else {
		ap->blkno = NULLFSBLOCK;