History

Merge branch 'jk/jbd2-revoke-overflow'

Theodore Ts'o committed 7 years ago

Commit a6d40402 parents 0d0a60c 19014d621 files · +675 −478Browse files

Showing the changes to include/linux (1 of 21 files). Show all

Unified · Split

include/linux/jbd2.h+50−37
@@ -456,7 +456,9 @@ struct jbd2_revoke_table_s; · 455 unmodified lines
456456 * @h_transaction: Which compound transaction is this update a part of?
457457 * @h_journal: Which journal handle belongs to - used iff h_reserved set.
458458 * @h_rsv_handle: Handle reserved for finishing the logical operation.
459− * @h_buffer_credits: Number of remaining buffers we are allowed to dirty.
459+ * @h_total_credits: Number of remaining buffers we are allowed to add to
460+ journal. These are dirty buffers and revoke descriptor blocks.
461+ * @h_revoke_credits: Number of remaining revoke records available for handle
460462 * @h_ref: Reference count on this handle.
461463 * @h_err: Field for caller's use to track errors through large fs operations.
462464 * @h_sync: Flag for sync-on-close.
@@ -466,7 +468,8 @@ struct jbd2_revoke_table_s; · 3 unmodified lines
466468 * @h_type: For handle statistics.
467469 * @h_line_no: For handle statistics.
468470 * @h_start_jiffies: Handle Start time.
469− * @h_requested_credits: Holds @h_buffer_credits after handle is started.
471+ * @h_requested_credits: Holds @h_total_credits after handle is started.
472+ * @h_revoke_credits_requested: Holds @h_revoke_credits after handle is started.
470473 * @saved_alloc_context: Saved context while transaction is open.
471474 **/
472475
@@ -483,7 +486,9 @@ struct jbd2_journal_handle · 10 unmodified lines
483486 };
484487
485488 handle_t *h_rsv_handle;
486− int h_buffer_credits;
489+ int h_total_credits;
490+ int h_revoke_credits;
491+ int h_revoke_credits_requested;
487492 int h_ref;
488493 int h_err;
489494
@@ -660,11 +665,24 @@ struct transaction_s · 170 unmodified lines
660665 atomic_t t_updates;
661666
662667 /*
663− * Number of buffers reserved for use by all handles in this transaction
664− * handle but not yet modified. [none]
668+ * Number of blocks reserved for this transaction in the journal.
669+ * This is including all credits reserved when starting transaction
670+ * handles as well as all journal descriptor blocks needed for this
671+ * transaction. [none]
665672 */
666673 atomic_t t_outstanding_credits;
667674
675+ /*
676+ * Number of revoke records for this transaction added by already
677+ * stopped handles. [none]
678+ */
679+ atomic_t t_outstanding_revokes;
680+
681+ /*
682+ * How many handles used this transaction? [none]
683+ */
684+ atomic_t t_handle_count;
685+
668686 /*
669687 * Forward and backward links for the circular list of all transactions
670688 * awaiting checkpoint. [j_list_lock]
@@ -682,11 +700,6 @@ struct transaction_s · 11 unmodified lines
682700 */
683701 ktime_t t_start_time;
684702
685− /*
686− * How many handles used this transaction? [none]
687− */
688− atomic_t t_handle_count;
689−
690703 /*
691704 * This transaction is being forced and some process is
692705 * waiting for it to finish.
@@ -1003,6 +1016,13 @@ struct journal_s · 310 unmodified lines
10031016 */
10041017 int j_max_transaction_buffers;
10051018
1019+ /**
1020+ * @j_revoke_records_per_block:
1021+ *
1022+ * Number of revoke records that fit in one descriptor block.
1023+ */
1024+ int j_revoke_records_per_block;
1025+
10061026 /**
10071027 * @j_commit_interval:
10081028 *
@@ -1337,14 +1357,16 @@ static inline handle_t *journal_current_handle(void) · 328 unmodified lines
13371357
13381358 extern handle_t *jbd2_journal_start(journal_t *, int nblocks);
13391359 extern handle_t *jbd2__journal_start(journal_t *, int blocks, int rsv_blocks,
1340− gfp_t gfp_mask, unsigned int type,
1341− unsigned int line_no);
1360+ int revoke_records, gfp_t gfp_mask,
1361+ unsigned int type, unsigned int line_no);
13421362 extern int jbd2_journal_restart(handle_t *, int nblocks);
1343−extern int jbd2__journal_restart(handle_t *, int nblocks, gfp_t gfp_mask);
1363+extern int jbd2__journal_restart(handle_t *, int nblocks,
1364+ int revoke_records, gfp_t gfp_mask);
13441365 extern int jbd2_journal_start_reserved(handle_t *handle,
13451366 unsigned int type, unsigned int line_no);
13461367 extern void jbd2_journal_free_reserved(handle_t *handle);
1347−extern int jbd2_journal_extend (handle_t *, int nblocks);
1368+extern int jbd2_journal_extend(handle_t *handle, int nblocks,
1369+ int revoke_records);
13481370 extern int jbd2_journal_get_write_access(handle_t *, struct buffer_head *);
13491371 extern int jbd2_journal_get_create_access (handle_t *, struct buffer_head *);
13501372 extern int jbd2_journal_get_undo_access(handle_t *, struct buffer_head *);
@@ -1539,38 +1561,19 @@ static inline int jbd2_journal_has_csum_v2or3(journal_t *journal) · 188 unmodified lines
15391561 return journal->j_chksum_driver != NULL;
15401562 }
15411563
1542−/*
1543− * We reserve t_outstanding_credits >> JBD2_CONTROL_BLOCKS_SHIFT for
1544− * transaction control blocks.
1545− */
1546−#define JBD2_CONTROL_BLOCKS_SHIFT 5
1547−
1548−/*
1549− * Return the minimum number of blocks which must be free in the journal
1550− * before a new transaction may be started. Must be called under j_state_lock.
1551− */
1552−static inline int jbd2_space_needed(journal_t *journal)
1553−{
1554− int nblocks = journal->j_max_transaction_buffers;
1555− return nblocks + (nblocks >> JBD2_CONTROL_BLOCKS_SHIFT);
1556−}
1557−
15581564 /*
15591565 * Return number of free blocks in the log. Must be called under j_state_lock.
15601566 */
15611567 static inline unsigned long jbd2_log_space_left(journal_t *journal)
15621568 {
15631569 /* Allow for rounding errors */
1564− unsigned long free = journal->j_free - 32;
1570+ long free = journal->j_free - 32;
15651571
15661572 if (journal->j_committing_transaction) {
1567− unsigned long committing = atomic_read(&journal->
1568− j_committing_transaction->t_outstanding_credits);
1569−
1570− /* Transaction + control blocks */
1571− free -= committing + (committing >> JBD2_CONTROL_BLOCKS_SHIFT);
1573+ free -= atomic_read(&journal->
1574+ j_committing_transaction->t_outstanding_credits);
15721575 }
1573− return free;
1576+ return max_t(long, free, 0);
15741577 }
15751578
15761579 /*
@@ -1624,6 +1627,16 @@ static inline tid_t jbd2_get_latest_transaction(journal_t *journal) · 47 unmodified lines
16241627 return tid;
16251628 }
16261629
1630+
1631+static inline int jbd2_handle_buffer_credits(handle_t *handle)
1632+{
1633+ journal_t *journal = handle->h_transaction->t_journal;
1634+
1635+ return handle->h_total_credits -
1636+ DIV_ROUND_UP(handle->h_revoke_credits_requested,
1637+ journal->j_revoke_records_per_block);
1638+}
1639+
16271640 #ifdef __KERNEL__
16281641
16291642 #define buffer_trace_init(bh) do {} while (0)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t