Skip to content

Commit 2152404

Browse files
committed
Merge tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4
Pull ext4 bug fixes from Ted Ts'o: "Fix a number of ext4 bugs" * tag 'ext4_for_linus_stable' of git://git.kernel.org/pub/scm/linux/kernel/git/tytso/ext4: ext4: fix special inode number checks in __ext4_iget() ext4: track writeback errors using the generic tracking infrastructure ext4: use ext4_write_inode() when fsyncing w/o a journal ext4: avoid kernel warning when writing the superblock to a dead device ext4: fix a potential fiemap/page fault deadlock w/ inline_data ext4: make sure enough credits are reserved for dioread_nolock writes
2 parents e2b745f + 191ce17 commit 2152404

File tree

4 files changed

+19
-10
lines changed

4 files changed

+19
-10
lines changed

fs/ext4/fsync.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -116,18 +116,23 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
116116
goto out;
117117
}
118118

119+
ret = file_write_and_wait_range(file, start, end);
120+
if (ret)
121+
return ret;
122+
119123
if (!journal) {
120-
ret = __generic_file_fsync(file, start, end, datasync);
124+
struct writeback_control wbc = {
125+
.sync_mode = WB_SYNC_ALL
126+
};
127+
128+
ret = ext4_write_inode(inode, &wbc);
121129
if (!ret)
122130
ret = ext4_sync_parent(inode);
123131
if (test_opt(inode->i_sb, BARRIER))
124132
goto issue_flush;
125133
goto out;
126134
}
127135

128-
ret = file_write_and_wait_range(file, start, end);
129-
if (ret)
130-
return ret;
131136
/*
132137
* data=writeback,ordered:
133138
* The caller's filemap_fdatawrite()/wait will sync the data.
@@ -159,6 +164,9 @@ int ext4_sync_file(struct file *file, loff_t start, loff_t end, int datasync)
159164
ret = err;
160165
}
161166
out:
167+
err = file_check_and_advance_wb_err(file);
168+
if (ret == 0)
169+
ret = err;
162170
trace_ext4_sync_file_exit(inode, ret);
163171
return ret;
164172
}

fs/ext4/inline.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1890,12 +1890,12 @@ int ext4_inline_data_fiemap(struct inode *inode,
18901890
physical += (char *)ext4_raw_inode(&iloc) - iloc.bh->b_data;
18911891
physical += offsetof(struct ext4_inode, i_block);
18921892

1893-
if (physical)
1894-
error = fiemap_fill_next_extent(fieinfo, start, physical,
1895-
inline_len, flags);
18961893
brelse(iloc.bh);
18971894
out:
18981895
up_read(&EXT4_I(inode)->xattr_sem);
1896+
if (physical)
1897+
error = fiemap_fill_next_extent(fieinfo, start, physical,
1898+
inline_len, flags);
18991899
return (error < 0 ? error : 0);
19001900
}
19011901

fs/ext4/inode.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2778,7 +2778,8 @@ static int ext4_writepages(struct address_space *mapping,
27782778
* We may need to convert up to one extent per block in
27792779
* the page and we may dirty the inode.
27802780
*/
2781-
rsv_blocks = 1 + (PAGE_SIZE >> inode->i_blkbits);
2781+
rsv_blocks = 1 + ext4_chunk_trans_blocks(inode,
2782+
PAGE_SIZE >> inode->i_blkbits);
27822783
}
27832784

27842785
/*
@@ -4833,7 +4834,7 @@ struct inode *__ext4_iget(struct super_block *sb, unsigned long ino,
48334834
gid_t i_gid;
48344835
projid_t i_projid;
48354836

4836-
if (((flags & EXT4_IGET_NORMAL) &&
4837+
if ((!(flags & EXT4_IGET_SPECIAL) &&
48374838
(ino < EXT4_FIRST_INO(sb) && ino != EXT4_ROOT_INO)) ||
48384839
(ino < EXT4_ROOT_INO) ||
48394840
(ino > le32_to_cpu(EXT4_SB(sb)->s_es->s_inodes_count))) {

fs/ext4/super.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4902,7 +4902,7 @@ static int ext4_commit_super(struct super_block *sb, int sync)
49024902
ext4_superblock_csum_set(sb);
49034903
if (sync)
49044904
lock_buffer(sbh);
4905-
if (buffer_write_io_error(sbh)) {
4905+
if (buffer_write_io_error(sbh) || !buffer_uptodate(sbh)) {
49064906
/*
49074907
* Oh, dear. A previous attempt to write the
49084908
* superblock failed. This could happen because the

0 commit comments

Comments
 (0)