transaction.c (16217dc79dbc599b110dda26d0421df47904bba4) | transaction.c (e03a9976afce6634826d56c33531dd10bb9a9166) |
---|---|
1/* 2 * linux/fs/jbd2/transaction.c 3 * 4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998 5 * 6 * Copyright 1998 Red Hat corp --- All Rights Reserved 7 * 8 * This file is part of the Linux kernel and is made available under --- 145 unchanged lines hidden (view full) --- 154 tid_t tid = journal->j_running_transaction->t_tid; 155 156 prepare_to_wait(&journal->j_wait_transaction_locked, &wait, 157 TASK_UNINTERRUPTIBLE); 158 need_to_start = !tid_geq(journal->j_commit_request, tid); 159 read_unlock(&journal->j_state_lock); 160 if (need_to_start) 161 jbd2_log_start_commit(journal, tid); | 1/* 2 * linux/fs/jbd2/transaction.c 3 * 4 * Written by Stephen C. Tweedie <sct@redhat.com>, 1998 5 * 6 * Copyright 1998 Red Hat corp --- All Rights Reserved 7 * 8 * This file is part of the Linux kernel and is made available under --- 145 unchanged lines hidden (view full) --- 154 tid_t tid = journal->j_running_transaction->t_tid; 155 156 prepare_to_wait(&journal->j_wait_transaction_locked, &wait, 157 TASK_UNINTERRUPTIBLE); 158 need_to_start = !tid_geq(journal->j_commit_request, tid); 159 read_unlock(&journal->j_state_lock); 160 if (need_to_start) 161 jbd2_log_start_commit(journal, tid); |
162 jbd2_might_wait_for_commit(journal); |
|
162 schedule(); 163 finish_wait(&journal->j_wait_transaction_locked, &wait); 164} 165 166static void sub_reserved_credits(journal_t *journal, int blocks) 167{ 168 atomic_sub(blocks, &journal->j_reserved_credits); 169 wake_up(&journal->j_wait_reserved); --- 7 unchanged lines hidden (view full) --- 177 */ 178static int add_transaction_credits(journal_t *journal, int blocks, 179 int rsv_blocks) 180{ 181 transaction_t *t = journal->j_running_transaction; 182 int needed; 183 int total = blocks + rsv_blocks; 184 | 163 schedule(); 164 finish_wait(&journal->j_wait_transaction_locked, &wait); 165} 166 167static void sub_reserved_credits(journal_t *journal, int blocks) 168{ 169 atomic_sub(blocks, &journal->j_reserved_credits); 170 wake_up(&journal->j_wait_reserved); --- 7 unchanged lines hidden (view full) --- 178 */ 179static int add_transaction_credits(journal_t *journal, int blocks, 180 int rsv_blocks) 181{ 182 transaction_t *t = journal->j_running_transaction; 183 int needed; 184 int total = blocks + rsv_blocks; 185 |
185 jbd2_might_wait_for_commit(journal); 186 | |
187 /* 188 * If the current transaction is locked down for commit, wait 189 * for the lock to be released. 190 */ 191 if (t->t_state == T_LOCKED) { 192 wait_transaction_locked(journal); 193 return 1; 194 } --- 14 unchanged lines hidden (view full) --- 209 210 /* 211 * Is the number of reserved credits in the current transaction too 212 * big to fit this handle? Wait until reserved credits are freed. 213 */ 214 if (atomic_read(&journal->j_reserved_credits) + total > 215 journal->j_max_transaction_buffers) { 216 read_unlock(&journal->j_state_lock); | 186 /* 187 * If the current transaction is locked down for commit, wait 188 * for the lock to be released. 189 */ 190 if (t->t_state == T_LOCKED) { 191 wait_transaction_locked(journal); 192 return 1; 193 } --- 14 unchanged lines hidden (view full) --- 208 209 /* 210 * Is the number of reserved credits in the current transaction too 211 * big to fit this handle? Wait until reserved credits are freed. 212 */ 213 if (atomic_read(&journal->j_reserved_credits) + total > 214 journal->j_max_transaction_buffers) { 215 read_unlock(&journal->j_state_lock); |
216 jbd2_might_wait_for_commit(journal); |
|
217 wait_event(journal->j_wait_reserved, 218 atomic_read(&journal->j_reserved_credits) + total <= 219 journal->j_max_transaction_buffers); 220 return 1; 221 } 222 223 wait_transaction_locked(journal); 224 return 1; --- 8 unchanged lines hidden (view full) --- 233 * 234 * We must therefore ensure the necessary space in the journal 235 * *before* starting to dirty potentially checkpointed buffers 236 * in the new transaction. 237 */ 238 if (jbd2_log_space_left(journal) < jbd2_space_needed(journal)) { 239 atomic_sub(total, &t->t_outstanding_credits); 240 read_unlock(&journal->j_state_lock); | 217 wait_event(journal->j_wait_reserved, 218 atomic_read(&journal->j_reserved_credits) + total <= 219 journal->j_max_transaction_buffers); 220 return 1; 221 } 222 223 wait_transaction_locked(journal); 224 return 1; --- 8 unchanged lines hidden (view full) --- 233 * 234 * We must therefore ensure the necessary space in the journal 235 * *before* starting to dirty potentially checkpointed buffers 236 * in the new transaction. 237 */ 238 if (jbd2_log_space_left(journal) < jbd2_space_needed(journal)) { 239 atomic_sub(total, &t->t_outstanding_credits); 240 read_unlock(&journal->j_state_lock); |
241 jbd2_might_wait_for_commit(journal); |
|
241 write_lock(&journal->j_state_lock); 242 if (jbd2_log_space_left(journal) < jbd2_space_needed(journal)) 243 __jbd2_log_wait_for_space(journal); 244 write_unlock(&journal->j_state_lock); 245 return 1; 246 } 247 248 /* No reservation? We are done... */ 249 if (!rsv_blocks) 250 return 0; 251 252 needed = atomic_add_return(rsv_blocks, &journal->j_reserved_credits); 253 /* We allow at most half of a transaction to be reserved */ 254 if (needed > journal->j_max_transaction_buffers / 2) { 255 sub_reserved_credits(journal, rsv_blocks); 256 atomic_sub(total, &t->t_outstanding_credits); 257 read_unlock(&journal->j_state_lock); | 242 write_lock(&journal->j_state_lock); 243 if (jbd2_log_space_left(journal) < jbd2_space_needed(journal)) 244 __jbd2_log_wait_for_space(journal); 245 write_unlock(&journal->j_state_lock); 246 return 1; 247 } 248 249 /* No reservation? We are done... */ 250 if (!rsv_blocks) 251 return 0; 252 253 needed = atomic_add_return(rsv_blocks, &journal->j_reserved_credits); 254 /* We allow at most half of a transaction to be reserved */ 255 if (needed > journal->j_max_transaction_buffers / 2) { 256 sub_reserved_credits(journal, rsv_blocks); 257 atomic_sub(total, &t->t_outstanding_credits); 258 read_unlock(&journal->j_state_lock); |
259 jbd2_might_wait_for_commit(journal); |
|
258 wait_event(journal->j_wait_reserved, 259 atomic_read(&journal->j_reserved_credits) + rsv_blocks 260 <= journal->j_max_transaction_buffers / 2); 261 return 1; 262 } 263 return 0; 264} 265 --- 2321 unchanged lines hidden --- | 260 wait_event(journal->j_wait_reserved, 261 atomic_read(&journal->j_reserved_credits) + rsv_blocks 262 <= journal->j_max_transaction_buffers / 2); 263 return 1; 264 } 265 return 0; 266} 267 --- 2321 unchanged lines hidden --- |