diff options
Diffstat (limited to 'fs/jbd2')
-rw-r--r-- | fs/jbd2/transaction.c | 46 |
1 files changed, 27 insertions, 19 deletions
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c index d95cc9d0401d..f3479d6e0a83 100644 --- a/fs/jbd2/transaction.c +++ b/fs/jbd2/transaction.c | |||
@@ -82,6 +82,32 @@ jbd2_get_transaction(journal_t *journal, transaction_t *transaction) | |||
82 | */ | 82 | */ |
83 | 83 | ||
84 | /* | 84 | /* |
85 | * Update transiaction's maximum wait time, if debugging is enabled. | ||
86 | * | ||
87 | * In order for t_max_wait to be reliable, it must be protected by a | ||
88 | * lock. But doing so will mean that start_this_handle() can not be | ||
89 | * run in parallel on SMP systems, which limits our scalability. So | ||
90 | * unless debugging is enabled, we no longer update t_max_wait, which | ||
91 | * means that maximum wait time reported by the jbd2_run_stats | ||
92 | * tracepoint will always be zero. | ||
93 | */ | ||
94 | static inline void update_t_max_wait(transaction_t *transaction) | ||
95 | { | ||
96 | #ifdef CONFIG_JBD2_DEBUG | ||
97 | unsigned long ts = jiffies; | ||
98 | |||
99 | if (jbd2_journal_enable_debug && | ||
100 | time_after(transaction->t_start, ts)) { | ||
101 | ts = jbd2_time_diff(ts, transaction->t_start); | ||
102 | spin_lock(&transaction->t_handle_lock); | ||
103 | if (ts > transaction->t_max_wait) | ||
104 | transaction->t_max_wait = ts; | ||
105 | spin_unlock(&transaction->t_handle_lock); | ||
106 | } | ||
107 | #endif | ||
108 | } | ||
109 | |||
110 | /* | ||
85 | * start_this_handle: Given a handle, deal with any locking or stalling | 111 | * start_this_handle: Given a handle, deal with any locking or stalling |
86 | * needed to make sure that there is enough journal space for the handle | 112 | * needed to make sure that there is enough journal space for the handle |
87 | * to begin. Attach the handle to a transaction and set up the | 113 | * to begin. Attach the handle to a transaction and set up the |
@@ -95,7 +121,6 @@ static int start_this_handle(journal_t *journal, handle_t *handle, | |||
95 | int needed; | 121 | int needed; |
96 | int nblocks = handle->h_buffer_credits; | 122 | int nblocks = handle->h_buffer_credits; |
97 | transaction_t *new_transaction = NULL; | 123 | transaction_t *new_transaction = NULL; |
98 | unsigned long ts = jiffies; | ||
99 | 124 | ||
100 | if (nblocks > journal->j_max_transaction_buffers) { | 125 | if (nblocks > journal->j_max_transaction_buffers) { |
101 | printk(KERN_ERR "JBD: %s wants too many credits (%d > %d)\n", | 126 | printk(KERN_ERR "JBD: %s wants too many credits (%d > %d)\n", |
@@ -241,25 +266,8 @@ repeat: | |||
241 | 266 | ||
242 | /* OK, account for the buffers that this operation expects to | 267 | /* OK, account for the buffers that this operation expects to |
243 | * use and add the handle to the running transaction. | 268 | * use and add the handle to the running transaction. |
244 | * | ||
245 | * In order for t_max_wait to be reliable, it must be | ||
246 | * protected by a lock. But doing so will mean that | ||
247 | * start_this_handle() can not be run in parallel on SMP | ||
248 | * systems, which limits our scalability. So we only enable | ||
249 | * it when debugging is enabled. We may want to use a | ||
250 | * separate flag, eventually, so we can enable this | ||
251 | * independently of debugging. | ||
252 | */ | 269 | */ |
253 | #ifdef CONFIG_JBD2_DEBUG | 270 | update_t_max_wait(transaction); |
254 | if (jbd2_journal_enable_debug && | ||
255 | time_after(transaction->t_start, ts)) { | ||
256 | ts = jbd2_time_diff(ts, transaction->t_start); | ||
257 | spin_lock(&transaction->t_handle_lock); | ||
258 | if (ts > transaction->t_max_wait) | ||
259 | transaction->t_max_wait = ts; | ||
260 | spin_unlock(&transaction->t_handle_lock); | ||
261 | } | ||
262 | #endif | ||
263 | handle->h_transaction = transaction; | 271 | handle->h_transaction = transaction; |
264 | atomic_inc(&transaction->t_updates); | 272 | atomic_inc(&transaction->t_updates); |
265 | atomic_inc(&transaction->t_handle_count); | 273 | atomic_inc(&transaction->t_handle_count); |