Skip to content

Commit 54fbdd1

Browse files
Christoph Hellwigdjwong
authored andcommitted
xfs: factor out a new xfs_log_force_inode helper
Create a new helper to force the log up to the last LSN touching an inode. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Brian Foster <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent d9fdd0a commit 54fbdd1

File tree

4 files changed

+22
-24
lines changed

4 files changed

+22
-24
lines changed

fs/xfs/xfs_export.c

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
#include "xfs_trans.h"
1616
#include "xfs_inode_item.h"
1717
#include "xfs_icache.h"
18-
#include "xfs_log.h"
1918
#include "xfs_pnfs.h"
2019

2120
/*
@@ -221,18 +220,7 @@ STATIC int
221220
xfs_fs_nfs_commit_metadata(
222221
struct inode *inode)
223222
{
224-
struct xfs_inode *ip = XFS_I(inode);
225-
struct xfs_mount *mp = ip->i_mount;
226-
xfs_lsn_t lsn = 0;
227-
228-
xfs_ilock(ip, XFS_ILOCK_SHARED);
229-
if (xfs_ipincount(ip))
230-
lsn = ip->i_itemp->ili_last_lsn;
231-
xfs_iunlock(ip, XFS_ILOCK_SHARED);
232-
233-
if (!lsn)
234-
return 0;
235-
return xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL);
223+
return xfs_log_force_inode(XFS_I(inode));
236224
}
237225

238226
const struct export_operations xfs_export_operations = {

fs/xfs/xfs_file.c

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,19 +80,9 @@ xfs_dir_fsync(
8080
int datasync)
8181
{
8282
struct xfs_inode *ip = XFS_I(file->f_mapping->host);
83-
struct xfs_mount *mp = ip->i_mount;
84-
xfs_lsn_t lsn = 0;
8583

8684
trace_xfs_dir_fsync(ip);
87-
88-
xfs_ilock(ip, XFS_ILOCK_SHARED);
89-
if (xfs_ipincount(ip))
90-
lsn = ip->i_itemp->ili_last_lsn;
91-
xfs_iunlock(ip, XFS_ILOCK_SHARED);
92-
93-
if (!lsn)
94-
return 0;
95-
return xfs_log_force_lsn(mp, lsn, XFS_LOG_SYNC, NULL);
85+
return xfs_log_force_inode(ip);
9686
}
9787

9888
STATIC int

fs/xfs/xfs_inode.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3945,3 +3945,22 @@ xfs_irele(
39453945
trace_xfs_irele(ip, _RET_IP_);
39463946
iput(VFS_I(ip));
39473947
}
3948+
3949+
/*
3950+
* Ensure all commited transactions touching the inode are written to the log.
3951+
*/
3952+
int
3953+
xfs_log_force_inode(
3954+
struct xfs_inode *ip)
3955+
{
3956+
xfs_lsn_t lsn = 0;
3957+
3958+
xfs_ilock(ip, XFS_ILOCK_SHARED);
3959+
if (xfs_ipincount(ip))
3960+
lsn = ip->i_itemp->ili_last_lsn;
3961+
xfs_iunlock(ip, XFS_ILOCK_SHARED);
3962+
3963+
if (!lsn)
3964+
return 0;
3965+
return xfs_log_force_lsn(ip->i_mount, lsn, XFS_LOG_SYNC, NULL);
3966+
}

fs/xfs/xfs_inode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ int xfs_itruncate_extents_flags(struct xfs_trans **,
426426
struct xfs_inode *, int, xfs_fsize_t, int);
427427
void xfs_iext_realloc(xfs_inode_t *, int, int);
428428

429+
int xfs_log_force_inode(struct xfs_inode *ip);
429430
void xfs_iunpin_wait(xfs_inode_t *);
430431
#define xfs_ipincount(ip) ((unsigned int) atomic_read(&ip->i_pincount))
431432

0 commit comments

Comments
 (0)