public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Dave Chinner <david@fromorbit.com>
To: xfs@oss.sgi.com
Subject: [PATCH 04/14] xfs: use wait queues directly for log grant queues
Date: Mon, 29 Nov 2010 12:38:22 +1100	[thread overview]
Message-ID: <1290994712-21376-5-git-send-email-david@fromorbit.com> (raw)
In-Reply-To: <1290994712-21376-1-git-send-email-david@fromorbit.com>

From: Dave Chinner <dchinner@redhat.com>

The log grant queues are one of the few places left using sv_t
constructs for waiting. Convert them to use wait queues directly
while we are cleaning up the code to move one step closer to remove
the sv_t type from the XFS codebase.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
---
 fs/xfs/xfs_log.c      |   32 +++++++++++++++++++++-----------
 fs/xfs/xfs_log_priv.h |    2 +-
 2 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c
index 69a9563..93b5b2d 100644
--- a/fs/xfs/xfs_log.c
+++ b/fs/xfs/xfs_log.c
@@ -739,7 +739,7 @@ xfs_log_move_tail(xfs_mount_t	*mp,
 				break;
 			tail_lsn = 0;
 			free_bytes -= tic->t_unit_res;
-			sv_signal(&tic->t_wait);
+			wake_up(&tic->t_wait);
 		}
 	}
 
@@ -759,7 +759,7 @@ xfs_log_move_tail(xfs_mount_t	*mp,
 				break;
 			tail_lsn = 0;
 			free_bytes -= need_bytes;
-			sv_signal(&tic->t_wait);
+			wake_up(&tic->t_wait);
 		}
 	}
 	spin_unlock(&log->l_grant_lock);
@@ -2537,6 +2537,7 @@ xlog_grant_log_space(
 {
 	int			 free_bytes;
 	int			 need_bytes;
+	DECLARE_WAITQUEUE(wait, current);
 
 #ifdef DEBUG
 	if (log->l_flags & XLOG_ACTIVE_RECOVERY)
@@ -2573,7 +2574,12 @@ redo:
 
 		XFS_STATS_INC(xs_sleep_logspace);
 		trace_xfs_log_grant_sleep(log, tic);
-		sv_wait(&tic->t_wait, PINOD|PLTWAIT, &log->l_grant_lock, s);
+
+		add_wait_queue_exclusive(&tic->t_wait, &wait);
+		__set_current_state(TASK_UNINTERRUPTIBLE);
+		spin_unlock(&log->l_grant_lock);
+		schedule();
+		remove_wait_queue(&tic->t_wait, &wait);
 
 		spin_lock(&log->l_grant_lock);
 		trace_xfs_log_grant_wake(log, tic);
@@ -2617,6 +2623,7 @@ xlog_regrant_write_log_space(
 {
 	int			free_bytes;
 	int			need_bytes;
+	DECLARE_WAITQUEUE(wait, current);
 
 	tic->t_curr_res = tic->t_unit_res;
 	xlog_tic_reset_res(tic);
@@ -2662,7 +2669,7 @@ redo:
 					break;
 				}
 				free_bytes -= ntic->t_unit_res;
-				sv_signal(&ntic->t_wait);
+				wake_up(&ntic->t_wait);
 			}
 			list_add_tail(&tic->t_queue, &log->l_writeq);
 			if (woke_all)
@@ -2675,7 +2682,12 @@ redo:
 
 		XFS_STATS_INC(xs_sleep_logspace);
 		trace_xfs_log_regrant_write_sleep(log, tic);
-		sv_wait(&tic->t_wait, PINOD|PLTWAIT, &log->l_grant_lock, s);
+
+		add_wait_queue_exclusive(&tic->t_wait, &wait);
+		__set_current_state(TASK_UNINTERRUPTIBLE);
+		spin_unlock(&log->l_grant_lock);
+		schedule();
+		remove_wait_queue(&tic->t_wait, &wait);
 
 		spin_lock(&log->l_grant_lock);
 		trace_xfs_log_regrant_write_wake(log, tic);
@@ -3237,10 +3249,8 @@ xfs_log_ticket_put(
 	xlog_ticket_t	*ticket)
 {
 	ASSERT(atomic_read(&ticket->t_ref) > 0);
-	if (atomic_dec_and_test(&ticket->t_ref)) {
-		sv_destroy(&ticket->t_wait);
+	if (atomic_dec_and_test(&ticket->t_ref))
 		kmem_zone_free(xfs_log_ticket_zone, ticket);
-	}
 }
 
 xlog_ticket_t *
@@ -3373,7 +3383,7 @@ xlog_ticket_alloc(
 	tic->t_trans_type	= 0;
 	if (xflags & XFS_LOG_PERM_RESERV)
 		tic->t_flags |= XLOG_TIC_PERM_RESERV;
-	sv_init(&tic->t_wait, SV_DEFAULT, "logtick");
+	init_waitqueue_head(&tic->t_wait);
 
 	xlog_tic_reset_res(tic);
 
@@ -3701,10 +3711,10 @@ xfs_log_force_umount(
 	 * action is protected by the GRANTLOCK.
 	 */
 	list_for_each_entry(tic, &log->l_reserveq, t_queue)
-		sv_signal(&tic->t_wait);
+		wake_up(&tic->t_wait);
 
 	list_for_each_entry(tic, &log->l_writeq, t_queue)
-		sv_signal(&tic->t_wait);
+		wake_up(&tic->t_wait);
 	spin_unlock(&log->l_grant_lock);
 
 	if (!(log->l_iclog->ic_state & XLOG_STATE_IOERROR)) {
diff --git a/fs/xfs/xfs_log_priv.h b/fs/xfs/xfs_log_priv.h
index 4ebaf07..6fcee10 100644
--- a/fs/xfs/xfs_log_priv.h
+++ b/fs/xfs/xfs_log_priv.h
@@ -242,7 +242,7 @@ typedef struct xlog_res {
 } xlog_res_t;
 
 typedef struct xlog_ticket {
-	sv_t		   t_wait;	 /* ticket wait queue            : 20 */
+	wait_queue_head_t  t_wait;	 /* ticket wait queue */
 	struct list_head   t_queue;	 /* reserve/write queue */
 	xlog_tid_t	   t_tid;	 /* transaction identifier	 : 4  */
 	atomic_t	   t_ref;	 /* ticket reference count       : 4  */
-- 
1.7.2.3

_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs

  parent reply	other threads:[~2010-11-29  1:37 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-29  1:38 [PATCH 0/14] xfs: grant lock scaling and removal V2 Dave Chinner
2010-11-29  1:38 ` [PATCH 01/14] xfs: convert log grant ticket queues to list heads Dave Chinner
2010-11-30 22:59   ` Christoph Hellwig
2010-11-29  1:38 ` [PATCH 02/14] xfs: clean up log space grant functions Dave Chinner
2010-12-01 12:30   ` Christoph Hellwig
2010-12-02  1:48     ` Dave Chinner
2010-12-02 11:40       ` Christoph Hellwig
2010-12-03  6:45         ` Dave Chinner
2010-11-29  1:38 ` [PATCH 03/14] xfs: convert log grant heads to LSN notation Dave Chinner
2010-12-01 12:42   ` Christoph Hellwig
2010-12-02  1:49     ` Dave Chinner
2010-12-01 13:05   ` Christoph Hellwig
2010-12-02  2:01     ` Dave Chinner
2010-12-02 11:47       ` Christoph Hellwig
2010-11-29  1:38 ` Dave Chinner [this message]
2010-12-01 12:34   ` [PATCH 04/14] xfs: use wait queues directly for log grant queues Christoph Hellwig
2010-12-02  2:02     ` Dave Chinner
2010-11-29  1:38 ` [PATCH 05/14] xfs: make AIL tail pushing independent of the grant lock Dave Chinner
2010-12-01 12:45   ` Christoph Hellwig
2010-12-02  2:04     ` Dave Chinner
2010-11-29  1:38 ` [PATCH 06/14] xfs: convert l_last_sync_lsn to an atomic variable Dave Chinner
2010-12-01 12:54   ` Christoph Hellwig
2010-11-29  1:38 ` [PATCH 07/14] xfs: convert l_tail_lsn " Dave Chinner
2010-12-01 12:56   ` Christoph Hellwig
2010-11-29  1:38 ` [PATCH 08/14] xfs: convert log grant heads to atomic variables Dave Chinner
2010-12-01 12:59   ` Christoph Hellwig
2010-12-02  2:04     ` Dave Chinner
2010-11-29  1:38 ` [PATCH 09/14] xfs: introduce new locks for the log grant ticket wait queues Dave Chinner
2010-12-01 13:12   ` Christoph Hellwig
2010-12-02  2:10     ` Dave Chinner
2010-12-02 11:48       ` Christoph Hellwig
2010-11-29  1:38 ` [PATCH 10/14] xfs: convert grant head manipulations to lockless algorithm Dave Chinner
2010-12-01 13:15   ` Christoph Hellwig
2010-12-02  2:11     ` Dave Chinner
2010-11-29  1:38 ` [PATCH 11/14] xfs: remove log grant lock Dave Chinner
2010-12-01 13:15   ` Christoph Hellwig
2010-11-29  1:38 ` [PATCH 12/14] xfs: kill useless spinlock_destroy macro Dave Chinner
2010-12-01 13:19   ` Christoph Hellwig
2010-11-29  1:38 ` [PATCH 13/14] xfs: replace use of sv_t with waitqueues in the log Dave Chinner
2010-12-01 13:20   ` Christoph Hellwig
2010-11-29  1:38 ` [PATCH 14/14] xfs: remove sv wrappers Dave Chinner
2010-12-01 13:20   ` 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=1290994712-21376-5-git-send-email-david@fromorbit.com \
    --to=david@fromorbit.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox