diff options
author | Christoph Hellwig <hch@infradead.org> | 2012-02-19 21:31:29 -0500 |
---|---|---|
committer | Ben Myers <bpm@sgi.com> | 2012-02-22 23:31:45 -0500 |
commit | e179840d74606ab1935c83fe5ad9d93c95ddc956 (patch) | |
tree | 47899d69dd92e2e804c7cf47f9cc53abdafdf335 /fs/xfs | |
parent | 23ee3df349b8b8fd153bd02fccf08b31aec5bce3 (diff) |
xfs: share code for grant head wakeups
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/xfs')
-rw-r--r-- | fs/xfs/xfs_log.c | 50 | ||||
-rw-r--r-- | fs/xfs/xfs_trace.h | 1 |
2 files changed, 20 insertions, 31 deletions
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index c2d13827582b..685997548fb8 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -171,49 +171,39 @@ xlog_grant_head_wake_all( | |||
171 | spin_unlock(&head->lock); | 171 | spin_unlock(&head->lock); |
172 | } | 172 | } |
173 | 173 | ||
174 | STATIC bool | 174 | static inline int |
175 | xlog_reserveq_wake( | 175 | xlog_ticket_reservation( |
176 | struct log *log, | 176 | struct log *log, |
177 | int *free_bytes) | 177 | struct xlog_grant_head *head, |
178 | struct xlog_ticket *tic) | ||
178 | { | 179 | { |
179 | struct xlog_ticket *tic; | 180 | if (head == &log->l_write_head) { |
180 | int need_bytes; | 181 | ASSERT(tic->t_flags & XLOG_TIC_PERM_RESERV); |
181 | 182 | return tic->t_unit_res; | |
182 | list_for_each_entry(tic, &log->l_reserve_head.waiters, t_queue) { | 183 | } else { |
183 | if (tic->t_flags & XLOG_TIC_PERM_RESERV) | 184 | if (tic->t_flags & XLOG_TIC_PERM_RESERV) |
184 | need_bytes = tic->t_unit_res * tic->t_cnt; | 185 | return tic->t_unit_res * tic->t_cnt; |
185 | else | 186 | else |
186 | need_bytes = tic->t_unit_res; | 187 | return tic->t_unit_res; |
187 | |||
188 | if (*free_bytes < need_bytes) | ||
189 | return false; | ||
190 | *free_bytes -= need_bytes; | ||
191 | |||
192 | trace_xfs_log_grant_wake_up(log, tic); | ||
193 | wake_up_process(tic->t_task); | ||
194 | } | 188 | } |
195 | |||
196 | return true; | ||
197 | } | 189 | } |
198 | 190 | ||
199 | STATIC bool | 191 | STATIC bool |
200 | xlog_writeq_wake( | 192 | xlog_grant_head_wake( |
201 | struct log *log, | 193 | struct log *log, |
194 | struct xlog_grant_head *head, | ||
202 | int *free_bytes) | 195 | int *free_bytes) |
203 | { | 196 | { |
204 | struct xlog_ticket *tic; | 197 | struct xlog_ticket *tic; |
205 | int need_bytes; | 198 | int need_bytes; |
206 | 199 | ||
207 | list_for_each_entry(tic, &log->l_write_head.waiters, t_queue) { | 200 | list_for_each_entry(tic, &head->waiters, t_queue) { |
208 | ASSERT(tic->t_flags & XLOG_TIC_PERM_RESERV); | 201 | need_bytes = xlog_ticket_reservation(log, head, tic); |
209 | |||
210 | need_bytes = tic->t_unit_res; | ||
211 | |||
212 | if (*free_bytes < need_bytes) | 202 | if (*free_bytes < need_bytes) |
213 | return false; | 203 | return false; |
214 | *free_bytes -= need_bytes; | ||
215 | 204 | ||
216 | trace_xfs_log_regrant_write_wake_up(log, tic); | 205 | *free_bytes -= need_bytes; |
206 | trace_xfs_log_grant_wake_up(log, tic); | ||
217 | wake_up_process(tic->t_task); | 207 | wake_up_process(tic->t_task); |
218 | } | 208 | } |
219 | 209 | ||
@@ -772,7 +762,7 @@ xfs_log_space_wake( | |||
772 | 762 | ||
773 | spin_lock(&log->l_write_head.lock); | 763 | spin_lock(&log->l_write_head.lock); |
774 | free_bytes = xlog_space_left(log, &log->l_write_head.grant); | 764 | free_bytes = xlog_space_left(log, &log->l_write_head.grant); |
775 | xlog_writeq_wake(log, &free_bytes); | 765 | xlog_grant_head_wake(log, &log->l_write_head, &free_bytes); |
776 | spin_unlock(&log->l_write_head.lock); | 766 | spin_unlock(&log->l_write_head.lock); |
777 | } | 767 | } |
778 | 768 | ||
@@ -781,7 +771,7 @@ xfs_log_space_wake( | |||
781 | 771 | ||
782 | spin_lock(&log->l_reserve_head.lock); | 772 | spin_lock(&log->l_reserve_head.lock); |
783 | free_bytes = xlog_space_left(log, &log->l_reserve_head.grant); | 773 | free_bytes = xlog_space_left(log, &log->l_reserve_head.grant); |
784 | xlog_reserveq_wake(log, &free_bytes); | 774 | xlog_grant_head_wake(log, &log->l_reserve_head, &free_bytes); |
785 | spin_unlock(&log->l_reserve_head.lock); | 775 | spin_unlock(&log->l_reserve_head.lock); |
786 | } | 776 | } |
787 | } | 777 | } |
@@ -2562,7 +2552,7 @@ xlog_grant_log_space( | |||
2562 | free_bytes = xlog_space_left(log, &log->l_reserve_head.grant); | 2552 | free_bytes = xlog_space_left(log, &log->l_reserve_head.grant); |
2563 | if (!list_empty_careful(&log->l_reserve_head.waiters)) { | 2553 | if (!list_empty_careful(&log->l_reserve_head.waiters)) { |
2564 | spin_lock(&log->l_reserve_head.lock); | 2554 | spin_lock(&log->l_reserve_head.lock); |
2565 | if (!xlog_reserveq_wake(log, &free_bytes) || | 2555 | if (!xlog_grant_head_wake(log, &log->l_reserve_head, &free_bytes) || |
2566 | free_bytes < need_bytes) { | 2556 | free_bytes < need_bytes) { |
2567 | error = xlog_grant_head_wait(log, &log->l_reserve_head, | 2557 | error = xlog_grant_head_wait(log, &log->l_reserve_head, |
2568 | tic, need_bytes); | 2558 | tic, need_bytes); |
@@ -2618,7 +2608,7 @@ xlog_regrant_write_log_space( | |||
2618 | free_bytes = xlog_space_left(log, &log->l_write_head.grant); | 2608 | free_bytes = xlog_space_left(log, &log->l_write_head.grant); |
2619 | if (!list_empty_careful(&log->l_write_head.waiters)) { | 2609 | if (!list_empty_careful(&log->l_write_head.waiters)) { |
2620 | spin_lock(&log->l_write_head.lock); | 2610 | spin_lock(&log->l_write_head.lock); |
2621 | if (!xlog_writeq_wake(log, &free_bytes) || | 2611 | if (!xlog_grant_head_wake(log, &log->l_write_head, &free_bytes) || |
2622 | free_bytes < need_bytes) { | 2612 | free_bytes < need_bytes) { |
2623 | error = xlog_grant_head_wait(log, &log->l_write_head, | 2613 | error = xlog_grant_head_wait(log, &log->l_write_head, |
2624 | tic, need_bytes); | 2614 | tic, need_bytes); |
diff --git a/fs/xfs/xfs_trace.h b/fs/xfs/xfs_trace.h index 7ee18e91bf89..482bebf8c7ef 100644 --- a/fs/xfs/xfs_trace.h +++ b/fs/xfs/xfs_trace.h | |||
@@ -837,7 +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_wake_up); | ||
841 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_enter); | 840 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_enter); |
842 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_exit); | 841 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_exit); |
843 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_sub); | 842 | DEFINE_LOGGRANT_EVENT(xfs_log_regrant_reserve_sub); |