diff options
Diffstat (limited to 'fs/jbd')
| -rw-r--r-- | fs/jbd/checkpoint.c | 33 | ||||
| -rw-r--r-- | fs/jbd/commit.c | 188 | ||||
| -rw-r--r-- | fs/jbd/journal.c | 188 | ||||
| -rw-r--r-- | fs/jbd/recovery.c | 59 | ||||
| -rw-r--r-- | fs/jbd/revoke.c | 70 | ||||
| -rw-r--r-- | fs/jbd/transaction.c | 145 |
6 files changed, 402 insertions, 281 deletions
diff --git a/fs/jbd/checkpoint.c b/fs/jbd/checkpoint.c index 47678a26c13b..0208cc7ac5d0 100644 --- a/fs/jbd/checkpoint.c +++ b/fs/jbd/checkpoint.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/checkpoint.c | 2 | * linux/fs/checkpoint.c |
| 3 | * | 3 | * |
| 4 | * Written by Stephen C. Tweedie <sct@redhat.com>, 1999 | 4 | * Written by Stephen C. Tweedie <sct@redhat.com>, 1999 |
| 5 | * | 5 | * |
| 6 | * Copyright 1999 Red Hat Software --- All Rights Reserved | 6 | * Copyright 1999 Red Hat Software --- All Rights Reserved |
| @@ -9,8 +9,8 @@ | |||
| 9 | * the terms of the GNU General Public License, version 2, or at your | 9 | * the terms of the GNU General Public License, version 2, or at your |
| 10 | * option, any later version, incorporated herein by reference. | 10 | * option, any later version, incorporated herein by reference. |
| 11 | * | 11 | * |
| 12 | * Checkpoint routines for the generic filesystem journaling code. | 12 | * Checkpoint routines for the generic filesystem journaling code. |
| 13 | * Part of the ext2fs journaling system. | 13 | * Part of the ext2fs journaling system. |
| 14 | * | 14 | * |
| 15 | * Checkpointing is the process of ensuring that a section of the log is | 15 | * Checkpointing is the process of ensuring that a section of the log is |
| 16 | * committed fully to disk, so that that portion of the log can be | 16 | * committed fully to disk, so that that portion of the log can be |
| @@ -145,6 +145,7 @@ void __log_wait_for_space(journal_t *journal) | |||
| 145 | * jbd_unlock_bh_state(). | 145 | * jbd_unlock_bh_state(). |
| 146 | */ | 146 | */ |
| 147 | static void jbd_sync_bh(journal_t *journal, struct buffer_head *bh) | 147 | static void jbd_sync_bh(journal_t *journal, struct buffer_head *bh) |
| 148 | __releases(journal->j_list_lock) | ||
| 148 | { | 149 | { |
| 149 | get_bh(bh); | 150 | get_bh(bh); |
| 150 | spin_unlock(&journal->j_list_lock); | 151 | spin_unlock(&journal->j_list_lock); |
| @@ -225,7 +226,7 @@ __flush_batch(journal_t *journal, struct buffer_head **bhs, int *batch_count) | |||
| 225 | * Try to flush one buffer from the checkpoint list to disk. | 226 | * Try to flush one buffer from the checkpoint list to disk. |
| 226 | * | 227 | * |
| 227 | * Return 1 if something happened which requires us to abort the current | 228 | * Return 1 if something happened which requires us to abort the current |
| 228 | * scan of the checkpoint list. | 229 | * scan of the checkpoint list. |
| 229 | * | 230 | * |
| 230 | * Called with j_list_lock held and drops it if 1 is returned | 231 | * Called with j_list_lock held and drops it if 1 is returned |
| 231 | * Called under jbd_lock_bh_state(jh2bh(jh)), and drops it | 232 | * Called under jbd_lock_bh_state(jh2bh(jh)), and drops it |
| @@ -269,7 +270,7 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh, | |||
| 269 | * possibly block, while still holding the journal lock. | 270 | * possibly block, while still holding the journal lock. |
| 270 | * We cannot afford to let the transaction logic start | 271 | * We cannot afford to let the transaction logic start |
| 271 | * messing around with this buffer before we write it to | 272 | * messing around with this buffer before we write it to |
| 272 | * disk, as that would break recoverability. | 273 | * disk, as that would break recoverability. |
| 273 | */ | 274 | */ |
| 274 | BUFFER_TRACE(bh, "queue"); | 275 | BUFFER_TRACE(bh, "queue"); |
| 275 | get_bh(bh); | 276 | get_bh(bh); |
| @@ -292,7 +293,7 @@ static int __process_buffer(journal_t *journal, struct journal_head *jh, | |||
| 292 | * Perform an actual checkpoint. We take the first transaction on the | 293 | * Perform an actual checkpoint. We take the first transaction on the |
| 293 | * list of transactions to be checkpointed and send all its buffers | 294 | * list of transactions to be checkpointed and send all its buffers |
| 294 | * to disk. We submit larger chunks of data at once. | 295 | * to disk. We submit larger chunks of data at once. |
| 295 | * | 296 | * |
| 296 | * The journal should be locked before calling this function. | 297 | * The journal should be locked before calling this function. |
| 297 | */ | 298 | */ |
| 298 | int log_do_checkpoint(journal_t *journal) | 299 | int log_do_checkpoint(journal_t *journal) |
| @@ -303,10 +304,10 @@ int log_do_checkpoint(journal_t *journal) | |||
| 303 | 304 | ||
| 304 | jbd_debug(1, "Start checkpoint\n"); | 305 | jbd_debug(1, "Start checkpoint\n"); |
| 305 | 306 | ||
| 306 | /* | 307 | /* |
| 307 | * First thing: if there are any transactions in the log which | 308 | * First thing: if there are any transactions in the log which |
| 308 | * don't need checkpointing, just eliminate them from the | 309 | * don't need checkpointing, just eliminate them from the |
| 309 | * journal straight away. | 310 | * journal straight away. |
| 310 | */ | 311 | */ |
| 311 | result = cleanup_journal_tail(journal); | 312 | result = cleanup_journal_tail(journal); |
| 312 | jbd_debug(1, "cleanup_journal_tail returned %d\n", result); | 313 | jbd_debug(1, "cleanup_journal_tail returned %d\n", result); |
| @@ -384,9 +385,9 @@ out: | |||
| 384 | * we have already got rid of any since the last update of the log tail | 385 | * we have already got rid of any since the last update of the log tail |
| 385 | * in the journal superblock. If so, we can instantly roll the | 386 | * in the journal superblock. If so, we can instantly roll the |
| 386 | * superblock forward to remove those transactions from the log. | 387 | * superblock forward to remove those transactions from the log. |
| 387 | * | 388 | * |
| 388 | * Return <0 on error, 0 on success, 1 if there was nothing to clean up. | 389 | * Return <0 on error, 0 on success, 1 if there was nothing to clean up. |
| 389 | * | 390 | * |
| 390 | * Called with the journal lock held. | 391 | * Called with the journal lock held. |
| 391 | * | 392 | * |
| 392 | * This is the only part of the journaling code which really needs to be | 393 | * This is the only part of the journaling code which really needs to be |
| @@ -403,8 +404,8 @@ int cleanup_journal_tail(journal_t *journal) | |||
| 403 | unsigned long blocknr, freed; | 404 | unsigned long blocknr, freed; |
| 404 | 405 | ||
| 405 | /* OK, work out the oldest transaction remaining in the log, and | 406 | /* OK, work out the oldest transaction remaining in the log, and |
| 406 | * the log block it starts at. | 407 | * the log block it starts at. |
| 407 | * | 408 | * |
| 408 | * If the log is now empty, we need to work out which is the | 409 | * If the log is now empty, we need to work out which is the |
| 409 | * next transaction ID we will write, and where it will | 410 | * next transaction ID we will write, and where it will |
| 410 | * start. */ | 411 | * start. */ |
| @@ -479,7 +480,7 @@ static int journal_clean_one_cp_list(struct journal_head *jh, int *released) | |||
| 479 | if (!jh) | 480 | if (!jh) |
| 480 | return 0; | 481 | return 0; |
| 481 | 482 | ||
| 482 | last_jh = jh->b_cpprev; | 483 | last_jh = jh->b_cpprev; |
| 483 | do { | 484 | do { |
| 484 | jh = next_jh; | 485 | jh = next_jh; |
| 485 | next_jh = jh->b_cpnext; | 486 | next_jh = jh->b_cpnext; |
| @@ -557,7 +558,7 @@ out: | |||
| 557 | return ret; | 558 | return ret; |
| 558 | } | 559 | } |
| 559 | 560 | ||
| 560 | /* | 561 | /* |
| 561 | * journal_remove_checkpoint: called after a buffer has been committed | 562 | * journal_remove_checkpoint: called after a buffer has been committed |
| 562 | * to disk (either by being write-back flushed to disk, or being | 563 | * to disk (either by being write-back flushed to disk, or being |
| 563 | * committed to the log). | 564 | * committed to the log). |
| @@ -635,7 +636,7 @@ out: | |||
| 635 | * Called with the journal locked. | 636 | * Called with the journal locked. |
| 636 | * Called with j_list_lock held. | 637 | * Called with j_list_lock held. |
| 637 | */ | 638 | */ |
| 638 | void __journal_insert_checkpoint(struct journal_head *jh, | 639 | void __journal_insert_checkpoint(struct journal_head *jh, |
| 639 | transaction_t *transaction) | 640 | transaction_t *transaction) |
| 640 | { | 641 | { |
| 641 | JBUFFER_TRACE(jh, "entry"); | 642 | JBUFFER_TRACE(jh, "entry"); |
| @@ -657,7 +658,7 @@ void __journal_insert_checkpoint(struct journal_head *jh, | |||
| 657 | 658 | ||
| 658 | /* | 659 | /* |
| 659 | * We've finished with this transaction structure: adios... | 660 | * We've finished with this transaction structure: adios... |
| 660 | * | 661 | * |
| 661 | * The transaction must have no links except for the checkpoint by this | 662 | * The transaction must have no links except for the checkpoint by this |
| 662 | * point. | 663 | * point. |
| 663 | * | 664 | * |
diff --git a/fs/jbd/commit.c b/fs/jbd/commit.c index 0971814c38b8..32a8caf0c41e 100644 --- a/fs/jbd/commit.c +++ b/fs/jbd/commit.c | |||
| @@ -160,6 +160,117 @@ static int journal_write_commit_record(journal_t *journal, | |||
| 160 | return (ret == -EIO); | 160 | return (ret == -EIO); |
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | static void journal_do_submit_data(struct buffer_head **wbuf, int bufs) | ||
| 164 | { | ||
| 165 | int i; | ||
| 166 | |||
| 167 | for (i = 0; i < bufs; i++) { | ||
| 168 | wbuf[i]->b_end_io = end_buffer_write_sync; | ||
| 169 | /* We use-up our safety reference in submit_bh() */ | ||
| 170 | submit_bh(WRITE, wbuf[i]); | ||
| 171 | } | ||
| 172 | } | ||
| 173 | |||
| 174 | /* | ||
| 175 | * Submit all the data buffers to disk | ||
| 176 | */ | ||
| 177 | static void journal_submit_data_buffers(journal_t *journal, | ||
| 178 | transaction_t *commit_transaction) | ||
| 179 | { | ||
| 180 | struct journal_head *jh; | ||
| 181 | struct buffer_head *bh; | ||
| 182 | int locked; | ||
| 183 | int bufs = 0; | ||
| 184 | struct buffer_head **wbuf = journal->j_wbuf; | ||
| 185 | |||
| 186 | /* | ||
| 187 | * Whenever we unlock the journal and sleep, things can get added | ||
| 188 | * onto ->t_sync_datalist, so we have to keep looping back to | ||
| 189 | * write_out_data until we *know* that the list is empty. | ||
| 190 | * | ||
| 191 | * Cleanup any flushed data buffers from the data list. Even in | ||
| 192 | * abort mode, we want to flush this out as soon as possible. | ||
| 193 | */ | ||
| 194 | write_out_data: | ||
| 195 | cond_resched(); | ||
| 196 | spin_lock(&journal->j_list_lock); | ||
| 197 | |||
| 198 | while (commit_transaction->t_sync_datalist) { | ||
| 199 | jh = commit_transaction->t_sync_datalist; | ||
| 200 | bh = jh2bh(jh); | ||
| 201 | locked = 0; | ||
| 202 | |||
| 203 | /* Get reference just to make sure buffer does not disappear | ||
| 204 | * when we are forced to drop various locks */ | ||
| 205 | get_bh(bh); | ||
| 206 | /* If the buffer is dirty, we need to submit IO and hence | ||
| 207 | * we need the buffer lock. We try to lock the buffer without | ||
| 208 | * blocking. If we fail, we need to drop j_list_lock and do | ||
| 209 | * blocking lock_buffer(). | ||
| 210 | */ | ||
| 211 | if (buffer_dirty(bh)) { | ||
| 212 | if (test_set_buffer_locked(bh)) { | ||
| 213 | BUFFER_TRACE(bh, "needs blocking lock"); | ||
| 214 | spin_unlock(&journal->j_list_lock); | ||
| 215 | /* Write out all data to prevent deadlocks */ | ||
| 216 | journal_do_submit_data(wbuf, bufs); | ||
| 217 | bufs = 0; | ||
| 218 | lock_buffer(bh); | ||
| 219 | spin_lock(&journal->j_list_lock); | ||
| 220 | } | ||
| 221 | locked = 1; | ||
| 222 | } | ||
| 223 | /* We have to get bh_state lock. Again out of order, sigh. */ | ||
| 224 | if (!inverted_lock(journal, bh)) { | ||
| 225 | jbd_lock_bh_state(bh); | ||
| 226 | spin_lock(&journal->j_list_lock); | ||
| 227 | } | ||
| 228 | /* Someone already cleaned up the buffer? */ | ||
| 229 | if (!buffer_jbd(bh) | ||
| 230 | || jh->b_transaction != commit_transaction | ||
| 231 | || jh->b_jlist != BJ_SyncData) { | ||
| 232 | jbd_unlock_bh_state(bh); | ||
| 233 | if (locked) | ||
| 234 | unlock_buffer(bh); | ||
| 235 | BUFFER_TRACE(bh, "already cleaned up"); | ||
| 236 | put_bh(bh); | ||
| 237 | continue; | ||
| 238 | } | ||
| 239 | if (locked && test_clear_buffer_dirty(bh)) { | ||
| 240 | BUFFER_TRACE(bh, "needs writeout, adding to array"); | ||
| 241 | wbuf[bufs++] = bh; | ||
| 242 | __journal_file_buffer(jh, commit_transaction, | ||
| 243 | BJ_Locked); | ||
| 244 | jbd_unlock_bh_state(bh); | ||
| 245 | if (bufs == journal->j_wbufsize) { | ||
| 246 | spin_unlock(&journal->j_list_lock); | ||
| 247 | journal_do_submit_data(wbuf, bufs); | ||
| 248 | bufs = 0; | ||
| 249 | goto write_out_data; | ||
| 250 | } | ||
| 251 | } | ||
| 252 | else { | ||
| 253 | BUFFER_TRACE(bh, "writeout complete: unfile"); | ||
| 254 | __journal_unfile_buffer(jh); | ||
| 255 | jbd_unlock_bh_state(bh); | ||
| 256 | if (locked) | ||
| 257 | unlock_buffer(bh); | ||
| 258 | journal_remove_journal_head(bh); | ||
| 259 | /* Once for our safety reference, once for | ||
| 260 | * journal_remove_journal_head() */ | ||
| 261 | put_bh(bh); | ||
| 262 | put_bh(bh); | ||
| 263 | } | ||
| 264 | |||
| 265 | if (lock_need_resched(&journal->j_list_lock)) { | ||
| 266 | spin_unlock(&journal->j_list_lock); | ||
| 267 | goto write_out_data; | ||
| 268 | } | ||
| 269 | } | ||
| 270 | spin_unlock(&journal->j_list_lock); | ||
| 271 | journal_do_submit_data(wbuf, bufs); | ||
| 272 | } | ||
| 273 | |||
| 163 | /* | 274 | /* |
| 164 | * journal_commit_transaction | 275 | * journal_commit_transaction |
| 165 | * | 276 | * |
| @@ -261,7 +372,7 @@ void journal_commit_transaction(journal_t *journal) | |||
| 261 | struct buffer_head *bh = jh2bh(jh); | 372 | struct buffer_head *bh = jh2bh(jh); |
| 262 | 373 | ||
| 263 | jbd_lock_bh_state(bh); | 374 | jbd_lock_bh_state(bh); |
| 264 | kfree(jh->b_committed_data); | 375 | jbd_slab_free(jh->b_committed_data, bh->b_size); |
| 265 | jh->b_committed_data = NULL; | 376 | jh->b_committed_data = NULL; |
| 266 | jbd_unlock_bh_state(bh); | 377 | jbd_unlock_bh_state(bh); |
| 267 | } | 378 | } |
| @@ -313,80 +424,13 @@ void journal_commit_transaction(journal_t *journal) | |||
| 313 | * Now start flushing things to disk, in the order they appear | 424 | * Now start flushing things to disk, in the order they appear |
| 314 | * on the transaction lists. Data blocks go first. | 425 | * on the transaction lists. Data blocks go first. |
| 315 | */ | 426 | */ |
| 316 | |||
| 317 | err = 0; | 427 | err = 0; |
| 318 | /* | 428 | journal_submit_data_buffers(journal, commit_transaction); |
| 319 | * Whenever we unlock the journal and sleep, things can get added | ||
| 320 | * onto ->t_sync_datalist, so we have to keep looping back to | ||
| 321 | * write_out_data until we *know* that the list is empty. | ||
| 322 | */ | ||
| 323 | bufs = 0; | ||
| 324 | /* | ||
| 325 | * Cleanup any flushed data buffers from the data list. Even in | ||
| 326 | * abort mode, we want to flush this out as soon as possible. | ||
| 327 | */ | ||
| 328 | write_out_data: | ||
| 329 | cond_resched(); | ||
| 330 | spin_lock(&journal->j_list_lock); | ||
| 331 | |||
| 332 | while (commit_transaction->t_sync_datalist) { | ||
| 333 | struct buffer_head *bh; | ||
| 334 | |||
| 335 | jh = commit_transaction->t_sync_datalist; | ||
| 336 | commit_transaction->t_sync_datalist = jh->b_tnext; | ||
| 337 | bh = jh2bh(jh); | ||
| 338 | if (buffer_locked(bh)) { | ||
| 339 | BUFFER_TRACE(bh, "locked"); | ||
| 340 | if (!inverted_lock(journal, bh)) | ||
| 341 | goto write_out_data; | ||
| 342 | __journal_temp_unlink_buffer(jh); | ||
| 343 | __journal_file_buffer(jh, commit_transaction, | ||
| 344 | BJ_Locked); | ||
| 345 | jbd_unlock_bh_state(bh); | ||
| 346 | if (lock_need_resched(&journal->j_list_lock)) { | ||
| 347 | spin_unlock(&journal->j_list_lock); | ||
| 348 | goto write_out_data; | ||
| 349 | } | ||
| 350 | } else { | ||
| 351 | if (buffer_dirty(bh)) { | ||
| 352 | BUFFER_TRACE(bh, "start journal writeout"); | ||
| 353 | get_bh(bh); | ||
| 354 | wbuf[bufs++] = bh; | ||
| 355 | if (bufs == journal->j_wbufsize) { | ||
| 356 | jbd_debug(2, "submit %d writes\n", | ||
| 357 | bufs); | ||
| 358 | spin_unlock(&journal->j_list_lock); | ||
| 359 | ll_rw_block(SWRITE, bufs, wbuf); | ||
| 360 | journal_brelse_array(wbuf, bufs); | ||
| 361 | bufs = 0; | ||
| 362 | goto write_out_data; | ||
| 363 | } | ||
| 364 | } else { | ||
| 365 | BUFFER_TRACE(bh, "writeout complete: unfile"); | ||
| 366 | if (!inverted_lock(journal, bh)) | ||
| 367 | goto write_out_data; | ||
| 368 | __journal_unfile_buffer(jh); | ||
| 369 | jbd_unlock_bh_state(bh); | ||
| 370 | journal_remove_journal_head(bh); | ||
| 371 | put_bh(bh); | ||
| 372 | if (lock_need_resched(&journal->j_list_lock)) { | ||
| 373 | spin_unlock(&journal->j_list_lock); | ||
| 374 | goto write_out_data; | ||
| 375 | } | ||
| 376 | } | ||
| 377 | } | ||
| 378 | } | ||
| 379 | |||
| 380 | if (bufs) { | ||
| 381 | spin_unlock(&journal->j_list_lock); | ||
| 382 | ll_rw_block(SWRITE, bufs, wbuf); | ||
| 383 | journal_brelse_array(wbuf, bufs); | ||
| 384 | spin_lock(&journal->j_list_lock); | ||
| 385 | } | ||
| 386 | 429 | ||
| 387 | /* | 430 | /* |
| 388 | * Wait for all previously submitted IO to complete. | 431 | * Wait for all previously submitted IO to complete. |
| 389 | */ | 432 | */ |
| 433 | spin_lock(&journal->j_list_lock); | ||
| 390 | while (commit_transaction->t_locked_list) { | 434 | while (commit_transaction->t_locked_list) { |
| 391 | struct buffer_head *bh; | 435 | struct buffer_head *bh; |
| 392 | 436 | ||
| @@ -745,14 +789,14 @@ restart_loop: | |||
| 745 | * Otherwise, we can just throw away the frozen data now. | 789 | * Otherwise, we can just throw away the frozen data now. |
| 746 | */ | 790 | */ |
| 747 | if (jh->b_committed_data) { | 791 | if (jh->b_committed_data) { |
| 748 | kfree(jh->b_committed_data); | 792 | jbd_slab_free(jh->b_committed_data, bh->b_size); |
| 749 | jh->b_committed_data = NULL; | 793 | jh->b_committed_data = NULL; |
| 750 | if (jh->b_frozen_data) { | 794 | if (jh->b_frozen_data) { |
| 751 | jh->b_committed_data = jh->b_frozen_data; | 795 | jh->b_committed_data = jh->b_frozen_data; |
| 752 | jh->b_frozen_data = NULL; | 796 | jh->b_frozen_data = NULL; |
| 753 | } | 797 | } |
| 754 | } else if (jh->b_frozen_data) { | 798 | } else if (jh->b_frozen_data) { |
| 755 | kfree(jh->b_frozen_data); | 799 | jbd_slab_free(jh->b_frozen_data, bh->b_size); |
| 756 | jh->b_frozen_data = NULL; | 800 | jh->b_frozen_data = NULL; |
| 757 | } | 801 | } |
| 758 | 802 | ||
diff --git a/fs/jbd/journal.c b/fs/jbd/journal.c index 7f96b5cb6781..7af6099c911c 100644 --- a/fs/jbd/journal.c +++ b/fs/jbd/journal.c | |||
| @@ -34,6 +34,7 @@ | |||
| 34 | #include <linux/suspend.h> | 34 | #include <linux/suspend.h> |
| 35 | #include <linux/pagemap.h> | 35 | #include <linux/pagemap.h> |
| 36 | #include <linux/kthread.h> | 36 | #include <linux/kthread.h> |
| 37 | #include <linux/poison.h> | ||
| 37 | #include <linux/proc_fs.h> | 38 | #include <linux/proc_fs.h> |
| 38 | 39 | ||
| 39 | #include <asm/uaccess.h> | 40 | #include <asm/uaccess.h> |
| @@ -83,6 +84,7 @@ EXPORT_SYMBOL(journal_force_commit); | |||
| 83 | 84 | ||
| 84 | static int journal_convert_superblock_v1(journal_t *, journal_superblock_t *); | 85 | static int journal_convert_superblock_v1(journal_t *, journal_superblock_t *); |
| 85 | static void __journal_abort_soft (journal_t *journal, int errno); | 86 | static void __journal_abort_soft (journal_t *journal, int errno); |
| 87 | static int journal_create_jbd_slab(size_t slab_size); | ||
| 86 | 88 | ||
| 87 | /* | 89 | /* |
| 88 | * Helper function used to manage commit timeouts | 90 | * Helper function used to manage commit timeouts |
| @@ -179,7 +181,7 @@ loop: | |||
| 179 | transaction->t_expires)) | 181 | transaction->t_expires)) |
| 180 | should_sleep = 0; | 182 | should_sleep = 0; |
| 181 | if (journal->j_flags & JFS_UNMOUNT) | 183 | if (journal->j_flags & JFS_UNMOUNT) |
| 182 | should_sleep = 0; | 184 | should_sleep = 0; |
| 183 | if (should_sleep) { | 185 | if (should_sleep) { |
| 184 | spin_unlock(&journal->j_state_lock); | 186 | spin_unlock(&journal->j_state_lock); |
| 185 | schedule(); | 187 | schedule(); |
| @@ -269,7 +271,7 @@ static void journal_kill_thread(journal_t *journal) | |||
| 269 | int journal_write_metadata_buffer(transaction_t *transaction, | 271 | int journal_write_metadata_buffer(transaction_t *transaction, |
| 270 | struct journal_head *jh_in, | 272 | struct journal_head *jh_in, |
| 271 | struct journal_head **jh_out, | 273 | struct journal_head **jh_out, |
| 272 | int blocknr) | 274 | unsigned long blocknr) |
| 273 | { | 275 | { |
| 274 | int need_copy_out = 0; | 276 | int need_copy_out = 0; |
| 275 | int done_copy_out = 0; | 277 | int done_copy_out = 0; |
| @@ -327,10 +329,10 @@ repeat: | |||
| 327 | char *tmp; | 329 | char *tmp; |
| 328 | 330 | ||
| 329 | jbd_unlock_bh_state(bh_in); | 331 | jbd_unlock_bh_state(bh_in); |
| 330 | tmp = jbd_rep_kmalloc(bh_in->b_size, GFP_NOFS); | 332 | tmp = jbd_slab_alloc(bh_in->b_size, GFP_NOFS); |
| 331 | jbd_lock_bh_state(bh_in); | 333 | jbd_lock_bh_state(bh_in); |
| 332 | if (jh_in->b_frozen_data) { | 334 | if (jh_in->b_frozen_data) { |
| 333 | kfree(tmp); | 335 | jbd_slab_free(tmp, bh_in->b_size); |
| 334 | goto repeat; | 336 | goto repeat; |
| 335 | } | 337 | } |
| 336 | 338 | ||
| @@ -576,7 +578,7 @@ int journal_next_log_block(journal_t *journal, unsigned long *retp) | |||
| 576 | * this is a no-op. If needed, we can use j_blk_offset - everything is | 578 | * this is a no-op. If needed, we can use j_blk_offset - everything is |
| 577 | * ready. | 579 | * ready. |
| 578 | */ | 580 | */ |
| 579 | int journal_bmap(journal_t *journal, unsigned long blocknr, | 581 | int journal_bmap(journal_t *journal, unsigned long blocknr, |
| 580 | unsigned long *retp) | 582 | unsigned long *retp) |
| 581 | { | 583 | { |
| 582 | int err = 0; | 584 | int err = 0; |
| @@ -694,13 +696,13 @@ fail: | |||
| 694 | * @bdev: Block device on which to create the journal | 696 | * @bdev: Block device on which to create the journal |
| 695 | * @fs_dev: Device which hold journalled filesystem for this journal. | 697 | * @fs_dev: Device which hold journalled filesystem for this journal. |
| 696 | * @start: Block nr Start of journal. | 698 | * @start: Block nr Start of journal. |
| 697 | * @len: Lenght of the journal in blocks. | 699 | * @len: Length of the journal in blocks. |
| 698 | * @blocksize: blocksize of journalling device | 700 | * @blocksize: blocksize of journalling device |
| 699 | * @returns: a newly created journal_t * | 701 | * @returns: a newly created journal_t * |
| 700 | * | 702 | * |
| 701 | * journal_init_dev creates a journal which maps a fixed contiguous | 703 | * journal_init_dev creates a journal which maps a fixed contiguous |
| 702 | * range of blocks on an arbitrary block device. | 704 | * range of blocks on an arbitrary block device. |
| 703 | * | 705 | * |
| 704 | */ | 706 | */ |
| 705 | journal_t * journal_init_dev(struct block_device *bdev, | 707 | journal_t * journal_init_dev(struct block_device *bdev, |
| 706 | struct block_device *fs_dev, | 708 | struct block_device *fs_dev, |
| @@ -713,18 +715,8 @@ journal_t * journal_init_dev(struct block_device *bdev, | |||
| 713 | if (!journal) | 715 | if (!journal) |
| 714 | return NULL; | 716 | return NULL; |
| 715 | 717 | ||
| 716 | journal->j_dev = bdev; | ||
| 717 | journal->j_fs_dev = fs_dev; | ||
| 718 | journal->j_blk_offset = start; | ||
| 719 | journal->j_maxlen = len; | ||
| 720 | journal->j_blocksize = blocksize; | ||
| 721 | |||
| 722 | bh = __getblk(journal->j_dev, start, journal->j_blocksize); | ||
| 723 | J_ASSERT(bh != NULL); | ||
| 724 | journal->j_sb_buffer = bh; | ||
| 725 | journal->j_superblock = (journal_superblock_t *)bh->b_data; | ||
| 726 | |||
| 727 | /* journal descriptor can store up to n blocks -bzzz */ | 718 | /* journal descriptor can store up to n blocks -bzzz */ |
| 719 | journal->j_blocksize = blocksize; | ||
| 728 | n = journal->j_blocksize / sizeof(journal_block_tag_t); | 720 | n = journal->j_blocksize / sizeof(journal_block_tag_t); |
| 729 | journal->j_wbufsize = n; | 721 | journal->j_wbufsize = n; |
| 730 | journal->j_wbuf = kmalloc(n * sizeof(struct buffer_head*), GFP_KERNEL); | 722 | journal->j_wbuf = kmalloc(n * sizeof(struct buffer_head*), GFP_KERNEL); |
| @@ -734,14 +726,23 @@ journal_t * journal_init_dev(struct block_device *bdev, | |||
| 734 | kfree(journal); | 726 | kfree(journal); |
| 735 | journal = NULL; | 727 | journal = NULL; |
| 736 | } | 728 | } |
| 729 | journal->j_dev = bdev; | ||
| 730 | journal->j_fs_dev = fs_dev; | ||
| 731 | journal->j_blk_offset = start; | ||
| 732 | journal->j_maxlen = len; | ||
| 733 | |||
| 734 | bh = __getblk(journal->j_dev, start, journal->j_blocksize); | ||
| 735 | J_ASSERT(bh != NULL); | ||
| 736 | journal->j_sb_buffer = bh; | ||
| 737 | journal->j_superblock = (journal_superblock_t *)bh->b_data; | ||
| 737 | 738 | ||
| 738 | return journal; | 739 | return journal; |
| 739 | } | 740 | } |
| 740 | 741 | ||
| 741 | /** | 742 | /** |
| 742 | * journal_t * journal_init_inode () - creates a journal which maps to a inode. | 743 | * journal_t * journal_init_inode () - creates a journal which maps to a inode. |
| 743 | * @inode: An inode to create the journal in | 744 | * @inode: An inode to create the journal in |
| 744 | * | 745 | * |
| 745 | * journal_init_inode creates a journal which maps an on-disk inode as | 746 | * journal_init_inode creates a journal which maps an on-disk inode as |
| 746 | * the journal. The inode must exist already, must support bmap() and | 747 | * the journal. The inode must exist already, must support bmap() and |
| 747 | * must have all data blocks preallocated. | 748 | * must have all data blocks preallocated. |
| @@ -761,7 +762,7 @@ journal_t * journal_init_inode (struct inode *inode) | |||
| 761 | journal->j_inode = inode; | 762 | journal->j_inode = inode; |
| 762 | jbd_debug(1, | 763 | jbd_debug(1, |
| 763 | "journal %p: inode %s/%ld, size %Ld, bits %d, blksize %ld\n", | 764 | "journal %p: inode %s/%ld, size %Ld, bits %d, blksize %ld\n", |
| 764 | journal, inode->i_sb->s_id, inode->i_ino, | 765 | journal, inode->i_sb->s_id, inode->i_ino, |
| 765 | (long long) inode->i_size, | 766 | (long long) inode->i_size, |
| 766 | inode->i_sb->s_blocksize_bits, inode->i_sb->s_blocksize); | 767 | inode->i_sb->s_blocksize_bits, inode->i_sb->s_blocksize); |
| 767 | 768 | ||
| @@ -796,10 +797,10 @@ journal_t * journal_init_inode (struct inode *inode) | |||
| 796 | return journal; | 797 | return journal; |
| 797 | } | 798 | } |
| 798 | 799 | ||
| 799 | /* | 800 | /* |
| 800 | * If the journal init or create aborts, we need to mark the journal | 801 | * If the journal init or create aborts, we need to mark the journal |
| 801 | * superblock as being NULL to prevent the journal destroy from writing | 802 | * superblock as being NULL to prevent the journal destroy from writing |
| 802 | * back a bogus superblock. | 803 | * back a bogus superblock. |
| 803 | */ | 804 | */ |
| 804 | static void journal_fail_superblock (journal_t *journal) | 805 | static void journal_fail_superblock (journal_t *journal) |
| 805 | { | 806 | { |
| @@ -818,7 +819,7 @@ static void journal_fail_superblock (journal_t *journal) | |||
| 818 | static int journal_reset(journal_t *journal) | 819 | static int journal_reset(journal_t *journal) |
| 819 | { | 820 | { |
| 820 | journal_superblock_t *sb = journal->j_superblock; | 821 | journal_superblock_t *sb = journal->j_superblock; |
| 821 | unsigned int first, last; | 822 | unsigned long first, last; |
| 822 | 823 | ||
| 823 | first = be32_to_cpu(sb->s_first); | 824 | first = be32_to_cpu(sb->s_first); |
| 824 | last = be32_to_cpu(sb->s_maxlen); | 825 | last = be32_to_cpu(sb->s_maxlen); |
| @@ -842,13 +843,13 @@ static int journal_reset(journal_t *journal) | |||
| 842 | return 0; | 843 | return 0; |
| 843 | } | 844 | } |
| 844 | 845 | ||
| 845 | /** | 846 | /** |
| 846 | * int journal_create() - Initialise the new journal file | 847 | * int journal_create() - Initialise the new journal file |
| 847 | * @journal: Journal to create. This structure must have been initialised | 848 | * @journal: Journal to create. This structure must have been initialised |
| 848 | * | 849 | * |
| 849 | * Given a journal_t structure which tells us which disk blocks we can | 850 | * Given a journal_t structure which tells us which disk blocks we can |
| 850 | * use, create a new journal superblock and initialise all of the | 851 | * use, create a new journal superblock and initialise all of the |
| 851 | * journal fields from scratch. | 852 | * journal fields from scratch. |
| 852 | **/ | 853 | **/ |
| 853 | int journal_create(journal_t *journal) | 854 | int journal_create(journal_t *journal) |
| 854 | { | 855 | { |
| @@ -913,7 +914,7 @@ int journal_create(journal_t *journal) | |||
| 913 | return journal_reset(journal); | 914 | return journal_reset(journal); |
| 914 | } | 915 | } |
| 915 | 916 | ||
| 916 | /** | 917 | /** |
| 917 | * void journal_update_superblock() - Update journal sb on disk. | 918 | * void journal_update_superblock() - Update journal sb on disk. |
| 918 | * @journal: The journal to update. | 919 | * @journal: The journal to update. |
| 919 | * @wait: Set to '0' if you don't want to wait for IO completion. | 920 | * @wait: Set to '0' if you don't want to wait for IO completion. |
| @@ -937,7 +938,7 @@ void journal_update_superblock(journal_t *journal, int wait) | |||
| 937 | journal->j_transaction_sequence) { | 938 | journal->j_transaction_sequence) { |
| 938 | jbd_debug(1,"JBD: Skipping superblock update on recovered sb " | 939 | jbd_debug(1,"JBD: Skipping superblock update on recovered sb " |
| 939 | "(start %ld, seq %d, errno %d)\n", | 940 | "(start %ld, seq %d, errno %d)\n", |
| 940 | journal->j_tail, journal->j_tail_sequence, | 941 | journal->j_tail, journal->j_tail_sequence, |
| 941 | journal->j_errno); | 942 | journal->j_errno); |
| 942 | goto out; | 943 | goto out; |
| 943 | } | 944 | } |
| @@ -1060,7 +1061,7 @@ static int load_superblock(journal_t *journal) | |||
| 1060 | /** | 1061 | /** |
| 1061 | * int journal_load() - Read journal from disk. | 1062 | * int journal_load() - Read journal from disk. |
| 1062 | * @journal: Journal to act on. | 1063 | * @journal: Journal to act on. |
| 1063 | * | 1064 | * |
| 1064 | * Given a journal_t structure which tells us which disk blocks contain | 1065 | * Given a journal_t structure which tells us which disk blocks contain |
| 1065 | * a journal, read the journal from disk to initialise the in-memory | 1066 | * a journal, read the journal from disk to initialise the in-memory |
| 1066 | * structures. | 1067 | * structures. |
| @@ -1068,17 +1069,17 @@ static int load_superblock(journal_t *journal) | |||
| 1068 | int journal_load(journal_t *journal) | 1069 | int journal_load(journal_t *journal) |
| 1069 | { | 1070 | { |
| 1070 | int err; | 1071 | int err; |
| 1072 | journal_superblock_t *sb; | ||
| 1071 | 1073 | ||
| 1072 | err = load_superblock(journal); | 1074 | err = load_superblock(journal); |
| 1073 | if (err) | 1075 | if (err) |
| 1074 | return err; | 1076 | return err; |
| 1075 | 1077 | ||
| 1078 | sb = journal->j_superblock; | ||
| 1076 | /* If this is a V2 superblock, then we have to check the | 1079 | /* If this is a V2 superblock, then we have to check the |
| 1077 | * features flags on it. */ | 1080 | * features flags on it. */ |
| 1078 | 1081 | ||
| 1079 | if (journal->j_format_version >= 2) { | 1082 | if (journal->j_format_version >= 2) { |
| 1080 | journal_superblock_t *sb = journal->j_superblock; | ||
| 1081 | |||
| 1082 | if ((sb->s_feature_ro_compat & | 1083 | if ((sb->s_feature_ro_compat & |
| 1083 | ~cpu_to_be32(JFS_KNOWN_ROCOMPAT_FEATURES)) || | 1084 | ~cpu_to_be32(JFS_KNOWN_ROCOMPAT_FEATURES)) || |
| 1084 | (sb->s_feature_incompat & | 1085 | (sb->s_feature_incompat & |
| @@ -1089,6 +1090,13 @@ int journal_load(journal_t *journal) | |||
| 1089 | } | 1090 | } |
| 1090 | } | 1091 | } |
| 1091 | 1092 | ||
| 1093 | /* | ||
| 1094 | * Create a slab for this blocksize | ||
| 1095 | */ | ||
| 1096 | err = journal_create_jbd_slab(be32_to_cpu(sb->s_blocksize)); | ||
| 1097 | if (err) | ||
| 1098 | return err; | ||
| 1099 | |||
| 1092 | /* Let the recovery code check whether it needs to recover any | 1100 | /* Let the recovery code check whether it needs to recover any |
| 1093 | * data from the journal. */ | 1101 | * data from the journal. */ |
| 1094 | if (journal_recover(journal)) | 1102 | if (journal_recover(journal)) |
| @@ -1163,9 +1171,9 @@ void journal_destroy(journal_t *journal) | |||
| 1163 | * @compat: bitmask of compatible features | 1171 | * @compat: bitmask of compatible features |
| 1164 | * @ro: bitmask of features that force read-only mount | 1172 | * @ro: bitmask of features that force read-only mount |
| 1165 | * @incompat: bitmask of incompatible features | 1173 | * @incompat: bitmask of incompatible features |
| 1166 | * | 1174 | * |
| 1167 | * Check whether the journal uses all of a given set of | 1175 | * Check whether the journal uses all of a given set of |
| 1168 | * features. Return true (non-zero) if it does. | 1176 | * features. Return true (non-zero) if it does. |
| 1169 | **/ | 1177 | **/ |
| 1170 | 1178 | ||
| 1171 | int journal_check_used_features (journal_t *journal, unsigned long compat, | 1179 | int journal_check_used_features (journal_t *journal, unsigned long compat, |
| @@ -1194,7 +1202,7 @@ int journal_check_used_features (journal_t *journal, unsigned long compat, | |||
| 1194 | * @compat: bitmask of compatible features | 1202 | * @compat: bitmask of compatible features |
| 1195 | * @ro: bitmask of features that force read-only mount | 1203 | * @ro: bitmask of features that force read-only mount |
| 1196 | * @incompat: bitmask of incompatible features | 1204 | * @incompat: bitmask of incompatible features |
| 1197 | * | 1205 | * |
| 1198 | * Check whether the journaling code supports the use of | 1206 | * Check whether the journaling code supports the use of |
| 1199 | * all of a given set of features on this journal. Return true | 1207 | * all of a given set of features on this journal. Return true |
| 1200 | * (non-zero) if it can. */ | 1208 | * (non-zero) if it can. */ |
| @@ -1232,7 +1240,7 @@ int journal_check_available_features (journal_t *journal, unsigned long compat, | |||
| 1232 | * @incompat: bitmask of incompatible features | 1240 | * @incompat: bitmask of incompatible features |
| 1233 | * | 1241 | * |
| 1234 | * Mark a given journal feature as present on the | 1242 | * Mark a given journal feature as present on the |
| 1235 | * superblock. Returns true if the requested features could be set. | 1243 | * superblock. Returns true if the requested features could be set. |
| 1236 | * | 1244 | * |
| 1237 | */ | 1245 | */ |
| 1238 | 1246 | ||
| @@ -1318,7 +1326,7 @@ static int journal_convert_superblock_v1(journal_t *journal, | |||
| 1318 | /** | 1326 | /** |
| 1319 | * int journal_flush () - Flush journal | 1327 | * int journal_flush () - Flush journal |
| 1320 | * @journal: Journal to act on. | 1328 | * @journal: Journal to act on. |
| 1321 | * | 1329 | * |
| 1322 | * Flush all data for a given journal to disk and empty the journal. | 1330 | * Flush all data for a given journal to disk and empty the journal. |
| 1323 | * Filesystems can use this when remounting readonly to ensure that | 1331 | * Filesystems can use this when remounting readonly to ensure that |
| 1324 | * recovery does not need to happen on remount. | 1332 | * recovery does not need to happen on remount. |
| @@ -1385,7 +1393,7 @@ int journal_flush(journal_t *journal) | |||
| 1385 | * int journal_wipe() - Wipe journal contents | 1393 | * int journal_wipe() - Wipe journal contents |
| 1386 | * @journal: Journal to act on. | 1394 | * @journal: Journal to act on. |
| 1387 | * @write: flag (see below) | 1395 | * @write: flag (see below) |
| 1388 | * | 1396 | * |
| 1389 | * Wipe out all of the contents of a journal, safely. This will produce | 1397 | * Wipe out all of the contents of a journal, safely. This will produce |
| 1390 | * a warning if the journal contains any valid recovery information. | 1398 | * a warning if the journal contains any valid recovery information. |
| 1391 | * Must be called between journal_init_*() and journal_load(). | 1399 | * Must be called between journal_init_*() and journal_load(). |
| @@ -1440,7 +1448,7 @@ static const char *journal_dev_name(journal_t *journal, char *buffer) | |||
| 1440 | 1448 | ||
| 1441 | /* | 1449 | /* |
| 1442 | * Journal abort has very specific semantics, which we describe | 1450 | * Journal abort has very specific semantics, which we describe |
| 1443 | * for journal abort. | 1451 | * for journal abort. |
| 1444 | * | 1452 | * |
| 1445 | * Two internal function, which provide abort to te jbd layer | 1453 | * Two internal function, which provide abort to te jbd layer |
| 1446 | * itself are here. | 1454 | * itself are here. |
| @@ -1495,7 +1503,7 @@ static void __journal_abort_soft (journal_t *journal, int errno) | |||
| 1495 | * Perform a complete, immediate shutdown of the ENTIRE | 1503 | * Perform a complete, immediate shutdown of the ENTIRE |
| 1496 | * journal (not of a single transaction). This operation cannot be | 1504 | * journal (not of a single transaction). This operation cannot be |
| 1497 | * undone without closing and reopening the journal. | 1505 | * undone without closing and reopening the journal. |
| 1498 | * | 1506 | * |
| 1499 | * The journal_abort function is intended to support higher level error | 1507 | * The journal_abort function is intended to support higher level error |
| 1500 | * recovery mechanisms such as the ext2/ext3 remount-readonly error | 1508 | * recovery mechanisms such as the ext2/ext3 remount-readonly error |
| 1501 | * mode. | 1509 | * mode. |
| @@ -1529,7 +1537,7 @@ static void __journal_abort_soft (journal_t *journal, int errno) | |||
| 1529 | * supply an errno; a null errno implies that absolutely no further | 1537 | * supply an errno; a null errno implies that absolutely no further |
| 1530 | * writes are done to the journal (unless there are any already in | 1538 | * writes are done to the journal (unless there are any already in |
| 1531 | * progress). | 1539 | * progress). |
| 1532 | * | 1540 | * |
| 1533 | */ | 1541 | */ |
| 1534 | 1542 | ||
| 1535 | void journal_abort(journal_t *journal, int errno) | 1543 | void journal_abort(journal_t *journal, int errno) |
| @@ -1537,7 +1545,7 @@ void journal_abort(journal_t *journal, int errno) | |||
| 1537 | __journal_abort_soft(journal, errno); | 1545 | __journal_abort_soft(journal, errno); |
| 1538 | } | 1546 | } |
| 1539 | 1547 | ||
| 1540 | /** | 1548 | /** |
| 1541 | * int journal_errno () - returns the journal's error state. | 1549 | * int journal_errno () - returns the journal's error state. |
| 1542 | * @journal: journal to examine. | 1550 | * @journal: journal to examine. |
| 1543 | * | 1551 | * |
| @@ -1561,7 +1569,7 @@ int journal_errno(journal_t *journal) | |||
| 1561 | return err; | 1569 | return err; |
| 1562 | } | 1570 | } |
| 1563 | 1571 | ||
| 1564 | /** | 1572 | /** |
| 1565 | * int journal_clear_err () - clears the journal's error state | 1573 | * int journal_clear_err () - clears the journal's error state |
| 1566 | * @journal: journal to act on. | 1574 | * @journal: journal to act on. |
| 1567 | * | 1575 | * |
| @@ -1581,7 +1589,7 @@ int journal_clear_err(journal_t *journal) | |||
| 1581 | return err; | 1589 | return err; |
| 1582 | } | 1590 | } |
| 1583 | 1591 | ||
| 1584 | /** | 1592 | /** |
| 1585 | * void journal_ack_err() - Ack journal err. | 1593 | * void journal_ack_err() - Ack journal err. |
| 1586 | * @journal: journal to act on. | 1594 | * @journal: journal to act on. |
| 1587 | * | 1595 | * |
| @@ -1603,7 +1611,7 @@ int journal_blocks_per_page(struct inode *inode) | |||
| 1603 | 1611 | ||
| 1604 | /* | 1612 | /* |
| 1605 | * Simple support for retrying memory allocations. Introduced to help to | 1613 | * Simple support for retrying memory allocations. Introduced to help to |
| 1606 | * debug different VM deadlock avoidance strategies. | 1614 | * debug different VM deadlock avoidance strategies. |
| 1607 | */ | 1615 | */ |
| 1608 | void * __jbd_kmalloc (const char *where, size_t size, gfp_t flags, int retry) | 1616 | void * __jbd_kmalloc (const char *where, size_t size, gfp_t flags, int retry) |
| 1609 | { | 1617 | { |
| @@ -1611,6 +1619,77 @@ void * __jbd_kmalloc (const char *where, size_t size, gfp_t flags, int retry) | |||
| 1611 | } | 1619 | } |
| 1612 | 1620 | ||
| 1613 | /* | 1621 | /* |
| 1622 | * jbd slab management: create 1k, 2k, 4k, 8k slabs as needed | ||
| 1623 | * and allocate frozen and commit buffers from these slabs. | ||
| 1624 | * | ||
| 1625 | * Reason for doing this is to avoid, SLAB_DEBUG - since it could | ||
| 1626 | * cause bh to cross page boundary. | ||
| 1627 | */ | ||
| 1628 | |||
| 1629 | #define JBD_MAX_SLABS 5 | ||
| 1630 | #define JBD_SLAB_INDEX(size) (size >> 11) | ||
| 1631 | |||
| 1632 | static kmem_cache_t *jbd_slab[JBD_MAX_SLABS]; | ||
| 1633 | static const char *jbd_slab_names[JBD_MAX_SLABS] = { | ||
| 1634 | "jbd_1k", "jbd_2k", "jbd_4k", NULL, "jbd_8k" | ||
| 1635 | }; | ||
| 1636 | |||
| 1637 | static void journal_destroy_jbd_slabs(void) | ||
| 1638 | { | ||
| 1639 | int i; | ||
| 1640 | |||
| 1641 | for (i = 0; i < JBD_MAX_SLABS; i++) { | ||
| 1642 | if (jbd_slab[i]) | ||
| 1643 | kmem_cache_destroy(jbd_slab[i]); | ||
| 1644 | jbd_slab[i] = NULL; | ||
| 1645 | } | ||
| 1646 | } | ||
| 1647 | |||
| 1648 | static int journal_create_jbd_slab(size_t slab_size) | ||
| 1649 | { | ||
| 1650 | int i = JBD_SLAB_INDEX(slab_size); | ||
| 1651 | |||
| 1652 | BUG_ON(i >= JBD_MAX_SLABS); | ||
| 1653 | |||
| 1654 | /* | ||
| 1655 | * Check if we already have a slab created for this size | ||
| 1656 | */ | ||
| 1657 | if (jbd_slab[i]) | ||
| 1658 | return 0; | ||
| 1659 | |||
| 1660 | /* | ||
| 1661 | * Create a slab and force alignment to be same as slabsize - | ||
| 1662 | * this will make sure that allocations won't cross the page | ||
| 1663 | * boundary. | ||
| 1664 | */ | ||
| 1665 | jbd_slab[i] = kmem_cache_create(jbd_slab_names[i], | ||
| 1666 | slab_size, slab_size, 0, NULL, NULL); | ||
| 1667 | if (!jbd_slab[i]) { | ||
| 1668 | printk(KERN_EMERG "JBD: no memory for jbd_slab cache\n"); | ||
| 1669 | return -ENOMEM; | ||
| 1670 | } | ||
| 1671 | return 0; | ||
| 1672 | } | ||
| 1673 | |||
| 1674 | void * jbd_slab_alloc(size_t size, gfp_t flags) | ||
| 1675 | { | ||
| 1676 | int idx; | ||
| 1677 | |||
| 1678 | idx = JBD_SLAB_INDEX(size); | ||
| 1679 | BUG_ON(jbd_slab[idx] == NULL); | ||
| 1680 | return kmem_cache_alloc(jbd_slab[idx], flags | __GFP_NOFAIL); | ||
| 1681 | } | ||
| 1682 | |||
| 1683 | void jbd_slab_free(void *ptr, size_t size) | ||
| 1684 | { | ||
| 1685 | int idx; | ||
| 1686 | |||
| 1687 | idx = JBD_SLAB_INDEX(size); | ||
| 1688 | BUG_ON(jbd_slab[idx] == NULL); | ||
| 1689 | kmem_cache_free(jbd_slab[idx], ptr); | ||
| 1690 | } | ||
| 1691 | |||
| 1692 | /* | ||
| 1614 | * Journal_head storage management | 1693 | * Journal_head storage management |
| 1615 | */ | 1694 | */ |
| 1616 | static kmem_cache_t *journal_head_cache; | 1695 | static kmem_cache_t *journal_head_cache; |
| @@ -1675,7 +1754,7 @@ static void journal_free_journal_head(struct journal_head *jh) | |||
| 1675 | { | 1754 | { |
| 1676 | #ifdef CONFIG_JBD_DEBUG | 1755 | #ifdef CONFIG_JBD_DEBUG |
| 1677 | atomic_dec(&nr_journal_heads); | 1756 | atomic_dec(&nr_journal_heads); |
| 1678 | memset(jh, 0x5b, sizeof(*jh)); | 1757 | memset(jh, JBD_POISON_FREE, sizeof(*jh)); |
| 1679 | #endif | 1758 | #endif |
| 1680 | kmem_cache_free(journal_head_cache, jh); | 1759 | kmem_cache_free(journal_head_cache, jh); |
| 1681 | } | 1760 | } |
| @@ -1798,13 +1877,13 @@ static void __journal_remove_journal_head(struct buffer_head *bh) | |||
| 1798 | printk(KERN_WARNING "%s: freeing " | 1877 | printk(KERN_WARNING "%s: freeing " |
| 1799 | "b_frozen_data\n", | 1878 | "b_frozen_data\n", |
| 1800 | __FUNCTION__); | 1879 | __FUNCTION__); |
| 1801 | kfree(jh->b_frozen_data); | 1880 | jbd_slab_free(jh->b_frozen_data, bh->b_size); |
| 1802 | } | 1881 | } |
| 1803 | if (jh->b_committed_data) { | 1882 | if (jh->b_committed_data) { |
| 1804 | printk(KERN_WARNING "%s: freeing " | 1883 | printk(KERN_WARNING "%s: freeing " |
| 1805 | "b_committed_data\n", | 1884 | "b_committed_data\n", |
| 1806 | __FUNCTION__); | 1885 | __FUNCTION__); |
| 1807 | kfree(jh->b_committed_data); | 1886 | jbd_slab_free(jh->b_committed_data, bh->b_size); |
| 1808 | } | 1887 | } |
| 1809 | bh->b_private = NULL; | 1888 | bh->b_private = NULL; |
| 1810 | jh->b_bh = NULL; /* debug, really */ | 1889 | jh->b_bh = NULL; /* debug, really */ |
| @@ -1960,19 +2039,14 @@ static void journal_destroy_caches(void) | |||
| 1960 | journal_destroy_revoke_caches(); | 2039 | journal_destroy_revoke_caches(); |
| 1961 | journal_destroy_journal_head_cache(); | 2040 | journal_destroy_journal_head_cache(); |
| 1962 | journal_destroy_handle_cache(); | 2041 | journal_destroy_handle_cache(); |
| 2042 | journal_destroy_jbd_slabs(); | ||
| 1963 | } | 2043 | } |
| 1964 | 2044 | ||
| 1965 | static int __init journal_init(void) | 2045 | static int __init journal_init(void) |
| 1966 | { | 2046 | { |
| 1967 | int ret; | 2047 | int ret; |
| 1968 | 2048 | ||
| 1969 | /* Static check for data structure consistency. There's no code | 2049 | BUILD_BUG_ON(sizeof(struct journal_superblock_s) != 1024); |
| 1970 | * invoked --- we'll just get a linker failure if things aren't right. | ||
| 1971 | */ | ||
| 1972 | extern void journal_bad_superblock_size(void); | ||
| 1973 | if (sizeof(struct journal_superblock_s) != 1024) | ||
| 1974 | journal_bad_superblock_size(); | ||
| 1975 | |||
| 1976 | 2050 | ||
| 1977 | ret = journal_init_caches(); | 2051 | ret = journal_init_caches(); |
| 1978 | if (ret != 0) | 2052 | if (ret != 0) |
diff --git a/fs/jbd/recovery.c b/fs/jbd/recovery.c index 80d7f53fd0a7..11563fe2a52b 100644 --- a/fs/jbd/recovery.c +++ b/fs/jbd/recovery.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/recovery.c | 2 | * linux/fs/recovery.c |
| 3 | * | 3 | * |
| 4 | * Written by Stephen C. Tweedie <sct@redhat.com>, 1999 | 4 | * Written by Stephen C. Tweedie <sct@redhat.com>, 1999 |
| 5 | * | 5 | * |
| 6 | * Copyright 1999-2000 Red Hat Software --- All Rights Reserved | 6 | * Copyright 1999-2000 Red Hat Software --- All Rights Reserved |
| @@ -10,7 +10,7 @@ | |||
| 10 | * option, any later version, incorporated herein by reference. | 10 | * option, any later version, incorporated herein by reference. |
| 11 | * | 11 | * |
| 12 | * Journal recovery routines for the generic filesystem journaling code; | 12 | * Journal recovery routines for the generic filesystem journaling code; |
| 13 | * part of the ext2fs journaling system. | 13 | * part of the ext2fs journaling system. |
| 14 | */ | 14 | */ |
| 15 | 15 | ||
| 16 | #ifndef __KERNEL__ | 16 | #ifndef __KERNEL__ |
| @@ -25,9 +25,9 @@ | |||
| 25 | 25 | ||
| 26 | /* | 26 | /* |
| 27 | * Maintain information about the progress of the recovery job, so that | 27 | * Maintain information about the progress of the recovery job, so that |
| 28 | * the different passes can carry information between them. | 28 | * the different passes can carry information between them. |
| 29 | */ | 29 | */ |
| 30 | struct recovery_info | 30 | struct recovery_info |
| 31 | { | 31 | { |
| 32 | tid_t start_transaction; | 32 | tid_t start_transaction; |
| 33 | tid_t end_transaction; | 33 | tid_t end_transaction; |
| @@ -46,7 +46,7 @@ static int scan_revoke_records(journal_t *, struct buffer_head *, | |||
| 46 | #ifdef __KERNEL__ | 46 | #ifdef __KERNEL__ |
| 47 | 47 | ||
| 48 | /* Release readahead buffers after use */ | 48 | /* Release readahead buffers after use */ |
| 49 | void journal_brelse_array(struct buffer_head *b[], int n) | 49 | static void journal_brelse_array(struct buffer_head *b[], int n) |
| 50 | { | 50 | { |
| 51 | while (--n >= 0) | 51 | while (--n >= 0) |
| 52 | brelse (b[n]); | 52 | brelse (b[n]); |
| @@ -116,7 +116,7 @@ static int do_readahead(journal_t *journal, unsigned int start) | |||
| 116 | err = 0; | 116 | err = 0; |
| 117 | 117 | ||
| 118 | failed: | 118 | failed: |
| 119 | if (nbufs) | 119 | if (nbufs) |
| 120 | journal_brelse_array(bufs, nbufs); | 120 | journal_brelse_array(bufs, nbufs); |
| 121 | return err; | 121 | return err; |
| 122 | } | 122 | } |
| @@ -128,7 +128,7 @@ failed: | |||
| 128 | * Read a block from the journal | 128 | * Read a block from the journal |
| 129 | */ | 129 | */ |
| 130 | 130 | ||
| 131 | static int jread(struct buffer_head **bhp, journal_t *journal, | 131 | static int jread(struct buffer_head **bhp, journal_t *journal, |
| 132 | unsigned int offset) | 132 | unsigned int offset) |
| 133 | { | 133 | { |
| 134 | int err; | 134 | int err; |
| @@ -212,14 +212,14 @@ do { \ | |||
| 212 | /** | 212 | /** |
| 213 | * journal_recover - recovers a on-disk journal | 213 | * journal_recover - recovers a on-disk journal |
| 214 | * @journal: the journal to recover | 214 | * @journal: the journal to recover |
| 215 | * | 215 | * |
| 216 | * The primary function for recovering the log contents when mounting a | 216 | * The primary function for recovering the log contents when mounting a |
| 217 | * journaled device. | 217 | * journaled device. |
| 218 | * | 218 | * |
| 219 | * Recovery is done in three passes. In the first pass, we look for the | 219 | * Recovery is done in three passes. In the first pass, we look for the |
| 220 | * end of the log. In the second, we assemble the list of revoke | 220 | * end of the log. In the second, we assemble the list of revoke |
| 221 | * blocks. In the third and final pass, we replay any un-revoked blocks | 221 | * blocks. In the third and final pass, we replay any un-revoked blocks |
| 222 | * in the log. | 222 | * in the log. |
| 223 | */ | 223 | */ |
| 224 | int journal_recover(journal_t *journal) | 224 | int journal_recover(journal_t *journal) |
| 225 | { | 225 | { |
| @@ -231,10 +231,10 @@ int journal_recover(journal_t *journal) | |||
| 231 | memset(&info, 0, sizeof(info)); | 231 | memset(&info, 0, sizeof(info)); |
| 232 | sb = journal->j_superblock; | 232 | sb = journal->j_superblock; |
| 233 | 233 | ||
| 234 | /* | 234 | /* |
| 235 | * The journal superblock's s_start field (the current log head) | 235 | * The journal superblock's s_start field (the current log head) |
| 236 | * is always zero if, and only if, the journal was cleanly | 236 | * is always zero if, and only if, the journal was cleanly |
| 237 | * unmounted. | 237 | * unmounted. |
| 238 | */ | 238 | */ |
| 239 | 239 | ||
| 240 | if (!sb->s_start) { | 240 | if (!sb->s_start) { |
| @@ -253,7 +253,7 @@ int journal_recover(journal_t *journal) | |||
| 253 | jbd_debug(0, "JBD: recovery, exit status %d, " | 253 | jbd_debug(0, "JBD: recovery, exit status %d, " |
| 254 | "recovered transactions %u to %u\n", | 254 | "recovered transactions %u to %u\n", |
| 255 | err, info.start_transaction, info.end_transaction); | 255 | err, info.start_transaction, info.end_transaction); |
| 256 | jbd_debug(0, "JBD: Replayed %d and revoked %d/%d blocks\n", | 256 | jbd_debug(0, "JBD: Replayed %d and revoked %d/%d blocks\n", |
| 257 | info.nr_replays, info.nr_revoke_hits, info.nr_revokes); | 257 | info.nr_replays, info.nr_revoke_hits, info.nr_revokes); |
| 258 | 258 | ||
| 259 | /* Restart the log at the next transaction ID, thus invalidating | 259 | /* Restart the log at the next transaction ID, thus invalidating |
| @@ -268,15 +268,15 @@ int journal_recover(journal_t *journal) | |||
| 268 | /** | 268 | /** |
| 269 | * journal_skip_recovery - Start journal and wipe exiting records | 269 | * journal_skip_recovery - Start journal and wipe exiting records |
| 270 | * @journal: journal to startup | 270 | * @journal: journal to startup |
| 271 | * | 271 | * |
| 272 | * Locate any valid recovery information from the journal and set up the | 272 | * Locate any valid recovery information from the journal and set up the |
| 273 | * journal structures in memory to ignore it (presumably because the | 273 | * journal structures in memory to ignore it (presumably because the |
| 274 | * caller has evidence that it is out of date). | 274 | * caller has evidence that it is out of date). |
| 275 | * This function does'nt appear to be exorted.. | 275 | * This function does'nt appear to be exorted.. |
| 276 | * | 276 | * |
| 277 | * We perform one pass over the journal to allow us to tell the user how | 277 | * We perform one pass over the journal to allow us to tell the user how |
| 278 | * much recovery information is being erased, and to let us initialise | 278 | * much recovery information is being erased, and to let us initialise |
| 279 | * the journal transaction sequence numbers to the next unused ID. | 279 | * the journal transaction sequence numbers to the next unused ID. |
| 280 | */ | 280 | */ |
| 281 | int journal_skip_recovery(journal_t *journal) | 281 | int journal_skip_recovery(journal_t *journal) |
| 282 | { | 282 | { |
| @@ -297,7 +297,7 @@ int journal_skip_recovery(journal_t *journal) | |||
| 297 | #ifdef CONFIG_JBD_DEBUG | 297 | #ifdef CONFIG_JBD_DEBUG |
| 298 | int dropped = info.end_transaction - be32_to_cpu(sb->s_sequence); | 298 | int dropped = info.end_transaction - be32_to_cpu(sb->s_sequence); |
| 299 | #endif | 299 | #endif |
| 300 | jbd_debug(0, | 300 | jbd_debug(0, |
| 301 | "JBD: ignoring %d transaction%s from the journal.\n", | 301 | "JBD: ignoring %d transaction%s from the journal.\n", |
| 302 | dropped, (dropped == 1) ? "" : "s"); | 302 | dropped, (dropped == 1) ? "" : "s"); |
| 303 | journal->j_transaction_sequence = ++info.end_transaction; | 303 | journal->j_transaction_sequence = ++info.end_transaction; |
| @@ -314,7 +314,7 @@ static int do_one_pass(journal_t *journal, | |||
| 314 | unsigned long next_log_block; | 314 | unsigned long next_log_block; |
| 315 | int err, success = 0; | 315 | int err, success = 0; |
| 316 | journal_superblock_t * sb; | 316 | journal_superblock_t * sb; |
| 317 | journal_header_t * tmp; | 317 | journal_header_t * tmp; |
| 318 | struct buffer_head * bh; | 318 | struct buffer_head * bh; |
| 319 | unsigned int sequence; | 319 | unsigned int sequence; |
| 320 | int blocktype; | 320 | int blocktype; |
| @@ -324,10 +324,10 @@ static int do_one_pass(journal_t *journal, | |||
| 324 | MAX_BLOCKS_PER_DESC = ((journal->j_blocksize-sizeof(journal_header_t)) | 324 | MAX_BLOCKS_PER_DESC = ((journal->j_blocksize-sizeof(journal_header_t)) |
| 325 | / sizeof(journal_block_tag_t)); | 325 | / sizeof(journal_block_tag_t)); |
| 326 | 326 | ||
| 327 | /* | 327 | /* |
| 328 | * First thing is to establish what we expect to find in the log | 328 | * First thing is to establish what we expect to find in the log |
| 329 | * (in terms of transaction IDs), and where (in terms of log | 329 | * (in terms of transaction IDs), and where (in terms of log |
| 330 | * block offsets): query the superblock. | 330 | * block offsets): query the superblock. |
| 331 | */ | 331 | */ |
| 332 | 332 | ||
| 333 | sb = journal->j_superblock; | 333 | sb = journal->j_superblock; |
| @@ -344,7 +344,7 @@ static int do_one_pass(journal_t *journal, | |||
| 344 | * Now we walk through the log, transaction by transaction, | 344 | * Now we walk through the log, transaction by transaction, |
| 345 | * making sure that each transaction has a commit block in the | 345 | * making sure that each transaction has a commit block in the |
| 346 | * expected place. Each complete transaction gets replayed back | 346 | * expected place. Each complete transaction gets replayed back |
| 347 | * into the main filesystem. | 347 | * into the main filesystem. |
| 348 | */ | 348 | */ |
| 349 | 349 | ||
| 350 | while (1) { | 350 | while (1) { |
| @@ -379,8 +379,8 @@ static int do_one_pass(journal_t *journal, | |||
| 379 | next_log_block++; | 379 | next_log_block++; |
| 380 | wrap(journal, next_log_block); | 380 | wrap(journal, next_log_block); |
| 381 | 381 | ||
| 382 | /* What kind of buffer is it? | 382 | /* What kind of buffer is it? |
| 383 | * | 383 | * |
| 384 | * If it is a descriptor block, check that it has the | 384 | * If it is a descriptor block, check that it has the |
| 385 | * expected sequence number. Otherwise, we're all done | 385 | * expected sequence number. Otherwise, we're all done |
| 386 | * here. */ | 386 | * here. */ |
| @@ -394,7 +394,7 @@ static int do_one_pass(journal_t *journal, | |||
| 394 | 394 | ||
| 395 | blocktype = be32_to_cpu(tmp->h_blocktype); | 395 | blocktype = be32_to_cpu(tmp->h_blocktype); |
| 396 | sequence = be32_to_cpu(tmp->h_sequence); | 396 | sequence = be32_to_cpu(tmp->h_sequence); |
| 397 | jbd_debug(3, "Found magic %d, sequence %d\n", | 397 | jbd_debug(3, "Found magic %d, sequence %d\n", |
| 398 | blocktype, sequence); | 398 | blocktype, sequence); |
| 399 | 399 | ||
| 400 | if (sequence != next_commit_ID) { | 400 | if (sequence != next_commit_ID) { |
| @@ -438,7 +438,7 @@ static int do_one_pass(journal_t *journal, | |||
| 438 | /* Recover what we can, but | 438 | /* Recover what we can, but |
| 439 | * report failure at the end. */ | 439 | * report failure at the end. */ |
| 440 | success = err; | 440 | success = err; |
| 441 | printk (KERN_ERR | 441 | printk (KERN_ERR |
| 442 | "JBD: IO error %d recovering " | 442 | "JBD: IO error %d recovering " |
| 443 | "block %ld in log\n", | 443 | "block %ld in log\n", |
| 444 | err, io_block); | 444 | err, io_block); |
| @@ -452,7 +452,7 @@ static int do_one_pass(journal_t *journal, | |||
| 452 | * revoked, then we're all done | 452 | * revoked, then we're all done |
| 453 | * here. */ | 453 | * here. */ |
| 454 | if (journal_test_revoke | 454 | if (journal_test_revoke |
| 455 | (journal, blocknr, | 455 | (journal, blocknr, |
| 456 | next_commit_ID)) { | 456 | next_commit_ID)) { |
| 457 | brelse(obh); | 457 | brelse(obh); |
| 458 | ++info->nr_revoke_hits; | 458 | ++info->nr_revoke_hits; |
| @@ -465,7 +465,7 @@ static int do_one_pass(journal_t *journal, | |||
| 465 | blocknr, | 465 | blocknr, |
| 466 | journal->j_blocksize); | 466 | journal->j_blocksize); |
| 467 | if (nbh == NULL) { | 467 | if (nbh == NULL) { |
| 468 | printk(KERN_ERR | 468 | printk(KERN_ERR |
| 469 | "JBD: Out of memory " | 469 | "JBD: Out of memory " |
| 470 | "during recovery.\n"); | 470 | "during recovery.\n"); |
| 471 | err = -ENOMEM; | 471 | err = -ENOMEM; |
| @@ -531,12 +531,13 @@ static int do_one_pass(journal_t *journal, | |||
| 531 | default: | 531 | default: |
| 532 | jbd_debug(3, "Unrecognised magic %d, end of scan.\n", | 532 | jbd_debug(3, "Unrecognised magic %d, end of scan.\n", |
| 533 | blocktype); | 533 | blocktype); |
| 534 | brelse(bh); | ||
| 534 | goto done; | 535 | goto done; |
| 535 | } | 536 | } |
| 536 | } | 537 | } |
| 537 | 538 | ||
| 538 | done: | 539 | done: |
| 539 | /* | 540 | /* |
| 540 | * We broke out of the log scan loop: either we came to the | 541 | * We broke out of the log scan loop: either we came to the |
| 541 | * known end of the log or we found an unexpected block in the | 542 | * known end of the log or we found an unexpected block in the |
| 542 | * log. If the latter happened, then we know that the "current" | 543 | * log. If the latter happened, then we know that the "current" |
| @@ -566,7 +567,7 @@ static int do_one_pass(journal_t *journal, | |||
| 566 | 567 | ||
| 567 | /* Scan a revoke record, marking all blocks mentioned as revoked. */ | 568 | /* Scan a revoke record, marking all blocks mentioned as revoked. */ |
| 568 | 569 | ||
| 569 | static int scan_revoke_records(journal_t *journal, struct buffer_head *bh, | 570 | static int scan_revoke_records(journal_t *journal, struct buffer_head *bh, |
| 570 | tid_t sequence, struct recovery_info *info) | 571 | tid_t sequence, struct recovery_info *info) |
| 571 | { | 572 | { |
| 572 | journal_revoke_header_t *header; | 573 | journal_revoke_header_t *header; |
diff --git a/fs/jbd/revoke.c b/fs/jbd/revoke.c index a56144183462..c532429d8d9b 100644 --- a/fs/jbd/revoke.c +++ b/fs/jbd/revoke.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/revoke.c | 2 | * linux/fs/revoke.c |
| 3 | * | 3 | * |
| 4 | * Written by Stephen C. Tweedie <sct@redhat.com>, 2000 | 4 | * Written by Stephen C. Tweedie <sct@redhat.com>, 2000 |
| 5 | * | 5 | * |
| 6 | * Copyright 2000 Red Hat corp --- All Rights Reserved | 6 | * Copyright 2000 Red Hat corp --- All Rights Reserved |
| @@ -15,10 +15,10 @@ | |||
| 15 | * Revoke is the mechanism used to prevent old log records for deleted | 15 | * Revoke is the mechanism used to prevent old log records for deleted |
| 16 | * metadata from being replayed on top of newer data using the same | 16 | * metadata from being replayed on top of newer data using the same |
| 17 | * blocks. The revoke mechanism is used in two separate places: | 17 | * blocks. The revoke mechanism is used in two separate places: |
| 18 | * | 18 | * |
| 19 | * + Commit: during commit we write the entire list of the current | 19 | * + Commit: during commit we write the entire list of the current |
| 20 | * transaction's revoked blocks to the journal | 20 | * transaction's revoked blocks to the journal |
| 21 | * | 21 | * |
| 22 | * + Recovery: during recovery we record the transaction ID of all | 22 | * + Recovery: during recovery we record the transaction ID of all |
| 23 | * revoked blocks. If there are multiple revoke records in the log | 23 | * revoked blocks. If there are multiple revoke records in the log |
| 24 | * for a single block, only the last one counts, and if there is a log | 24 | * for a single block, only the last one counts, and if there is a log |
| @@ -29,7 +29,7 @@ | |||
| 29 | * single transaction: | 29 | * single transaction: |
| 30 | * | 30 | * |
| 31 | * Block is revoked and then journaled: | 31 | * Block is revoked and then journaled: |
| 32 | * The desired end result is the journaling of the new block, so we | 32 | * The desired end result is the journaling of the new block, so we |
| 33 | * cancel the revoke before the transaction commits. | 33 | * cancel the revoke before the transaction commits. |
| 34 | * | 34 | * |
| 35 | * Block is journaled and then revoked: | 35 | * Block is journaled and then revoked: |
| @@ -41,7 +41,7 @@ | |||
| 41 | * transaction must have happened after the block was journaled and so | 41 | * transaction must have happened after the block was journaled and so |
| 42 | * the revoke must take precedence. | 42 | * the revoke must take precedence. |
| 43 | * | 43 | * |
| 44 | * Block is revoked and then written as data: | 44 | * Block is revoked and then written as data: |
| 45 | * The data write is allowed to succeed, but the revoke is _not_ | 45 | * The data write is allowed to succeed, but the revoke is _not_ |
| 46 | * cancelled. We still need to prevent old log records from | 46 | * cancelled. We still need to prevent old log records from |
| 47 | * overwriting the new data. We don't even need to clear the revoke | 47 | * overwriting the new data. We don't even need to clear the revoke |
| @@ -54,7 +54,7 @@ | |||
| 54 | * buffer has not been revoked, and cancel_revoke | 54 | * buffer has not been revoked, and cancel_revoke |
| 55 | * need do nothing. | 55 | * need do nothing. |
| 56 | * RevokeValid set, Revoked set: | 56 | * RevokeValid set, Revoked set: |
| 57 | * buffer has been revoked. | 57 | * buffer has been revoked. |
| 58 | */ | 58 | */ |
| 59 | 59 | ||
| 60 | #ifndef __KERNEL__ | 60 | #ifndef __KERNEL__ |
| @@ -77,7 +77,7 @@ static kmem_cache_t *revoke_table_cache; | |||
| 77 | journal replay, this involves recording the transaction ID of the | 77 | journal replay, this involves recording the transaction ID of the |
| 78 | last transaction to revoke this block. */ | 78 | last transaction to revoke this block. */ |
| 79 | 79 | ||
| 80 | struct jbd_revoke_record_s | 80 | struct jbd_revoke_record_s |
| 81 | { | 81 | { |
| 82 | struct list_head hash; | 82 | struct list_head hash; |
| 83 | tid_t sequence; /* Used for recovery only */ | 83 | tid_t sequence; /* Used for recovery only */ |
| @@ -90,8 +90,8 @@ struct jbd_revoke_table_s | |||
| 90 | { | 90 | { |
| 91 | /* It is conceivable that we might want a larger hash table | 91 | /* It is conceivable that we might want a larger hash table |
| 92 | * for recovery. Must be a power of two. */ | 92 | * for recovery. Must be a power of two. */ |
| 93 | int hash_size; | 93 | int hash_size; |
| 94 | int hash_shift; | 94 | int hash_shift; |
| 95 | struct list_head *hash_table; | 95 | struct list_head *hash_table; |
| 96 | }; | 96 | }; |
| 97 | 97 | ||
| @@ -301,22 +301,22 @@ void journal_destroy_revoke(journal_t *journal) | |||
| 301 | 301 | ||
| 302 | #ifdef __KERNEL__ | 302 | #ifdef __KERNEL__ |
| 303 | 303 | ||
| 304 | /* | 304 | /* |
| 305 | * journal_revoke: revoke a given buffer_head from the journal. This | 305 | * journal_revoke: revoke a given buffer_head from the journal. This |
| 306 | * prevents the block from being replayed during recovery if we take a | 306 | * prevents the block from being replayed during recovery if we take a |
| 307 | * crash after this current transaction commits. Any subsequent | 307 | * crash after this current transaction commits. Any subsequent |
| 308 | * metadata writes of the buffer in this transaction cancel the | 308 | * metadata writes of the buffer in this transaction cancel the |
| 309 | * revoke. | 309 | * revoke. |
| 310 | * | 310 | * |
| 311 | * Note that this call may block --- it is up to the caller to make | 311 | * Note that this call may block --- it is up to the caller to make |
| 312 | * sure that there are no further calls to journal_write_metadata | 312 | * sure that there are no further calls to journal_write_metadata |
| 313 | * before the revoke is complete. In ext3, this implies calling the | 313 | * before the revoke is complete. In ext3, this implies calling the |
| 314 | * revoke before clearing the block bitmap when we are deleting | 314 | * revoke before clearing the block bitmap when we are deleting |
| 315 | * metadata. | 315 | * metadata. |
| 316 | * | 316 | * |
| 317 | * Revoke performs a journal_forget on any buffer_head passed in as a | 317 | * Revoke performs a journal_forget on any buffer_head passed in as a |
| 318 | * parameter, but does _not_ forget the buffer_head if the bh was only | 318 | * parameter, but does _not_ forget the buffer_head if the bh was only |
| 319 | * found implicitly. | 319 | * found implicitly. |
| 320 | * | 320 | * |
| 321 | * bh_in may not be a journalled buffer - it may have come off | 321 | * bh_in may not be a journalled buffer - it may have come off |
| 322 | * the hash tables without an attached journal_head. | 322 | * the hash tables without an attached journal_head. |
| @@ -325,7 +325,7 @@ void journal_destroy_revoke(journal_t *journal) | |||
| 325 | * by one. | 325 | * by one. |
| 326 | */ | 326 | */ |
| 327 | 327 | ||
| 328 | int journal_revoke(handle_t *handle, unsigned long blocknr, | 328 | int journal_revoke(handle_t *handle, unsigned long blocknr, |
| 329 | struct buffer_head *bh_in) | 329 | struct buffer_head *bh_in) |
| 330 | { | 330 | { |
| 331 | struct buffer_head *bh = NULL; | 331 | struct buffer_head *bh = NULL; |
| @@ -487,7 +487,7 @@ void journal_switch_revoke_table(journal_t *journal) | |||
| 487 | else | 487 | else |
| 488 | journal->j_revoke = journal->j_revoke_table[0]; | 488 | journal->j_revoke = journal->j_revoke_table[0]; |
| 489 | 489 | ||
| 490 | for (i = 0; i < journal->j_revoke->hash_size; i++) | 490 | for (i = 0; i < journal->j_revoke->hash_size; i++) |
| 491 | INIT_LIST_HEAD(&journal->j_revoke->hash_table[i]); | 491 | INIT_LIST_HEAD(&journal->j_revoke->hash_table[i]); |
| 492 | } | 492 | } |
| 493 | 493 | ||
| @@ -498,7 +498,7 @@ void journal_switch_revoke_table(journal_t *journal) | |||
| 498 | * Called with the journal lock held. | 498 | * Called with the journal lock held. |
| 499 | */ | 499 | */ |
| 500 | 500 | ||
| 501 | void journal_write_revoke_records(journal_t *journal, | 501 | void journal_write_revoke_records(journal_t *journal, |
| 502 | transaction_t *transaction) | 502 | transaction_t *transaction) |
| 503 | { | 503 | { |
| 504 | struct journal_head *descriptor; | 504 | struct journal_head *descriptor; |
| @@ -507,7 +507,7 @@ void journal_write_revoke_records(journal_t *journal, | |||
| 507 | struct list_head *hash_list; | 507 | struct list_head *hash_list; |
| 508 | int i, offset, count; | 508 | int i, offset, count; |
| 509 | 509 | ||
| 510 | descriptor = NULL; | 510 | descriptor = NULL; |
| 511 | offset = 0; | 511 | offset = 0; |
| 512 | count = 0; | 512 | count = 0; |
| 513 | 513 | ||
| @@ -519,10 +519,10 @@ void journal_write_revoke_records(journal_t *journal, | |||
| 519 | hash_list = &revoke->hash_table[i]; | 519 | hash_list = &revoke->hash_table[i]; |
| 520 | 520 | ||
| 521 | while (!list_empty(hash_list)) { | 521 | while (!list_empty(hash_list)) { |
| 522 | record = (struct jbd_revoke_record_s *) | 522 | record = (struct jbd_revoke_record_s *) |
| 523 | hash_list->next; | 523 | hash_list->next; |
| 524 | write_one_revoke_record(journal, transaction, | 524 | write_one_revoke_record(journal, transaction, |
| 525 | &descriptor, &offset, | 525 | &descriptor, &offset, |
| 526 | record); | 526 | record); |
| 527 | count++; | 527 | count++; |
| 528 | list_del(&record->hash); | 528 | list_del(&record->hash); |
| @@ -534,14 +534,14 @@ void journal_write_revoke_records(journal_t *journal, | |||
| 534 | jbd_debug(1, "Wrote %d revoke records\n", count); | 534 | jbd_debug(1, "Wrote %d revoke records\n", count); |
| 535 | } | 535 | } |
| 536 | 536 | ||
| 537 | /* | 537 | /* |
| 538 | * Write out one revoke record. We need to create a new descriptor | 538 | * Write out one revoke record. We need to create a new descriptor |
| 539 | * block if the old one is full or if we have not already created one. | 539 | * block if the old one is full or if we have not already created one. |
| 540 | */ | 540 | */ |
| 541 | 541 | ||
| 542 | static void write_one_revoke_record(journal_t *journal, | 542 | static void write_one_revoke_record(journal_t *journal, |
| 543 | transaction_t *transaction, | 543 | transaction_t *transaction, |
| 544 | struct journal_head **descriptorp, | 544 | struct journal_head **descriptorp, |
| 545 | int *offsetp, | 545 | int *offsetp, |
| 546 | struct jbd_revoke_record_s *record) | 546 | struct jbd_revoke_record_s *record) |
| 547 | { | 547 | { |
| @@ -584,21 +584,21 @@ static void write_one_revoke_record(journal_t *journal, | |||
| 584 | *descriptorp = descriptor; | 584 | *descriptorp = descriptor; |
| 585 | } | 585 | } |
| 586 | 586 | ||
| 587 | * ((__be32 *)(&jh2bh(descriptor)->b_data[offset])) = | 587 | * ((__be32 *)(&jh2bh(descriptor)->b_data[offset])) = |
| 588 | cpu_to_be32(record->blocknr); | 588 | cpu_to_be32(record->blocknr); |
| 589 | offset += 4; | 589 | offset += 4; |
| 590 | *offsetp = offset; | 590 | *offsetp = offset; |
| 591 | } | 591 | } |
| 592 | 592 | ||
| 593 | /* | 593 | /* |
| 594 | * Flush a revoke descriptor out to the journal. If we are aborting, | 594 | * Flush a revoke descriptor out to the journal. If we are aborting, |
| 595 | * this is a noop; otherwise we are generating a buffer which needs to | 595 | * this is a noop; otherwise we are generating a buffer which needs to |
| 596 | * be waited for during commit, so it has to go onto the appropriate | 596 | * be waited for during commit, so it has to go onto the appropriate |
| 597 | * journal buffer list. | 597 | * journal buffer list. |
| 598 | */ | 598 | */ |
| 599 | 599 | ||
| 600 | static void flush_descriptor(journal_t *journal, | 600 | static void flush_descriptor(journal_t *journal, |
| 601 | struct journal_head *descriptor, | 601 | struct journal_head *descriptor, |
| 602 | int offset) | 602 | int offset) |
| 603 | { | 603 | { |
| 604 | journal_revoke_header_t *header; | 604 | journal_revoke_header_t *header; |
| @@ -618,7 +618,7 @@ static void flush_descriptor(journal_t *journal, | |||
| 618 | } | 618 | } |
| 619 | #endif | 619 | #endif |
| 620 | 620 | ||
| 621 | /* | 621 | /* |
| 622 | * Revoke support for recovery. | 622 | * Revoke support for recovery. |
| 623 | * | 623 | * |
| 624 | * Recovery needs to be able to: | 624 | * Recovery needs to be able to: |
| @@ -629,7 +629,7 @@ static void flush_descriptor(journal_t *journal, | |||
| 629 | * check whether a given block in a given transaction should be replayed | 629 | * check whether a given block in a given transaction should be replayed |
| 630 | * (ie. has not been revoked by a revoke record in that or a subsequent | 630 | * (ie. has not been revoked by a revoke record in that or a subsequent |
| 631 | * transaction) | 631 | * transaction) |
| 632 | * | 632 | * |
| 633 | * empty the revoke table after recovery. | 633 | * empty the revoke table after recovery. |
| 634 | */ | 634 | */ |
| 635 | 635 | ||
| @@ -637,11 +637,11 @@ static void flush_descriptor(journal_t *journal, | |||
| 637 | * First, setting revoke records. We create a new revoke record for | 637 | * First, setting revoke records. We create a new revoke record for |
| 638 | * every block ever revoked in the log as we scan it for recovery, and | 638 | * every block ever revoked in the log as we scan it for recovery, and |
| 639 | * we update the existing records if we find multiple revokes for a | 639 | * we update the existing records if we find multiple revokes for a |
| 640 | * single block. | 640 | * single block. |
| 641 | */ | 641 | */ |
| 642 | 642 | ||
| 643 | int journal_set_revoke(journal_t *journal, | 643 | int journal_set_revoke(journal_t *journal, |
| 644 | unsigned long blocknr, | 644 | unsigned long blocknr, |
| 645 | tid_t sequence) | 645 | tid_t sequence) |
| 646 | { | 646 | { |
| 647 | struct jbd_revoke_record_s *record; | 647 | struct jbd_revoke_record_s *record; |
| @@ -653,18 +653,18 @@ int journal_set_revoke(journal_t *journal, | |||
| 653 | if (tid_gt(sequence, record->sequence)) | 653 | if (tid_gt(sequence, record->sequence)) |
| 654 | record->sequence = sequence; | 654 | record->sequence = sequence; |
| 655 | return 0; | 655 | return 0; |
| 656 | } | 656 | } |
| 657 | return insert_revoke_hash(journal, blocknr, sequence); | 657 | return insert_revoke_hash(journal, blocknr, sequence); |
| 658 | } | 658 | } |
| 659 | 659 | ||
| 660 | /* | 660 | /* |
| 661 | * Test revoke records. For a given block referenced in the log, has | 661 | * Test revoke records. For a given block referenced in the log, has |
| 662 | * that block been revoked? A revoke record with a given transaction | 662 | * that block been revoked? A revoke record with a given transaction |
| 663 | * sequence number revokes all blocks in that transaction and earlier | 663 | * sequence number revokes all blocks in that transaction and earlier |
| 664 | * ones, but later transactions still need replayed. | 664 | * ones, but later transactions still need replayed. |
| 665 | */ | 665 | */ |
| 666 | 666 | ||
| 667 | int journal_test_revoke(journal_t *journal, | 667 | int journal_test_revoke(journal_t *journal, |
| 668 | unsigned long blocknr, | 668 | unsigned long blocknr, |
| 669 | tid_t sequence) | 669 | tid_t sequence) |
| 670 | { | 670 | { |
diff --git a/fs/jbd/transaction.c b/fs/jbd/transaction.c index 508b2ea91f43..e1b3c8af4d17 100644 --- a/fs/jbd/transaction.c +++ b/fs/jbd/transaction.c | |||
| @@ -1,6 +1,6 @@ | |||
| 1 | /* | 1 | /* |
| 2 | * linux/fs/transaction.c | 2 | * linux/fs/transaction.c |
| 3 | * | 3 | * |
| 4 | * Written by Stephen C. Tweedie <sct@redhat.com>, 1998 | 4 | * Written by Stephen C. Tweedie <sct@redhat.com>, 1998 |
| 5 | * | 5 | * |
| 6 | * Copyright 1998 Red Hat corp --- All Rights Reserved | 6 | * Copyright 1998 Red Hat corp --- All Rights Reserved |
| @@ -10,7 +10,7 @@ | |||
| 10 | * option, any later version, incorporated herein by reference. | 10 | * option, any later version, incorporated herein by reference. |
| 11 | * | 11 | * |
| 12 | * Generic filesystem transaction handling code; part of the ext2fs | 12 | * Generic filesystem transaction handling code; part of the ext2fs |
| 13 | * journaling system. | 13 | * journaling system. |
| 14 | * | 14 | * |
| 15 | * This file manages transactions (compound commits managed by the | 15 | * This file manages transactions (compound commits managed by the |
| 16 | * journaling code) and handles (individual atomic operations by the | 16 | * journaling code) and handles (individual atomic operations by the |
| @@ -74,7 +74,7 @@ get_transaction(journal_t *journal, transaction_t *transaction) | |||
| 74 | * start_this_handle: Given a handle, deal with any locking or stalling | 74 | * start_this_handle: Given a handle, deal with any locking or stalling |
| 75 | * needed to make sure that there is enough journal space for the handle | 75 | * needed to make sure that there is enough journal space for the handle |
| 76 | * to begin. Attach the handle to a transaction and set up the | 76 | * to begin. Attach the handle to a transaction and set up the |
| 77 | * transaction's buffer credits. | 77 | * transaction's buffer credits. |
| 78 | */ | 78 | */ |
| 79 | 79 | ||
| 80 | static int start_this_handle(journal_t *journal, handle_t *handle) | 80 | static int start_this_handle(journal_t *journal, handle_t *handle) |
| @@ -117,7 +117,7 @@ repeat_locked: | |||
| 117 | if (is_journal_aborted(journal) || | 117 | if (is_journal_aborted(journal) || |
| 118 | (journal->j_errno != 0 && !(journal->j_flags & JFS_ACK_ERR))) { | 118 | (journal->j_errno != 0 && !(journal->j_flags & JFS_ACK_ERR))) { |
| 119 | spin_unlock(&journal->j_state_lock); | 119 | spin_unlock(&journal->j_state_lock); |
| 120 | ret = -EROFS; | 120 | ret = -EROFS; |
| 121 | goto out; | 121 | goto out; |
| 122 | } | 122 | } |
| 123 | 123 | ||
| @@ -182,7 +182,7 @@ repeat_locked: | |||
| 182 | goto repeat; | 182 | goto repeat; |
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | /* | 185 | /* |
| 186 | * The commit code assumes that it can get enough log space | 186 | * The commit code assumes that it can get enough log space |
| 187 | * without forcing a checkpoint. This is *critical* for | 187 | * without forcing a checkpoint. This is *critical* for |
| 188 | * correctness: a checkpoint of a buffer which is also | 188 | * correctness: a checkpoint of a buffer which is also |
| @@ -191,7 +191,7 @@ repeat_locked: | |||
| 191 | * | 191 | * |
| 192 | * We must therefore ensure the necessary space in the journal | 192 | * We must therefore ensure the necessary space in the journal |
| 193 | * *before* starting to dirty potentially checkpointed buffers | 193 | * *before* starting to dirty potentially checkpointed buffers |
| 194 | * in the new transaction. | 194 | * in the new transaction. |
| 195 | * | 195 | * |
| 196 | * The worst part is, any transaction currently committing can | 196 | * The worst part is, any transaction currently committing can |
| 197 | * reduce the free space arbitrarily. Be careful to account for | 197 | * reduce the free space arbitrarily. Be careful to account for |
| @@ -246,13 +246,13 @@ static handle_t *new_handle(int nblocks) | |||
| 246 | } | 246 | } |
| 247 | 247 | ||
| 248 | /** | 248 | /** |
| 249 | * handle_t *journal_start() - Obtain a new handle. | 249 | * handle_t *journal_start() - Obtain a new handle. |
| 250 | * @journal: Journal to start transaction on. | 250 | * @journal: Journal to start transaction on. |
| 251 | * @nblocks: number of block buffer we might modify | 251 | * @nblocks: number of block buffer we might modify |
| 252 | * | 252 | * |
| 253 | * We make sure that the transaction can guarantee at least nblocks of | 253 | * We make sure that the transaction can guarantee at least nblocks of |
| 254 | * modified buffers in the log. We block until the log can guarantee | 254 | * modified buffers in the log. We block until the log can guarantee |
| 255 | * that much space. | 255 | * that much space. |
| 256 | * | 256 | * |
| 257 | * This function is visible to journal users (like ext3fs), so is not | 257 | * This function is visible to journal users (like ext3fs), so is not |
| 258 | * called with the journal already locked. | 258 | * called with the journal already locked. |
| @@ -292,11 +292,11 @@ handle_t *journal_start(journal_t *journal, int nblocks) | |||
| 292 | * int journal_extend() - extend buffer credits. | 292 | * int journal_extend() - extend buffer credits. |
| 293 | * @handle: handle to 'extend' | 293 | * @handle: handle to 'extend' |
| 294 | * @nblocks: nr blocks to try to extend by. | 294 | * @nblocks: nr blocks to try to extend by. |
| 295 | * | 295 | * |
| 296 | * Some transactions, such as large extends and truncates, can be done | 296 | * Some transactions, such as large extends and truncates, can be done |
| 297 | * atomically all at once or in several stages. The operation requests | 297 | * atomically all at once or in several stages. The operation requests |
| 298 | * a credit for a number of buffer modications in advance, but can | 298 | * a credit for a number of buffer modications in advance, but can |
| 299 | * extend its credit if it needs more. | 299 | * extend its credit if it needs more. |
| 300 | * | 300 | * |
| 301 | * journal_extend tries to give the running handle more buffer credits. | 301 | * journal_extend tries to give the running handle more buffer credits. |
| 302 | * It does not guarantee that allocation - this is a best-effort only. | 302 | * It does not guarantee that allocation - this is a best-effort only. |
| @@ -363,7 +363,7 @@ out: | |||
| 363 | * int journal_restart() - restart a handle . | 363 | * int journal_restart() - restart a handle . |
| 364 | * @handle: handle to restart | 364 | * @handle: handle to restart |
| 365 | * @nblocks: nr credits requested | 365 | * @nblocks: nr credits requested |
| 366 | * | 366 | * |
| 367 | * Restart a handle for a multi-transaction filesystem | 367 | * Restart a handle for a multi-transaction filesystem |
| 368 | * operation. | 368 | * operation. |
| 369 | * | 369 | * |
| @@ -462,7 +462,7 @@ void journal_lock_updates(journal_t *journal) | |||
| 462 | /** | 462 | /** |
| 463 | * void journal_unlock_updates (journal_t* journal) - release barrier | 463 | * void journal_unlock_updates (journal_t* journal) - release barrier |
| 464 | * @journal: Journal to release the barrier on. | 464 | * @journal: Journal to release the barrier on. |
| 465 | * | 465 | * |
| 466 | * Release a transaction barrier obtained with journal_lock_updates(). | 466 | * Release a transaction barrier obtained with journal_lock_updates(). |
| 467 | * | 467 | * |
| 468 | * Should be called without the journal lock held. | 468 | * Should be called without the journal lock held. |
| @@ -547,8 +547,8 @@ repeat: | |||
| 547 | jbd_lock_bh_state(bh); | 547 | jbd_lock_bh_state(bh); |
| 548 | 548 | ||
| 549 | /* We now hold the buffer lock so it is safe to query the buffer | 549 | /* We now hold the buffer lock so it is safe to query the buffer |
| 550 | * state. Is the buffer dirty? | 550 | * state. Is the buffer dirty? |
| 551 | * | 551 | * |
| 552 | * If so, there are two possibilities. The buffer may be | 552 | * If so, there are two possibilities. The buffer may be |
| 553 | * non-journaled, and undergoing a quite legitimate writeback. | 553 | * non-journaled, and undergoing a quite legitimate writeback. |
| 554 | * Otherwise, it is journaled, and we don't expect dirty buffers | 554 | * Otherwise, it is journaled, and we don't expect dirty buffers |
| @@ -566,7 +566,7 @@ repeat: | |||
| 566 | */ | 566 | */ |
| 567 | if (jh->b_transaction) { | 567 | if (jh->b_transaction) { |
| 568 | J_ASSERT_JH(jh, | 568 | J_ASSERT_JH(jh, |
| 569 | jh->b_transaction == transaction || | 569 | jh->b_transaction == transaction || |
| 570 | jh->b_transaction == | 570 | jh->b_transaction == |
| 571 | journal->j_committing_transaction); | 571 | journal->j_committing_transaction); |
| 572 | if (jh->b_next_transaction) | 572 | if (jh->b_next_transaction) |
| @@ -580,7 +580,7 @@ repeat: | |||
| 580 | */ | 580 | */ |
| 581 | JBUFFER_TRACE(jh, "Unexpected dirty buffer"); | 581 | JBUFFER_TRACE(jh, "Unexpected dirty buffer"); |
| 582 | jbd_unexpected_dirty_buffer(jh); | 582 | jbd_unexpected_dirty_buffer(jh); |
| 583 | } | 583 | } |
| 584 | 584 | ||
| 585 | unlock_buffer(bh); | 585 | unlock_buffer(bh); |
| 586 | 586 | ||
| @@ -653,7 +653,7 @@ repeat: | |||
| 653 | * buffer had better remain locked during the kmalloc, | 653 | * buffer had better remain locked during the kmalloc, |
| 654 | * but that should be true --- we hold the journal lock | 654 | * but that should be true --- we hold the journal lock |
| 655 | * still and the buffer is already on the BUF_JOURNAL | 655 | * still and the buffer is already on the BUF_JOURNAL |
| 656 | * list so won't be flushed. | 656 | * list so won't be flushed. |
| 657 | * | 657 | * |
| 658 | * Subtle point, though: if this is a get_undo_access, | 658 | * Subtle point, though: if this is a get_undo_access, |
| 659 | * then we will be relying on the frozen_data to contain | 659 | * then we will be relying on the frozen_data to contain |
| @@ -666,8 +666,9 @@ repeat: | |||
| 666 | if (!frozen_buffer) { | 666 | if (!frozen_buffer) { |
| 667 | JBUFFER_TRACE(jh, "allocate memory for buffer"); | 667 | JBUFFER_TRACE(jh, "allocate memory for buffer"); |
| 668 | jbd_unlock_bh_state(bh); | 668 | jbd_unlock_bh_state(bh); |
| 669 | frozen_buffer = jbd_kmalloc(jh2bh(jh)->b_size, | 669 | frozen_buffer = |
| 670 | GFP_NOFS); | 670 | jbd_slab_alloc(jh2bh(jh)->b_size, |
| 671 | GFP_NOFS); | ||
| 671 | if (!frozen_buffer) { | 672 | if (!frozen_buffer) { |
| 672 | printk(KERN_EMERG | 673 | printk(KERN_EMERG |
| 673 | "%s: OOM for frozen_buffer\n", | 674 | "%s: OOM for frozen_buffer\n", |
| @@ -726,7 +727,7 @@ done: | |||
| 726 | 727 | ||
| 727 | out: | 728 | out: |
| 728 | if (unlikely(frozen_buffer)) /* It's usually NULL */ | 729 | if (unlikely(frozen_buffer)) /* It's usually NULL */ |
| 729 | kfree(frozen_buffer); | 730 | jbd_slab_free(frozen_buffer, bh->b_size); |
| 730 | 731 | ||
| 731 | JBUFFER_TRACE(jh, "exit"); | 732 | JBUFFER_TRACE(jh, "exit"); |
| 732 | return error; | 733 | return error; |
| @@ -764,8 +765,8 @@ int journal_get_write_access(handle_t *handle, struct buffer_head *bh) | |||
| 764 | * manually rather than reading off disk), then we need to keep the | 765 | * manually rather than reading off disk), then we need to keep the |
| 765 | * buffer_head locked until it has been completely filled with new | 766 | * buffer_head locked until it has been completely filled with new |
| 766 | * data. In this case, we should be able to make the assertion that | 767 | * data. In this case, we should be able to make the assertion that |
| 767 | * the bh is not already part of an existing transaction. | 768 | * the bh is not already part of an existing transaction. |
| 768 | * | 769 | * |
| 769 | * The buffer should already be locked by the caller by this point. | 770 | * The buffer should already be locked by the caller by this point. |
| 770 | * There is no lock ranking violation: it was a newly created, | 771 | * There is no lock ranking violation: it was a newly created, |
| 771 | * unlocked buffer beforehand. */ | 772 | * unlocked buffer beforehand. */ |
| @@ -777,7 +778,7 @@ int journal_get_write_access(handle_t *handle, struct buffer_head *bh) | |||
| 777 | * | 778 | * |
| 778 | * Call this if you create a new bh. | 779 | * Call this if you create a new bh. |
| 779 | */ | 780 | */ |
| 780 | int journal_get_create_access(handle_t *handle, struct buffer_head *bh) | 781 | int journal_get_create_access(handle_t *handle, struct buffer_head *bh) |
| 781 | { | 782 | { |
| 782 | transaction_t *transaction = handle->h_transaction; | 783 | transaction_t *transaction = handle->h_transaction; |
| 783 | journal_t *journal = transaction->t_journal; | 784 | journal_t *journal = transaction->t_journal; |
| @@ -846,13 +847,13 @@ out: | |||
| 846 | * do not reuse freed space until the deallocation has been committed, | 847 | * do not reuse freed space until the deallocation has been committed, |
| 847 | * since if we overwrote that space we would make the delete | 848 | * since if we overwrote that space we would make the delete |
| 848 | * un-rewindable in case of a crash. | 849 | * un-rewindable in case of a crash. |
| 849 | * | 850 | * |
| 850 | * To deal with that, journal_get_undo_access requests write access to a | 851 | * To deal with that, journal_get_undo_access requests write access to a |
| 851 | * buffer for parts of non-rewindable operations such as delete | 852 | * buffer for parts of non-rewindable operations such as delete |
| 852 | * operations on the bitmaps. The journaling code must keep a copy of | 853 | * operations on the bitmaps. The journaling code must keep a copy of |
| 853 | * the buffer's contents prior to the undo_access call until such time | 854 | * the buffer's contents prior to the undo_access call until such time |
| 854 | * as we know that the buffer has definitely been committed to disk. | 855 | * as we know that the buffer has definitely been committed to disk. |
| 855 | * | 856 | * |
| 856 | * We never need to know which transaction the committed data is part | 857 | * We never need to know which transaction the committed data is part |
| 857 | * of, buffers touched here are guaranteed to be dirtied later and so | 858 | * of, buffers touched here are guaranteed to be dirtied later and so |
| 858 | * will be committed to a new transaction in due course, at which point | 859 | * will be committed to a new transaction in due course, at which point |
| @@ -879,7 +880,7 @@ int journal_get_undo_access(handle_t *handle, struct buffer_head *bh) | |||
| 879 | 880 | ||
| 880 | repeat: | 881 | repeat: |
| 881 | if (!jh->b_committed_data) { | 882 | if (!jh->b_committed_data) { |
| 882 | committed_data = jbd_kmalloc(jh2bh(jh)->b_size, GFP_NOFS); | 883 | committed_data = jbd_slab_alloc(jh2bh(jh)->b_size, GFP_NOFS); |
| 883 | if (!committed_data) { | 884 | if (!committed_data) { |
| 884 | printk(KERN_EMERG "%s: No memory for committed data\n", | 885 | printk(KERN_EMERG "%s: No memory for committed data\n", |
| 885 | __FUNCTION__); | 886 | __FUNCTION__); |
| @@ -906,17 +907,17 @@ repeat: | |||
| 906 | out: | 907 | out: |
| 907 | journal_put_journal_head(jh); | 908 | journal_put_journal_head(jh); |
| 908 | if (unlikely(committed_data)) | 909 | if (unlikely(committed_data)) |
| 909 | kfree(committed_data); | 910 | jbd_slab_free(committed_data, bh->b_size); |
| 910 | return err; | 911 | return err; |
| 911 | } | 912 | } |
| 912 | 913 | ||
| 913 | /** | 914 | /** |
| 914 | * int journal_dirty_data() - mark a buffer as containing dirty data which | 915 | * int journal_dirty_data() - mark a buffer as containing dirty data which |
| 915 | * needs to be flushed before we can commit the | 916 | * needs to be flushed before we can commit the |
| 916 | * current transaction. | 917 | * current transaction. |
| 917 | * @handle: transaction | 918 | * @handle: transaction |
| 918 | * @bh: bufferhead to mark | 919 | * @bh: bufferhead to mark |
| 919 | * | 920 | * |
| 920 | * The buffer is placed on the transaction's data list and is marked as | 921 | * The buffer is placed on the transaction's data list and is marked as |
| 921 | * belonging to the transaction. | 922 | * belonging to the transaction. |
| 922 | * | 923 | * |
| @@ -945,15 +946,15 @@ int journal_dirty_data(handle_t *handle, struct buffer_head *bh) | |||
| 945 | 946 | ||
| 946 | /* | 947 | /* |
| 947 | * What if the buffer is already part of a running transaction? | 948 | * What if the buffer is already part of a running transaction? |
| 948 | * | 949 | * |
| 949 | * There are two cases: | 950 | * There are two cases: |
| 950 | * 1) It is part of the current running transaction. Refile it, | 951 | * 1) It is part of the current running transaction. Refile it, |
| 951 | * just in case we have allocated it as metadata, deallocated | 952 | * just in case we have allocated it as metadata, deallocated |
| 952 | * it, then reallocated it as data. | 953 | * it, then reallocated it as data. |
| 953 | * 2) It is part of the previous, still-committing transaction. | 954 | * 2) It is part of the previous, still-committing transaction. |
| 954 | * If all we want to do is to guarantee that the buffer will be | 955 | * If all we want to do is to guarantee that the buffer will be |
| 955 | * written to disk before this new transaction commits, then | 956 | * written to disk before this new transaction commits, then |
| 956 | * being sure that the *previous* transaction has this same | 957 | * being sure that the *previous* transaction has this same |
| 957 | * property is sufficient for us! Just leave it on its old | 958 | * property is sufficient for us! Just leave it on its old |
| 958 | * transaction. | 959 | * transaction. |
| 959 | * | 960 | * |
| @@ -1075,18 +1076,18 @@ no_journal: | |||
| 1075 | return 0; | 1076 | return 0; |
| 1076 | } | 1077 | } |
| 1077 | 1078 | ||
| 1078 | /** | 1079 | /** |
| 1079 | * int journal_dirty_metadata() - mark a buffer as containing dirty metadata | 1080 | * int journal_dirty_metadata() - mark a buffer as containing dirty metadata |
| 1080 | * @handle: transaction to add buffer to. | 1081 | * @handle: transaction to add buffer to. |
| 1081 | * @bh: buffer to mark | 1082 | * @bh: buffer to mark |
| 1082 | * | 1083 | * |
| 1083 | * mark dirty metadata which needs to be journaled as part of the current | 1084 | * mark dirty metadata which needs to be journaled as part of the current |
| 1084 | * transaction. | 1085 | * transaction. |
| 1085 | * | 1086 | * |
| 1086 | * The buffer is placed on the transaction's metadata list and is marked | 1087 | * The buffer is placed on the transaction's metadata list and is marked |
| 1087 | * as belonging to the transaction. | 1088 | * as belonging to the transaction. |
| 1088 | * | 1089 | * |
| 1089 | * Returns error number or 0 on success. | 1090 | * Returns error number or 0 on success. |
| 1090 | * | 1091 | * |
| 1091 | * Special care needs to be taken if the buffer already belongs to the | 1092 | * Special care needs to be taken if the buffer already belongs to the |
| 1092 | * current committing transaction (in which case we should have frozen | 1093 | * current committing transaction (in which case we should have frozen |
| @@ -1134,11 +1135,11 @@ int journal_dirty_metadata(handle_t *handle, struct buffer_head *bh) | |||
| 1134 | 1135 | ||
| 1135 | set_buffer_jbddirty(bh); | 1136 | set_buffer_jbddirty(bh); |
| 1136 | 1137 | ||
| 1137 | /* | 1138 | /* |
| 1138 | * Metadata already on the current transaction list doesn't | 1139 | * Metadata already on the current transaction list doesn't |
| 1139 | * need to be filed. Metadata on another transaction's list must | 1140 | * need to be filed. Metadata on another transaction's list must |
| 1140 | * be committing, and will be refiled once the commit completes: | 1141 | * be committing, and will be refiled once the commit completes: |
| 1141 | * leave it alone for now. | 1142 | * leave it alone for now. |
| 1142 | */ | 1143 | */ |
| 1143 | if (jh->b_transaction != transaction) { | 1144 | if (jh->b_transaction != transaction) { |
| 1144 | JBUFFER_TRACE(jh, "already on other transaction"); | 1145 | JBUFFER_TRACE(jh, "already on other transaction"); |
| @@ -1164,7 +1165,7 @@ out: | |||
| 1164 | return 0; | 1165 | return 0; |
| 1165 | } | 1166 | } |
| 1166 | 1167 | ||
| 1167 | /* | 1168 | /* |
| 1168 | * journal_release_buffer: undo a get_write_access without any buffer | 1169 | * journal_release_buffer: undo a get_write_access without any buffer |
| 1169 | * updates, if the update decided in the end that it didn't need access. | 1170 | * updates, if the update decided in the end that it didn't need access. |
| 1170 | * | 1171 | * |
| @@ -1175,20 +1176,20 @@ journal_release_buffer(handle_t *handle, struct buffer_head *bh) | |||
| 1175 | BUFFER_TRACE(bh, "entry"); | 1176 | BUFFER_TRACE(bh, "entry"); |
| 1176 | } | 1177 | } |
| 1177 | 1178 | ||
| 1178 | /** | 1179 | /** |
| 1179 | * void journal_forget() - bforget() for potentially-journaled buffers. | 1180 | * void journal_forget() - bforget() for potentially-journaled buffers. |
| 1180 | * @handle: transaction handle | 1181 | * @handle: transaction handle |
| 1181 | * @bh: bh to 'forget' | 1182 | * @bh: bh to 'forget' |
| 1182 | * | 1183 | * |
| 1183 | * We can only do the bforget if there are no commits pending against the | 1184 | * We can only do the bforget if there are no commits pending against the |
| 1184 | * buffer. If the buffer is dirty in the current running transaction we | 1185 | * buffer. If the buffer is dirty in the current running transaction we |
| 1185 | * can safely unlink it. | 1186 | * can safely unlink it. |
| 1186 | * | 1187 | * |
| 1187 | * bh may not be a journalled buffer at all - it may be a non-JBD | 1188 | * bh may not be a journalled buffer at all - it may be a non-JBD |
| 1188 | * buffer which came off the hashtable. Check for this. | 1189 | * buffer which came off the hashtable. Check for this. |
| 1189 | * | 1190 | * |
| 1190 | * Decrements bh->b_count by one. | 1191 | * Decrements bh->b_count by one. |
| 1191 | * | 1192 | * |
| 1192 | * Allow this call even if the handle has aborted --- it may be part of | 1193 | * Allow this call even if the handle has aborted --- it may be part of |
| 1193 | * the caller's cleanup after an abort. | 1194 | * the caller's cleanup after an abort. |
| 1194 | */ | 1195 | */ |
| @@ -1236,7 +1237,7 @@ int journal_forget (handle_t *handle, struct buffer_head *bh) | |||
| 1236 | 1237 | ||
| 1237 | drop_reserve = 1; | 1238 | drop_reserve = 1; |
| 1238 | 1239 | ||
| 1239 | /* | 1240 | /* |
| 1240 | * We are no longer going to journal this buffer. | 1241 | * We are no longer going to journal this buffer. |
| 1241 | * However, the commit of this transaction is still | 1242 | * However, the commit of this transaction is still |
| 1242 | * important to the buffer: the delete that we are now | 1243 | * important to the buffer: the delete that we are now |
| @@ -1245,7 +1246,7 @@ int journal_forget (handle_t *handle, struct buffer_head *bh) | |||
| 1245 | * | 1246 | * |
| 1246 | * So, if we have a checkpoint on the buffer, we should | 1247 | * So, if we have a checkpoint on the buffer, we should |
| 1247 | * now refile the buffer on our BJ_Forget list so that | 1248 | * now refile the buffer on our BJ_Forget list so that |
| 1248 | * we know to remove the checkpoint after we commit. | 1249 | * we know to remove the checkpoint after we commit. |
| 1249 | */ | 1250 | */ |
| 1250 | 1251 | ||
| 1251 | if (jh->b_cp_transaction) { | 1252 | if (jh->b_cp_transaction) { |
| @@ -1263,7 +1264,7 @@ int journal_forget (handle_t *handle, struct buffer_head *bh) | |||
| 1263 | } | 1264 | } |
| 1264 | } | 1265 | } |
| 1265 | } else if (jh->b_transaction) { | 1266 | } else if (jh->b_transaction) { |
| 1266 | J_ASSERT_JH(jh, (jh->b_transaction == | 1267 | J_ASSERT_JH(jh, (jh->b_transaction == |
| 1267 | journal->j_committing_transaction)); | 1268 | journal->j_committing_transaction)); |
| 1268 | /* However, if the buffer is still owned by a prior | 1269 | /* However, if the buffer is still owned by a prior |
| 1269 | * (committing) transaction, we can't drop it yet... */ | 1270 | * (committing) transaction, we can't drop it yet... */ |
| @@ -1293,7 +1294,7 @@ drop: | |||
| 1293 | /** | 1294 | /** |
| 1294 | * int journal_stop() - complete a transaction | 1295 | * int journal_stop() - complete a transaction |
| 1295 | * @handle: tranaction to complete. | 1296 | * @handle: tranaction to complete. |
| 1296 | * | 1297 | * |
| 1297 | * All done for a particular handle. | 1298 | * All done for a particular handle. |
| 1298 | * | 1299 | * |
| 1299 | * There is not much action needed here. We just return any remaining | 1300 | * There is not much action needed here. We just return any remaining |
| @@ -1302,7 +1303,7 @@ drop: | |||
| 1302 | * filesystem is marked for synchronous update. | 1303 | * filesystem is marked for synchronous update. |
| 1303 | * | 1304 | * |
| 1304 | * journal_stop itself will not usually return an error, but it may | 1305 | * journal_stop itself will not usually return an error, but it may |
| 1305 | * do so in unusual circumstances. In particular, expect it to | 1306 | * do so in unusual circumstances. In particular, expect it to |
| 1306 | * return -EIO if a journal_abort has been executed since the | 1307 | * return -EIO if a journal_abort has been executed since the |
| 1307 | * transaction began. | 1308 | * transaction began. |
| 1308 | */ | 1309 | */ |
| @@ -1372,7 +1373,7 @@ int journal_stop(handle_t *handle) | |||
| 1372 | if (handle->h_sync || | 1373 | if (handle->h_sync || |
| 1373 | transaction->t_outstanding_credits > | 1374 | transaction->t_outstanding_credits > |
| 1374 | journal->j_max_transaction_buffers || | 1375 | journal->j_max_transaction_buffers || |
| 1375 | time_after_eq(jiffies, transaction->t_expires)) { | 1376 | time_after_eq(jiffies, transaction->t_expires)) { |
| 1376 | /* Do this even for aborted journals: an abort still | 1377 | /* Do this even for aborted journals: an abort still |
| 1377 | * completes the commit thread, it just doesn't write | 1378 | * completes the commit thread, it just doesn't write |
| 1378 | * anything to disk. */ | 1379 | * anything to disk. */ |
| @@ -1387,7 +1388,7 @@ int journal_stop(handle_t *handle) | |||
| 1387 | 1388 | ||
| 1388 | /* | 1389 | /* |
| 1389 | * Special case: JFS_SYNC synchronous updates require us | 1390 | * Special case: JFS_SYNC synchronous updates require us |
| 1390 | * to wait for the commit to complete. | 1391 | * to wait for the commit to complete. |
| 1391 | */ | 1392 | */ |
| 1392 | if (handle->h_sync && !(current->flags & PF_MEMALLOC)) | 1393 | if (handle->h_sync && !(current->flags & PF_MEMALLOC)) |
| 1393 | err = log_wait_commit(journal, tid); | 1394 | err = log_wait_commit(journal, tid); |
| @@ -1438,7 +1439,7 @@ int journal_force_commit(journal_t *journal) | |||
| 1438 | * jbd_lock_bh_state(jh2bh(jh)) is held. | 1439 | * jbd_lock_bh_state(jh2bh(jh)) is held. |
| 1439 | */ | 1440 | */ |
| 1440 | 1441 | ||
| 1441 | static inline void | 1442 | static inline void |
| 1442 | __blist_add_buffer(struct journal_head **list, struct journal_head *jh) | 1443 | __blist_add_buffer(struct journal_head **list, struct journal_head *jh) |
| 1443 | { | 1444 | { |
| 1444 | if (!*list) { | 1445 | if (!*list) { |
| @@ -1453,7 +1454,7 @@ __blist_add_buffer(struct journal_head **list, struct journal_head *jh) | |||
| 1453 | } | 1454 | } |
| 1454 | } | 1455 | } |
| 1455 | 1456 | ||
| 1456 | /* | 1457 | /* |
| 1457 | * Remove a buffer from a transaction list, given the transaction's list | 1458 | * Remove a buffer from a transaction list, given the transaction's list |
| 1458 | * head pointer. | 1459 | * head pointer. |
| 1459 | * | 1460 | * |
| @@ -1474,7 +1475,7 @@ __blist_del_buffer(struct journal_head **list, struct journal_head *jh) | |||
| 1474 | jh->b_tnext->b_tprev = jh->b_tprev; | 1475 | jh->b_tnext->b_tprev = jh->b_tprev; |
| 1475 | } | 1476 | } |
| 1476 | 1477 | ||
| 1477 | /* | 1478 | /* |
| 1478 | * Remove a buffer from the appropriate transaction list. | 1479 | * Remove a buffer from the appropriate transaction list. |
| 1479 | * | 1480 | * |
| 1480 | * Note that this function can *change* the value of | 1481 | * Note that this function can *change* the value of |
| @@ -1594,17 +1595,17 @@ out: | |||
| 1594 | } | 1595 | } |
| 1595 | 1596 | ||
| 1596 | 1597 | ||
| 1597 | /** | 1598 | /** |
| 1598 | * int journal_try_to_free_buffers() - try to free page buffers. | 1599 | * int journal_try_to_free_buffers() - try to free page buffers. |
| 1599 | * @journal: journal for operation | 1600 | * @journal: journal for operation |
| 1600 | * @page: to try and free | 1601 | * @page: to try and free |
| 1601 | * @unused_gfp_mask: unused | 1602 | * @unused_gfp_mask: unused |
| 1602 | * | 1603 | * |
| 1603 | * | 1604 | * |
| 1604 | * For all the buffers on this page, | 1605 | * For all the buffers on this page, |
| 1605 | * if they are fully written out ordered data, move them onto BUF_CLEAN | 1606 | * if they are fully written out ordered data, move them onto BUF_CLEAN |
| 1606 | * so try_to_free_buffers() can reap them. | 1607 | * so try_to_free_buffers() can reap them. |
| 1607 | * | 1608 | * |
| 1608 | * This function returns non-zero if we wish try_to_free_buffers() | 1609 | * This function returns non-zero if we wish try_to_free_buffers() |
| 1609 | * to be called. We do this if the page is releasable by try_to_free_buffers(). | 1610 | * to be called. We do this if the page is releasable by try_to_free_buffers(). |
| 1610 | * We also do it if the page has locked or dirty buffers and the caller wants | 1611 | * We also do it if the page has locked or dirty buffers and the caller wants |
| @@ -1628,7 +1629,7 @@ out: | |||
| 1628 | * cannot happen because we never reallocate freed data as metadata | 1629 | * cannot happen because we never reallocate freed data as metadata |
| 1629 | * while the data is part of a transaction. Yes? | 1630 | * while the data is part of a transaction. Yes? |
| 1630 | */ | 1631 | */ |
| 1631 | int journal_try_to_free_buffers(journal_t *journal, | 1632 | int journal_try_to_free_buffers(journal_t *journal, |
| 1632 | struct page *page, gfp_t unused_gfp_mask) | 1633 | struct page *page, gfp_t unused_gfp_mask) |
| 1633 | { | 1634 | { |
| 1634 | struct buffer_head *head; | 1635 | struct buffer_head *head; |
| @@ -1696,7 +1697,7 @@ static int __dispose_buffer(struct journal_head *jh, transaction_t *transaction) | |||
| 1696 | } | 1697 | } |
| 1697 | 1698 | ||
| 1698 | /* | 1699 | /* |
| 1699 | * journal_invalidatepage | 1700 | * journal_invalidatepage |
| 1700 | * | 1701 | * |
| 1701 | * This code is tricky. It has a number of cases to deal with. | 1702 | * This code is tricky. It has a number of cases to deal with. |
| 1702 | * | 1703 | * |
| @@ -1704,15 +1705,15 @@ static int __dispose_buffer(struct journal_head *jh, transaction_t *transaction) | |||
| 1704 | * | 1705 | * |
| 1705 | * i_size must be updated on disk before we start calling invalidatepage on the | 1706 | * i_size must be updated on disk before we start calling invalidatepage on the |
| 1706 | * data. | 1707 | * data. |
| 1707 | * | 1708 | * |
| 1708 | * This is done in ext3 by defining an ext3_setattr method which | 1709 | * This is done in ext3 by defining an ext3_setattr method which |
| 1709 | * updates i_size before truncate gets going. By maintaining this | 1710 | * updates i_size before truncate gets going. By maintaining this |
| 1710 | * invariant, we can be sure that it is safe to throw away any buffers | 1711 | * invariant, we can be sure that it is safe to throw away any buffers |
| 1711 | * attached to the current transaction: once the transaction commits, | 1712 | * attached to the current transaction: once the transaction commits, |
| 1712 | * we know that the data will not be needed. | 1713 | * we know that the data will not be needed. |
| 1713 | * | 1714 | * |
| 1714 | * Note however that we can *not* throw away data belonging to the | 1715 | * Note however that we can *not* throw away data belonging to the |
| 1715 | * previous, committing transaction! | 1716 | * previous, committing transaction! |
| 1716 | * | 1717 | * |
| 1717 | * Any disk blocks which *are* part of the previous, committing | 1718 | * Any disk blocks which *are* part of the previous, committing |
| 1718 | * transaction (and which therefore cannot be discarded immediately) are | 1719 | * transaction (and which therefore cannot be discarded immediately) are |
| @@ -1731,7 +1732,7 @@ static int __dispose_buffer(struct journal_head *jh, transaction_t *transaction) | |||
| 1731 | * don't make guarantees about the order in which data hits disk --- in | 1732 | * don't make guarantees about the order in which data hits disk --- in |
| 1732 | * particular we don't guarantee that new dirty data is flushed before | 1733 | * particular we don't guarantee that new dirty data is flushed before |
| 1733 | * transaction commit --- so it is always safe just to discard data | 1734 | * transaction commit --- so it is always safe just to discard data |
| 1734 | * immediately in that mode. --sct | 1735 | * immediately in that mode. --sct |
| 1735 | */ | 1736 | */ |
| 1736 | 1737 | ||
| 1737 | /* | 1738 | /* |
| @@ -1875,9 +1876,9 @@ zap_buffer_unlocked: | |||
| 1875 | return may_free; | 1876 | return may_free; |
| 1876 | } | 1877 | } |
| 1877 | 1878 | ||
| 1878 | /** | 1879 | /** |
| 1879 | * void journal_invalidatepage() | 1880 | * void journal_invalidatepage() |
| 1880 | * @journal: journal to use for flush... | 1881 | * @journal: journal to use for flush... |
| 1881 | * @page: page to flush | 1882 | * @page: page to flush |
| 1882 | * @offset: length of page to invalidate. | 1883 | * @offset: length of page to invalidate. |
| 1883 | * | 1884 | * |
| @@ -1885,7 +1886,7 @@ zap_buffer_unlocked: | |||
| 1885 | * | 1886 | * |
| 1886 | */ | 1887 | */ |
| 1887 | void journal_invalidatepage(journal_t *journal, | 1888 | void journal_invalidatepage(journal_t *journal, |
| 1888 | struct page *page, | 1889 | struct page *page, |
| 1889 | unsigned long offset) | 1890 | unsigned long offset) |
| 1890 | { | 1891 | { |
| 1891 | struct buffer_head *head, *bh, *next; | 1892 | struct buffer_head *head, *bh, *next; |
| @@ -1907,7 +1908,7 @@ void journal_invalidatepage(journal_t *journal, | |||
| 1907 | next = bh->b_this_page; | 1908 | next = bh->b_this_page; |
| 1908 | 1909 | ||
| 1909 | if (offset <= curr_off) { | 1910 | if (offset <= curr_off) { |
| 1910 | /* This block is wholly outside the truncation point */ | 1911 | /* This block is wholly outside the truncation point */ |
| 1911 | lock_buffer(bh); | 1912 | lock_buffer(bh); |
| 1912 | may_free &= journal_unmap_buffer(journal, bh); | 1913 | may_free &= journal_unmap_buffer(journal, bh); |
| 1913 | unlock_buffer(bh); | 1914 | unlock_buffer(bh); |
| @@ -1923,8 +1924,8 @@ void journal_invalidatepage(journal_t *journal, | |||
| 1923 | } | 1924 | } |
| 1924 | } | 1925 | } |
| 1925 | 1926 | ||
| 1926 | /* | 1927 | /* |
| 1927 | * File a buffer on the given transaction list. | 1928 | * File a buffer on the given transaction list. |
| 1928 | */ | 1929 | */ |
| 1929 | void __journal_file_buffer(struct journal_head *jh, | 1930 | void __journal_file_buffer(struct journal_head *jh, |
| 1930 | transaction_t *transaction, int jlist) | 1931 | transaction_t *transaction, int jlist) |
| @@ -1947,7 +1948,7 @@ void __journal_file_buffer(struct journal_head *jh, | |||
| 1947 | * with __jbd_unexpected_dirty_buffer()'s handling of dirty | 1948 | * with __jbd_unexpected_dirty_buffer()'s handling of dirty |
| 1948 | * state. */ | 1949 | * state. */ |
| 1949 | 1950 | ||
| 1950 | if (jlist == BJ_Metadata || jlist == BJ_Reserved || | 1951 | if (jlist == BJ_Metadata || jlist == BJ_Reserved || |
| 1951 | jlist == BJ_Shadow || jlist == BJ_Forget) { | 1952 | jlist == BJ_Shadow || jlist == BJ_Forget) { |
| 1952 | if (test_clear_buffer_dirty(bh) || | 1953 | if (test_clear_buffer_dirty(bh) || |
| 1953 | test_clear_buffer_jbddirty(bh)) | 1954 | test_clear_buffer_jbddirty(bh)) |
| @@ -2007,7 +2008,7 @@ void journal_file_buffer(struct journal_head *jh, | |||
| 2007 | jbd_unlock_bh_state(jh2bh(jh)); | 2008 | jbd_unlock_bh_state(jh2bh(jh)); |
| 2008 | } | 2009 | } |
| 2009 | 2010 | ||
| 2010 | /* | 2011 | /* |
| 2011 | * Remove a buffer from its current buffer list in preparation for | 2012 | * Remove a buffer from its current buffer list in preparation for |
| 2012 | * dropping it from its current transaction entirely. If the buffer has | 2013 | * dropping it from its current transaction entirely. If the buffer has |
| 2013 | * already started to be used by a subsequent transaction, refile the | 2014 | * already started to be used by a subsequent transaction, refile the |
| @@ -2059,7 +2060,7 @@ void __journal_refile_buffer(struct journal_head *jh) | |||
| 2059 | * to the caller to remove the journal_head if necessary. For the | 2060 | * to the caller to remove the journal_head if necessary. For the |
| 2060 | * unlocked journal_refile_buffer call, the caller isn't going to be | 2061 | * unlocked journal_refile_buffer call, the caller isn't going to be |
| 2061 | * doing anything else to the buffer so we need to do the cleanup | 2062 | * doing anything else to the buffer so we need to do the cleanup |
| 2062 | * ourselves to avoid a jh leak. | 2063 | * ourselves to avoid a jh leak. |
| 2063 | * | 2064 | * |
| 2064 | * *** The journal_head may be freed by this call! *** | 2065 | * *** The journal_head may be freed by this call! *** |
| 2065 | */ | 2066 | */ |
