diff options
author | Christoph Hellwig <hch@infradead.org> | 2012-02-19 21:31:28 -0500 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2012-02-22 23:29:39 -0500 |
commit | 23ee3df349b8b8fd153bd02fccf08b31aec5bce3 (patch) | |
tree | 6ed2f0a4ab33da6b315a9c484e130849ebca8875 /fs | |
parent | a79bf2d75b8f96bcdb6714138cd53cb3c358669c (diff) |
xfs: share code for grant head waiting
Reviewed-by: Mark Tinguely <tinguely@sgi.com>
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/xfs_log.c | 63 | ||||
-rw-r--r-- | fs/xfs/xfs_trace.h | 2 |
2 files changed, 18 insertions, 47 deletions
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index a0d1376b3d48..c2d13827582b 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -221,12 +221,13 @@ xlog_writeq_wake( | |||
221 | } | 221 | } |
222 | 222 | ||
223 | STATIC int | 223 | STATIC int |
224 | xlog_reserveq_wait( | 224 | xlog_grant_head_wait( |
225 | struct log *log, | 225 | struct log *log, |
226 | struct xlog_grant_head *head, | ||
226 | struct xlog_ticket *tic, | 227 | struct xlog_ticket *tic, |
227 | int need_bytes) | 228 | int need_bytes) |
228 | { | 229 | { |
229 | list_add_tail(&tic->t_queue, &log->l_reserve_head.waiters); | 230 | list_add_tail(&tic->t_queue, &head->waiters); |
230 | 231 | ||
231 | do { | 232 | do { |
232 | if (XLOG_FORCED_SHUTDOWN(log)) | 233 | if (XLOG_FORCED_SHUTDOWN(log)) |
@@ -234,7 +235,7 @@ xlog_reserveq_wait( | |||
234 | xlog_grant_push_ail(log, need_bytes); | 235 | xlog_grant_push_ail(log, need_bytes); |
235 | 236 | ||
236 | __set_current_state(TASK_UNINTERRUPTIBLE); | 237 | __set_current_state(TASK_UNINTERRUPTIBLE); |
237 | spin_unlock(&log->l_reserve_head.lock); | 238 | spin_unlock(&head->lock); |
238 | 239 | ||
239 | XFS_STATS_INC(xs_sleep_logspace); | 240 | XFS_STATS_INC(xs_sleep_logspace); |
240 | 241 | ||
@@ -242,44 +243,10 @@ xlog_reserveq_wait( | |||
242 | schedule(); | 243 | schedule(); |
243 | trace_xfs_log_grant_wake(log, tic); | 244 | trace_xfs_log_grant_wake(log, tic); |
244 | 245 | ||
245 | spin_lock(&log->l_reserve_head.lock); | 246 | spin_lock(&head->lock); |
246 | if (XLOG_FORCED_SHUTDOWN(log)) | 247 | if (XLOG_FORCED_SHUTDOWN(log)) |
247 | goto shutdown; | 248 | goto shutdown; |
248 | } while (xlog_space_left(log, &log->l_reserve_head.grant) < need_bytes); | 249 | } while (xlog_space_left(log, &head->grant) < need_bytes); |
249 | |||
250 | list_del_init(&tic->t_queue); | ||
251 | return 0; | ||
252 | shutdown: | ||
253 | list_del_init(&tic->t_queue); | ||
254 | return XFS_ERROR(EIO); | ||
255 | } | ||
256 | |||
257 | STATIC int | ||
258 | xlog_writeq_wait( | ||
259 | struct log *log, | ||
260 | struct xlog_ticket *tic, | ||
261 | int need_bytes) | ||
262 | { | ||
263 | list_add_tail(&tic->t_queue, &log->l_write_head.waiters); | ||
264 | |||
265 | do { | ||
266 | if (XLOG_FORCED_SHUTDOWN(log)) | ||
267 | goto shutdown; | ||
268 | xlog_grant_push_ail(log, need_bytes); | ||
269 | |||
270 | __set_current_state(TASK_UNINTERRUPTIBLE); | ||
271 | spin_unlock(&log->l_write_head.lock); | ||
272 | |||
273 | XFS_STATS_INC(xs_sleep_logspace); | ||
274 | |||
275 | trace_xfs_log_regrant_write_sleep(log, tic); | ||
276 | schedule(); | ||
277 | trace_xfs_log_regrant_write_wake(log, tic); | ||
278 | |||
279 | spin_lock(&log->l_write_head.lock); | ||
280 | if (XLOG_FORCED_SHUTDOWN(log)) | ||
281 | goto shutdown; | ||
282 | } while (xlog_space_left(log, &log->l_write_head.grant) < need_bytes); | ||
283 | 250 | ||
284 | list_del_init(&tic->t_queue); | 251 | list_del_init(&tic->t_queue); |
285 | return 0; | 252 | return 0; |
@@ -2596,12 +2563,15 @@ xlog_grant_log_space( | |||
2596 | if (!list_empty_careful(&log->l_reserve_head.waiters)) { | 2563 | if (!list_empty_careful(&log->l_reserve_head.waiters)) { |
2597 | spin_lock(&log->l_reserve_head.lock); | 2564 | spin_lock(&log->l_reserve_head.lock); |
2598 | if (!xlog_reserveq_wake(log, &free_bytes) || | 2565 | if (!xlog_reserveq_wake(log, &free_bytes) || |
2599 | free_bytes < need_bytes) | 2566 | free_bytes < need_bytes) { |
2600 | error = xlog_reserveq_wait(log, tic, need_bytes); | 2567 | error = xlog_grant_head_wait(log, &log->l_reserve_head, |
2568 | tic, need_bytes); | ||
2569 | } | ||
2601 | spin_unlock(&log->l_reserve_head.lock); | 2570 | spin_unlock(&log->l_reserve_head.lock); |
2602 | } else if (free_bytes < need_bytes) { | 2571 | } else if (free_bytes < need_bytes) { |
2603 | spin_lock(&log->l_reserve_head.lock); | 2572 | spin_lock(&log->l_reserve_head.lock); |
2604 | error = xlog_reserveq_wait(log, tic, need_bytes); | 2573 | error = xlog_grant_head_wait(log, &log->l_reserve_head, tic, |
2574 | need_bytes); | ||
2605 | spin_unlock(&log->l_reserve_head.lock); | 2575 | spin_unlock(&log->l_reserve_head.lock); |
2606 | } | 2576 | } |
2607 | if (error) | 2577 | if (error) |
@@ -2649,12 +2619,15 @@ xlog_regrant_write_log_space( | |||
2649 | if (!list_empty_careful(&log->l_write_head.waiters)) { | 2619 | if (!list_empty_careful(&log->l_write_head.waiters)) { |
2650 | spin_lock(&log->l_write_head.lock); | 2620 | spin_lock(&log->l_write_head.lock); |
2651 | if (!xlog_writeq_wake(log, &free_bytes) || | 2621 | if (!xlog_writeq_wake(log, &free_bytes) || |
2652 | free_bytes < need_bytes) | 2622 | free_bytes < need_bytes) { |
2653 | error = xlog_writeq_wait(log, tic, need_bytes); | 2623 | error = xlog_grant_head_wait(log, &log->l_write_head, |
2624 | tic, need_bytes); | ||
2625 | } | ||
2654 | spin_unlock(&log->l_write_head.lock); | 2626 | spin_unlock(&log->l_write_head.lock); |
2655 | } else if (free_bytes < need_bytes) { | 2627 | } else if (free_bytes < need_bytes) { |
2656 | spin_lock(&log->l_write_head.lock); | 2628 | spin_lock(&log->l_write_head.lock); |
2657 | error = xlog_writeq_wait(log, tic, need_bytes); | 2629 | error = xlog_grant_head_wait(log, &log->l_write_head, tic, |
2630 | need_bytes); | ||
2658 | spin_unlock(&log->l_write_head.lock); | 2631 | spin_unlock(&log->l_write_head.lock); |
2659 | } | 2632 | } |
2660 | 2633 | ||
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index a80e30854fce..7ee18e91bf89 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h | |||
@@ -837,8 +837,6 @@ DEFINE_LOGGRANT_EVENT(xfs_log_grant_wake_up); | |||
837 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_enter); | 837 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_enter); |
838 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_exit); | 838 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_exit); |
839 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_error); | 839 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_error); |
840 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_sleep); | ||
841 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_wake); | ||
842 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_wake_up); | 840 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_write_wake_up); |
843 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_enter); | 841 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_enter); |
844 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_exit); | 842 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_exit); |