From: Ben Myers <bpm@sgi.com>
To: Christoph Hellwig <hch@infradead.org>
Cc: xfs@oss.sgi.com
Subject: Re: [patch 11/12] xfs: share code for grant head availability checks
Date: Thu, 16 Feb 2012 15:25:06 -0600 [thread overview]
Message-ID: <20120216212506.GZ7762@sgi.com> (raw)
In-Reply-To: <20111212141435.484216051@bombadil.infradead.org>
Add xlog_grant_head_check() to replace sections of
xlog_regrant_write_log_space() and xlog_grant_log_space().
On Mon, Dec 12, 2011 at 09:13:58AM -0500, Christoph Hellwig wrote:
> Signed-off-by: Christoph Hellwig <hch@lst.de>
>
> ---
> fs/xfs/xfs_log.c | 133 ++++++++++++++++++++++++-------------------------------
> 1 file changed, 60 insertions(+), 73 deletions(-)
>
> Index: xfs/fs/xfs/xfs_log.c
> ===================================================================
> --- xfs.orig/fs/xfs/xfs_log.c 2011-12-11 21:32:08.763640044 +0100
> +++ xfs/fs/xfs/xfs_log.c 2011-12-11 21:36:10.395664344 +0100
> @@ -245,6 +245,60 @@ shutdown:
> return XFS_ERROR(EIO);
> }
>
> +/*
> + * Atomically get the log space required for a log ticket.
> + *
> + * Once a ticket gets put onto head->waiters, it will only return after the
> + * needed reservation is satisfied.
> + *
> + * This function is structured so that it has a lock free fast path. This is
> + * necessary because every new transaction reservation will come through this
> + * path. Hence any lock will be globally hot if we take it unconditionally on
> + * every pass.
> + *
> + * As tickets are only ever moved on and off head->waiters under head->lock, we
> + * only need to take that lock if we are going to add the ticket to the queue
> + * and sleep. We can avoid taking the lock if the ticket was never added to
> + * head->waiters because the t_queue list head will be empty and we hold the
> + * only reference to it so it can safely be checked unlocked.
> + */
> +STATIC int
> +xlog_grant_head_check(
> + struct log *log,
> + struct xlog_grant_head *head,
> + struct xlog_ticket *tic,
> + int *need_bytes)
> +{
> + int free_bytes;
> + int error = 0;
> +
> + ASSERT(!(log->l_flags & XLOG_ACTIVE_RECOVERY));
> +
> + /*
> + * If there are other waiters on the queue then give them a chance at
> + * logspace before us. Wake up the first waiters, if we do not wake
> + * up all the waiters then go to sleep waiting for more free space,
> + * otherwise try to get some space for this transaction.
> + */
> + *need_bytes = xlog_ticket_reservation(log, head, tic);
> + free_bytes = xlog_space_left(log, &head->grant);
> + if (!list_empty_careful(&head->waiters)) {
> + spin_lock(&head->lock);
> + if (!xlog_grant_head_wake(log, head, &free_bytes) ||
> + free_bytes < *need_bytes) {
> + error = xlog_grant_head_wait(log, head, tic,
> + *need_bytes);
> + }
> + spin_unlock(&head->lock);
> + } else if (free_bytes < *need_bytes) {
> + spin_lock(&head->lock);
> + error = xlog_grant_head_wait(log, head, tic, *need_bytes);
> + spin_unlock(&head->lock);
> + }
> +
> + return error;
> +}
> +
> static void
> xlog_tic_reset_res(xlog_ticket_t *tic)
> {
> @@ -2511,59 +2565,18 @@ restart:
> return 0;
> } /* xlog_state_get_iclog_space */
>
> -/*
> - * Atomically get the log space required for a log ticket.
> - *
> - * Once a ticket gets put onto the reserveq, it will only return after the
> - * needed reservation is satisfied.
> - *
> - * This function is structured so that it has a lock free fast path. This is
> - * necessary because every new transaction reservation will come through this
> - * path. Hence any lock will be globally hot if we take it unconditionally on
> - * every pass.
> - *
> - * As tickets are only ever moved on and off the l_reserve.waiters under the
> - * l_reserve.lock, we only need to take that lock if we are going to add
> - * the ticket to the queue and sleep. We can avoid taking the lock if the ticket
> - * was never added to the reserveq because the t_queue list head will be empty
> - * and we hold the only reference to it so it can safely be checked unlocked.
> - */
> STATIC int
> xlog_grant_log_space(
> struct log *log,
> struct xlog_ticket *tic)
> {
> - int free_bytes, need_bytes;
> + int need_bytes;
> int error = 0;
>
> - ASSERT(!(log->l_flags & XLOG_ACTIVE_RECOVERY));
> -
> trace_xfs_log_grant_enter(log, tic);
>
> - /*
> - * If there are other waiters on the queue then give them a chance at
> - * logspace before us. Wake up the first waiters, if we do not wake
> - * up all the waiters then go to sleep waiting for more free space,
> - * otherwise try to get some space for this transaction.
> - */
> - need_bytes = tic->t_unit_res;
> - if (tic->t_flags & XFS_LOG_PERM_RESERV)
> - need_bytes *= tic->t_ocnt;
^
Here the calculation was done with tic->t_ocnt.
You don't see it in this patch, but xlog_ticket_reservation is using
t_cnt. I haven't looked into which is correct.
Other than that this patch looks good to me.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2012-02-16 21:25 UTC|newest]
Thread overview: 49+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-12 14:13 [patch 00/12] log grant code cleanups Christoph Hellwig
2011-12-12 14:13 ` [patch 01/12] xfs: split tail_lsn assignments from log space wakeups Christoph Hellwig
2012-01-17 18:48 ` Mark Tinguely
2012-01-25 16:09 ` Christoph Hellwig
2012-02-16 18:21 ` Ben Myers
2012-02-17 19:21 ` Christoph Hellwig
2011-12-12 14:13 ` [patch 02/12] xfs: do exact log space wakeups in xlog_ungrant_log_space Christoph Hellwig
2012-01-17 22:42 ` Mark Tinguely
2012-02-16 18:36 ` Ben Myers
2011-12-12 14:13 ` [patch 03/12] xfs: remove xfs_trans_unlocked_item Christoph Hellwig
2012-01-23 14:31 ` Mark Tinguely
2012-02-16 18:51 ` Ben Myers
2011-12-12 14:13 ` [patch 04/12] xfs: cleanup xfs_log_space_wake Christoph Hellwig
2012-01-23 19:22 ` Mark Tinguely
2012-01-25 16:10 ` Christoph Hellwig
2012-01-25 19:09 ` Mark Tinguely
2012-01-26 16:13 ` Mark Tinguely
2012-01-26 22:12 ` Dave Chinner
2012-02-16 19:06 ` Ben Myers
2011-12-12 14:13 ` [patch 05/12] xfs: remove log space waitqueues Christoph Hellwig
2012-01-23 21:58 ` Mark Tinguely
2011-12-12 14:13 ` [patch 06/12] xfs: add the xlog_grant_head structure Christoph Hellwig
2012-01-24 15:35 ` Mark Tinguely
2012-02-16 20:23 ` Ben Myers
2011-12-12 14:13 ` [patch 07/12] xfs: add xlog_grant_head_init Christoph Hellwig
2012-01-24 15:43 ` Mark Tinguely
2012-02-16 20:29 ` Ben Myers
2011-12-12 14:13 ` [patch 08/12] xfs: add xlog_grant_head_wake_all Christoph Hellwig
2012-01-24 15:46 ` Mark Tinguely
2012-02-16 20:44 ` Ben Myers
2011-12-12 14:13 ` [patch 09/12] xfs: share code for grant head waiting Christoph Hellwig
2012-01-24 18:10 ` Mark Tinguely
2012-02-16 20:51 ` Ben Myers
2011-12-12 14:13 ` [patch 10/12] xfs: shared code for grant head wakeups Christoph Hellwig
2012-01-24 18:37 ` Mark Tinguely
2012-02-16 21:08 ` Ben Myers
2011-12-12 14:13 ` [patch 11/12] xfs: share code for grant head availability checks Christoph Hellwig
2012-01-24 18:53 ` Mark Tinguely
2012-02-16 21:25 ` Ben Myers [this message]
2012-02-17 2:41 ` Dave Chinner
2011-12-12 14:13 ` [patch 12/12] xfs: split and cleanup xfs_log_reserve Christoph Hellwig
2012-02-16 21:36 ` Ben Myers
2012-02-19 21:16 ` Christoph Hellwig
2012-02-16 6:16 ` [patch 00/12] log grant code cleanups Dave Chinner
2012-02-17 18:00 ` Christoph Hellwig
2012-02-16 21:46 ` Ben Myers
2012-02-19 21:17 ` Christoph Hellwig
2012-02-20 21:59 ` Ben Myers
-- strict thread matches above, loose matches on Subject: below --
2012-02-20 2:31 [PATCH 00/12] log grant code cleanups V2 Christoph Hellwig
2012-02-20 2:31 ` [PATCH 11/12] xfs: share code for grant head availability checks Christoph Hellwig
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20120216212506.GZ7762@sgi.com \
--to=bpm@sgi.com \
--cc=hch@infradead.org \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.