]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
ext4: check for shutdown and r/o file system in ext4_write_inode()
authorTheodore Ts'o <tytso@mit.edu>
Wed, 19 Dec 2018 19:36:58 +0000 (14:36 -0500)
committerKleber Sacilotto de Souza <kleber.souza@canonical.com>
Wed, 14 Aug 2019 09:18:49 +0000 (11:18 +0200)
BugLink: https://bugs.launchpad.net/bugs/1837257
commit 18f2c4fcebf2582f96cbd5f2238f4f354a0e4847 upstream.

If the file system has been shut down or is read-only, then
ext4_write_inode() needs to bail out early.

Also use jbd2_complete_transaction() instead of ext4_force_commit() so
we only force a commit if it is needed.

Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Cc: stable@kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
fs/ext4/inode.c

index 6efebae3e892b45393b2885e249568cd40701279..284d05d70c5d9b39e9ecdf82e19962b6e8592666 100644 (file)
@@ -5278,9 +5278,13 @@ int ext4_write_inode(struct inode *inode, struct writeback_control *wbc)
 {
        int err;
 
-       if (WARN_ON_ONCE(current->flags & PF_MEMALLOC))
+       if (WARN_ON_ONCE(current->flags & PF_MEMALLOC) ||
+           sb_rdonly(inode->i_sb))
                return 0;
 
+       if (unlikely(ext4_forced_shutdown(EXT4_SB(inode->i_sb))))
+               return -EIO;
+
        if (EXT4_SB(inode->i_sb)->s_journal) {
                if (ext4_journal_current_handle()) {
                        jbd_debug(1, "called recursively, non-PF_MEMALLOC!\n");
@@ -5296,7 +5300,8 @@ int ext4_write_inode(struct inode *inode, struct writeback_control *wbc)
                if (wbc->sync_mode != WB_SYNC_ALL || wbc->for_sync)
                        return 0;
 
-               err = ext4_force_commit(inode->i_sb);
+               err = jbd2_complete_transaction(EXT4_SB(inode->i_sb)->s_journal,
+                                               EXT4_I(inode)->i_sync_tid);
        } else {
                struct ext4_iloc iloc;