Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit bb86d21c authored by Jie Liu's avatar Jie Liu Committed by Ben Myers
Browse files

xfs: fix the extent count when allocating an new indirection array entry



At xfs_iext_add(), if extent(s) are being appended to the last page in
the indirection array and the new extent(s) don't fit in the page, the
number of extents(erp->er_extcount) in a new allocated entry should be
the minimum value between count and XFS_LINEAR_EXTS, instead of count.

For now, there is no existing test case can demonstrates a problem with
the er_extcount being set incorrectly here, but it obviously like a bug.

Signed-off-by: default avatarJie Liu <jeff.liu@oracle.com>
Reviewed-by: default avatarBen Myers <bpm@sgi.com>
Signed-off-by: default avatarBen Myers <bpm@sgi.com>
parent 10e6e65d
Loading
Loading
Loading
Loading
+4 −5
Original line number Diff line number Diff line
@@ -1021,18 +1021,17 @@ xfs_iext_add(
		 * the next index needed in the indirection array.
		 */
		else {
			int	count = ext_diff;
			uint	count = ext_diff;

			while (count) {
				erp = xfs_iext_irec_new(ifp, erp_idx);
				erp->er_extcount = count;
				count -= MIN(count, (int)XFS_LINEAR_EXTS);
				if (count) {
				erp->er_extcount = min(count, XFS_LINEAR_EXTS);
				count -= erp->er_extcount;
				if (count)
					erp_idx++;
			}
		}
	}
	}
	ifp->if_bytes = new_size;
}