Whamcloud - gitweb
LU-13467 llite: truncate deadlock with DoM files 88/38288/3
authorAndriy Skulysh <c17819@cray.com>
Thu, 27 Feb 2020 21:15:41 +0000 (23:15 +0200)
committerOleg Drokin <green@whamcloud.com>
Fri, 19 Jun 2020 16:50:48 +0000 (16:50 +0000)
All MDT intent RPCs are sent with inode mutex locked
while read/write and setattr unlocks inode mutex on entry,
takes LDLM lock and locks inode mutex again and sends the RPC.
So a deadlock can occur since LDLM lock is the same in case of DoM.

In fact read/write and setattr takes lli_trunc_sem, so
inode mutex can be ommited in truncate case.

Replace inode_lock with new lli_setattr_mutex to keep protection
from concurrent setattr time updates.

HPE-bug-id: LUS-8455
Change-Id: Ie294154306cc3b6cff977a2dff485e8d44145ed9
Reviewed-by: Andrew Perepechko <c17827@cray.com>
Reviewed-by: Vitaly Fertman <c17818@cray.com>
Signed-off-by: Andriy Skulysh <c17819@cray.com>
Reviewed-on: https://review.whamcloud.com/38288
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Mike Pershin <mpershin@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/llite/llite_internal.h
lustre/llite/llite_lib.c
lustre/llite/vvp_io.c

index 0302620..b504614 100644 (file)
@@ -185,6 +185,7 @@ struct ll_inode_info {
                        char                   *lli_symlink_name;
                        struct ll_trunc_sem     lli_trunc_sem;
                        struct range_lock_tree  lli_write_tree;
                        char                   *lli_symlink_name;
                        struct ll_trunc_sem     lli_trunc_sem;
                        struct range_lock_tree  lli_write_tree;
+                       struct mutex            lli_setattr_mutex;
 
                        struct rw_semaphore     lli_glimpse_sem;
                        ktime_t                 lli_glimpse_time;
 
                        struct rw_semaphore     lli_glimpse_sem;
                        ktime_t                 lli_glimpse_time;
index 0aaae5f..d43e793 100644 (file)
@@ -1037,6 +1037,7 @@ void ll_lli_init(struct ll_inode_info *lli)
                init_rwsem(&lli->lli_lsm_sem);
        } else {
                mutex_init(&lli->lli_size_mutex);
                init_rwsem(&lli->lli_lsm_sem);
        } else {
                mutex_init(&lli->lli_size_mutex);
+               mutex_init(&lli->lli_setattr_mutex);
                lli->lli_symlink_name = NULL;
                ll_trunc_sem_init(&lli->lli_trunc_sem);
                range_lock_tree_init(&lli->lli_write_tree);
                lli->lli_symlink_name = NULL;
                ll_trunc_sem_init(&lli->lli_trunc_sem);
                range_lock_tree_init(&lli->lli_write_tree);
index 85d630f..94df8b5 100644 (file)
@@ -738,13 +738,13 @@ static int vvp_io_setattr_start(const struct lu_env *env,
 
        if (cl_io_is_trunc(io)) {
                trunc_sem_down_write(&lli->lli_trunc_sem);
 
        if (cl_io_is_trunc(io)) {
                trunc_sem_down_write(&lli->lli_trunc_sem);
-               inode_lock(inode);
+               mutex_lock(&lli->lli_setattr_mutex);
                inode_dio_wait(inode);
        } else if (cl_io_is_fallocate(io)) {
                inode_lock(inode);
                inode_dio_wait(inode);
        } else {
                inode_dio_wait(inode);
        } else if (cl_io_is_fallocate(io)) {
                inode_lock(inode);
                inode_dio_wait(inode);
        } else {
-               inode_lock(inode);
+               mutex_lock(&lli->lli_setattr_mutex);
        }
 
        if (io->u.ci_setattr.sa_avalid & TIMES_SET_FLAGS)
        }
 
        if (io->u.ci_setattr.sa_avalid & TIMES_SET_FLAGS)
@@ -764,12 +764,12 @@ static void vvp_io_setattr_end(const struct lu_env *env,
                /* Truncate in memory pages - they must be clean pages
                 * because osc has already notified to destroy osc_extents. */
                vvp_do_vmtruncate(inode, io->u.ci_setattr.sa_attr.lvb_size);
                /* Truncate in memory pages - they must be clean pages
                 * because osc has already notified to destroy osc_extents. */
                vvp_do_vmtruncate(inode, io->u.ci_setattr.sa_attr.lvb_size);
-               inode_unlock(inode);
+               mutex_unlock(&lli->lli_setattr_mutex);
                trunc_sem_up_write(&lli->lli_trunc_sem);
        } else if (cl_io_is_fallocate(io)) {
                inode_unlock(inode);
        } else {
                trunc_sem_up_write(&lli->lli_trunc_sem);
        } else if (cl_io_is_fallocate(io)) {
                inode_unlock(inode);
        } else {
-               inode_unlock(inode);
+               mutex_unlock(&lli->lli_setattr_mutex);
        }
 }
 
        }
 }