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 BB2746F62A for ; Mon, 30 Aug 2021 13:15:15 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A67411A048 for ; Mon, 30 Aug 2021 13:15:15 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (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 firstgate.proxmox.com (Proxmox) with ESMTPS id 499F41A000 for ; Mon, 30 Aug 2021 13:15:11 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 1ED0B441E6 for ; Mon, 30 Aug 2021 13:15:11 +0200 (CEST) From: Hannes Laimer To: pbs-devel@lists.proxmox.com Date: Mon, 30 Aug 2021 13:14:54 +0200 Message-Id: <20210830111505.38694-5-h.laimer@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210830111505.38694-1-h.laimer@proxmox.com> References: <20210830111505.38694-1-h.laimer@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.184 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH v2 proxmox-backup 04/15] backup: add check_if_available function to ds X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Aug 2021 11:15:15 -0000 Makes sure a removable datastore is available, meaning it is plugged in and mounted correctly. For not removable datastores the function will never result in an Error, since they're always available. --- src/backup/datastore.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/backup/datastore.rs b/src/backup/datastore.rs index 848459e8..ef3400d7 100644 --- a/src/backup/datastore.rs +++ b/src/backup/datastore.rs @@ -52,6 +52,24 @@ pub fn check_backup_owner( Ok(()) } +pub fn check_if_available(config: &datastore::DataStoreConfig) -> Result<(), Error> { + if let (Some(uuid), Some(config_mount_point)) = ( + config.backing_device.clone(), + config.backing_device_mount_point.clone(), + ) { + match tools::disks::get_mount_point_by_uuid(&uuid) { + Ok(mount_point) if mount_point.eq(&config_mount_point) => Ok(()), + _ => Err(format_err!( + "The removale device for datastore '{}' has to be mounted at '{}'!", + config.name, + config_mount_point + )), + } + } else { + Ok(()) + } +} + /// Datastore Management /// /// A Datastore can store severals backups, and provides the @@ -69,6 +87,9 @@ impl DataStore { let (config, _digest) = datastore::config()?; let config: datastore::DataStoreConfig = config.lookup("datastore", name)?; + + check_if_available(&config)?; + let path = PathBuf::from(&config.path); let mut map = DATASTORE_MAP.lock().unwrap(); @@ -103,6 +124,8 @@ impl DataStore { } fn open_with_path(store_name: &str, path: &Path, config: DataStoreConfig) -> Result { + check_if_available(&config)?; + let chunk_store = ChunkStore::open(store_name, path)?; let mut gc_status_path = chunk_store.base_path(); -- 2.30.2