History

jbd2: Fine tune estimate of necessary descriptor blocks

Currently we reserve j_max_transaction_buffers / 32 for transaction descriptor blocks. Now that revoke descriptors are accounted for separately this estimate is unnecessarily high and we can actually compute much tighter estimate. In the common case of 32k journal blocks and 4k blocksize this actually reduces the amount of reserved descriptor blocks from 256 to ~25 which allows us to fit more real data into a transaction.

Jan Kara committed 7 years ago

Commit 19014d61 parent 0094f981 file · +16 −5Browse files

Unified · Split

fs/jbd2/transaction.c+16−5
@@ -63,14 +63,25 @@ void jbd2_journal_free_transaction(transaction_t *transaction) · 62 unmodified lines
63}63}
64 64
65/*65/*
66 * We reserve t_outstanding_credits >> JBD2_CONTROL_BLOCKS_SHIFT for66 * Base amount of descriptor blocks we reserve for each transaction.
67 * transaction descriptor blocks.
68 */67 */
69#define JBD2_CONTROL_BLOCKS_SHIFT 5
70
71static int jbd2_descriptor_blocks_per_trans(journal_t *journal)68static int jbd2_descriptor_blocks_per_trans(journal_t *journal)
72{69{
73 return journal->j_max_transaction_buffers >> JBD2_CONTROL_BLOCKS_SHIFT;70 int tag_space = journal->j_blocksize - sizeof(journal_header_t);
71 int tags_per_block;
72
73 /* Subtract UUID */
74 tag_space -= 16;
75 if (jbd2_journal_has_csum_v2or3(journal))
76 tag_space -= sizeof(struct jbd2_journal_block_tail);
77 /* Commit code leaves a slack space of 16 bytes at the end of block */
78 tags_per_block = (tag_space - 16) / journal_tag_bytes(journal);
79 /*
80 * Revoke descriptors are accounted separately so we need to reserve
81 * space for commit block and normal transaction descriptor blocks.
82 */
83 return 1 + DIV_ROUND_UP(journal->j_max_transaction_buffers,
84 tags_per_block);
74}85}
75 86
76/*87/*

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