.. | .. |
---|
| 1 | +/* SPDX-License-Identifier: GPL-2.0-or-later */ |
---|
1 | 2 | /* |
---|
2 | 3 | * linux/include/linux/jbd2.h |
---|
3 | 4 | * |
---|
4 | 5 | * Written by Stephen C. Tweedie <sct@redhat.com> |
---|
5 | 6 | * |
---|
6 | 7 | * Copyright 1998-2000 Red Hat, Inc --- All Rights Reserved |
---|
7 | | - * |
---|
8 | | - * This file is part of the Linux kernel and is made available under |
---|
9 | | - * the terms of the GNU General Public License, version 2, or at your |
---|
10 | | - * option, any later version, incorporated herein by reference. |
---|
11 | 8 | * |
---|
12 | 9 | * Definitions for transaction data structures for the buffer cache |
---|
13 | 10 | * filesystem journaling support. |
---|
.. | .. |
---|
30 | 27 | #include <linux/timer.h> |
---|
31 | 28 | #include <linux/slab.h> |
---|
32 | 29 | #include <linux/bit_spinlock.h> |
---|
| 30 | +#include <linux/blkdev.h> |
---|
33 | 31 | #include <crypto/hash.h> |
---|
34 | 32 | #endif |
---|
35 | 33 | |
---|
.. | .. |
---|
70 | 68 | extern void jbd2_free(void *ptr, size_t size); |
---|
71 | 69 | |
---|
72 | 70 | #define JBD2_MIN_JOURNAL_BLOCKS 1024 |
---|
| 71 | +#define JBD2_MIN_FC_BLOCKS 256 |
---|
73 | 72 | |
---|
74 | 73 | #ifdef __KERNEL__ |
---|
75 | 74 | |
---|
.. | .. |
---|
265 | 264 | /* 0x0050 */ |
---|
266 | 265 | __u8 s_checksum_type; /* checksum type */ |
---|
267 | 266 | __u8 s_padding2[3]; |
---|
268 | | - __u32 s_padding[42]; |
---|
| 267 | +/* 0x0054 */ |
---|
| 268 | + __be32 s_num_fc_blks; /* Number of fast commit blocks */ |
---|
| 269 | +/* 0x0058 */ |
---|
| 270 | + __u32 s_padding[41]; |
---|
269 | 271 | __be32 s_checksum; /* crc32c(superblock) */ |
---|
270 | 272 | |
---|
271 | 273 | /* 0x0100 */ |
---|
.. | .. |
---|
291 | 293 | #define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004 |
---|
292 | 294 | #define JBD2_FEATURE_INCOMPAT_CSUM_V2 0x00000008 |
---|
293 | 295 | #define JBD2_FEATURE_INCOMPAT_CSUM_V3 0x00000010 |
---|
| 296 | +#define JBD2_FEATURE_INCOMPAT_FAST_COMMIT 0x00000020 |
---|
294 | 297 | |
---|
295 | 298 | /* See "journal feature predicate functions" below */ |
---|
296 | 299 | |
---|
.. | .. |
---|
301 | 304 | JBD2_FEATURE_INCOMPAT_64BIT | \ |
---|
302 | 305 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT | \ |
---|
303 | 306 | JBD2_FEATURE_INCOMPAT_CSUM_V2 | \ |
---|
304 | | - JBD2_FEATURE_INCOMPAT_CSUM_V3) |
---|
| 307 | + JBD2_FEATURE_INCOMPAT_CSUM_V3 | \ |
---|
| 308 | + JBD2_FEATURE_INCOMPAT_FAST_COMMIT) |
---|
305 | 309 | |
---|
306 | 310 | #ifdef __KERNEL__ |
---|
307 | 311 | |
---|
.. | .. |
---|
316 | 320 | BH_Revoked, /* Has been revoked from the log */ |
---|
317 | 321 | BH_RevokeValid, /* Revoked flag is valid */ |
---|
318 | 322 | BH_JBDDirty, /* Is dirty but journaled */ |
---|
319 | | - BH_State, /* Pins most journal_head state */ |
---|
320 | 323 | BH_JournalHead, /* Pins bh->b_private and jh->b_bh */ |
---|
321 | 324 | BH_Shadow, /* IO on shadow buffer is running */ |
---|
322 | 325 | BH_Verified, /* Metadata block has been verified ok */ |
---|
.. | .. |
---|
345 | 348 | return bh->b_private; |
---|
346 | 349 | } |
---|
347 | 350 | |
---|
348 | | -static inline void jbd_lock_bh_state(struct buffer_head *bh) |
---|
349 | | -{ |
---|
350 | | -#ifndef CONFIG_PREEMPT_RT_BASE |
---|
351 | | - bit_spin_lock(BH_State, &bh->b_state); |
---|
352 | | -#else |
---|
353 | | - spin_lock(&bh->b_state_lock); |
---|
354 | | -#endif |
---|
355 | | -} |
---|
356 | | - |
---|
357 | | -static inline int jbd_trylock_bh_state(struct buffer_head *bh) |
---|
358 | | -{ |
---|
359 | | -#ifndef CONFIG_PREEMPT_RT_BASE |
---|
360 | | - return bit_spin_trylock(BH_State, &bh->b_state); |
---|
361 | | -#else |
---|
362 | | - return spin_trylock(&bh->b_state_lock); |
---|
363 | | -#endif |
---|
364 | | -} |
---|
365 | | - |
---|
366 | | -static inline int jbd_is_locked_bh_state(struct buffer_head *bh) |
---|
367 | | -{ |
---|
368 | | -#ifndef CONFIG_PREEMPT_RT_BASE |
---|
369 | | - return bit_spin_is_locked(BH_State, &bh->b_state); |
---|
370 | | -#else |
---|
371 | | - return spin_is_locked(&bh->b_state_lock); |
---|
372 | | -#endif |
---|
373 | | -} |
---|
374 | | - |
---|
375 | | -static inline void jbd_unlock_bh_state(struct buffer_head *bh) |
---|
376 | | -{ |
---|
377 | | -#ifndef CONFIG_PREEMPT_RT_BASE |
---|
378 | | - bit_spin_unlock(BH_State, &bh->b_state); |
---|
379 | | -#else |
---|
380 | | - spin_unlock(&bh->b_state_lock); |
---|
381 | | -#endif |
---|
382 | | -} |
---|
383 | | - |
---|
384 | 351 | static inline void jbd_lock_bh_journal_head(struct buffer_head *bh) |
---|
385 | 352 | { |
---|
386 | | -#ifndef CONFIG_PREEMPT_RT_BASE |
---|
387 | 353 | bit_spin_lock(BH_JournalHead, &bh->b_state); |
---|
388 | | -#else |
---|
389 | | - spin_lock(&bh->b_journal_head_lock); |
---|
390 | | -#endif |
---|
391 | 354 | } |
---|
392 | 355 | |
---|
393 | 356 | static inline void jbd_unlock_bh_journal_head(struct buffer_head *bh) |
---|
394 | 357 | { |
---|
395 | | -#ifndef CONFIG_PREEMPT_RT_BASE |
---|
396 | 358 | bit_spin_unlock(BH_JournalHead, &bh->b_state); |
---|
397 | | -#else |
---|
398 | | - spin_unlock(&bh->b_journal_head_lock); |
---|
399 | | -#endif |
---|
400 | 359 | } |
---|
401 | 360 | |
---|
402 | 361 | #define J_ASSERT(assert) BUG_ON(!(assert)) |
---|
.. | .. |
---|
442 | 401 | #define JI_WAIT_DATA (1 << __JI_WAIT_DATA) |
---|
443 | 402 | |
---|
444 | 403 | /** |
---|
445 | | - * struct jbd_inode - The jbd_inode type is the structure linking inodes in |
---|
| 404 | + * struct jbd2_inode - The jbd_inode type is the structure linking inodes in |
---|
446 | 405 | * ordered mode present in a transaction so that we can sync them during commit. |
---|
447 | 406 | */ |
---|
448 | 407 | struct jbd2_inode { |
---|
.. | .. |
---|
499 | 458 | struct jbd2_revoke_table_s; |
---|
500 | 459 | |
---|
501 | 460 | /** |
---|
502 | | - * struct handle_s - The handle_s type is the concrete type associated with |
---|
503 | | - * handle_t. |
---|
| 461 | + * struct jbd2_journal_handle - The jbd2_journal_handle type is the concrete |
---|
| 462 | + * type associated with handle_t. |
---|
504 | 463 | * @h_transaction: Which compound transaction is this update a part of? |
---|
505 | 464 | * @h_journal: Which journal handle belongs to - used iff h_reserved set. |
---|
506 | 465 | * @h_rsv_handle: Handle reserved for finishing the logical operation. |
---|
507 | | - * @h_buffer_credits: Number of remaining buffers we are allowed to dirty. |
---|
| 466 | + * @h_total_credits: Number of remaining buffers we are allowed to add to |
---|
| 467 | + * journal. These are dirty buffers and revoke descriptor blocks. |
---|
| 468 | + * @h_revoke_credits: Number of remaining revoke records available for handle |
---|
508 | 469 | * @h_ref: Reference count on this handle. |
---|
509 | 470 | * @h_err: Field for caller's use to track errors through large fs operations. |
---|
510 | 471 | * @h_sync: Flag for sync-on-close. |
---|
.. | .. |
---|
514 | 475 | * @h_type: For handle statistics. |
---|
515 | 476 | * @h_line_no: For handle statistics. |
---|
516 | 477 | * @h_start_jiffies: Handle Start time. |
---|
517 | | - * @h_requested_credits: Holds @h_buffer_credits after handle is started. |
---|
| 478 | + * @h_requested_credits: Holds @h_total_credits after handle is started. |
---|
| 479 | + * @h_revoke_credits_requested: Holds @h_revoke_credits after handle is started. |
---|
518 | 480 | * @saved_alloc_context: Saved context while transaction is open. |
---|
519 | 481 | **/ |
---|
520 | 482 | |
---|
.. | .. |
---|
531 | 493 | }; |
---|
532 | 494 | |
---|
533 | 495 | handle_t *h_rsv_handle; |
---|
534 | | - int h_buffer_credits; |
---|
| 496 | + int h_total_credits; |
---|
| 497 | + int h_revoke_credits; |
---|
| 498 | + int h_revoke_credits_requested; |
---|
535 | 499 | int h_ref; |
---|
536 | 500 | int h_err; |
---|
537 | 501 | |
---|
.. | .. |
---|
583 | 547 | * ->jbd_lock_bh_journal_head() (This is "innermost") |
---|
584 | 548 | * |
---|
585 | 549 | * j_state_lock |
---|
586 | | - * ->jbd_lock_bh_state() |
---|
| 550 | + * ->b_state_lock |
---|
587 | 551 | * |
---|
588 | | - * jbd_lock_bh_state() |
---|
| 552 | + * b_state_lock |
---|
589 | 553 | * ->j_list_lock |
---|
590 | 554 | * |
---|
591 | 555 | * j_state_lock |
---|
.. | .. |
---|
615 | 579 | enum { |
---|
616 | 580 | T_RUNNING, |
---|
617 | 581 | T_LOCKED, |
---|
| 582 | + T_SWITCH, |
---|
618 | 583 | T_FLUSH, |
---|
619 | 584 | T_COMMIT, |
---|
620 | 585 | T_COMMIT_DFLUSH, |
---|
.. | .. |
---|
670 | 635 | struct journal_head *t_shadow_list; |
---|
671 | 636 | |
---|
672 | 637 | /* |
---|
673 | | - * List of inodes whose data we've modified in data=ordered mode. |
---|
| 638 | + * List of inodes associated with the transaction; e.g., ext4 uses |
---|
| 639 | + * this to track inodes in data=ordered and data=journal mode that |
---|
| 640 | + * need special handling on transaction commit; also used by ocfs2. |
---|
674 | 641 | * [j_list_lock] |
---|
675 | 642 | */ |
---|
676 | 643 | struct list_head t_inode_list; |
---|
.. | .. |
---|
702 | 669 | |
---|
703 | 670 | /* |
---|
704 | 671 | * Number of outstanding updates running on this transaction |
---|
705 | | - * [t_handle_lock] |
---|
| 672 | + * [none] |
---|
706 | 673 | */ |
---|
707 | 674 | atomic_t t_updates; |
---|
708 | 675 | |
---|
709 | 676 | /* |
---|
710 | | - * Number of buffers reserved for use by all handles in this transaction |
---|
711 | | - * handle but not yet modified. [t_handle_lock] |
---|
| 677 | + * Number of blocks reserved for this transaction in the journal. |
---|
| 678 | + * This is including all credits reserved when starting transaction |
---|
| 679 | + * handles as well as all journal descriptor blocks needed for this |
---|
| 680 | + * transaction. [none] |
---|
712 | 681 | */ |
---|
713 | 682 | atomic_t t_outstanding_credits; |
---|
| 683 | + |
---|
| 684 | + /* |
---|
| 685 | + * Number of revoke records for this transaction added by already |
---|
| 686 | + * stopped handles. [none] |
---|
| 687 | + */ |
---|
| 688 | + atomic_t t_outstanding_revokes; |
---|
| 689 | + |
---|
| 690 | + /* |
---|
| 691 | + * How many handles used this transaction? [none] |
---|
| 692 | + */ |
---|
| 693 | + atomic_t t_handle_count; |
---|
714 | 694 | |
---|
715 | 695 | /* |
---|
716 | 696 | * Forward and backward links for the circular list of all transactions |
---|
.. | .. |
---|
728 | 708 | * When this transaction started, in nanoseconds [no locking] |
---|
729 | 709 | */ |
---|
730 | 710 | ktime_t t_start_time; |
---|
731 | | - |
---|
732 | | - /* |
---|
733 | | - * How many handles used this transaction? [t_handle_lock] |
---|
734 | | - */ |
---|
735 | | - atomic_t t_handle_count; |
---|
736 | 711 | |
---|
737 | 712 | /* |
---|
738 | 713 | * This transaction is being forced and some process is |
---|
.. | .. |
---|
780 | 755 | |
---|
781 | 756 | #define JBD2_NR_BATCH 64 |
---|
782 | 757 | |
---|
| 758 | +enum passtype {PASS_SCAN, PASS_REVOKE, PASS_REPLAY}; |
---|
| 759 | + |
---|
| 760 | +#define JBD2_FC_REPLAY_STOP 0 |
---|
| 761 | +#define JBD2_FC_REPLAY_CONTINUE 1 |
---|
| 762 | + |
---|
783 | 763 | /** |
---|
784 | 764 | * struct journal_s - The journal_s type is the concrete type associated with |
---|
785 | 765 | * journal_t. |
---|
.. | .. |
---|
798 | 778 | * abort)? [j_state_lock] |
---|
799 | 779 | */ |
---|
800 | 780 | int j_errno; |
---|
| 781 | + |
---|
| 782 | + /** |
---|
| 783 | + * @j_abort_mutex: Lock the whole aborting procedure. |
---|
| 784 | + */ |
---|
| 785 | + struct mutex j_abort_mutex; |
---|
801 | 786 | |
---|
802 | 787 | /** |
---|
803 | 788 | * @j_sb_buffer: The first part of the superblock buffer. |
---|
.. | .. |
---|
886 | 871 | wait_queue_head_t j_wait_reserved; |
---|
887 | 872 | |
---|
888 | 873 | /** |
---|
| 874 | + * @j_fc_wait: |
---|
| 875 | + * |
---|
| 876 | + * Wait queue to wait for completion of async fast commits. |
---|
| 877 | + */ |
---|
| 878 | + wait_queue_head_t j_fc_wait; |
---|
| 879 | + |
---|
| 880 | + /** |
---|
889 | 881 | * @j_checkpoint_mutex: |
---|
890 | 882 | * |
---|
891 | 883 | * Semaphore for locking against concurrent checkpoints. |
---|
.. | .. |
---|
943 | 935 | unsigned long j_last; |
---|
944 | 936 | |
---|
945 | 937 | /** |
---|
| 938 | + * @j_fc_first: |
---|
| 939 | + * |
---|
| 940 | + * The block number of the first fast commit block in the journal |
---|
| 941 | + * [j_state_lock]. |
---|
| 942 | + */ |
---|
| 943 | + unsigned long j_fc_first; |
---|
| 944 | + |
---|
| 945 | + /** |
---|
| 946 | + * @j_fc_off: |
---|
| 947 | + * |
---|
| 948 | + * Number of fast commit blocks currently allocated. Accessed only |
---|
| 949 | + * during fast commit. Currently only process can do fast commit, so |
---|
| 950 | + * this field is not protected by any lock. |
---|
| 951 | + */ |
---|
| 952 | + unsigned long j_fc_off; |
---|
| 953 | + |
---|
| 954 | + /** |
---|
| 955 | + * @j_fc_last: |
---|
| 956 | + * |
---|
| 957 | + * The block number one beyond the last fast commit block in the journal |
---|
| 958 | + * [j_state_lock]. |
---|
| 959 | + */ |
---|
| 960 | + unsigned long j_fc_last; |
---|
| 961 | + |
---|
| 962 | + /** |
---|
946 | 963 | * @j_dev: Device where we store the journal. |
---|
947 | 964 | */ |
---|
948 | 965 | struct block_device *j_dev; |
---|
.. | .. |
---|
973 | 990 | struct block_device *j_fs_dev; |
---|
974 | 991 | |
---|
975 | 992 | /** |
---|
976 | | - * @j_maxlen: Total maximum capacity of the journal region on disk. |
---|
| 993 | + * @j_total_len: Total maximum capacity of the journal region on disk. |
---|
977 | 994 | */ |
---|
978 | | - unsigned int j_maxlen; |
---|
| 995 | + unsigned int j_total_len; |
---|
979 | 996 | |
---|
980 | 997 | /** |
---|
981 | 998 | * @j_reserved_credits: |
---|
.. | .. |
---|
1051 | 1068 | int j_max_transaction_buffers; |
---|
1052 | 1069 | |
---|
1053 | 1070 | /** |
---|
| 1071 | + * @j_revoke_records_per_block: |
---|
| 1072 | + * |
---|
| 1073 | + * Number of revoke records that fit in one descriptor block. |
---|
| 1074 | + */ |
---|
| 1075 | + int j_revoke_records_per_block; |
---|
| 1076 | + |
---|
| 1077 | + /** |
---|
1054 | 1078 | * @j_commit_interval: |
---|
1055 | 1079 | * |
---|
1056 | 1080 | * What is the maximum transaction lifetime before we begin a commit? |
---|
.. | .. |
---|
1086 | 1110 | struct buffer_head **j_wbuf; |
---|
1087 | 1111 | |
---|
1088 | 1112 | /** |
---|
| 1113 | + * @j_fc_wbuf: Array of fast commit bhs for fast commit. Accessed only |
---|
| 1114 | + * during a fast commit. Currently only process can do fast commit, so |
---|
| 1115 | + * this field is not protected by any lock. |
---|
| 1116 | + */ |
---|
| 1117 | + struct buffer_head **j_fc_wbuf; |
---|
| 1118 | + |
---|
| 1119 | + /** |
---|
1089 | 1120 | * @j_wbufsize: |
---|
1090 | 1121 | * |
---|
1091 | 1122 | * Size of @j_wbuf array. |
---|
1092 | 1123 | */ |
---|
1093 | 1124 | int j_wbufsize; |
---|
| 1125 | + |
---|
| 1126 | + /** |
---|
| 1127 | + * @j_fc_wbufsize: |
---|
| 1128 | + * |
---|
| 1129 | + * Size of @j_fc_wbuf array. |
---|
| 1130 | + */ |
---|
| 1131 | + int j_fc_wbufsize; |
---|
1094 | 1132 | |
---|
1095 | 1133 | /** |
---|
1096 | 1134 | * @j_last_sync_writer: |
---|
.. | .. |
---|
1131 | 1169 | */ |
---|
1132 | 1170 | void (*j_commit_callback)(journal_t *, |
---|
1133 | 1171 | transaction_t *); |
---|
| 1172 | + |
---|
| 1173 | + /** |
---|
| 1174 | + * @j_submit_inode_data_buffers: |
---|
| 1175 | + * |
---|
| 1176 | + * This function is called for all inodes associated with the |
---|
| 1177 | + * committing transaction marked with JI_WRITE_DATA flag |
---|
| 1178 | + * before we start to write out the transaction to the journal. |
---|
| 1179 | + */ |
---|
| 1180 | + int (*j_submit_inode_data_buffers) |
---|
| 1181 | + (struct jbd2_inode *); |
---|
| 1182 | + |
---|
| 1183 | + /** |
---|
| 1184 | + * @j_finish_inode_data_buffers: |
---|
| 1185 | + * |
---|
| 1186 | + * This function is called for all inodes associated with the |
---|
| 1187 | + * committing transaction marked with JI_WAIT_DATA flag |
---|
| 1188 | + * after we have written the transaction to the journal |
---|
| 1189 | + * but before we write out the commit block. |
---|
| 1190 | + */ |
---|
| 1191 | + int (*j_finish_inode_data_buffers) |
---|
| 1192 | + (struct jbd2_inode *); |
---|
1134 | 1193 | |
---|
1135 | 1194 | /* |
---|
1136 | 1195 | * Journal statistics |
---|
.. | .. |
---|
1191 | 1250 | */ |
---|
1192 | 1251 | struct lockdep_map j_trans_commit_map; |
---|
1193 | 1252 | #endif |
---|
| 1253 | + |
---|
| 1254 | + /** |
---|
| 1255 | + * @j_fc_cleanup_callback: |
---|
| 1256 | + * |
---|
| 1257 | + * Clean-up after fast commit or full commit. JBD2 calls this function |
---|
| 1258 | + * after every commit operation. |
---|
| 1259 | + */ |
---|
| 1260 | + void (*j_fc_cleanup_callback)(struct journal_s *journal, int); |
---|
| 1261 | + |
---|
| 1262 | + /** |
---|
| 1263 | + * @j_fc_replay_callback: |
---|
| 1264 | + * |
---|
| 1265 | + * File-system specific function that performs replay of a fast |
---|
| 1266 | + * commit. JBD2 calls this function for each fast commit block found in |
---|
| 1267 | + * the journal. This function should return JBD2_FC_REPLAY_CONTINUE |
---|
| 1268 | + * to indicate that the block was processed correctly and more fast |
---|
| 1269 | + * commit replay should continue. Return value of JBD2_FC_REPLAY_STOP |
---|
| 1270 | + * indicates the end of replay (no more blocks remaining). A negative |
---|
| 1271 | + * return value indicates error. |
---|
| 1272 | + */ |
---|
| 1273 | + int (*j_fc_replay_callback)(struct journal_s *journal, |
---|
| 1274 | + struct buffer_head *bh, |
---|
| 1275 | + enum passtype pass, int off, |
---|
| 1276 | + tid_t expected_commit_id); |
---|
1194 | 1277 | }; |
---|
1195 | 1278 | |
---|
1196 | 1279 | #define jbd2_might_wait_for_commit(j) \ |
---|
1197 | 1280 | do { \ |
---|
1198 | 1281 | rwsem_acquire(&j->j_trans_commit_map, 0, 0, _THIS_IP_); \ |
---|
1199 | | - rwsem_release(&j->j_trans_commit_map, 1, _THIS_IP_); \ |
---|
| 1282 | + rwsem_release(&j->j_trans_commit_map, _THIS_IP_); \ |
---|
1200 | 1283 | } while (0) |
---|
1201 | 1284 | |
---|
1202 | 1285 | /* journal feature predicate functions */ |
---|
.. | .. |
---|
1261 | 1344 | JBD2_FEATURE_INCOMPAT_FUNCS(async_commit, ASYNC_COMMIT) |
---|
1262 | 1345 | JBD2_FEATURE_INCOMPAT_FUNCS(csum2, CSUM_V2) |
---|
1263 | 1346 | JBD2_FEATURE_INCOMPAT_FUNCS(csum3, CSUM_V3) |
---|
| 1347 | +JBD2_FEATURE_INCOMPAT_FUNCS(fast_commit, FAST_COMMIT) |
---|
1264 | 1348 | |
---|
1265 | 1349 | /* |
---|
1266 | 1350 | * Journal flag definitions |
---|
.. | .. |
---|
1274 | 1358 | #define JBD2_ABORT_ON_SYNCDATA_ERR 0x040 /* Abort the journal on file |
---|
1275 | 1359 | * data write error in ordered |
---|
1276 | 1360 | * mode */ |
---|
1277 | | -#define JBD2_REC_ERR 0x080 /* The errno in the sb has been recorded */ |
---|
| 1361 | +#define JBD2_FAST_COMMIT_ONGOING 0x100 /* Fast commit is ongoing */ |
---|
| 1362 | +#define JBD2_FULL_COMMIT_ONGOING 0x200 /* Full commit is ongoing */ |
---|
1278 | 1363 | |
---|
1279 | 1364 | /* |
---|
1280 | 1365 | * Function declarations for the journaling transaction and buffer |
---|
.. | .. |
---|
1283 | 1368 | |
---|
1284 | 1369 | /* Filing buffers */ |
---|
1285 | 1370 | extern void jbd2_journal_unfile_buffer(journal_t *, struct journal_head *); |
---|
1286 | | -extern void __jbd2_journal_refile_buffer(struct journal_head *); |
---|
| 1371 | +extern bool __jbd2_journal_refile_buffer(struct journal_head *); |
---|
1287 | 1372 | extern void jbd2_journal_refile_buffer(journal_t *, struct journal_head *); |
---|
1288 | 1373 | extern void __jbd2_journal_file_buffer(struct journal_head *, transaction_t *, int); |
---|
1289 | 1374 | extern void __journal_free_buffer(struct journal_head *bh); |
---|
.. | .. |
---|
1384 | 1469 | |
---|
1385 | 1470 | extern handle_t *jbd2_journal_start(journal_t *, int nblocks); |
---|
1386 | 1471 | extern handle_t *jbd2__journal_start(journal_t *, int blocks, int rsv_blocks, |
---|
1387 | | - gfp_t gfp_mask, unsigned int type, |
---|
1388 | | - unsigned int line_no); |
---|
| 1472 | + int revoke_records, gfp_t gfp_mask, |
---|
| 1473 | + unsigned int type, unsigned int line_no); |
---|
1389 | 1474 | extern int jbd2_journal_restart(handle_t *, int nblocks); |
---|
1390 | | -extern int jbd2__journal_restart(handle_t *, int nblocks, gfp_t gfp_mask); |
---|
| 1475 | +extern int jbd2__journal_restart(handle_t *, int nblocks, |
---|
| 1476 | + int revoke_records, gfp_t gfp_mask); |
---|
1391 | 1477 | extern int jbd2_journal_start_reserved(handle_t *handle, |
---|
1392 | 1478 | unsigned int type, unsigned int line_no); |
---|
1393 | 1479 | extern void jbd2_journal_free_reserved(handle_t *handle); |
---|
1394 | | -extern int jbd2_journal_extend (handle_t *, int nblocks); |
---|
| 1480 | +extern int jbd2_journal_extend(handle_t *handle, int nblocks, |
---|
| 1481 | + int revoke_records); |
---|
1395 | 1482 | extern int jbd2_journal_get_write_access(handle_t *, struct buffer_head *); |
---|
1396 | 1483 | extern int jbd2_journal_get_create_access (handle_t *, struct buffer_head *); |
---|
1397 | 1484 | extern int jbd2_journal_get_undo_access(handle_t *, struct buffer_head *); |
---|
.. | .. |
---|
1399 | 1486 | struct jbd2_buffer_trigger_type *type); |
---|
1400 | 1487 | extern int jbd2_journal_dirty_metadata (handle_t *, struct buffer_head *); |
---|
1401 | 1488 | extern int jbd2_journal_forget (handle_t *, struct buffer_head *); |
---|
1402 | | -extern void journal_sync_buffer (struct buffer_head *); |
---|
1403 | 1489 | extern int jbd2_journal_invalidatepage(journal_t *, |
---|
1404 | 1490 | struct page *, unsigned int, unsigned int); |
---|
1405 | | -extern int jbd2_journal_try_to_free_buffers(journal_t *, struct page *, gfp_t); |
---|
| 1491 | +extern int jbd2_journal_try_to_free_buffers(journal_t *journal, struct page *page); |
---|
1406 | 1492 | extern int jbd2_journal_stop(handle_t *); |
---|
1407 | 1493 | extern int jbd2_journal_flush (journal_t *); |
---|
1408 | 1494 | extern void jbd2_journal_lock_updates (journal_t *); |
---|
.. | .. |
---|
1429 | 1515 | extern void jbd2_journal_update_sb_errno(journal_t *); |
---|
1430 | 1516 | extern int jbd2_journal_update_sb_log_tail (journal_t *, tid_t, |
---|
1431 | 1517 | unsigned long, int); |
---|
1432 | | -extern void __jbd2_journal_abort_hard (journal_t *); |
---|
1433 | 1518 | extern void jbd2_journal_abort (journal_t *, int); |
---|
1434 | 1519 | extern int jbd2_journal_errno (journal_t *); |
---|
1435 | 1520 | extern void jbd2_journal_ack_err (journal_t *); |
---|
.. | .. |
---|
1437 | 1522 | extern int jbd2_journal_bmap(journal_t *, unsigned long, unsigned long long *); |
---|
1438 | 1523 | extern int jbd2_journal_force_commit(journal_t *); |
---|
1439 | 1524 | extern int jbd2_journal_force_commit_nested(journal_t *); |
---|
1440 | | -extern int jbd2_journal_inode_add_write(handle_t *handle, struct jbd2_inode *inode); |
---|
1441 | | -extern int jbd2_journal_inode_add_wait(handle_t *handle, struct jbd2_inode *inode); |
---|
1442 | 1525 | extern int jbd2_journal_inode_ranged_write(handle_t *handle, |
---|
1443 | 1526 | struct jbd2_inode *inode, loff_t start_byte, |
---|
1444 | 1527 | loff_t length); |
---|
1445 | 1528 | extern int jbd2_journal_inode_ranged_wait(handle_t *handle, |
---|
1446 | 1529 | struct jbd2_inode *inode, loff_t start_byte, |
---|
1447 | 1530 | loff_t length); |
---|
| 1531 | +extern int jbd2_journal_submit_inode_data_buffers( |
---|
| 1532 | + struct jbd2_inode *jinode); |
---|
| 1533 | +extern int jbd2_journal_finish_inode_data_buffers( |
---|
| 1534 | + struct jbd2_inode *jinode); |
---|
1448 | 1535 | extern int jbd2_journal_begin_ordered_truncate(journal_t *journal, |
---|
1449 | 1536 | struct jbd2_inode *inode, loff_t new_size); |
---|
1450 | 1537 | extern void jbd2_journal_init_jbd_inode(struct jbd2_inode *jinode, struct inode *inode); |
---|
.. | .. |
---|
1529 | 1616 | extern void __jbd2_journal_drop_transaction(journal_t *, transaction_t *); |
---|
1530 | 1617 | extern int jbd2_cleanup_journal_tail(journal_t *); |
---|
1531 | 1618 | |
---|
| 1619 | +/* Fast commit related APIs */ |
---|
| 1620 | +int jbd2_fc_begin_commit(journal_t *journal, tid_t tid); |
---|
| 1621 | +int jbd2_fc_end_commit(journal_t *journal); |
---|
| 1622 | +int jbd2_fc_end_commit_fallback(journal_t *journal); |
---|
| 1623 | +int jbd2_fc_get_buf(journal_t *journal, struct buffer_head **bh_out); |
---|
| 1624 | +int jbd2_submit_inode_data(struct jbd2_inode *jinode); |
---|
| 1625 | +int jbd2_wait_inode_data(journal_t *journal, struct jbd2_inode *jinode); |
---|
| 1626 | +int jbd2_fc_wait_bufs(journal_t *journal, int num_blks); |
---|
| 1627 | +int jbd2_fc_release_bufs(journal_t *journal); |
---|
| 1628 | + |
---|
| 1629 | +static inline int jbd2_journal_get_max_txn_bufs(journal_t *journal) |
---|
| 1630 | +{ |
---|
| 1631 | + return (journal->j_total_len - journal->j_fc_wbufsize) / 4; |
---|
| 1632 | +} |
---|
| 1633 | + |
---|
1532 | 1634 | /* |
---|
1533 | 1635 | * is_journal_abort |
---|
1534 | 1636 | * |
---|
.. | .. |
---|
1590 | 1692 | } |
---|
1591 | 1693 | |
---|
1592 | 1694 | /* |
---|
1593 | | - * We reserve t_outstanding_credits >> JBD2_CONTROL_BLOCKS_SHIFT for |
---|
1594 | | - * transaction control blocks. |
---|
1595 | | - */ |
---|
1596 | | -#define JBD2_CONTROL_BLOCKS_SHIFT 5 |
---|
1597 | | - |
---|
1598 | | -/* |
---|
1599 | | - * Return the minimum number of blocks which must be free in the journal |
---|
1600 | | - * before a new transaction may be started. Must be called under j_state_lock. |
---|
1601 | | - */ |
---|
1602 | | -static inline int jbd2_space_needed(journal_t *journal) |
---|
1603 | | -{ |
---|
1604 | | - int nblocks = journal->j_max_transaction_buffers; |
---|
1605 | | - return nblocks + (nblocks >> JBD2_CONTROL_BLOCKS_SHIFT); |
---|
1606 | | -} |
---|
1607 | | - |
---|
1608 | | -/* |
---|
1609 | 1695 | * Return number of free blocks in the log. Must be called under j_state_lock. |
---|
1610 | 1696 | */ |
---|
1611 | 1697 | static inline unsigned long jbd2_log_space_left(journal_t *journal) |
---|
.. | .. |
---|
1614 | 1700 | long free = journal->j_free - 32; |
---|
1615 | 1701 | |
---|
1616 | 1702 | if (journal->j_committing_transaction) { |
---|
1617 | | - unsigned long committing = atomic_read(&journal-> |
---|
1618 | | - j_committing_transaction->t_outstanding_credits); |
---|
1619 | | - |
---|
1620 | | - /* Transaction + control blocks */ |
---|
1621 | | - free -= committing + (committing >> JBD2_CONTROL_BLOCKS_SHIFT); |
---|
| 1703 | + free -= atomic_read(&journal-> |
---|
| 1704 | + j_committing_transaction->t_outstanding_credits); |
---|
1622 | 1705 | } |
---|
1623 | 1706 | return max_t(long, free, 0); |
---|
1624 | 1707 | } |
---|
.. | .. |
---|
1653 | 1736 | JBD_MAX_CHECKSUM_SIZE); |
---|
1654 | 1737 | |
---|
1655 | 1738 | desc.shash.tfm = journal->j_chksum_driver; |
---|
1656 | | - desc.shash.flags = 0; |
---|
1657 | 1739 | *(u32 *)desc.ctx = crc; |
---|
1658 | 1740 | |
---|
1659 | 1741 | err = crypto_shash_update(&desc.shash, address, length); |
---|
.. | .. |
---|
1675 | 1757 | return tid; |
---|
1676 | 1758 | } |
---|
1677 | 1759 | |
---|
| 1760 | +static inline int jbd2_handle_buffer_credits(handle_t *handle) |
---|
| 1761 | +{ |
---|
| 1762 | + journal_t *journal; |
---|
| 1763 | + |
---|
| 1764 | + if (!handle->h_reserved) |
---|
| 1765 | + journal = handle->h_transaction->t_journal; |
---|
| 1766 | + else |
---|
| 1767 | + journal = handle->h_journal; |
---|
| 1768 | + |
---|
| 1769 | + return handle->h_total_credits - |
---|
| 1770 | + DIV_ROUND_UP(handle->h_revoke_credits_requested, |
---|
| 1771 | + journal->j_revoke_records_per_block); |
---|
| 1772 | +} |
---|
| 1773 | + |
---|
1678 | 1774 | #ifdef __KERNEL__ |
---|
1679 | 1775 | |
---|
1680 | 1776 | #define buffer_trace_init(bh) do {} while (0) |
---|