Received: by 2002:a05:6a10:5594:0:0:0:0 with SMTP id ee20csp561445pxb; Mon, 25 Apr 2022 16:35:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJjyCWLSXazXpkb8ETVbP0RtaRSuyZWuwaD//v+cQABAhB8q2S7NI1FebYkqneQO8W6VEO X-Received: by 2002:a17:902:f701:b0:14d:7cea:82af with SMTP id h1-20020a170902f70100b0014d7cea82afmr19994193plo.71.1650929752700; Mon, 25 Apr 2022 16:35:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650929752; cv=none; d=google.com; s=arc-20160816; b=KwhCqRusrEaq2eLat2Hnb6Jy5/yzTZcvzCy2BDytskc18J33/81vvQJaMCRBoaPYLn NgduSwNnpeV/XLaAkBMcM2Q9hJmpQrT9rbcO3lcL7a1KXdiADy3UqETLoiPOWFLEw/EB gg1NALLJRLqWoK7WU+c5XBcfVbbU53PZgGAJbMpPddNKm4I/+wWUQlvf8iymBAzr6FJZ ZK6VaF9D7YFw+ZdMcXTUGlb0w6c6O8X6F2dt7zMpCz1nZFpJTeS2jv6uyQeZDVhLnBlV TvtSy2DNL+UbEFLi4DCiSdumiG0s5Gv6s0SSXwnhCNMFoRwuSm2rDpGdHxTnpNVq1D+i jdfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=2c+M7J/C99EHmRZ2ed7WZCBt5ls8UbJ2QrJdqTRJXeU=; b=yu7cowF6DQbKYBHQ43pQWn7y4o8E+kCLUZU3Huu0mQ96jCMqOSrYqyr2EaQacQU9rc vsab3dBWEVQnjFQ9suk55SaKV4aoZ/9qHF38VWU0AGDRT7RiNNWwZ9WYf7ykk2p/IyIG k6degltf5hvN7j9UMNUx8RQpZVLGRLmkIeVGR5/OsiVOAM0U7zkxsti97vzzXNAR2wKX cple7EvB/KuJ9gdB2HoMx5bb+Jeag8W6cnmy49Nx8ue/28E+3ORi6JMfJzxSrryjVDZ9 BR0vvLycfYByBZTggXUHzV5l7q9Y+7cdS5ZTpF3OeyGT1VCkD2z36DYipcRTAkF8aQUH W8Cg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RZfmfyZP; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 15-20020a63040f000000b003aaee7fbbd0si9648548pge.447.2022.04.25.16.35.24; Mon, 25 Apr 2022 16:35:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=RZfmfyZP; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245049AbiDYUEE (ORCPT + 99 others); Mon, 25 Apr 2022 16:04:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47508 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234273AbiDYUEE (ORCPT ); Mon, 25 Apr 2022 16:04:04 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 78BA490CCA for ; Mon, 25 Apr 2022 13:00:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1650916857; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding; bh=2c+M7J/C99EHmRZ2ed7WZCBt5ls8UbJ2QrJdqTRJXeU=; b=RZfmfyZP5d3Se2DdTOwppboTFzQxWpL0UYVzJ7n2Xu8qHpsWhGXCWyw7k/SIzU95+PE1EF 7yrLeutrU8FPprp3EMZoNGSNv7Y55huOSh9x+ivxeLIx+rY8vtY2V9E+pI4wOdVKTVqSB+ rAe5XnB9t9CncPtP4+gj2uI881EN6Ko= Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-127-jh7GzwaGNtyvvl3A-3CSOw-1; Mon, 25 Apr 2022 16:00:56 -0400 X-MC-Unique: jh7GzwaGNtyvvl3A-3CSOw-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A4B66381A827; Mon, 25 Apr 2022 20:00:55 +0000 (UTC) Received: from nyarly.redhat.com (ovpn-116-126.gru2.redhat.com [10.97.116.126]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 10DE8141511F; Mon, 25 Apr 2022 20:00:52 +0000 (UTC) From: Thiago Becker To: linux-nfs@vger.kernel.org, steved@redhat.com Cc: trbecker@gmail.com, Thiago Becker Subject: [PATCH] nfsrahead: fix oops caused by non-starndard naming schemes Date: Mon, 25 Apr 2022 16:59:49 -0300 Message-Id: <20220425195948.2627428-1-tbecker@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW, SPF_HELO_NONE,SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org brtfs uses a non standard naming scheme for its fs structures, which causes nfsrahead to take a long time scanning all the memory available and then crashes. This causes the udev to take forever to quiesce and delays the system startup. This t=patch refactors the way the device number is obtained to handle this situation. Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2078147 Signed-off-by: Thiago Becker --- tools/nfsrahead/main.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/tools/nfsrahead/main.c b/tools/nfsrahead/main.c index b3af3aa8..83a389f7 100644 --- a/tools/nfsrahead/main.c +++ b/tools/nfsrahead/main.c @@ -26,27 +26,31 @@ struct device_info { }; /* Convert a string in the format n:m to a device number */ -static dev_t dev_from_arg(const char *device_number) +static int fill_device_number(struct device_info *info) { - char *s = strdup(device_number), *p; + char *s = strdup(info->device_number), *p; char *maj_s, *min_s; unsigned int maj, min; - dev_t dev; + int err = -EINVAL; maj_s = p = s; - for ( ; *p != ':'; p++) + for ( ; *p != ':' && *p != '\0'; p++) ; + if (*p == '\0') + goto out_free; + + err = 0; *p = '\0'; min_s = p + 1; maj = strtol(maj_s, NULL, 10); min = strtol(min_s, NULL, 10); - dev = makedev(maj, min); - + info->dev = makedev(maj, min); +out_free: free(s); - return dev; + return err; } #define sfree(ptr) if (ptr) free(ptr) @@ -55,7 +59,7 @@ static dev_t dev_from_arg(const char *device_number) static void init_device_info(struct device_info *di, const char *device_number) { di->device_number = strdup(device_number); - di->dev = dev_from_arg(device_number); + di->dev = 0; di->mountpoint = NULL; di->fstype = NULL; } @@ -76,6 +80,8 @@ static int get_mountinfo(const char *device_number, struct device_info *device_i char *target; init_device_info(device_info, device_number); + if ((ret = fill_device_number(device_info)) < 0) + goto out_free_device_info; mnttbl = mnt_new_table(); @@ -101,6 +107,7 @@ out_free_fs: mnt_free_fs(fs); out_free_tbl: mnt_free_table(mnttbl); +out_free_device_info: free(device_info->device_number); device_info->device_number = NULL; return ret; -- 2.35.1