aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/jbd2.h
diff options
context:
space:
mode:
authorJan Kara <jack@suse.cz>2013-06-04 12:35:11 -0400
committerTheodore Ts'o <tytso@mit.edu>2013-06-04 12:35:11 -0400
commit8f7d89f36829b9061a14f9040cda1372f264c4fe (patch)
tree2864747255fb15044c376519c0cb10bb223e9361 /include/linux/jbd2.h
parentf29fad72105287e6899d9128a9d494514f220e77 (diff)
jbd2: transaction reservation support
In some cases we cannot start a transaction because of locking constraints and passing started transaction into those places is not handy either because we could block transaction commit for too long. Transaction reservation is designed to solve these issues. It reserves a handle with given number of credits in the journal and the handle can be later attached to the running transaction without blocking on commit or checkpointing. Reserved handles do not block transaction commit in any way, they only reduce maximum size of the running transaction (because we have to always be prepared to accomodate request for attaching reserved handle). Signed-off-by: Jan Kara <jack@suse.cz> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'include/linux/jbd2.h')
-rw-r--r--include/linux/jbd2.h28
1 files changed, 24 insertions, 4 deletions
diff --git a/include/linux/jbd2.h b/include/linux/jbd2.h
index 8028dd581cb0..fb91c8debe6a 100644
--- a/include/linux/jbd2.h
+++ b/include/linux/jbd2.h
@@ -410,8 +410,15 @@ struct jbd2_revoke_table_s;
410 410
411struct jbd2_journal_handle 411struct jbd2_journal_handle
412{ 412{
413 /* Which compound transaction is this update a part of? */ 413 union {
414 transaction_t *h_transaction; 414 /* Which compound transaction is this update a part of? */
415 transaction_t *h_transaction;
416 /* Which journal handle belongs to - used iff h_reserved set */
417 journal_t *h_journal;
418 };
419
420 /* Handle reserved for finishing the logical operation */
421 handle_t *h_rsv_handle;
415 422
416 /* Number of remaining buffers we are allowed to dirty: */ 423 /* Number of remaining buffers we are allowed to dirty: */
417 int h_buffer_credits; 424 int h_buffer_credits;
@@ -426,6 +433,7 @@ struct jbd2_journal_handle
426 /* Flags [no locking] */ 433 /* Flags [no locking] */
427 unsigned int h_sync: 1; /* sync-on-close */ 434 unsigned int h_sync: 1; /* sync-on-close */
428 unsigned int h_jdata: 1; /* force data journaling */ 435 unsigned int h_jdata: 1; /* force data journaling */
436 unsigned int h_reserved: 1; /* handle with reserved credits */
429 unsigned int h_aborted: 1; /* fatal error on handle */ 437 unsigned int h_aborted: 1; /* fatal error on handle */
430 unsigned int h_type: 8; /* for handle statistics */ 438 unsigned int h_type: 8; /* for handle statistics */
431 unsigned int h_line_no: 16; /* for handle statistics */ 439 unsigned int h_line_no: 16; /* for handle statistics */
@@ -690,6 +698,7 @@ jbd2_time_diff(unsigned long start, unsigned long end)
690 * @j_wait_done_commit: Wait queue for waiting for commit to complete 698 * @j_wait_done_commit: Wait queue for waiting for commit to complete
691 * @j_wait_commit: Wait queue to trigger commit 699 * @j_wait_commit: Wait queue to trigger commit
692 * @j_wait_updates: Wait queue to wait for updates to complete 700 * @j_wait_updates: Wait queue to wait for updates to complete
701 * @j_wait_reserved: Wait queue to wait for reserved buffer credits to drop
693 * @j_checkpoint_mutex: Mutex for locking against concurrent checkpoints 702 * @j_checkpoint_mutex: Mutex for locking against concurrent checkpoints
694 * @j_head: Journal head - identifies the first unused block in the journal 703 * @j_head: Journal head - identifies the first unused block in the journal
695 * @j_tail: Journal tail - identifies the oldest still-used block in the 704 * @j_tail: Journal tail - identifies the oldest still-used block in the
@@ -703,6 +712,7 @@ jbd2_time_diff(unsigned long start, unsigned long end)
703 * journal 712 * journal
704 * @j_fs_dev: Device which holds the client fs. For internal journal this will 713 * @j_fs_dev: Device which holds the client fs. For internal journal this will
705 * be equal to j_dev 714 * be equal to j_dev
715 * @j_reserved_credits: Number of buffers reserved from the running transaction
706 * @j_maxlen: Total maximum capacity of the journal region on disk. 716 * @j_maxlen: Total maximum capacity of the journal region on disk.
707 * @j_list_lock: Protects the buffer lists and internal buffer state. 717 * @j_list_lock: Protects the buffer lists and internal buffer state.
708 * @j_inode: Optional inode where we store the journal. If present, all journal 718 * @j_inode: Optional inode where we store the journal. If present, all journal
@@ -801,6 +811,9 @@ struct journal_s
801 /* Wait queue to wait for updates to complete */ 811 /* Wait queue to wait for updates to complete */
802 wait_queue_head_t j_wait_updates; 812 wait_queue_head_t j_wait_updates;
803 813
814 /* Wait queue to wait for reserved buffer credits to drop */
815 wait_queue_head_t j_wait_reserved;
816
804 /* Semaphore for locking against concurrent checkpoints */ 817 /* Semaphore for locking against concurrent checkpoints */
805 struct mutex j_checkpoint_mutex; 818 struct mutex j_checkpoint_mutex;
806 819
@@ -855,6 +868,9 @@ struct journal_s
855 /* Total maximum capacity of the journal region on disk. */ 868 /* Total maximum capacity of the journal region on disk. */
856 unsigned int j_maxlen; 869 unsigned int j_maxlen;
857 870
871 /* Number of buffers reserved from the running transaction */
872 atomic_t j_reserved_credits;
873
858 /* 874 /*
859 * Protects the buffer lists and internal buffer state. 875 * Protects the buffer lists and internal buffer state.
860 */ 876 */
@@ -1091,10 +1107,14 @@ static inline handle_t *journal_current_handle(void)
1091 */ 1107 */
1092 1108
1093extern handle_t *jbd2_journal_start(journal_t *, int nblocks); 1109extern handle_t *jbd2_journal_start(journal_t *, int nblocks);
1094extern handle_t *jbd2__journal_start(journal_t *, int nblocks, gfp_t gfp_mask, 1110extern handle_t *jbd2__journal_start(journal_t *, int blocks, int rsv_blocks,
1095 unsigned int type, unsigned int line_no); 1111 gfp_t gfp_mask, unsigned int type,
1112 unsigned int line_no);
1096extern int jbd2_journal_restart(handle_t *, int nblocks); 1113extern int jbd2_journal_restart(handle_t *, int nblocks);
1097extern int jbd2__journal_restart(handle_t *, int nblocks, gfp_t gfp_mask); 1114extern int jbd2__journal_restart(handle_t *, int nblocks, gfp_t gfp_mask);
1115extern int jbd2_journal_start_reserved(handle_t *handle,
1116 unsigned int type, unsigned int line_no);
1117extern void jbd2_journal_free_reserved(handle_t *handle);
1098extern int jbd2_journal_extend (handle_t *, int nblocks); 1118extern int jbd2_journal_extend (handle_t *, int nblocks);
1099extern int jbd2_journal_get_write_access(handle_t *, struct buffer_head *); 1119extern int jbd2_journal_get_write_access(handle_t *, struct buffer_head *);
1100extern int jbd2_journal_get_create_access (handle_t *, struct buffer_head *); 1120extern int jbd2_journal_get_create_access (handle_t *, struct buffer_head *);