From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 5AC95636F7 for ; Tue, 22 Dec 2020 14:25:57 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 58AB92C935 for ; Tue, 22 Dec 2020 14:25:57 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [212.186.127.180]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 3A6202C928 for ; Tue, 22 Dec 2020 14:25:56 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 07FE342F20 for ; Tue, 22 Dec 2020 14:25:56 +0100 (CET) Date: Tue, 22 Dec 2020 14:25:54 +0100 From: Wolfgang Bumiller To: Aaron Lauterer Cc: pve-devel@lists.proxmox.com Message-ID: <20201222132554.ix5t53v7nldlmjhf@wobu-vie.proxmox.com> References: <20201222105340.23286-1-a.lauterer@proxmox.com> <20201222125725.ecdspkp44334w7et@wobu-vie.proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201222125725.ecdspkp44334w7et@wobu-vie.proxmox.com> User-Agent: NeoMutt/20180716 X-SPAM-LEVEL: Spam detection results: 0 AWL -0.201 Adjusted score from AWL reputation of From: address KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment KAM_NUMSUBJECT 0.5 Subject ends in numbers excluding current years RCVD_IN_DNSWL_MED -2.3 Sender listed at https://www.dnswl.org/, medium trust SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [plugin.pm] Subject: Re: [pve-devel] [PATCH storage] fix 3214: storage dir structure creation with mkdir 0 X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Dec 2020 13:25:57 -0000 On Tue, Dec 22, 2020 at 01:57:25PM +0100, Wolfgang Bumiller wrote: > On Tue, Dec 22, 2020 at 11:53:40AM +0100, Aaron Lauterer wrote: > > We fail early when `mkdir 0` is set for the storage to avoid creating > > the directories in the storage path. > > > > This means that once `mkdir 0` is set, the code to create the needed > > directory structure (e.g. dump, image, ...) at the storage location will > > never run. > > > > Adding an additional check to only return early if the storage path > > currently does not exist solves the problem. > > > > Signed-off-by: Aaron Lauterer > > --- > > PVE/Storage/Plugin.pm | 4 ++-- > > 1 file changed, 2 insertions(+), 2 deletions(-) > > > > diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm > > index 57c58a9..bda1beb 100644 > > --- a/PVE/Storage/Plugin.pm > > +++ b/PVE/Storage/Plugin.pm > > @@ -1158,8 +1158,8 @@ sub activate_storage { > > "directory '$path' does not exist or is unreachable\n"; > > } > > > > - > > - return if defined($scfg->{mkdir}) && !$scfg->{mkdir}; > > + my $st = File::stat::stat($path); > > + return if defined($scfg->{mkdir}) && !$scfg->{mkdir} && !defined($st); > > Instead of calling stat you can just use the `-d` prefix operator. scratch that, we already perform that check right above this code... and `mkdir` here changes meaning from "create the path to the storage" to "create the directries *inside* the storage"... this is bad :|