Whamcloud - gitweb
LU-10650 obd: add check to obd_statfs 43/31243/7
authorAlexander Boyko <c17825@cray.com>
Fri, 9 Feb 2018 12:07:19 +0000 (07:07 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 27 Feb 2018 03:42:12 +0000 (03:42 +0000)
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 <c17825@cray.com>
Cray-bug-id: LUS-2665
Change-Id: I55a9ffa7e036f486388a8f548051d28974d47951
Reviewed-on: https://review.whamcloud.com/31243
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Alexey Lyashkov <c17817@cray.com>
Reviewed-by: Andriy Skulysh <c17819@cray.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/obd_class.h
lustre/tests/sanity.sh

index 72da1c8..748cc47 100644 (file)
@@ -1132,6 +1132,8 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp,
         if (obd == NULL)
                 RETURN(-EINVAL);
 
         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);
        if (!obd->obd_type || !obd->obd_type->typ_dt_ops->o_statfs) {
                CERROR("%s: no %s operation\n", obd->obd_name, __func__);
                RETURN(-EOPNOTSUPP);
index d49a4cd..62f31a9 100755 (executable)
@@ -16373,6 +16373,25 @@ test_271c() {
 }
 run_test 271c "DoM: IO lock at open saves enqueue RPCs"
 
 }
 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
 cleanup_test_300() {
        trap 0
        umask $SAVE_UMASK