Skip to content

Commit

Permalink
xfs: use wait queues directly for the log wait queues
Browse files Browse the repository at this point in the history
The log grant queues are one of the few places left using sv_t
constructs for waiting. Given we are touching this code, we should
convert them to plain wait queues. While there, convert all the
other sv_t users in the log code as well.

Seeing as this removes the last users of the sv_t type, remove the
header file defining the wrapper and the fragments that still
reference it.

Signed-off-by: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
  • Loading branch information
Dave Chinner authored and Dave Chinner committed Dec 21, 2010
1 parent a69ed03 commit eb40a87
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 106 deletions.
59 changes: 0 additions & 59 deletions fs/xfs/linux-2.6/sv.h

This file was deleted.

1 change: 0 additions & 1 deletion fs/xfs/linux-2.6/xfs_linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@

#include <kmem.h>
#include <mrlock.h>
#include <sv.h>
#include <time.h>

#include <support/debug.h>
Expand Down
1 change: 0 additions & 1 deletion fs/xfs/quota/xfs_dquot.c
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ xfs_qm_dqdestroy(
ASSERT(list_empty(&dqp->q_freelist));

mutex_destroy(&dqp->q_qlock);
sv_destroy(&dqp->q_pinwait);
kmem_zone_free(xfs_Gqm->qm_dqzone, dqp);

atomic_dec(&xfs_Gqm->qm_totaldquots);
Expand Down
64 changes: 28 additions & 36 deletions fs/xfs/xfs_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,8 @@ xfs_log_unmount_write(xfs_mount_t *mp)
if (!(iclog->ic_state == XLOG_STATE_ACTIVE ||
iclog->ic_state == XLOG_STATE_DIRTY)) {
if (!XLOG_FORCED_SHUTDOWN(log)) {
sv_wait(&iclog->ic_force_wait, PMEM,
&log->l_icloglock, s);
xlog_wait(&iclog->ic_force_wait,
&log->l_icloglock);
} else {
spin_unlock(&log->l_icloglock);
}
Expand Down Expand Up @@ -588,8 +588,8 @@ xfs_log_unmount_write(xfs_mount_t *mp)
|| iclog->ic_state == XLOG_STATE_DIRTY
|| iclog->ic_state == XLOG_STATE_IOERROR) ) {

sv_wait(&iclog->ic_force_wait, PMEM,
&log->l_icloglock, s);
xlog_wait(&iclog->ic_force_wait,
&log->l_icloglock);
} else {
spin_unlock(&log->l_icloglock);
}
Expand Down Expand Up @@ -700,7 +700,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);
}
}

Expand All @@ -719,7 +719,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);
Expand Down Expand Up @@ -1060,7 +1060,7 @@ xlog_alloc_log(xfs_mount_t *mp,

spin_lock_init(&log->l_icloglock);
spin_lock_init(&log->l_grant_lock);
sv_init(&log->l_flush_wait, 0, "flush_wait");
init_waitqueue_head(&log->l_flush_wait);

/* log record size must be multiple of BBSIZE; see xlog_rec_header_t */
ASSERT((XFS_BUF_SIZE(bp) & BBMASK) == 0);
Expand Down Expand Up @@ -1116,8 +1116,8 @@ xlog_alloc_log(xfs_mount_t *mp,

ASSERT(XFS_BUF_ISBUSY(iclog->ic_bp));
ASSERT(XFS_BUF_VALUSEMA(iclog->ic_bp) <= 0);
sv_init(&iclog->ic_force_wait, SV_DEFAULT, "iclog-force");
sv_init(&iclog->ic_write_wait, SV_DEFAULT, "iclog-write");
init_waitqueue_head(&iclog->ic_force_wait);
init_waitqueue_head(&iclog->ic_write_wait);

iclogp = &iclog->ic_next;
}
Expand All @@ -1132,11 +1132,8 @@ xlog_alloc_log(xfs_mount_t *mp,
out_free_iclog:
for (iclog = log->l_iclog; iclog; iclog = prev_iclog) {
prev_iclog = iclog->ic_next;
if (iclog->ic_bp) {
sv_destroy(&iclog->ic_force_wait);
sv_destroy(&iclog->ic_write_wait);
if (iclog->ic_bp)
xfs_buf_free(iclog->ic_bp);
}
kmem_free(iclog);
}
spinlock_destroy(&log->l_icloglock);
Expand Down Expand Up @@ -1453,8 +1450,6 @@ xlog_dealloc_log(xlog_t *log)

iclog = log->l_iclog;
for (i=0; i<log->l_iclog_bufs; i++) {
sv_destroy(&iclog->ic_force_wait);
sv_destroy(&iclog->ic_write_wait);
xfs_buf_free(iclog->ic_bp);
next_iclog = iclog->ic_next;
kmem_free(iclog);
Expand Down Expand Up @@ -2261,7 +2256,7 @@ xlog_state_do_callback(
xlog_state_clean_log(log);

/* wake up threads waiting in xfs_log_force() */
sv_broadcast(&iclog->ic_force_wait);
wake_up_all(&iclog->ic_force_wait);

iclog = iclog->ic_next;
} while (first_iclog != iclog);
Expand Down Expand Up @@ -2308,7 +2303,7 @@ xlog_state_do_callback(
spin_unlock(&log->l_icloglock);

if (wake)
sv_broadcast(&log->l_flush_wait);
wake_up_all(&log->l_flush_wait);
}


Expand Down Expand Up @@ -2359,7 +2354,7 @@ xlog_state_done_syncing(
* iclog buffer, we wake them all, one will get to do the
* I/O, the others get to wait for the result.
*/
sv_broadcast(&iclog->ic_write_wait);
wake_up_all(&iclog->ic_write_wait);
spin_unlock(&log->l_icloglock);
xlog_state_do_callback(log, aborted, iclog); /* also cleans log */
} /* xlog_state_done_syncing */
Expand Down Expand Up @@ -2408,7 +2403,7 @@ xlog_state_get_iclog_space(xlog_t *log,
XFS_STATS_INC(xs_log_noiclogs);

/* Wait for log writes to have flushed */
sv_wait(&log->l_flush_wait, 0, &log->l_icloglock, 0);
xlog_wait(&log->l_flush_wait, &log->l_icloglock);
goto restart;
}

Expand Down Expand Up @@ -2523,7 +2518,8 @@ xlog_grant_log_space(xlog_t *log,
goto error_return;

XFS_STATS_INC(xs_sleep_logspace);
sv_wait(&tic->t_wait, PINOD|PLTWAIT, &log->l_grant_lock, s);
xlog_wait(&tic->t_wait, &log->l_grant_lock);

/*
* If we got an error, and the filesystem is shutting down,
* we'll catch it down below. So just continue...
Expand Down Expand Up @@ -2552,7 +2548,7 @@ xlog_grant_log_space(xlog_t *log,
spin_lock(&log->l_grant_lock);

XFS_STATS_INC(xs_sleep_logspace);
sv_wait(&tic->t_wait, PINOD|PLTWAIT, &log->l_grant_lock, s);
xlog_wait(&tic->t_wait, &log->l_grant_lock);

spin_lock(&log->l_grant_lock);
if (XLOG_FORCED_SHUTDOWN(log))
Expand Down Expand Up @@ -2635,7 +2631,7 @@ xlog_regrant_write_log_space(xlog_t *log,
if (free_bytes < ntic->t_unit_res)
break;
free_bytes -= ntic->t_unit_res;
sv_signal(&ntic->t_wait);
wake_up(&ntic->t_wait);
}

if (ntic != list_first_entry(&log->l_writeq,
Expand All @@ -2650,8 +2646,7 @@ xlog_regrant_write_log_space(xlog_t *log,
spin_lock(&log->l_grant_lock);

XFS_STATS_INC(xs_sleep_logspace);
sv_wait(&tic->t_wait, PINOD|PLTWAIT,
&log->l_grant_lock, s);
xlog_wait(&tic->t_wait, &log->l_grant_lock);

/* If we're shutting down, this tic is already
* off the queue */
Expand All @@ -2677,8 +2672,7 @@ xlog_regrant_write_log_space(xlog_t *log,

XFS_STATS_INC(xs_sleep_logspace);
trace_xfs_log_regrant_write_sleep2(log, tic);

sv_wait(&tic->t_wait, PINOD|PLTWAIT, &log->l_grant_lock, s);
xlog_wait(&tic->t_wait, &log->l_grant_lock);

/* If we're shutting down, this tic is already off the queue */
spin_lock(&log->l_grant_lock);
Expand Down Expand Up @@ -3029,7 +3023,7 @@ _xfs_log_force(
return XFS_ERROR(EIO);
}
XFS_STATS_INC(xs_log_force_sleep);
sv_wait(&iclog->ic_force_wait, PINOD, &log->l_icloglock, s);
xlog_wait(&iclog->ic_force_wait, &log->l_icloglock);
/*
* No need to grab the log lock here since we're
* only deciding whether or not to return EIO
Expand Down Expand Up @@ -3147,8 +3141,8 @@ _xfs_log_force_lsn(

XFS_STATS_INC(xs_log_force_sleep);

sv_wait(&iclog->ic_prev->ic_write_wait,
PSWP, &log->l_icloglock, s);
xlog_wait(&iclog->ic_prev->ic_write_wait,
&log->l_icloglock);
if (log_flushed)
*log_flushed = 1;
already_slept = 1;
Expand Down Expand Up @@ -3176,7 +3170,7 @@ _xfs_log_force_lsn(
return XFS_ERROR(EIO);
}
XFS_STATS_INC(xs_log_force_sleep);
sv_wait(&iclog->ic_force_wait, PSWP, &log->l_icloglock, s);
xlog_wait(&iclog->ic_force_wait, &log->l_icloglock);
/*
* No need to grab the log lock here since we're
* only deciding whether or not to return EIO
Expand Down Expand Up @@ -3251,10 +3245,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 *
Expand Down Expand Up @@ -3387,7 +3379,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);

Expand Down Expand Up @@ -3719,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)) {
Expand Down
8 changes: 4 additions & 4 deletions fs/xfs/xfs_log_cil.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ xlog_cil_init(
INIT_LIST_HEAD(&cil->xc_committing);
spin_lock_init(&cil->xc_cil_lock);
init_rwsem(&cil->xc_ctx_lock);
sv_init(&cil->xc_commit_wait, SV_DEFAULT, "cilwait");
init_waitqueue_head(&cil->xc_commit_wait);

INIT_LIST_HEAD(&ctx->committing);
INIT_LIST_HEAD(&ctx->busy_extents);
Expand Down Expand Up @@ -563,7 +563,7 @@ xlog_cil_push(
* It is still being pushed! Wait for the push to
* complete, then start again from the beginning.
*/
sv_wait(&cil->xc_commit_wait, 0, &cil->xc_cil_lock, 0);
xlog_wait(&cil->xc_commit_wait, &cil->xc_cil_lock);
goto restart;
}
}
Expand All @@ -587,7 +587,7 @@ xlog_cil_push(
*/
spin_lock(&cil->xc_cil_lock);
ctx->commit_lsn = commit_lsn;
sv_broadcast(&cil->xc_commit_wait);
wake_up_all(&cil->xc_commit_wait);
spin_unlock(&cil->xc_cil_lock);

/* release the hounds! */
Expand Down Expand Up @@ -752,7 +752,7 @@ xlog_cil_force_lsn(
* It is still being pushed! Wait for the push to
* complete, then start again from the beginning.
*/
sv_wait(&cil->xc_commit_wait, 0, &cil->xc_cil_lock, 0);
xlog_wait(&cil->xc_commit_wait, &cil->xc_cil_lock);
goto restart;
}
if (ctx->sequence != sequence)
Expand Down
Loading

0 comments on commit eb40a87

Please sign in to comment.