Skip to content

Commit

Permalink
xfs: fix the extent count when allocating an new indirection array entry
Browse files Browse the repository at this point in the history
commit bb86d21 upstream.

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: Jie Liu <jeff.liu@oracle.com>
Reviewed-by: Ben Myers <bpm@sgi.com>
Signed-off-by: Ben Myers <bpm@sgi.com>

Signed-off-by: Jiri Slaby <jslaby@suse.cz>
  • Loading branch information
Jie Liu authored and Jiri Slaby committed Jul 4, 2014
1 parent 9af7672 commit 67820ad
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions fs/xfs/xfs_inode_fork.c
Original file line number Diff line number Diff line change
Expand Up @@ -1031,15 +1031,14 @@ 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++;
}
}
}
}
Expand Down

0 comments on commit 67820ad

Please sign in to comment.