ext4: make orphan functions be no-op in no-journal mode
authorAnatol Pomozov <anatol.pomozov@gmail.com>
Tue, 18 Sep 2012 17:38:59 +0000 (13:38 -0400)
committerStricted <info@stricted.net>
Thu, 11 Oct 2018 16:03:50 +0000 (18:03 +0200)
Instead of checking whether the handle is valid, we check if journal
is enabled. This avoids taking the s_orphan_lock mutex in all cases
when there is no journal in use, including the error paths where
ext4_orphan_del() is called with a handle set to NULL.

Signed-off-by: Anatol Pomozov <anatol.pomozov@gmail.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Conflicts:
fs/ext4/namei.c

Change-Id: I734ccb8069fceb12b864e7b9dceb37e27ab94c61

fs/ext4/namei.c

index dadeef4422d73653b55816be6b5e49c7c6d77e35..7588fdeed7d910a47fa017202c1b4c4851af6cde 100644 (file)
@@ -2622,7 +2622,7 @@ int ext4_orphan_add(handle_t *handle, struct inode *inode)
        struct ext4_iloc iloc;
        int err = 0, rc;
 
-       if (!EXT4_SB(sb)->s_journal)
+       if (!EXT4_SB(sb)->s_journal || is_bad_inode(inode))
                return 0;
 
        mutex_lock(&EXT4_SB(sb)->s_orphan_lock);
@@ -2696,7 +2696,7 @@ int ext4_orphan_del(handle_t *handle, struct inode *inode)
        struct ext4_iloc iloc;
        int err = 0;
 
-       if ((!EXT4_SB(inode->i_sb)->s_journal) &&
+       if (!EXT4_SB(inode->i_sb)->s_journal &&
            !(EXT4_SB(inode->i_sb)->s_mount_state & EXT4_ORPHAN_FS))
                return 0;