diff options
Diffstat (limited to 'include/linux/jbd2.h')
-rw-r--r-- | include/linux/jbd2.h | 135 |
1 files changed, 116 insertions, 19 deletions
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h index 06ef11457051..2cbf6fdb1799 100644 --- a/include/linux/jbd2.h +++ b/include/linux/jbd2.h | |||
@@ -149,6 +149,28 @@ typedef struct journal_header_s | |||
149 | __be32 h_sequence; | 149 | __be32 h_sequence; |
150 | } journal_header_t; | 150 | } journal_header_t; |
151 | 151 | ||
152 | /* | ||
153 | * Checksum types. | ||
154 | */ | ||
155 | #define JBD2_CRC32_CHKSUM 1 | ||
156 | #define JBD2_MD5_CHKSUM 2 | ||
157 | #define JBD2_SHA1_CHKSUM 3 | ||
158 | |||
159 | #define JBD2_CRC32_CHKSUM_SIZE 4 | ||
160 | |||
161 | #define JBD2_CHECKSUM_BYTES (32 / sizeof(u32)) | ||
162 | /* | ||
163 | * Commit block header for storing transactional checksums: | ||
164 | */ | ||
165 | struct commit_header { | ||
166 | __be32 h_magic; | ||
167 | __be32 h_blocktype; | ||
168 | __be32 h_sequence; | ||
169 | unsigned char h_chksum_type; | ||
170 | unsigned char h_chksum_size; | ||
171 | unsigned char h_padding[2]; | ||
172 | __be32 h_chksum[JBD2_CHECKSUM_BYTES]; | ||
173 | }; | ||
152 | 174 | ||
153 | /* | 175 | /* |
154 | * The block tag: used to describe a single buffer in the journal. | 176 | * The block tag: used to describe a single buffer in the journal. |
@@ -242,31 +264,25 @@ typedef struct journal_superblock_s | |||
242 | ((j)->j_format_version >= 2 && \ | 264 | ((j)->j_format_version >= 2 && \ |
243 | ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask)))) | 265 | ((j)->j_superblock->s_feature_incompat & cpu_to_be32((mask)))) |
244 | 266 | ||
245 | #define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001 | 267 | #define JBD2_FEATURE_COMPAT_CHECKSUM 0x00000001 |
246 | #define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002 | 268 | |
269 | #define JBD2_FEATURE_INCOMPAT_REVOKE 0x00000001 | ||
270 | #define JBD2_FEATURE_INCOMPAT_64BIT 0x00000002 | ||
271 | #define JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT 0x00000004 | ||
247 | 272 | ||
248 | /* Features known to this kernel version: */ | 273 | /* Features known to this kernel version: */ |
249 | #define JBD2_KNOWN_COMPAT_FEATURES 0 | 274 | #define JBD2_KNOWN_COMPAT_FEATURES JBD2_FEATURE_COMPAT_CHECKSUM |
250 | #define JBD2_KNOWN_ROCOMPAT_FEATURES 0 | 275 | #define JBD2_KNOWN_ROCOMPAT_FEATURES 0 |
251 | #define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \ | 276 | #define JBD2_KNOWN_INCOMPAT_FEATURES (JBD2_FEATURE_INCOMPAT_REVOKE | \ |
252 | JBD2_FEATURE_INCOMPAT_64BIT) | 277 | JBD2_FEATURE_INCOMPAT_64BIT | \ |
278 | JBD2_FEATURE_INCOMPAT_ASYNC_COMMIT) | ||
253 | 279 | ||
254 | #ifdef __KERNEL__ | 280 | #ifdef __KERNEL__ |
255 | 281 | ||
256 | #include <linux/fs.h> | 282 | #include <linux/fs.h> |
257 | #include <linux/sched.h> | 283 | #include <linux/sched.h> |
258 | 284 | ||
259 | #define JBD2_ASSERTIONS | 285 | #define J_ASSERT(assert) BUG_ON(!(assert)) |
260 | #ifdef JBD2_ASSERTIONS | ||
261 | #define J_ASSERT(assert) \ | ||
262 | do { \ | ||
263 | if (!(assert)) { \ | ||
264 | printk (KERN_EMERG \ | ||
265 | "Assertion failure in %s() at %s:%d: \"%s\"\n", \ | ||
266 | __FUNCTION__, __FILE__, __LINE__, # assert); \ | ||
267 | BUG(); \ | ||
268 | } \ | ||
269 | } while (0) | ||
270 | 286 | ||
271 | #if defined(CONFIG_BUFFER_DEBUG) | 287 | #if defined(CONFIG_BUFFER_DEBUG) |
272 | void buffer_assertion_failure(struct buffer_head *bh); | 288 | void buffer_assertion_failure(struct buffer_head *bh); |
@@ -282,10 +298,6 @@ void buffer_assertion_failure(struct buffer_head *bh); | |||
282 | #define J_ASSERT_JH(jh, expr) J_ASSERT(expr) | 298 | #define J_ASSERT_JH(jh, expr) J_ASSERT(expr) |
283 | #endif | 299 | #endif |
284 | 300 | ||
285 | #else | ||
286 | #define J_ASSERT(assert) do { } while (0) | ||
287 | #endif /* JBD2_ASSERTIONS */ | ||
288 | |||
289 | #if defined(JBD2_PARANOID_IOFAIL) | 301 | #if defined(JBD2_PARANOID_IOFAIL) |
290 | #define J_EXPECT(expr, why...) J_ASSERT(expr) | 302 | #define J_EXPECT(expr, why...) J_ASSERT(expr) |
291 | #define J_EXPECT_BH(bh, expr, why...) J_ASSERT_BH(bh, expr) | 303 | #define J_EXPECT_BH(bh, expr, why...) J_ASSERT_BH(bh, expr) |
@@ -406,9 +418,23 @@ struct handle_s | |||
406 | unsigned int h_sync: 1; /* sync-on-close */ | 418 | unsigned int h_sync: 1; /* sync-on-close */ |
407 | unsigned int h_jdata: 1; /* force data journaling */ | 419 | unsigned int h_jdata: 1; /* force data journaling */ |
408 | unsigned int h_aborted: 1; /* fatal error on handle */ | 420 | unsigned int h_aborted: 1; /* fatal error on handle */ |
421 | |||
422 | #ifdef CONFIG_DEBUG_LOCK_ALLOC | ||
423 | struct lockdep_map h_lockdep_map; | ||
424 | #endif | ||
409 | }; | 425 | }; |
410 | 426 | ||
411 | 427 | ||
428 | /* | ||
429 | * Some stats for checkpoint phase | ||
430 | */ | ||
431 | struct transaction_chp_stats_s { | ||
432 | unsigned long cs_chp_time; | ||
433 | unsigned long cs_forced_to_close; | ||
434 | unsigned long cs_written; | ||
435 | unsigned long cs_dropped; | ||
436 | }; | ||
437 | |||
412 | /* The transaction_t type is the guts of the journaling mechanism. It | 438 | /* The transaction_t type is the guts of the journaling mechanism. It |
413 | * tracks a compound transaction through its various states: | 439 | * tracks a compound transaction through its various states: |
414 | * | 440 | * |
@@ -456,6 +482,8 @@ struct transaction_s | |||
456 | /* | 482 | /* |
457 | * Transaction's current state | 483 | * Transaction's current state |
458 | * [no locking - only kjournald2 alters this] | 484 | * [no locking - only kjournald2 alters this] |
485 | * [j_list_lock] guards transition of a transaction into T_FINISHED | ||
486 | * state and subsequent call of __jbd2_journal_drop_transaction() | ||
459 | * FIXME: needs barriers | 487 | * FIXME: needs barriers |
460 | * KLUDGE: [use j_state_lock] | 488 | * KLUDGE: [use j_state_lock] |
461 | */ | 489 | */ |
@@ -544,6 +572,21 @@ struct transaction_s | |||
544 | spinlock_t t_handle_lock; | 572 | spinlock_t t_handle_lock; |
545 | 573 | ||
546 | /* | 574 | /* |
575 | * Longest time some handle had to wait for running transaction | ||
576 | */ | ||
577 | unsigned long t_max_wait; | ||
578 | |||
579 | /* | ||
580 | * When transaction started | ||
581 | */ | ||
582 | unsigned long t_start; | ||
583 | |||
584 | /* | ||
585 | * Checkpointing stats [j_checkpoint_sem] | ||
586 | */ | ||
587 | struct transaction_chp_stats_s t_chp_stats; | ||
588 | |||
589 | /* | ||
547 | * Number of outstanding updates running on this transaction | 590 | * Number of outstanding updates running on this transaction |
548 | * [t_handle_lock] | 591 | * [t_handle_lock] |
549 | */ | 592 | */ |
@@ -574,6 +617,39 @@ struct transaction_s | |||
574 | 617 | ||
575 | }; | 618 | }; |
576 | 619 | ||
620 | struct transaction_run_stats_s { | ||
621 | unsigned long rs_wait; | ||
622 | unsigned long rs_running; | ||
623 | unsigned long rs_locked; | ||
624 | unsigned long rs_flushing; | ||
625 | unsigned long rs_logging; | ||
626 | |||
627 | unsigned long rs_handle_count; | ||
628 | unsigned long rs_blocks; | ||
629 | unsigned long rs_blocks_logged; | ||
630 | }; | ||
631 | |||
632 | struct transaction_stats_s { | ||
633 | int ts_type; | ||
634 | unsigned long ts_tid; | ||
635 | union { | ||
636 | struct transaction_run_stats_s run; | ||
637 | struct transaction_chp_stats_s chp; | ||
638 | } u; | ||
639 | }; | ||
640 | |||
641 | #define JBD2_STATS_RUN 1 | ||
642 | #define JBD2_STATS_CHECKPOINT 2 | ||
643 | |||
644 | static inline unsigned long | ||
645 | jbd2_time_diff(unsigned long start, unsigned long end) | ||
646 | { | ||
647 | if (end >= start) | ||
648 | return end - start; | ||
649 | |||
650 | return end + (MAX_JIFFY_OFFSET - start); | ||
651 | } | ||
652 | |||
577 | /** | 653 | /** |
578 | * struct journal_s - The journal_s type is the concrete type associated with | 654 | * struct journal_s - The journal_s type is the concrete type associated with |
579 | * journal_t. | 655 | * journal_t. |
@@ -635,6 +711,12 @@ struct transaction_s | |||
635 | * @j_wbufsize: maximum number of buffer_heads allowed in j_wbuf, the | 711 | * @j_wbufsize: maximum number of buffer_heads allowed in j_wbuf, the |
636 | * number that will fit in j_blocksize | 712 | * number that will fit in j_blocksize |
637 | * @j_last_sync_writer: most recent pid which did a synchronous write | 713 | * @j_last_sync_writer: most recent pid which did a synchronous write |
714 | * @j_history: Buffer storing the transactions statistics history | ||
715 | * @j_history_max: Maximum number of transactions in the statistics history | ||
716 | * @j_history_cur: Current number of transactions in the statistics history | ||
717 | * @j_history_lock: Protect the transactions statistics history | ||
718 | * @j_proc_entry: procfs entry for the jbd statistics directory | ||
719 | * @j_stats: Overall statistics | ||
638 | * @j_private: An opaque pointer to fs-private information. | 720 | * @j_private: An opaque pointer to fs-private information. |
639 | */ | 721 | */ |
640 | 722 | ||
@@ -827,6 +909,19 @@ struct journal_s | |||
827 | pid_t j_last_sync_writer; | 909 | pid_t j_last_sync_writer; |
828 | 910 | ||
829 | /* | 911 | /* |
912 | * Journal statistics | ||
913 | */ | ||
914 | struct transaction_stats_s *j_history; | ||
915 | int j_history_max; | ||
916 | int j_history_cur; | ||
917 | /* | ||
918 | * Protect the transactions statistics history | ||
919 | */ | ||
920 | spinlock_t j_history_lock; | ||
921 | struct proc_dir_entry *j_proc_entry; | ||
922 | struct transaction_stats_s j_stats; | ||
923 | |||
924 | /* | ||
830 | * An opaque pointer to fs-private information. ext3 puts its | 925 | * An opaque pointer to fs-private information. ext3 puts its |
831 | * superblock pointer here | 926 | * superblock pointer here |
832 | */ | 927 | */ |
@@ -932,6 +1027,8 @@ extern int jbd2_journal_check_available_features | |||
932 | (journal_t *, unsigned long, unsigned long, unsigned long); | 1027 | (journal_t *, unsigned long, unsigned long, unsigned long); |
933 | extern int jbd2_journal_set_features | 1028 | extern int jbd2_journal_set_features |
934 | (journal_t *, unsigned long, unsigned long, unsigned long); | 1029 | (journal_t *, unsigned long, unsigned long, unsigned long); |
1030 | extern void jbd2_journal_clear_features | ||
1031 | (journal_t *, unsigned long, unsigned long, unsigned long); | ||
935 | extern int jbd2_journal_create (journal_t *); | 1032 | extern int jbd2_journal_create (journal_t *); |
936 | extern int jbd2_journal_load (journal_t *journal); | 1033 | extern int jbd2_journal_load (journal_t *journal); |
937 | extern void jbd2_journal_destroy (journal_t *); | 1034 | extern void jbd2_journal_destroy (journal_t *); |