Commit fed7e6c8 authored by Long Li's avatar Long Li
Browse files

xfs: make bunmapi observe forcealigin

hulk inclusion
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I9VTE3


CVE: NA

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

When unmapping a file with forced alignment, the unmap operation must align
to the extent hint size. Within a single extent hint size unit, there cannot
be both written and unwritten extents.

Signed-off-by: default avatarLong Li <leo.lilong@huawei.com>
parent 8f6f9b09
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -5288,6 +5288,12 @@ __xfs_bunmapi(
	XFS_STATS_INC(mp, xs_blk_unmap);
	isrt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip);
	end = start + len;
	if (xfs_inode_forcealign(ip) && ip->i_d.di_extsize > 1
			&& S_ISREG(VFS_I(ip)->i_mode)) {
		start = roundup_64(start, ip->i_d.di_extsize);
		end = rounddown_64(end, ip->i_d.di_extsize);
		len  = end - start;
	}

	if (!xfs_iext_lookup_extent_before(ip, ifp, &end, &icur, &got)) {
		*rlen = 0;