Skip to content

Commit

Permalink
xfs: split xfs_itruncate_finish
Browse files Browse the repository at this point in the history
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 <hch@lst.de>
Reviewed-by: Alex Elder <aelder@sgi.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
  • Loading branch information
Christoph Hellwig committed Jul 8, 2011
1 parent 857b977 commit 8f04c47
Show file tree
Hide file tree
Showing 7 changed files with 155 additions and 277 deletions.
10 changes: 1 addition & 9 deletions fs/xfs/linux-2.6/xfs_iops.c
Original file line number Diff line number Diff line change
Expand Up @@ -879,15 +879,7 @@ xfs_setattr_size(
ip->i_size = iattr->ia_size;
} else if (iattr->ia_size <= ip->i_size ||
(iattr->ia_size == 0 && ip->i_d.di_nextents)) {
/*
* Signal a sync transaction unless we are truncating an
* already unlinked file on a wsync filesystem.
*/
error = xfs_itruncate_finish(&tp, ip, iattr->ia_size,
XFS_DATA_FORK,
((ip->i_d.di_nlink != 0 ||
!(mp->m_flags & XFS_MOUNT_WSYNC))
? 1 : 0));
error = xfs_itruncate_data(&tp, ip, iattr->ia_size);
if (error)
goto out_trans_abort;

Expand Down
4 changes: 2 additions & 2 deletions fs/xfs/linux-2.6/xfs_trace.h
Original file line number Diff line number Diff line change
Expand Up @@ -1055,8 +1055,8 @@ DECLARE_EVENT_CLASS(xfs_itrunc_class,
DEFINE_EVENT(xfs_itrunc_class, name, \
TP_PROTO(struct xfs_inode *ip, xfs_fsize_t new_size), \
TP_ARGS(ip, new_size))
DEFINE_ITRUNC_EVENT(xfs_itruncate_finish_start);
DEFINE_ITRUNC_EVENT(xfs_itruncate_finish_end);
DEFINE_ITRUNC_EVENT(xfs_itruncate_data_start);
DEFINE_ITRUNC_EVENT(xfs_itruncate_data_end);

TRACE_EVENT(xfs_pagecache_inval,
TP_PROTO(struct xfs_inode *ip, xfs_off_t start, xfs_off_t finish),
Expand Down
2 changes: 1 addition & 1 deletion fs/xfs/quota/xfs_qm_syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ xfs_qm_scall_trunc_qfile(
xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip);

error = xfs_itruncate_finish(&tp, ip, 0, XFS_DATA_FORK, 1);
error = xfs_itruncate_data(&tp, ip, 0);
if (error) {
xfs_trans_cancel(tp, XFS_TRANS_RELEASE_LOG_RES |
XFS_TRANS_ABORT);
Expand Down
22 changes: 13 additions & 9 deletions fs/xfs/xfs_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,17 +822,21 @@ xfs_attr_inactive(xfs_inode_t *dp)
error = xfs_attr_root_inactive(&trans, dp);
if (error)
goto out;

/*
* signal synchronous inactive transactions unless this
* is a synchronous mount filesystem in which case we
* know that we're here because we've been called out of
* xfs_inactive which means that the last reference is gone
* and the unlink transaction has already hit the disk so
* async inactive transactions are safe.
* Signal synchronous inactive transactions unless this is a
* synchronous mount filesystem in which case we know that we're here
* because we've been called out of xfs_inactive which means that the
* last reference is gone and the unlink transaction has already hit
* the disk so async inactive transactions are safe.
*/
if ((error = xfs_itruncate_finish(&trans, dp, 0LL, XFS_ATTR_FORK,
(!(mp->m_flags & XFS_MOUNT_WSYNC)
? 1 : 0))))
if (!(mp->m_flags & XFS_MOUNT_WSYNC)) {
if (dp->i_d.di_anextents > 0)
xfs_trans_set_sync(trans);
}

error = xfs_itruncate_extents(&trans, dp, XFS_ATTR_FORK, 0);
if (error)
goto out;

/*
Expand Down
Loading

0 comments on commit 8f04c47

Please sign in to comment.