diff mbox series

[12/27] lustre: obd: check if sbi->ll_md_exp is initialized

Message ID 1623625897-17706-13-git-send-email-jsimmons@infradead.org (mailing list archive)
State New, archived
Headers show
Series lustre: sync to 2.14.52 | expand

Commit Message

James Simmons June 13, 2021, 11:11 p.m. UTC
From: Artem Blagodarenko <artem.blagodarenko@hpe.com>

Null reference at the start of obd_statfs() function is possible
because of ll_fill_super vs lctl race.

ll_md_exp is initialized in ll_fill_super()->
client_common_fill_super(), but if mount process stucks
in lustre_process_log() it doesn't reach client_common_fill_super().

HPE-bug-id: LUS-9150
WC-bug-id: https://jira.whamcloud.com/browse/LU-13942
Lustre-commit: 1de8c3739d6bac76b ("LU-13942 obd: check if sbi->ll_md_exp is initialized")
Signed-off-by: Artem Blagodarenko <artem.blagodarenko@hpe.com>
Reviewed-on: https://es-gerrit.dev.cray.com/157732
Reviewed-by: Alexander Zarochentsev <c17826@cray.com>
Tested-by: Alexander Lezhoev <c17454@cray.com>
Reviewed-by: Andriy Skulysh <c17819@cray.com>
Reviewed-on: https://review.whamcloud.com/39812
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Signed-off-by: James Simmons <jsimmons@infradead.org>
---
 fs/lustre/include/obd_class.h | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/fs/lustre/include/obd_class.h b/fs/lustre/include/obd_class.h
index 5cbed01..4cc5a7df 100644
--- a/fs/lustre/include/obd_class.h
+++ b/fs/lustre/include/obd_class.h
@@ -921,12 +921,13 @@  static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
 			     struct obd_statfs *osfs, time64_t max_age,
 			     u32 flags)
 {
-	struct obd_device *obd = exp->exp_obd;
+	struct obd_device *obd;
 	int rc = 0;
 
-	if (unlikely(!obd))
+	if (unlikely(!exp) || !exp->exp_obd)
 		return -EINVAL;
 
+	obd = exp->exp_obd;
 	rc = obd_check_dev_active(obd);
 	if (rc)
 		return rc;