[RFC v6 PATCH 02/10] xfs: create helper for ticket-less log res ungrant

Brian Foster
2020-04-06T12:36:39Z

Log reservation is currently acquired and released via log tickets.
The relog mechanism introduces behavior where relog reservation is
transferred between transaction log tickets and an external pool of
relog reservation for active relog items. Certain contexts will be
able to release outstanding relog reservation without the need for a
log ticket. Factor out a helper to allow byte granularity log
reservation ungrant.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
fs/xfs/xfs_log.c | 20 ++++++++++++++++----
fs/xfs/xfs_log.h | 1 +
2 files changed, 17 insertions(+), 4 deletions(-)

diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 00fda2e8e738..d6b63490a78b 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -2980,6 +2980,21 @@ xfs_log_ticket_regrant(
xfs_log_ticket_put(ticket);
}

+/*
+ * Restore log reservation directly to the grant heads.
+ */
+void
+xfs_log_ungrant_bytes(
+ struct xfs_mount *mp,
+ int bytes)
+{
+ struct xlog *log = mp->m_log;
+
+ xlog_grant_sub_space(log, &log->l_reserve_head.grant, bytes);
+ xlog_grant_sub_space(log, &log->l_write_head.grant, bytes);
+ xfs_log_space_wake(mp);
+}
+
/*
* Give back the space left from a reservation.
*
@@ -3018,12 +3033,9 @@ xfs_log_ticket_ungrant(
bytes += ticket->t_unit_res*ticket->t_cnt;
}

- xlog_grant_sub_space(log, &log->l_reserve_head.grant, bytes);
- xlog_grant_sub_space(log, &log->l_write_head.grant, bytes);
-
+ xfs_log_ungrant_bytes(log->l_mp, bytes);
trace_xfs_log_ticket_ungrant_exit(log, ticket);

- xfs_log_space_wake(log->l_mp);
xfs_log_ticket_put(ticket);
}

diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h
index 1412d6993f1e..6d2f30f42245 100644
--- a/fs/xfs/xfs_log.h
+++ b/fs/xfs/xfs_log.h
@@ -125,6 +125,7 @@ int xfs_log_reserve(struct xfs_mount *mp,
uint8_t clientid,
bool permanent);
int xfs_log_regrant(struct xfs_mount *mp, struct xlog_ticket *tic);
+void xfs_log_ungrant_bytes(struct xfs_mount *mp, int bytes);
void xfs_log_unmount(struct xfs_mount *mp);
int xfs_log_force_umount(struct xfs_mount *mp, int logerror);

--
2.21.1