Commit d4380177 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong
Browse files

xfs: move locking into xfs_bmap_punch_delalloc_range



Both callers want the same looking, so do it only once.

Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 03625721
Loading
Loading
Loading
Loading
+0 −2
Original line number Original line Diff line number Diff line
@@ -760,10 +760,8 @@ xfs_aops_discard_page(
		"page discard on page "PTR_FMT", inode 0x%llx, offset %llu.",
		"page discard on page "PTR_FMT", inode 0x%llx, offset %llu.",
			page, ip->i_ino, offset);
			page, ip->i_ino, offset);


	xfs_ilock(ip, XFS_ILOCK_EXCL);
	error = xfs_bmap_punch_delalloc_range(ip, start_fsb,
	error = xfs_bmap_punch_delalloc_range(ip, start_fsb,
			PAGE_SIZE / i_blocksize(inode));
			PAGE_SIZE / i_blocksize(inode));
	xfs_iunlock(ip, XFS_ILOCK_EXCL);
	if (error && !XFS_FORCED_SHUTDOWN(mp))
	if (error && !XFS_FORCED_SHUTDOWN(mp))
		xfs_alert(mp, "page discard unable to remove delalloc mapping.");
		xfs_alert(mp, "page discard unable to remove delalloc mapping.");
out_invalidate:
out_invalidate:
+5 −4
Original line number Original line Diff line number Diff line
@@ -702,16 +702,15 @@ xfs_bmap_punch_delalloc_range(
	struct xfs_iext_cursor	icur;
	struct xfs_iext_cursor	icur;
	int			error = 0;
	int			error = 0;


	ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
	xfs_ilock(ip, XFS_ILOCK_EXCL);

	if (!(ifp->if_flags & XFS_IFEXTENTS)) {
	if (!(ifp->if_flags & XFS_IFEXTENTS)) {
		error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK);
		error = xfs_iread_extents(NULL, ip, XFS_DATA_FORK);
		if (error)
		if (error)
			return error;
			goto out_unlock;
	}
	}


	if (!xfs_iext_lookup_extent_before(ip, ifp, &end_fsb, &icur, &got))
	if (!xfs_iext_lookup_extent_before(ip, ifp, &end_fsb, &icur, &got))
		return 0;
		goto out_unlock;


	while (got.br_startoff + got.br_blockcount > start_fsb) {
	while (got.br_startoff + got.br_blockcount > start_fsb) {
		del = got;
		del = got;
@@ -735,6 +734,8 @@ xfs_bmap_punch_delalloc_range(
			break;
			break;
	}
	}


out_unlock:
	xfs_iunlock(ip, XFS_ILOCK_EXCL);
	return error;
	return error;
}
}


+0 −3
Original line number Original line Diff line number Diff line
@@ -1204,11 +1204,8 @@ xfs_file_iomap_end_delalloc(
		truncate_pagecache_range(VFS_I(ip), XFS_FSB_TO_B(mp, start_fsb),
		truncate_pagecache_range(VFS_I(ip), XFS_FSB_TO_B(mp, start_fsb),
					 XFS_FSB_TO_B(mp, end_fsb) - 1);
					 XFS_FSB_TO_B(mp, end_fsb) - 1);


		xfs_ilock(ip, XFS_ILOCK_EXCL);
		error = xfs_bmap_punch_delalloc_range(ip, start_fsb,
		error = xfs_bmap_punch_delalloc_range(ip, start_fsb,
					       end_fsb - start_fsb);
					       end_fsb - start_fsb);
		xfs_iunlock(ip, XFS_ILOCK_EXCL);

		if (error && !XFS_FORCED_SHUTDOWN(mp)) {
		if (error && !XFS_FORCED_SHUTDOWN(mp)) {
			xfs_alert(mp, "%s: unable to clean up ino %lld",
			xfs_alert(mp, "%s: unable to clean up ino %lld",
				__func__, ip->i_ino);
				__func__, ip->i_ino);