Skip to content

Commit 8f04c47

Browse files
author
Christoph Hellwig
committed
xfs: split xfs_itruncate_finish
Split the guts of xfs_itruncate_finish that loop over the existing extents and calls xfs_bunmapi on them into a new helper, xfs_itruncate_externs. Make xfs_attr_inactive call it directly instead of xfs_itruncate_finish, which allows to simplify the latter a lot, by only letting it deal with the data fork. As a result xfs_itruncate_finish is renamed to xfs_itruncate_data to make its use case more obvious. Also remove the sync parameter from xfs_itruncate_data, which has been unessecary since the introduction of the busy extent list in 2002, and completely dead code since 2003 when the XFS_BMAPI_ASYNC parameter was made a no-op. I can't actually see why the xfs_attr_inactive needs to set the transaction sync, but let's keep this patch simple and without changes in behaviour. Also avoid passing a useless argument to xfs_isize_check, and make it private to xfs_inode.c. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Alex Elder <[email protected]> Reviewed-by: Dave Chinner <[email protected]>
1 parent 857b977 commit 8f04c47

File tree

7 files changed

+155
-277
lines changed

7 files changed

+155
-277
lines changed

fs/xfs/linux-2.6/xfs_iops.c

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -879,15 +879,7 @@ xfs_setattr_size(
879879
ip->i_size = iattr->ia_size;
880880
} else if (iattr->ia_size <= ip->i_size ||
881881
(iattr->ia_size == 0 && ip->i_d.di_nextents)) {
882-
/*
883-
* Signal a sync transaction unless we are truncating an
884-
* already unlinked file on a wsync filesystem.
885-
*/
886-
error = xfs_itruncate_finish(&tp, ip, iattr->ia_size,
887-
XFS_DATA_FORK,
888-
((ip->i_d.di_nlink != 0 ||
889-
!(mp->m_flags & XFS_MOUNT_WSYNC))
890-
? 1 : 0));
882+
error = xfs_itruncate_data(&tp, ip, iattr->ia_size);
891883
if (error)
892884
goto out_trans_abort;
893885

fs/xfs/linux-2.6/xfs_trace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,8 +1055,8 @@ DECLARE_EVENT_CLASS(xfs_itrunc_class,
10551055
DEFINE_EVENT(xfs_itrunc_class, name, \
10561056
TP_PROTO(struct xfs_inode *ip, xfs_fsize_t new_size), \
10571057
TP_ARGS(ip, new_size))
1058-
DEFINE_ITRUNC_EVENT(xfs_itruncate_finish_start);
1059-
DEFINE_ITRUNC_EVENT(xfs_itruncate_finish_end);
1058+
DEFINE_ITRUNC_EVENT(xfs_itruncate_data_start);
1059+
DEFINE_ITRUNC_EVENT(xfs_itruncate_data_end);
10601060

10611061
TRACE_EVENT(xfs_pagecache_inval,
10621062
TP_PROTO(struct xfs_inode *ip, xfs_off_t start, xfs_off_t finish),

fs/xfs/quota/xfs_qm_syscalls.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ xfs_qm_scall_trunc_qfile(
263263
xfs_ilock(ip, XFS_ILOCK_EXCL);
264264
xfs_trans_ijoin(tp, ip);
265265

266-
error = xfs_itruncate_finish(&tp, ip, 0, XFS_DATA_FORK, 1);
266+
error = xfs_itruncate_data(&tp, ip, 0);
267267
if (error) {
268268
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES |
269269
XFS_TRANS_ABORT);

fs/xfs/xfs_attr.c

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -822,17 +822,21 @@ xfs_attr_inactive(xfs_inode_t *dp)
822822
error = xfs_attr_root_inactive(&trans, dp);
823823
if (error)
824824
goto out;
825+
825826
/*
826-
* signal synchronous inactive transactions unless this
827-
* is a synchronous mount filesystem in which case we
828-
* know that we're here because we've been called out of
829-
* xfs_inactive which means that the last reference is gone
830-
* and the unlink transaction has already hit the disk so
831-
* async inactive transactions are safe.
827+
* Signal synchronous inactive transactions unless this is a
828+
* synchronous mount filesystem in which case we know that we're here
829+
* because we've been called out of xfs_inactive which means that the
830+
* last reference is gone and the unlink transaction has already hit
831+
* the disk so async inactive transactions are safe.
832832
*/
833-
if ((error = xfs_itruncate_finish(&trans, dp, 0LL, XFS_ATTR_FORK,
834-
(!(mp->m_flags & XFS_MOUNT_WSYNC)
835-
? 1 : 0))))
833+
if (!(mp->m_flags & XFS_MOUNT_WSYNC)) {
834+
if (dp->i_d.di_anextents > 0)
835+
xfs_trans_set_sync(trans);
836+
}
837+
838+
error = xfs_itruncate_extents(&trans, dp, XFS_ATTR_FORK, 0);
839+
if (error)
836840
goto out;
837841

838842
/*

0 commit comments

Comments
 (0)