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 341FB706F4 for ; Fri, 14 May 2021 09:00:02 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 1E20C12CE4 for ; Fri, 14 May 2021 09:00:02 +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 BD16F12CC5 for ; Fri, 14 May 2021 09:00:00 +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 811B642BCA for ; Fri, 14 May 2021 09:00:00 +0200 (CEST) To: Proxmox Backup Server development discussion , Dominik Csapak References: <20210510144554.19021-1-d.csapak@proxmox.com> From: Dietmar Maurer Message-ID: <7aa7c849-7e62-6c85-c487-c74ec0e1f144@proxmox.com> Date: Fri, 14 May 2021 08:59:57 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.0 MIME-Version: 1.0 In-Reply-To: <20210510144554.19021-1-d.csapak@proxmox.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-SPAM-LEVEL: Spam detection results: 0 AWL 0.217 Adjusted score from AWL reputation of From: address 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [media.rs, mod.rs, backup.rs] Subject: [pbs-devel] applied: [PATCH proxmox-backup 1/2] api2/tape/backup: add 'force-media-set' parameter to manual backup 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: Fri, 14 May 2021 07:00:02 -0000 applied both patches On 5/10/21 4:45 PM, Dominik Csapak wrote: > so that a user can force a new media set, e.g. if he uses the > allocation policy 'continue', but wants to manually start a new > media-set. > > Signed-off-by: Dominik Csapak > --- > src/api2/tape/backup.rs | 18 +++++++++++++++++- > src/api2/tape/media.rs | 2 +- > src/tape/media_pool.rs | 17 +++++++++++------ > src/tape/pool_writer/mod.rs | 3 ++- > 4 files changed, 31 insertions(+), 9 deletions(-) > > diff --git a/src/api2/tape/backup.rs b/src/api2/tape/backup.rs > index 4dc35945..77b11bb0 100644 > --- a/src/api2/tape/backup.rs > +++ b/src/api2/tape/backup.rs > @@ -226,6 +226,7 @@ pub fn do_tape_backup_job( > &setup, > email.clone(), > &mut summary, > + false, > ) > }); > > @@ -312,6 +313,12 @@ pub fn run_tape_backup_job( > type: TapeBackupJobSetup, > flatten: true, > }, > + "force-media-set": { > + description: "Ignore the allocation policy and start a new media-set.", > + optional: true, > + type: bool, > + default: false, > + }, > }, > }, > returns: { > @@ -327,6 +334,7 @@ pub fn run_tape_backup_job( > /// Backup datastore to tape media pool > pub fn backup( > setup: TapeBackupJobSetup, > + force_media_set: bool, > rpcenv: &mut dyn RpcEnvironment, > ) -> Result { > > @@ -373,6 +381,7 @@ pub fn backup( > &setup, > email.clone(), > &mut summary, > + force_media_set, > ); > > if let Some(email) = email { > @@ -403,6 +412,7 @@ fn backup_worker( > setup: &TapeBackupJobSetup, > email: Option, > summary: &mut TapeBackupJobSummary, > + force_media_set: bool, > ) -> Result<(), Error> { > > let status_path = Path::new(TAPE_STATUS_DIR); > @@ -413,7 +423,13 @@ fn backup_worker( > > let pool = MediaPool::with_config(status_path, &pool_config, changer_name, false)?; > > - let mut pool_writer = PoolWriter::new(pool, &setup.drive, worker, email)?; > + let mut pool_writer = PoolWriter::new( > + pool, > + &setup.drive, > + worker, > + email, > + force_media_set > + )?; > > let mut group_list = BackupInfo::list_backup_groups(&datastore.base_path())?; > > diff --git a/src/api2/tape/media.rs b/src/api2/tape/media.rs > index 811fcb7e..683c74b8 100644 > --- a/src/api2/tape/media.rs > +++ b/src/api2/tape/media.rs > @@ -129,7 +129,7 @@ pub async fn list_media( > // Call start_write_session, so that we show the same status a > // backup job would see. > pool.force_media_availability(); > - pool.start_write_session(current_time)?; > + pool.start_write_session(current_time, false)?; > > for media in pool.list_media() { > let expired = pool.media_is_expired(&media, current_time); > diff --git a/src/tape/media_pool.rs b/src/tape/media_pool.rs > index 039b46fc..dd471551 100644 > --- a/src/tape/media_pool.rs > +++ b/src/tape/media_pool.rs > @@ -258,7 +258,7 @@ impl MediaPool { > /// Make sure the current media set is usable for writing > /// > /// If not, starts a new media set. Also creates a new > - /// set if media_set_policy implies it. > + /// set if media_set_policy implies it, or if 'force' is true. > /// > /// Note: We also call this in list_media to compute correct media > /// status, so this must not change persistent/saved state. > @@ -267,6 +267,7 @@ impl MediaPool { > pub fn start_write_session( > &mut self, > current_time: i64, > + force: bool, > ) -> Result, Error> { > > let _pool_lock = if self.no_media_set_locking { > @@ -277,11 +278,15 @@ impl MediaPool { > > self.inventory.reload()?; > > - let mut create_new_set = match self.current_set_usable() { > - Err(err) => { > - Some(err.to_string()) > - } > - Ok(_) => None, > + let mut create_new_set = if force { > + Some(String::from("forced")) > + } else { > + match self.current_set_usable() { > + Err(err) => { > + Some(err.to_string()) > + } > + Ok(_) => None, > + } > }; > > if create_new_set.is_none() { > diff --git a/src/tape/pool_writer/mod.rs b/src/tape/pool_writer/mod.rs > index 99fdb48c..a788cbeb 100644 > --- a/src/tape/pool_writer/mod.rs > +++ b/src/tape/pool_writer/mod.rs > @@ -71,11 +71,12 @@ impl PoolWriter { > drive_name: &str, > worker: &WorkerTask, > notify_email: Option, > + force_media_set: bool, > ) -> Result { > > let current_time = proxmox::tools::time::epoch_i64(); > > - let new_media_set_reason = pool.start_write_session(current_time)?; > + let new_media_set_reason = pool.start_write_session(current_time, force_media_set)?; > if let Some(reason) = new_media_set_reason { > task_log!( > worker,