Whamcloud - gitweb
LU-16973 osd: adds SB_KERNMOUNT flag
authorAlex Zhuravlev <bzzz@whamcloud.com>
Mon, 25 Sep 2023 09:20:41 +0000 (12:20 +0300)
committerAndreas Dilger <adilger@whamcloud.com>
Thu, 28 Sep 2023 08:44:01 +0000 (08:44 +0000)
During umount mntput() is called. It uses delayed_mntput()
function, and it could take much time to finish. A block
device is occupied during delayed work.

[ 8753.941980] Lustre: server umount XXX complete
[ 8800.129136] sysrq: SysRq : Trigger a crash

PID: 319306   TASK:XXXX   CPU: 2    COMMAND: "kworker/2:0"
 #0 __schedule at ffffffff9754e1d4
 #1 preempt_schedule_common at ffffffff9754e6fa
 #2 _cond_resched at ffffffff9754e72d
 #3 invalidate_mapping_pages at ffffffff96e72da5
 #4 invalidate_bdev at ffffffff96f5d13c
 #5 ldiskfs_put_super at ffffffffc1c82e34 [ldiskfs]
 #6 generic_shutdown_super at ffffffff96f1bdcc
 #7 kill_block_super at ffffffff96f1bed1
 #8 deactivate_locked_super at ffffffff96f1b784
 #9 cleanup_mnt at ffffffff96f3b86b

Let's use SB_KERNMOUNT flag during mount, it leads to
synchronous mntput().
It also calls flush_delayed_fput during umount to finish
delayed fput.

Lustre-change: https://review.whamcloud.com//51731
Lustre-commit: eff11c8ce1f89f30dcc5af88b67b3d6c15a631a6

Change-Id: Ia6729f6cbac85c3626562e946a4b96665a143714
Signed-off-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52495
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/include/lustre_compat.h
lustre/osd-ldiskfs/osd_handler.c

index 9fc4925..f6b951e 100644 (file)
@@ -278,6 +278,9 @@ static inline void iov_iter_truncate(struct iov_iter *i, u64 count)
 #if !defined(SB_NODIRATIME) && defined(MS_NODIRATIME)
 # define SB_NODIRATIME MS_NODIRATIME
 #endif
+#if !defined(SB_KERNMOUNT) && defined(MS_KERNMOUNT)
+# define SB_KERNMOUNT MS_KERNMOUNT
+#endif
 
 #ifndef HAVE_FILE_OPERATIONS_READ_WRITE_ITER
 static inline void iov_iter_reexpand(struct iov_iter *i, size_t count)
index caa0193..dd3cc93 100644 (file)
@@ -8123,6 +8123,12 @@ static int osd_shutdown(const struct lu_env *env, struct osd_device *o)
        RETURN(0);
 }
 
+#ifdef HAVE_FLUSH_DELAYED_FPUT
+# define cfs_flush_delayed_fput() flush_delayed_fput()
+#else
+void (*cfs_flush_delayed_fput)(void);
+#endif /* HAVE_FLUSH_DELAYED_FPUT */
+
 static void osd_umount(const struct lu_env *env, struct osd_device *o)
 {
        ENTRY;
@@ -8139,6 +8145,9 @@ static void osd_umount(const struct lu_env *env, struct osd_device *o)
                o->od_mnt = NULL;
        }
 
+       /* to be sure all delayed fput are finished */
+       cfs_flush_delayed_fput();
+
        EXIT;
 }
 
@@ -8272,6 +8281,7 @@ static int osd_mount(const struct lu_env *env,
                GOTO(out, rc = -ENODEV);
        }
 
+       s_flags |= SB_KERNMOUNT;
        o->od_mnt = vfs_kern_mount(type, s_flags, dev, options);
        module_put(type->owner);
 
@@ -8897,6 +8907,12 @@ static int __init osd_init(void)
                }
        }
 
+#ifndef HAVE_FLUSH_DELAYED_FPUT
+       if (unlikely(cfs_flush_delayed_fput == NULL))
+               cfs_flush_delayed_fput =
+                       cfs_kallsyms_lookup_name("flush_delayed_fput");
+#endif
+
        return rc;
 }