Whamcloud - gitweb
LU-12977 ldiskfs: properly take inode_lock() for truncates 16/37116/5
authorJames Simmons <jsimmons@infradead.org>
Mon, 30 Dec 2019 17:48:05 +0000 (12:48 -0500)
committerOleg Drokin <green@whamcloud.com>
Tue, 28 Jan 2020 06:03:47 +0000 (06:03 +0000)
Originally Lustre grabbed the inode_lock() but this lead to
deadlocks as described in LU-6446 and LU-4252. The recent work
of LU-10048 changed the truncate code so that it is called
asynchronously from the main transactions. This should avoid
lock ordering issues. It should be safe to take the
inode_lock() around ldiskfs_truncate() and remove the WARN().

Test-Parameters: fstype=ldiskfs testlist=racer

Change-Id: Id7b6d05d054ab041980e946989aa1effae5c7111
Signed-off-by: James Simmons <jsimmons@infradead.org>
Reviewed-on: https://review.whamcloud.com/37116
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
23 files changed:
ldiskfs/kernel_patches/patches/rhel7/ext4-remove-truncate-warning.patch [deleted file]
ldiskfs/kernel_patches/patches/sles12/ext4-remove-truncate-warning.patch [deleted file]
ldiskfs/kernel_patches/patches/ubuntu18/ext4-remove-truncate-warning.patch [deleted file]
ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.2.series
ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.3.series
ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.4.series
ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.5.series
ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.6.series
ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.7.series
ldiskfs/kernel_patches/series/ldiskfs-3.10-rhel7.series
ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12.series
ldiskfs/kernel_patches/series/ldiskfs-3.12-sles12sp1.series
ldiskfs/kernel_patches/series/ldiskfs-4.15.0-20-ubuntu18.series
ldiskfs/kernel_patches/series/ldiskfs-4.15.0-24-ubuntu18.series
ldiskfs/kernel_patches/series/ldiskfs-4.18-rhel8.series
ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp2.series
ldiskfs/kernel_patches/series/ldiskfs-4.4-sles12sp3.series
ldiskfs/kernel_patches/series/ldiskfs-4.4.0-45-ubuntu14+16.series
ldiskfs/kernel_patches/series/ldiskfs-4.4.0-49-ubuntu14+16.series
ldiskfs/kernel_patches/series/ldiskfs-4.4.0-62-ubuntu14+16.series
ldiskfs/kernel_patches/series/ldiskfs-4.4.0-73-ubuntu14+16.series
ldiskfs/kernel_patches/series/ldiskfs-5.0.0-13-ubuntu19.series
lustre/osd-ldiskfs/osd_io.c

diff --git a/ldiskfs/kernel_patches/patches/rhel7/ext4-remove-truncate-warning.patch b/ldiskfs/kernel_patches/patches/rhel7/ext4-remove-truncate-warning.patch
deleted file mode 100644 (file)
index 6bfb54e..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-There will cause a deadlock if invoke ext4_truncate with i_mutex locked
-in lustre. Since lustre has own lock to provide protect so we don't
-need this check at all. 
-
-Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/inode.c
-===================================================================
---- linux-3.10.0-229.1.2.fc21.x86_64.orig/fs/ext4/inode.c
-+++ linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/inode.c
-@@ -3644,8 +3644,6 @@ void ext4_truncate(struct inode *inode)
-        * or it completely new indode. In those cases we might not
-        * have i_mutex locked because it's not necessary.
-        */
--      if (!(inode->i_state & (I_NEW|I_FREEING)))
--              WARN_ON(!mutex_is_locked(&inode->i_mutex));
-       trace_ext4_truncate_enter(inode);
-       if (!ext4_can_truncate(inode))
-Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/namei.c
-===================================================================
---- linux-3.10.0-229.1.2.fc21.x86_64.orig/fs/ext4/namei.c
-+++ linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/namei.c
-@@ -3163,8 +3163,6 @@ int ext4_orphan_add(handle_t *handle, st
-       if (!sbi->s_journal || is_bad_inode(inode))
-               return 0;
--      WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) &&
--                   !mutex_is_locked(&inode->i_mutex));
-       /*
-        * Exit early if inode already is on orphan list. This is a big speedup
-        * since we don't have to contend on the global s_orphan_lock.
-@@ -3245,8 +3243,6 @@ int ext4_orphan_del(handle_t *handle, st
-       if (!sbi->s_journal && !(sbi->s_mount_state & EXT4_ORPHAN_FS))
-               return 0;
--      WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) &&
--                   !mutex_is_locked(&inode->i_mutex));
-       /* Do this quick check before taking global s_orphan_lock. */
-       if (list_empty(&ei->i_orphan))
-               return 0;
diff --git a/ldiskfs/kernel_patches/patches/sles12/ext4-remove-truncate-warning.patch b/ldiskfs/kernel_patches/patches/sles12/ext4-remove-truncate-warning.patch
deleted file mode 100644 (file)
index d5ecfe1..0000000
+++ /dev/null
@@ -1,17 +0,0 @@
-There will cause a deadlock if invoke ext4_truncate with i_mutex locked
-in lustre. Since lustre has own lock to provide protect so we don't
-need this check at all. 
-
-Index: linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/inode.c
-===================================================================
---- linux-3.10.0-229.1.2.fc21.x86_64.orig/fs/ext4/inode.c
-+++ linux-3.10.0-229.1.2.fc21.x86_64/fs/ext4/inode.c
-@@ -3644,8 +3644,6 @@ void ext4_truncate(struct inode *inode)
-        * or it completely new indode. In those cases we might not
-        * have i_mutex locked because it's not necessary.
-        */
--      if (!(inode->i_state & (I_NEW|I_FREEING)))
--              WARN_ON(!mutex_is_locked(&inode->i_mutex));
-       trace_ext4_truncate_enter(inode);
-       if (!ext4_can_truncate(inode))
diff --git a/ldiskfs/kernel_patches/patches/ubuntu18/ext4-remove-truncate-warning.patch b/ldiskfs/kernel_patches/patches/ubuntu18/ext4-remove-truncate-warning.patch
deleted file mode 100644 (file)
index 17bc7e3..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-There will cause a deadlock if invoke ext4_truncate with i_mutex locked
-in lustre. Since lustre has own lock to provide protect so we don't
-need this check at all.
-
-Index: linux-4.15.0/fs/ext4/inode.c
-===================================================================
---- linux-4.15.0.orig/fs/ext4/inode.c
-+++ linux-4.15.0/fs/ext4/inode.c
-@@ -4398,8 +4398,6 @@ int ext4_truncate(struct inode *inode)
-        * or it's a completely new inode. In those cases we might not
-        * have i_mutex locked because it's not necessary.
-        */
--      if (!(inode->i_state & (I_NEW|I_FREEING)))
--              WARN_ON(!inode_is_locked(inode));
-       trace_ext4_truncate_enter(inode);
-       if (!ext4_can_truncate(inode))
-Index: linux-4.15.0/fs/ext4/namei.c
-===================================================================
---- linux-4.15.0.orig/fs/ext4/namei.c
-+++ linux-4.15.0/fs/ext4/namei.c
-@@ -3370,8 +3370,6 @@ int ext4_orphan_add(handle_t *handle, st
-       if (!sbi->s_journal || is_bad_inode(inode))
-               return 0;
--      WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) &&
--                   !inode_is_locked(inode));
-       /*
-        * Exit early if inode already is on orphan list. This is a big speedup
-        * since we don't have to contend on the global s_orphan_lock.
-@@ -3452,8 +3450,6 @@ int ext4_orphan_del(handle_t *handle, st
-       if (!sbi->s_journal && !(sbi->s_mount_state & EXT4_ORPHAN_FS))
-               return 0;
--      WARN_ON_ONCE(!(inode->i_state & (I_NEW | I_FREEING)) &&
--                   !inode_is_locked(inode));
-       /* Do this quick check before taking global s_orphan_lock. */
-       if (list_empty(&ei->i_orphan))
-               return 0;
index ac83b2f..1588268 100644 (file)
@@ -15,7 +15,6 @@ rhel7/ext4-nocmtime.patch
 rhel7/ext4-large-dir.patch
 rhel7.2/ext4-pdirop.patch
 rhel7/ext4-max-dir-size.patch
-rhel7/ext4-remove-truncate-warning.patch
 rhel7/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 rhel7/ext4-give-warning-with-dir-htree-growing.patch
 rhel7/ext4-mmp-brelse.patch
index 3dfecb7..ca71367 100644 (file)
@@ -15,7 +15,6 @@ rhel7/ext4-nocmtime.patch
 rhel7/ext4-large-dir.patch
 rhel7.2/ext4-pdirop.patch
 rhel7/ext4-max-dir-size.patch
-rhel7/ext4-remove-truncate-warning.patch
 rhel7.3/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 rhel7/ext4-give-warning-with-dir-htree-growing.patch
 rhel7/ext4-mmp-brelse.patch
index 66035ef..89fdbc2 100644 (file)
@@ -15,7 +15,6 @@ rhel7/ext4-nocmtime.patch
 rhel7.4/ext4-large-dir.patch
 rhel7.4/ext4-pdirop.patch
 rhel7/ext4-max-dir-size.patch
-rhel7/ext4-remove-truncate-warning.patch
 rhel7.3/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 rhel7/ext4-give-warning-with-dir-htree-growing.patch
 rhel7/ext4-mmp-brelse.patch
index 6c4e7dd..f6b3552 100644 (file)
@@ -15,7 +15,6 @@ rhel7/ext4-nocmtime.patch
 rhel7.4/ext4-large-dir.patch
 rhel7.4/ext4-pdirop.patch
 rhel7/ext4-max-dir-size.patch
-rhel7/ext4-remove-truncate-warning.patch
 rhel7.3/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 rhel7/ext4-give-warning-with-dir-htree-growing.patch
 rhel7/ext4-mmp-brelse.patch
index d10b17f..bcca593 100644 (file)
@@ -15,7 +15,6 @@ rhel7/ext4-nocmtime.patch
 rhel7.4/ext4-large-dir.patch
 rhel7.4/ext4-pdirop.patch
 rhel7/ext4-max-dir-size.patch
-rhel7/ext4-remove-truncate-warning.patch
 rhel7.6/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 rhel7/ext4-give-warning-with-dir-htree-growing.patch
 rhel7/ext4-mmp-brelse.patch
index 689b1ed..d564fc0 100644 (file)
@@ -15,7 +15,6 @@ rhel7/ext4-nocmtime.patch
 rhel7.7/ext4-large-dir.patch
 rhel7.7/ext4-pdirop.patch
 rhel7/ext4-max-dir-size.patch
-rhel7/ext4-remove-truncate-warning.patch
 rhel7.6/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 rhel7/ext4-give-warning-with-dir-htree-growing.patch
 rhel7/ext4-mmp-brelse.patch
index 2f67631..d5d372b 100644 (file)
@@ -15,7 +15,6 @@ rhel7/ext4-nocmtime.patch
 rhel7/ext4-large-dir.patch
 rhel7/ext4-pdirop.patch
 rhel7/ext4-max-dir-size.patch
-rhel7/ext4-remove-truncate-warning.patch
 rhel7/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 rhel7/ext4-give-warning-with-dir-htree-growing.patch
 rhel7/ext4-mmp-brelse.patch
index 6424192..b8f25a7 100644 (file)
@@ -15,7 +15,6 @@ rhel7/ext4-nocmtime.patch
 rhel7/ext4-large-dir.patch
 sles12/ext4-pdirop.patch
 rhel7/ext4-max-dir-size.patch
-sles12/ext4-remove-truncate-warning.patch
 sles12/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 rhel7/ext4-give-warning-with-dir-htree-growing.patch
 rhel7/ext4-mmp-brelse.patch
index ceacea6..da684d6 100644 (file)
@@ -15,7 +15,6 @@ rhel7/ext4-nocmtime.patch
 sles12sp1/ext4-large-dir.patch
 sles12/ext4-pdirop.patch
 rhel7/ext4-max-dir-size.patch
-rhel7/ext4-remove-truncate-warning.patch
 sles12/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 rhel7/ext4-give-warning-with-dir-htree-growing.patch
 rhel7/ext4-mmp-brelse.patch
index 46114cd..ca4e47d 100644 (file)
@@ -12,7 +12,6 @@ ubuntu18/ext4-data-in-dirent.patch
 ubuntu18/ext4-nocmtime.patch
 ubuntu18/ext4-pdirop.patch
 sles12sp2/ext4-max-dir-size.patch
-ubuntu18/ext4-remove-truncate-warning.patch
 ubuntu18/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 ubuntu18/ext4-give-warning-with-dir-htree-growing.patch
 ubuntu18/ext4-jcb-optimization.patch
index 5c6c4a9..21edbd5 100644 (file)
@@ -12,7 +12,6 @@ ubuntu18/ext4-data-in-dirent.patch
 ubuntu18/ext4-nocmtime.patch
 ubuntu18/ext4-pdirop.patch
 sles12sp2/ext4-max-dir-size.patch
-ubuntu18/ext4-remove-truncate-warning.patch
 ubuntu18/ext4-corrupted-inode-block-bitmaps-handling-patches-001.patch
 ubuntu18/ext4-give-warning-with-dir-htree-growing.patch
 ubuntu18/ext4-jcb-optimization.patch
index f476de4..b5b98a3 100644 (file)
@@ -12,7 +12,6 @@ ubuntu18/ext4-data-in-dirent.patch
 rhel8/ext4-nocmtime.patch
 rhel8/ext4-pdirop.patch
 sles12sp3/ext4-max-dir-size.patch
-ubuntu18/ext4-remove-truncate-warning.patch
 rhel8/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 ubuntu18/ext4-give-warning-with-dir-htree-growing.patch
 ubuntu18/ext4-jcb-optimization.patch
index 6b6e2d5..45b3845 100644 (file)
@@ -15,7 +15,6 @@ rhel7/ext4-nocmtime.patch
 sles12sp2/ext4-large-dir.patch
 sles12sp2/ext4-pdirop.patch
 sles12sp2/ext4-max-dir-size.patch
-rhel7/ext4-remove-truncate-warning.patch
 sles12sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 sles12sp2/ext4-give-warning-with-dir-htree-growing.patch
 sles12sp2/ext4-mmp-brelse.patch
index e247d1a..de29b53 100644 (file)
@@ -15,7 +15,6 @@ rhel7/ext4-nocmtime.patch
 sles12sp3/ext4-large-dir.patch
 sles12sp3/ext4-pdirop.patch
 sles12sp3/ext4-max-dir-size.patch
-rhel7/ext4-remove-truncate-warning.patch
 sles12sp3/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 sles12sp2/ext4-give-warning-with-dir-htree-growing.patch
 sles12sp2/ext4-mmp-brelse.patch
index 4b801ec..0318650 100644 (file)
@@ -15,7 +15,6 @@ rhel7/ext4-nocmtime.patch
 ubuntu14+16/ext4-large-dir.patch
 ubuntu14+16/ext4-pdirop.patch
 sles12sp2/ext4-max-dir-size.patch
-rhel7/ext4-remove-truncate-warning.patch
 sles12sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 sles12sp2/ext4-give-warning-with-dir-htree-growing.patch
 sles12sp2/ext4-mmp-brelse.patch
index f0cd928..65fff0b 100644 (file)
@@ -15,7 +15,6 @@ rhel7/ext4-nocmtime.patch
 ubuntu14+16/ext4-large-dir.patch
 ubuntu14+16/ext4-pdirop-001.patch
 sles12sp2/ext4-max-dir-size.patch
-rhel7/ext4-remove-truncate-warning.patch
 sles12sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 sles12sp2/ext4-give-warning-with-dir-htree-growing.patch
 sles12sp2/ext4-mmp-brelse.patch
index e9dcd34..2542292 100644 (file)
@@ -15,7 +15,6 @@ rhel7/ext4-nocmtime.patch
 ubuntu14+16/ext4-large-dir-001.patch
 ubuntu14+16/ext4-pdirop-001.patch
 sles12sp2/ext4-max-dir-size.patch
-rhel7/ext4-remove-truncate-warning.patch
 sles12sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 sles12sp2/ext4-give-warning-with-dir-htree-growing.patch
 sles12sp2/ext4-mmp-brelse.patch
index a688394..5f0232b 100644 (file)
@@ -15,7 +15,6 @@ rhel7/ext4-nocmtime.patch
 ubuntu14+16/ext4-large-dir-001.patch
 ubuntu14+16/ext4-pdirop-001.patch
 sles12sp2/ext4-max-dir-size.patch
-rhel7/ext4-remove-truncate-warning.patch
 sles12sp2/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 sles12sp2/ext4-give-warning-with-dir-htree-growing.patch
 sles12sp2/ext4-mmp-brelse.patch
index 011a1ca..1ab4116 100644 (file)
@@ -12,7 +12,6 @@ ubuntu18/ext4-data-in-dirent.patch
 rhel8/ext4-nocmtime.patch
 rhel8/ext4-pdirop.patch
 sles12sp3/ext4-max-dir-size.patch
-ubuntu18/ext4-remove-truncate-warning.patch
 rhel8/ext4-corrupted-inode-block-bitmaps-handling-patches.patch
 ubuntu18/ext4-give-warning-with-dir-htree-growing.patch
 ubuntu18/ext4-jcb-optimization.patch
index 0cffae6..9095b51 100644 (file)
@@ -2160,7 +2160,9 @@ void osd_execute_truncate(struct osd_object *obj)
                return;
        }
 
+       inode_lock(inode);
        ldiskfs_truncate(inode);
+       inode_unlock(inode);
 
        /*
         * For a partial-page truncate, flush the page to disk immediately to