Skip to content

Commit ed1575d

Browse files
committed
xfs: expose the log push threshold
Separate the computation of the log push threshold and the push logic in xlog_grant_push_ail. This enables higher level code to determine (for example) that it is holding on to a logged intent item and the log is so busy that it is more than 75% full. In that case, it would be desirable to move the log item towards the head to release the tail, which we will cover in the next patch. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com>
1 parent 4e919af commit ed1575d

File tree

2 files changed

+32
-10
lines changed

2 files changed

+32
-10
lines changed

fs/xfs/xfs_log.c

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,14 +1475,14 @@ xlog_commit_record(
14751475
}
14761476

14771477
/*
1478-
* Push on the buffer cache code if we ever use more than 75% of the on-disk
1479-
* log space. This code pushes on the lsn which would supposedly free up
1480-
* the 25% which we want to leave free. We may need to adopt a policy which
1481-
* pushes on an lsn which is further along in the log once we reach the high
1482-
* water mark. In this manner, we would be creating a low water mark.
1478+
* Compute the LSN that we'd need to push the log tail towards in order to have
1479+
* (a) enough on-disk log space to log the number of bytes specified, (b) at
1480+
* least 25% of the log space free, and (c) at least 256 blocks free. If the
1481+
* log free space already meets all three thresholds, this function returns
1482+
* NULLCOMMITLSN.
14831483
*/
1484-
STATIC void
1485-
xlog_grant_push_ail(
1484+
xfs_lsn_t
1485+
xlog_grant_push_threshold(
14861486
struct xlog *log,
14871487
int need_bytes)
14881488
{
@@ -1508,7 +1508,7 @@ xlog_grant_push_ail(
15081508
free_threshold = max(free_threshold, (log->l_logBBsize >> 2));
15091509
free_threshold = max(free_threshold, 256);
15101510
if (free_blocks >= free_threshold)
1511-
return;
1511+
return NULLCOMMITLSN;
15121512

15131513
xlog_crack_atomic_lsn(&log->l_tail_lsn, &threshold_cycle,
15141514
&threshold_block);
@@ -1528,13 +1528,33 @@ xlog_grant_push_ail(
15281528
if (XFS_LSN_CMP(threshold_lsn, last_sync_lsn) > 0)
15291529
threshold_lsn = last_sync_lsn;
15301530

1531+
return threshold_lsn;
1532+
}
1533+
1534+
/*
1535+
* Push the tail of the log if we need to do so to maintain the free log space
1536+
* thresholds set out by xlog_grant_push_threshold. We may need to adopt a
1537+
* policy which pushes on an lsn which is further along in the log once we
1538+
* reach the high water mark. In this manner, we would be creating a low water
1539+
* mark.
1540+
*/
1541+
STATIC void
1542+
xlog_grant_push_ail(
1543+
struct xlog *log,
1544+
int need_bytes)
1545+
{
1546+
xfs_lsn_t threshold_lsn;
1547+
1548+
threshold_lsn = xlog_grant_push_threshold(log, need_bytes);
1549+
if (threshold_lsn == NULLCOMMITLSN || XLOG_FORCED_SHUTDOWN(log))
1550+
return;
1551+
15311552
/*
15321553
* Get the transaction layer to kick the dirty buffers out to
15331554
* disk asynchronously. No point in trying to do this if
15341555
* the filesystem is shutting down.
15351556
*/
1536-
if (!XLOG_FORCED_SHUTDOWN(log))
1537-
xfs_ail_push(log->l_ailp, threshold_lsn);
1557+
xfs_ail_push(log->l_ailp, threshold_lsn);
15381558
}
15391559

15401560
/*

fs/xfs/xfs_log.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,6 @@ void xfs_log_quiesce(struct xfs_mount *mp);
141141
bool xfs_log_check_lsn(struct xfs_mount *, xfs_lsn_t);
142142
bool xfs_log_in_recovery(struct xfs_mount *);
143143

144+
xfs_lsn_t xlog_grant_push_threshold(struct xlog *log, int need_bytes);
145+
144146
#endif /* __XFS_LOG_H__ */

0 commit comments

Comments
 (0)