From 4f40429775c49468d9ec1fec34d5e7500ac01116 Mon Sep 17 00:00:00 2001 From: Alexander Boyko Date: Fri, 9 Feb 2018 07:07:19 -0500 Subject: [PATCH] LU-10650 obd: add check to obd_statfs The race could happend between mount and lctl get_param. Because procfs files are ready before a full obd initialization. For example: 3372:0:(dt_object.h:2509:dt_statfs()) ASSERTION( dev ) 3372:0:(dt_object.h:2509:dt_statfs()) LBUG Pid: 3372, comm: lctl Call Trace: libcfs_call_trace+0x4e/0x60[libcfs] lbug_with_loc+0x4c/0xb0[libcfs] tgt_statfs_internal+0x2ea/0x350[ptlrpc] ofd_statfs+0x66/0x470 [ofd] lprocfs_filesfree_seq_show+0xf6/0x520 [obdclass] ofd_filesfree_seq_show+0x12/0x20 [ofd] The patch adds a check of completed obd_setup to obd_statfs(). The patch adds the sanity 276 test. Signed-off-by: Alexander Boyko Cray-bug-id: LUS-2665 Change-Id: I55a9ffa7e036f486388a8f548051d28974d47951 Reviewed-on: https://review.whamcloud.com/31243 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Alexey Lyashkov Reviewed-by: Andriy Skulysh Reviewed-by: Oleg Drokin --- lustre/include/obd_class.h | 2 ++ lustre/tests/sanity.sh | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index 72da1c8..748cc47 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -1132,6 +1132,8 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, if (obd == NULL) RETURN(-EINVAL); + OBD_CHECK_DEV_ACTIVE(obd); + if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_statfs) { CERROR("%s: no %s operation\n", obd->obd_name, __func__); RETURN(-EOPNOTSUPP); diff --git a/lustre/tests/sanity.sh b/lustre/tests/sanity.sh index d49a4cd..62f31a9 100755 --- a/lustre/tests/sanity.sh +++ b/lustre/tests/sanity.sh @@ -16373,6 +16373,25 @@ test_271c() { } run_test 271c "DoM: IO lock at open saves enqueue RPCs" +test_276() { + remote_ost_nodsh && skip "remote OST with nodsh" && return + local pid + + do_facet ost1 "(while true; do \ + $LCTL get_param obdfilter.*.filesfree > /dev/null 2>&1; \ + done) & pid=\\\$!; echo \\\$pid > $TMP/sanity_276_pid" & + pid=$! + + for LOOP in $(seq 20); do + stop ost1 + start ost1 $(ostdevname 1) $OST_MOUNT_OPTS + done + kill -9 $pid + do_facet ost1 "pid=\\\$(cat $TMP/sanity_276_pid); kill -9 \\\$pid; \ + rm $TMP/sanity_276_pid" +} +run_test 276 "Race between mount and obd_statfs" + cleanup_test_300() { trap 0 umask $SAVE_UMASK -- 1.8.3.1