From eff11c8ce1f89f30dcc5af88b67b3d6c15a631a6 Mon Sep 17 00:00:00 2001 From: Alexander Boyko Date: Fri, 7 Jul 2023 15:35:51 -0400 Subject: [PATCH] LU-16973 osd: adds SB_KERNMOUNT flag 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. HPE-bug-id: LUS-11629 Signed-off-by: Alexander Boyko Change-Id: Ia6729f6cbac85c3626562e946a4b96665a143714 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/51731 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andrew Perepechko Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Reviewed-by: Neil Brown Reviewed-by: Oleg Drokin --- lustre/include/lustre_compat.h | 3 +++ lustre/osd-ldiskfs/osd_handler.c | 16 ++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/lustre/include/lustre_compat.h b/lustre/include/lustre_compat.h index 34042d5..cc19072 100644 --- a/lustre/include/lustre_compat.h +++ b/lustre/include/lustre_compat.h @@ -332,6 +332,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) diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index f8dee13..bc865f3 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -8196,6 +8196,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; @@ -8212,6 +8218,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; } @@ -8343,6 +8352,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); @@ -8950,6 +8960,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; } -- 1.8.3.1