Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp783204ybh; Sat, 7 Mar 2020 10:11:41 -0800 (PST) X-Google-Smtp-Source: ADFU+vsBdVtOaBU3+9SDZp3A605kN7QNJDT5a11ZbMCgVudN11xKOaL49k4btrAAqMKK7D85af/B X-Received: by 2002:a9d:6f07:: with SMTP id n7mr6905239otq.247.1583604701860; Sat, 07 Mar 2020 10:11:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1583604701; cv=none; d=google.com; s=arc-20160816; b=ENm6HzxUFtck5IPSuIwepHju0sC+TAI0z3x9dmxASEX0CFv7FmN01F0KoPxwLxT7LH 1z4OScJyYLpPNdwcBpsM9DGWBYK8R5tJsp5SbSwCcKjAqId4txIooASf8BBAvnvMWX0K TnDcDjuyxm17UvoEP3CYfXNgXSP/Cisr8E+PJ9P3Mfj5SASlQgrMrT8mqQQsX2DdsAIC 6emTyr51bQVWC+d/blV//IhIZfHf9it+9kYfeI6WXpIrFAqRAyv94jwTbcjyXufZy+DC oYlH2GSKkXJ0ZG2iqusEQPglKGOe4yc6TbHU1rM7rRp/myWrSwyIt/0GfeTjv4F//ONQ OacA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=fDevHSRkkkXiygIEy5ROgiPjcI+9eGq6Zn4sOIc/ffE=; b=VSTvqqLfQsrv4lt3KnX4DSFbk5usnEwh2kR7qdKmUIaQflfpkAkYBVCOP+JfxwTO2B aNxTtfSLc8i6vhyvPRiuRU2ORYsa7rdtTy5U1fvNkHwMwDS8UNq/PSXHKlLcuUeGAYpH IYk9LzYvQbbTqE8U+FgUibX/TwxkwpyQjMxs4WE6gE5V12aNEdvPebKJgNRCI/nWDune DMgSUNprIrgHmAA/2zBY8CLfACD1PdrQDwPhozgSZJDsArILpXIx0FMDVtPXXMuK7kAv DalpODc7VfvtAFf0Sr4xeGpbieeqeJsvVTTAw5iM6PI2FPUIqqRzLFNbefFDf2UT9tl0 gVfA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id e6si1446799oig.223.2020.03.07.10.11.18; Sat, 07 Mar 2020 10:11:41 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726114AbgCGSLR (ORCPT + 99 others); Sat, 7 Mar 2020 13:11:17 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:50753 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726109AbgCGSLR (ORCPT ); Sat, 7 Mar 2020 13:11:17 -0500 Received: from callcc.thunk.org (pool-72-93-95-157.bstnma.fios.verizon.net [72.93.95.157]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 027IBDf9018525 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Sat, 7 Mar 2020 13:11:13 -0500 Received: by callcc.thunk.org (Postfix, from userid 15806) id 1DEB042045B; Sat, 7 Mar 2020 13:11:13 -0500 (EST) Date: Sat, 7 Mar 2020 13:11:13 -0500 From: "Theodore Y. Ts'o" To: Lukas Czerner Cc: linux-ext4@vger.kernel.org, Zdenek Kabelac , Karel Zak , Carlos Maiolino Subject: Re: [PATCH v2] libext2fs/ismounted.c: check open(O_EXCL) before mntent file Message-ID: <20200307181113.GC99899@mit.edu> References: <20200225143445.13182-1-lczerner@redhat.com> <20200303135348.20827-1-lczerner@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200303135348.20827-1-lczerner@redhat.com> Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue, Mar 03, 2020 at 02:53:48PM +0100, Lukas Czerner wrote: > Currently the ext2fs_check_mount_point() will use the open(O_EXCL) check > on linux after all the other checks are done. However it is not > necessary to check mntent if open(O_EXCL) succeeds because it means that > the device is not mounted. > > Moreover the commit ea4d53b7 introduced a regression where a following > set of commands fails: > > vgcreate mygroup /dev/sda > lvcreate -L 1G -n lvol0 mygroup > mkfs.ext4 /dev/mygroup/lvol0 > mount /dev/mygroup/lvol0 /mnt > lvrename /dev/mygroup/lvol0 /dev/mygroup/lvol1 > lvcreate -L 1G -n lvol0 mygroup > mkfs.ext4 /dev/mygroup/lvol0 <<<--- This fails > > It fails because it thinks that /dev/mygroup/lvol0 is mounted because > the device name in /proc/mounts is not updated following the lvrename. > > Move the open(O_EXCL) check before the mntent check and return > immediatelly if the device is not busy. > > Fixes: ea4d53b7 ("libext2fs/ismounted.c: check device id in advance to skip false device names") > Signed-off-by: Lukas Czerner > Reported-by: Zdenek Kabelac > Reported-by: Karel Zak > Reviewed-by: Carlos Maiolino Applied, thanks. - Ted