add patch bail-early-when-clearing-inode-journal-flag-fails
[ext4-patch-queue.git] / bail-early-when-clearing-inode-journal-flag-fails
blob07a1fec1e25067c538f25c9e75f7661a0753d054
1 ext4: bail early when clearing inode journal flag fails
3 From: Jan Kara <jack@suse.cz>
5 When clearing inode journal flag, we call jbd2_journal_flush() to force
6 all the journalled data to their final locations. Currently we ignore
7 when this fails and continue clearing inode journal flag. This isn't a
8 big problem because when jbd2_journal_flush() fails, journal is likely
9 aborted anyway. But it can still lead to somewhat confusing results so
10 rather bail out early.
12 Coverity-id: 989044
13 Signed-off-by: Jan Kara <jack@suse.cz>
14 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
15 ---
16  fs/ext4/inode.c | 7 ++++++-
17  1 file changed, 6 insertions(+), 1 deletion(-)
19 diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
20 index e9777f9..3356ab5 100644
21 --- a/fs/ext4/inode.c
22 +++ b/fs/ext4/inode.c
23 @@ -4959,7 +4959,12 @@ int ext4_change_inode_journal_flag(struct inode *inode, int val)
24         if (val)
25                 ext4_set_inode_flag(inode, EXT4_INODE_JOURNAL_DATA);
26         else {
27 -               jbd2_journal_flush(journal);
28 +               err = jbd2_journal_flush(journal);
29 +               if (err < 0) {
30 +                       jbd2_journal_unlock_updates(journal);
31 +                       ext4_inode_resume_unlocked_dio(inode);
32 +                       return err;
33 +               }
34                 ext4_clear_inode_flag(inode, EXT4_INODE_JOURNAL_DATA);
35         }
36         ext4_set_aops(inode);