提交 489862d3 编写于 作者: J Jan Kara 提交者: Yang Yingliang

jbd2: Completely fill journal descriptor blocks

mainline inclusion
from mainline-5.5-rc1
commit b90bfdf581194a0fa5f6c26fef1e522f15f6212e
category: bugfix
bugzilla: 25031
CVE: NA
---------------------------

With 32-bit block numbers, we don't allocate the array for journal
buffer heads large enough for corresponding descriptor tags to fill the
descriptor block. Thus we end up writing out half-full descriptor blocks
to the journal unnecessarily growing the transaction. Fix the logic to
allocate the array large enough.
Signed-off-by: NJan Kara <jack@suse.cz>
Link: https://lore.kernel.org/r/20191105164437.32602-3-jack@suse.czSigned-off-by: NTheodore Ts'o <tytso@mit.edu>
Signed-off-by: Nzhangyi (F) <yi.zhang@huawei.com>
Reviewed-by: NYang Erkun <yangerkun@huawei.com>
Signed-off-by: NYang Yingliang <yangyingliang@huawei.com>
上级 84cbc05b
...@@ -1103,6 +1103,16 @@ static void jbd2_stats_proc_exit(journal_t *journal) ...@@ -1103,6 +1103,16 @@ static void jbd2_stats_proc_exit(journal_t *journal)
remove_proc_entry(journal->j_devname, proc_jbd2_stats); remove_proc_entry(journal->j_devname, proc_jbd2_stats);
} }
/* Minimum size of descriptor tag */
static int jbd2_min_tag_size(void)
{
/*
* Tag with 32-bit block numbers does not use last four bytes of the
* structure
*/
return sizeof(journal_block_tag_t) - 4;
}
/* /*
* Management for journal control blocks: functions to create and * Management for journal control blocks: functions to create and
* destroy journal_t structures, and to initialise and read existing * destroy journal_t structures, and to initialise and read existing
...@@ -1161,7 +1171,8 @@ static journal_t *journal_init_common(struct block_device *bdev, ...@@ -1161,7 +1171,8 @@ static journal_t *journal_init_common(struct block_device *bdev,
journal->j_fs_dev = fs_dev; journal->j_fs_dev = fs_dev;
journal->j_blk_offset = start; journal->j_blk_offset = start;
journal->j_maxlen = len; journal->j_maxlen = len;
n = journal->j_blocksize / sizeof(journal_block_tag_t); /* We need enough buffers to write out full descriptor block. */
n = journal->j_blocksize / jbd2_min_tag_size();
journal->j_wbufsize = n; journal->j_wbufsize = n;
journal->j_wbuf = kmalloc_array(n, sizeof(struct buffer_head *), journal->j_wbuf = kmalloc_array(n, sizeof(struct buffer_head *),
GFP_KERNEL); GFP_KERNEL);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册