mirror of
https://github.com/Fishwaldo/linux-bl808.git
synced 2025-06-17 20:25:19 +00:00
ext4: fix inline data updates with checksums enabled
The inline data code was updating the raw inode directly; this is problematic since if metadata checksums are enabled, ext4_mark_inode_dirty() must be called to update the inode's checksum. In addition, the jbd2 layer requires that get_write_access() be called before the metadata buffer is modified. Fix both of these problems. https://bugzilla.kernel.org/show_bug.cgi?id=200443 Signed-off-by: Theodore Ts'o <tytso@mit.edu> Cc: stable@vger.kernel.org
This commit is contained in:
parent
2dca60d98e
commit
362eca70b5
2 changed files with 18 additions and 17 deletions
|
@ -1389,9 +1389,10 @@ static int ext4_write_end(struct file *file,
|
|||
loff_t old_size = inode->i_size;
|
||||
int ret = 0, ret2;
|
||||
int i_size_changed = 0;
|
||||
int inline_data = ext4_has_inline_data(inode);
|
||||
|
||||
trace_ext4_write_end(inode, pos, len, copied);
|
||||
if (ext4_has_inline_data(inode)) {
|
||||
if (inline_data) {
|
||||
ret = ext4_write_inline_data_end(inode, pos, len,
|
||||
copied, page);
|
||||
if (ret < 0) {
|
||||
|
@ -1419,7 +1420,7 @@ static int ext4_write_end(struct file *file,
|
|||
* ordering of page lock and transaction start for journaling
|
||||
* filesystems.
|
||||
*/
|
||||
if (i_size_changed)
|
||||
if (i_size_changed || inline_data)
|
||||
ext4_mark_inode_dirty(handle, inode);
|
||||
|
||||
if (pos + len > inode->i_size && ext4_can_truncate(inode))
|
||||
|
@ -1493,6 +1494,7 @@ static int ext4_journalled_write_end(struct file *file,
|
|||
int partial = 0;
|
||||
unsigned from, to;
|
||||
int size_changed = 0;
|
||||
int inline_data = ext4_has_inline_data(inode);
|
||||
|
||||
trace_ext4_journalled_write_end(inode, pos, len, copied);
|
||||
from = pos & (PAGE_SIZE - 1);
|
||||
|
@ -1500,7 +1502,7 @@ static int ext4_journalled_write_end(struct file *file,
|
|||
|
||||
BUG_ON(!ext4_handle_valid(handle));
|
||||
|
||||
if (ext4_has_inline_data(inode)) {
|
||||
if (inline_data) {
|
||||
ret = ext4_write_inline_data_end(inode, pos, len,
|
||||
copied, page);
|
||||
if (ret < 0) {
|
||||
|
@ -1531,7 +1533,7 @@ static int ext4_journalled_write_end(struct file *file,
|
|||
if (old_size < pos)
|
||||
pagecache_isize_extended(inode, old_size, pos);
|
||||
|
||||
if (size_changed) {
|
||||
if (size_changed || inline_data) {
|
||||
ret2 = ext4_mark_inode_dirty(handle, inode);
|
||||
if (!ret)
|
||||
ret = ret2;
|
||||
|
@ -2028,11 +2030,7 @@ static int __ext4_journalled_writepage(struct page *page,
|
|||
}
|
||||
|
||||
if (inline_data) {
|
||||
BUFFER_TRACE(inode_bh, "get write access");
|
||||
ret = ext4_journal_get_write_access(handle, inode_bh);
|
||||
|
||||
err = ext4_handle_dirty_metadata(handle, inode, inode_bh);
|
||||
|
||||
ret = ext4_mark_inode_dirty(handle, inode);
|
||||
} else {
|
||||
ret = ext4_walk_page_buffers(handle, page_bufs, 0, len, NULL,
|
||||
do_journal_get_write_access);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue