From mboxrd@z Thu Jan 1 00:00:00 1970 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=-2.5 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_PASS,USER_AGENT_MUTT 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 9B677C43381 for ; Thu, 21 Mar 2019 20:48:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6637F218A5 for ; Thu, 21 Mar 2019 20:48:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726377AbfCUUsm (ORCPT ); Thu, 21 Mar 2019 16:48:42 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:57976 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726247AbfCUUsl (ORCPT ); Thu, 21 Mar 2019 16:48:41 -0400 Received: from callcc.thunk.org (guestnat-104-133-0-99.corp.google.com [104.133.0.99] (may be forged)) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id x2LKmO9Z025443 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 21 Mar 2019 16:48:25 -0400 Received: by callcc.thunk.org (Postfix, from userid 15806) id CA921420AA8; Thu, 21 Mar 2019 16:48:23 -0400 (EDT) Date: Thu, 21 Mar 2019 16:48:23 -0400 From: "Theodore Ts'o" To: Lukas Czerner Cc: Ext4 Developers List , darrick.wong@oracle.com Subject: Re: [PATCH 8/9] e2scrub_all: refactor device probe loop Message-ID: <20190321204823.GJ9434@mit.edu> References: <20190321020218.5154-1-tytso@mit.edu> <20190321020218.5154-8-tytso@mit.edu> <20190321102742.k2oos4epoj6fyjao@work> <20190321143141.GB9434@mit.edu> <20190321155703.ili5ghofgm3hneq5@work> <20190321182456.GG9434@mit.edu> <20190321201710.vw5g2kfp6p2b3jxk@work> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190321201710.vw5g2kfp6p2b3jxk@work> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Thu, Mar 21, 2019 at 09:17:10PM +0100, Lukas Czerner wrote: > > Right, I did mention it later in the reply. It can be filtered > > grep -v '^/dev/' Well, that assumes all device nodes are in /dev. Which is not necessarily always the case, especially in some of the more _whacky_ container setups which I've seen. (Hmm, is whacky redundant here?) I suppose can test whether or not the path is a block device or a directory..... > > For me this new function is the wors of all. > > cold cache: > real 0m2.115s > user 0m0.040s > sys 0m0.154s > > second time: > real 0m1.100s > user 0m0.037s > sys 0m0.122s > > But that's because of blkid which is terribly slow for some reason. I ran my test on a system with a NVMe SSD, and no HDD's attached. I just did an strace, and I see the util-linux folks have really done a great job of pessimizing blkid. :-( My version used to just pull the information from the blkid cache file and then verified the results, but it looks like the new, improved util-linux version of blkid scans the /dev directory and opens and reads from each device node, even when we're querying a single block device. Even lsblk is *amazingly* inefficient in terms of the number of useless file opens which it performs, although at least they are all /sysfs files. I'm half tempted to create and ship a binary which just calls ext2fs_check_mount_point() and returns the value, since it's the most efficient. This command sudo strace -o /tmp/st /build/e2fsprogs-maint/lib/ext2fs/tst_ismounted /dev/lambda/tp Opens /proc/mounts and does a trial mount of /dev/lambda/tp to make sure it's actually busy, and that's it. Sigh... - Ted