From patchwork Tue Jul 27 20:10:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 12403545 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 50445C432BE for ; Tue, 27 Jul 2021 20:10:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 38DCC60F9B for ; Tue, 27 Jul 2021 20:10:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231624AbhG0UKx (ORCPT ); Tue, 27 Jul 2021 16:10:53 -0400 Received: from mail-pl1-f175.google.com ([209.85.214.175]:34406 "EHLO mail-pl1-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229681AbhG0UKw (ORCPT ); Tue, 27 Jul 2021 16:10:52 -0400 Received: by mail-pl1-f175.google.com with SMTP id d1so10244944pll.1; Tue, 27 Jul 2021 13:10:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=X0wE//9HEqgwixzn3DN6w89is3z00f/t9Uc1uapEcFM=; b=DDghwk55mmd8mk+ce75D55/9nDA/U8F3AhBHDhVbBZDkLTl4N0l8VoAzNfsBLkdyR3 amFuFA9YC/vUIXG25x6CxzgvPXFacHsseCekBVLwQ7H3iQgy5EkN3ouPipFUxvRlkX3n CdNW+1dZzuQR7EzI4ib/i7jWnW5a0q1ts8a0hlfUdN6l5HbjRV4TC7UFJfU7BhYKWjdg /0+bpvUrmqxThNI8ebBMNWHfhTjcAgnXUUGFDGxEaQ8d4PdVySymak1Jl1AcD+I7bK+z XJAiefTEK2piDMrsYHr5aobmenj4ojtfNcp0W9A1ixj3b7Mn1CO931zMm4SQxBc8wbdj JBDA== X-Gm-Message-State: AOAM530j4Y/ZTDmDkHQnr57K924vXJWv6ZKODYJgijWan6HRMYUiiVbk EOS1xIvERHnwMuXvjE2wejybooojti0= X-Google-Smtp-Source: ABdhPJwtH/th0vT1ycklEZcYiTe97opY4s3/d0QLljvKYDRB//7itYCusI6O5h+4brJekhccvDJdug== X-Received: by 2002:a17:90a:bd18:: with SMTP id y24mr5955132pjr.83.1627416650857; Tue, 27 Jul 2021 13:10:50 -0700 (PDT) Received: from localhost ([191.96.121.85]) by smtp.gmail.com with ESMTPSA id y4sm3752116pjg.9.2021.07.27.13.10.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Jul 2021 13:10:49 -0700 (PDT) From: Luis Chamberlain To: fstests@vger.kernel.org Cc: hare@suse.de, dgilbert@interlog.com, jeyu@kernel.org, lucas.demarchi@intel.com, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 1/4] common/config: disable udevadm settle if CONFIG_NET is disabled Date: Tue, 27 Jul 2021 13:10:42 -0700 Message-Id: <20210727201045.2540681-2-mcgrof@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210727201045.2540681-1-mcgrof@kernel.org> References: <20210727201045.2540681-1-mcgrof@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org If CONFIG_NET is disabled kobject_uevent_net_broadcast() will be a no-op and so no uevent are sent and so 'udevadm settle' won't really do anything for you. We check for /proc/net to see if CONFIG_NET was enabled. Signed-off-by: Luis Chamberlain --- common/config | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/common/config b/common/config index adc16b59..005fd50a 100644 --- a/common/config +++ b/common/config @@ -240,7 +240,14 @@ else UDEV_SETTLE_PROG="$UDEV_SETTLE_PROG settle" fi # neither command is available, use sleep 1 -if [ "$UDEV_SETTLE_PROG" == "" ]; then +# +# Udev events are sent via netlink to userspace through +# kobject_uevent_net_broadcast(), and udev in userspace is in charge of +# handling the events. The command `udevadm settle` just checks if +# /run/udev/queue is 0, however, a kernel without CONFIG_NET will have +# kobject_uevent_net_broadcast() be a no-op, and so /run/udev/queue may not +# exist or always be 0. We check for /proc/net to see CONFIG_NET was enabled. +if [[ "$UDEV_SETTLE_PROG" == "" || ! -d /proc/net ]]; then UDEV_SETTLE_PROG="sleep 1" fi export UDEV_SETTLE_PROG From patchwork Tue Jul 27 20:10:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 12403547 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 78B51C432BE for ; Tue, 27 Jul 2021 20:10:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6305560F93 for ; Tue, 27 Jul 2021 20:10:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232123AbhG0UK5 (ORCPT ); Tue, 27 Jul 2021 16:10:57 -0400 Received: from mail-pj1-f41.google.com ([209.85.216.41]:42968 "EHLO mail-pj1-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232013AbhG0UK4 (ORCPT ); Tue, 27 Jul 2021 16:10:56 -0400 Received: by mail-pj1-f41.google.com with SMTP id o44-20020a17090a0a2fb0290176ca3e5a2fso856092pjo.1; Tue, 27 Jul 2021 13:10:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Glu03wx1EO+cRL+474sUvuGcwz/C/1OdSRJGdquxArU=; b=DfY9o1dbKJe7ZcE4nnMeU9nkIxC/EdzhWFRs6rOZbZ713qQuFwctJr+O7IPWNqN3Vp dvlX2ixAYHfC2xgYRN+/YMmLmUQbQwCFrlavDeQWw+0i87cUUOm0il6xoRJpJZ452Aiu hwFPjh7/kw4M7tlIRirgiGEAHyRReGHxRU6XhtDicF7xzS/YOo7UG6a7eVgOItMgOG9G F+5Pow8a59QVCvXqk1vD5S9ZXp8O0FKe/wjHsBXxNR7UnkEHuOmfUNlHAamsNazJOXXu KsxbYb9zmxyUMrLY12fMZMDruFXvyAXpVHgpL9l51pXmRSyOqLurkApaFdJxFns2ZU3J aM5g== X-Gm-Message-State: AOAM5313HENKHhErFuDlPhioFloC83hGiZ10F0XoavDDyCmZViRpmHpa xVm2iev101agBwYkIsF+J6LB2XAY5yw= X-Google-Smtp-Source: ABdhPJwHAwoc/tK2eDf9255hc8caNkNYgNs84Y0UZ+fINypfg8g46KSUM7llgRPnE2Qm6Fbj91gihQ== X-Received: by 2002:a05:6a00:b46:b029:334:54db:af17 with SMTP id p6-20020a056a000b46b029033454dbaf17mr24790725pfo.26.1627416654449; Tue, 27 Jul 2021 13:10:54 -0700 (PDT) Received: from localhost ([191.96.121.85]) by smtp.gmail.com with ESMTPSA id l9sm3622698pjq.40.2021.07.27.13.10.51 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Jul 2021 13:10:52 -0700 (PDT) From: Luis Chamberlain To: fstests@vger.kernel.org Cc: hare@suse.de, dgilbert@interlog.com, jeyu@kernel.org, lucas.demarchi@intel.com, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 2/4] common/scsi_debug: use udevadm settle instead of sleeping Date: Tue, 27 Jul 2021 13:10:43 -0700 Message-Id: <20210727201045.2540681-3-mcgrof@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210727201045.2540681-1-mcgrof@kernel.org> References: <20210727201045.2540681-1-mcgrof@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org The variable UDEV_SETTLE_PROG is already defined and used for lvm to either use `udevadm settle` in case it is available, and if not, use 'sleep 1' otherwise (ancient distros or CONFIG_NET is missing). Use it on scsi_debug to replace the sleep calls sprinkled in place after module removal. The correct thing to do is to just use udevadm settle when available, and only fall back to calling sleep when udevadm is not available or CONFIG_NET is disabled. Signed-off-by: Luis Chamberlain --- common/scsi_debug | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/scsi_debug b/common/scsi_debug index d9aa0bd2..e7988469 100644 --- a/common/scsi_debug +++ b/common/scsi_debug @@ -36,7 +36,7 @@ _get_scsi_debug_dev() echo "scsi_debug options $opts" >> $seqres.full modprobe scsi_debug $opts [ $? -eq 0 ] || _fail "scsi_debug modprobe failed" - sleep 1 + $UDEV_SETTLE_PROG device=`grep -wl scsi_debug /sys/block/sd*/device/model | awk -F / '{print $4}'` echo "/dev/$device" } @@ -50,7 +50,7 @@ _put_scsi_debug_dev() # modprobe is only quiet when the module is not found, not when the # module is in use. while [ $n -ge 0 ] && ! modprobe -nr scsi_debug >/dev/null 2>&1; do - sleep 1 + $UDEV_SETTLE_PROG n=$((n-1)) done rmmod scsi_debug || _fail "Could not remove scsi_debug module" From patchwork Tue Jul 27 20:10:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 12403549 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 92E15C4338F for ; Tue, 27 Jul 2021 20:11:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7B8DA60F9B for ; Tue, 27 Jul 2021 20:11:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232013AbhG0UK7 (ORCPT ); Tue, 27 Jul 2021 16:10:59 -0400 Received: from mail-pj1-f45.google.com ([209.85.216.45]:51140 "EHLO mail-pj1-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232111AbhG0UK7 (ORCPT ); Tue, 27 Jul 2021 16:10:59 -0400 Received: by mail-pj1-f45.google.com with SMTP id l19so1669519pjz.0; Tue, 27 Jul 2021 13:10:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cH8YESp6vV/FGgxzvuxVqtRKwWVyEJM+QYlLp40SNAQ=; b=Q1yKgk9R1XSIjyncuaiD/PII9d/XrY0CeqS5pB0ZC8ai74BdepIG75NNda/0BNTI5C LqjbT1Zs6kzCdF6DnYzkp5OsLGSAUa6fyLbh85SJkUXcMTs61B8BwfwgeILSq1tztVHN TrrrPSradvFUmPqYUkCaeQw64MtB/PrIh/XtbISCp2DlXrkPcCypfxi5aaIQsihhSeY0 ptKxRNi3nVdA01qGWQ0fQ8q8lcaHyr5+OK9DatduMM7ZK1XVMfLnHXOPo1+66I/20kUJ Bg01MPF64a9k3VV5jkufvjzM+M4tIk6xjWy2SbhACm3w1Ah6hRl7iXBaKWo/xXa8DalA XPng== X-Gm-Message-State: AOAM533Q5It6B1OQ233P74Y+kwo/lMkZRX6kFF1VLDivhYPWXBCTUmz8 jYtTIyBmMah3EfkgXkz/TWECosge3cw= X-Google-Smtp-Source: ABdhPJxNbBgkjCMRhfmz3kEC+j71ZYDpUZoIuhXDEXmktwWN8ywIspXtzKwDPnB32pAucKXMLmsgdQ== X-Received: by 2002:a17:902:f68d:b029:12c:4619:c63a with SMTP id l13-20020a170902f68db029012c4619c63amr3810522plg.66.1627416656886; Tue, 27 Jul 2021 13:10:56 -0700 (PDT) Received: from localhost ([191.96.121.85]) by smtp.gmail.com with ESMTPSA id y7sm4257548pfi.204.2021.07.27.13.10.55 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Jul 2021 13:10:55 -0700 (PDT) From: Luis Chamberlain To: fstests@vger.kernel.org Cc: hare@suse.de, dgilbert@interlog.com, jeyu@kernel.org, lucas.demarchi@intel.com, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 3/4] common/module: add a patient module rmmod Date: Tue, 27 Jul 2021 13:10:44 -0700 Message-Id: <20210727201045.2540681-4-mcgrof@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210727201045.2540681-1-mcgrof@kernel.org> References: <20210727201045.2540681-1-mcgrof@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org When we call rmmod it will fail if the refcnt is greater than 0. This is expected, however, if using test modules such as scsi_debug, userspace tests may expect that once userspace is done issuing out whatever it needs to that immediately after it can remove the module. This is not true, things can linger for a while when a test driver's reference count is greater than 0, and so userspace has to wait before it can reliably try rmmod. Furthermore... experience on older kernels shows it may be a while before we can actually remove the module even *after* /sys/module/$module/refcnt is 0. This is only currently observed on older kernels. Provide a check for the refcnt before we try to remove the module. And add a grace period to allow things quiesce before we really try removing the module so that we don't get false positives. An example of this is when using the scsi_debug module. Using udevadm settle does ensure the devices are properly ready to use after modprobe, however once you start using the module, say testing xfs with generic/108, you will see refcnt linger between 1 and 2, and once the test completes this eventually goes down to 0. The refcnt can be > 0 after userspace thinks it is done with a test, and so will fail to remove it. Likewise, on older kernels even with a refcnt of 0 the module may sometimes fail to be removed. Yes, the sleep 10 is rather large, however if you want to prevent false positives it is needed. Doug's patch recent test patch [0] helps with these older kernel kernels not having to require such large delays, however we have no way of telling currently if such scsi_debug quiesce patch is applied. [0] https://lore.kernel.org/linux-scsi/20210508230745.27923-1-dgilbert@interlog.com/ Signed-off-by: Luis Chamberlain --- common/module | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/common/module b/common/module index 39e4e793..064bc45e 100644 --- a/common/module +++ b/common/module @@ -81,3 +81,51 @@ _get_fs_module_param() { cat /sys/module/${FSTYP}/parameters/${1} 2>/dev/null } + +# checks the refcount and returns 0 if we can safely remove the module. rmmod +# does this check for us, but we can use this to also iterate checking for this +# refcount before we even try to remove the module. This is useful when using +# debug test modules which take a while to quiesce. +_patient_rmmod_check_refcnt() +{ + local module=$1 + local refcnt=0 + + if [[ -f /sys/module/$module/refcnt ]]; then + refcnt=$(cat /sys/module/$module/refcnt 2>/dev/null) + if [[ $? -ne 0 || $refcnt -eq 0 ]]; then + return 0 + fi + return 1 + fi + return 0 +} + +# patiently tries to wait to remove a module by ensuring first +# the refcnt is 0. We wait for 10 seconds at most. +_patient_rmmod() +{ + local module=$1 + local max_tries=10 + + while [[ $max_tries != 0 ]]; do + _patient_rmmod_check_refcnt $module + if [[ $? -eq 0 ]]; then + break + fi + sleep 1 + let max_tries=$max_tries-1 + done + + # give some grace time for when the refcnt is 0 as otherwise the + # removal can fail on older kernels. Refer to: + # https://bugzilla.kernel.org/show_bug.cgi?id=212337 + sleep 10 + + if [[ -d /sys/module/$module ]]; then + modprobe -r $module + return $? + fi + + return 0 +} From patchwork Tue Jul 27 20:10:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Luis Chamberlain X-Patchwork-Id: 12403551 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-17.0 required=3.0 tests=BAYES_00,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9D327C432BE for ; Tue, 27 Jul 2021 20:11:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 86B6F60F9D for ; Tue, 27 Jul 2021 20:11:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232278AbhG0ULD (ORCPT ); Tue, 27 Jul 2021 16:11:03 -0400 Received: from mail-pl1-f177.google.com ([209.85.214.177]:39569 "EHLO mail-pl1-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232186AbhG0ULB (ORCPT ); Tue, 27 Jul 2021 16:11:01 -0400 Received: by mail-pl1-f177.google.com with SMTP id e5so15548963pld.6; Tue, 27 Jul 2021 13:11:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=m1/cftuNWA0p2OVfbGsieFA7kuPnfaxa2Mc0nXC0ogw=; b=RFYfg0Xb3AqlW+b55FEITH3+wBF3zMtQYcwwHdiTWr4fqpA/xlxoswnPJoixh6aglw 6MR5DWOp2GC539wiMkTGiAPK6RknXTEQFtub9OC2weouFjT2MeqUYGxTUguKcW/D/hTE VohSwetyAM5iCPgokcu7+9Fm88ACEdCTpfV5kR9o6a/lVk+UyKLny2ccjjnIiwNMh3Dx ypv93TiSabxIWUAmyC+fViOmp/0kn4PMxcwmOahR0QEh2iYeBlIB9TV7zd+4hfRb9uo3 N7K5LJBI4EhdQ06zklcprOGHKNUw4wThZLBrerGoRcFwrtpQzrmsiseRDr7pU1RsyC56 HALA== X-Gm-Message-State: AOAM531Ur/Elo/tKVjJiL/2N2eEaNEDsZ0DClypBDGuKenEM2iNhJKrK gy2z1SxC95FoTsl6JU2QivSxWoc8wAo= X-Google-Smtp-Source: ABdhPJyLRnJk03C0VRwp6A9qgLwQ0loJxVKLSyBCZWHEgR/s7uQkNQ/NC5f+bq1PhP1MgHIr5CPYUQ== X-Received: by 2002:a63:3d0e:: with SMTP id k14mr25256222pga.351.1627416659219; Tue, 27 Jul 2021 13:10:59 -0700 (PDT) Received: from localhost ([191.96.121.85]) by smtp.gmail.com with ESMTPSA id c11sm5077097pfp.0.2021.07.27.13.10.57 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Jul 2021 13:10:58 -0700 (PDT) From: Luis Chamberlain To: fstests@vger.kernel.org Cc: hare@suse.de, dgilbert@interlog.com, jeyu@kernel.org, lucas.demarchi@intel.com, linux-kernel@vger.kernel.org, Luis Chamberlain Subject: [PATCH 4/4] common/scsi_debug: use the patient module remover Date: Tue, 27 Jul 2021 13:10:45 -0700 Message-Id: <20210727201045.2540681-5-mcgrof@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210727201045.2540681-1-mcgrof@kernel.org> References: <20210727201045.2540681-1-mcgrof@kernel.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: fstests@vger.kernel.org If you try to run tests such as generic/108 in a loop you'll eventually see a failure, but the failure can be a false positive and the test was just unable to remove the scsi_debug module. We need to give some time for the refcnt to become 0. For instance for the test generic/108 the refcnt lingers between 2 and 1. It should be 0 when we're done but a bit of time seems to be required. The chance of us trying to run rmmod when the refcnt is 2 or 1 is low, about 1/30 times if you run the test in a loop on linux-next today. Likewise, even when its 0 we just need a tiny breather before we can remove the module (sleep 10 suffices) but this is only required on older kernels. Otherwise removing the module will just fail. Some of these races are documented on the korg#212337, and Doug Gilbert has posted at least one patch attempt to try to help with this [1]. The patch does not resolve all the issues though, it helps though. [0] https://bugzilla.kernel.org/show_bug.cgi?id=212337 [1] https://lkml.kernel.org/r/20210508230745.27923-1-dgilbert@interlog.com Signed-off-by: Luis Chamberlain --- common/scsi_debug | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/common/scsi_debug b/common/scsi_debug index e7988469..3c9cd820 100644 --- a/common/scsi_debug +++ b/common/scsi_debug @@ -4,11 +4,13 @@ # # Functions useful for tests on unique block devices +. common/module + _require_scsi_debug() { # make sure we have the module and it's not already used modinfo scsi_debug 2>&1 > /dev/null || _notrun "scsi_debug module not found" - lsmod | grep -wq scsi_debug && (rmmod scsi_debug || _notrun "scsi_debug module in use") + lsmod | grep -wq scsi_debug && (_patient_rmmod scsi_debug || _notrun "scsi_debug module in use") # make sure it has the features we need # logical/physical sectors plus unmap support all went in together modinfo scsi_debug | grep -wq sector_size || _notrun "scsi_debug too old" @@ -53,5 +55,5 @@ _put_scsi_debug_dev() $UDEV_SETTLE_PROG n=$((n-1)) done - rmmod scsi_debug || _fail "Could not remove scsi_debug module" + _patient_rmmod scsi_debug || _fail "Could not remove scsi_debug module" }