[pbs-devel] [PATCH proxmox-backup v8 06/23] api: removable datastore creation

Hannes Laimer h.laimer at proxmox.com
Mon Apr 22 09:37:53 CEST 2024


On Mon Apr 22, 2024 at 9:28 AM CEST, Dietmar Maurer wrote:
> comments inline
>
> >  /// Create new datastore config.
> >  pub fn create_datastore(
> > -    config: DataStoreConfig,
> > +    mut config: DataStoreConfig,
> >      rpcenv: &mut dyn RpcEnvironment,
> >  ) -> Result<String, Error> {
> >      let lock = pbs_config::datastore::lock_config()?;
> > @@ -122,6 +149,31 @@ pub fn create_datastore(
> >          param_bail!("name", "datastore '{}' already exists.", config.name);
> >      }
> >  
> > +    if let Some(uuid) = &config.backing_device {
> > +        let already_used_by = section_config
> > +            .sections
> > +            .iter()
> > +            .flat_map(|(datastore_name, (_, config))| {
> > +                config
> > +                    .as_object()
> > +                    .and_then(|cfg| cfg.get("backing-device"))
> > +                    .and_then(|backing_device| backing_device.as_str())
> > +                    .filter(|&device_uuid| device_uuid == uuid)
> > +                    .map(|_| datastore_name)
> > +            })
> > +            .next();
> > +
> > +        if let Some(datastore_name) = already_used_by {
> > +            param_bail!(
> > +                "backing-device",
> > +                "device already in use by datastore '{datastore_name}'",
> > +            );
> > +        }
> > +        if let Some(mount_point) = config.get_mount_point() {
> > +            config.path = format!("{mount_point}/{}", config.path.trim_start_matches('/'));
>
> This looks redundant for me. I don't want to store the mount point
> in the datastore path.
>

we do use .path all over the place, so we really want that to be the
full path of where the datastore will be once mounted, if we don't have
the complete path(including mp) stored we'd have to add some logic
everywhere the datastore path is used

> > +        }
> > +    }
> > +
> >      let auth_id: Authid = rpcenv.get_auth_id().unwrap().parse()?;
> >      let to_stdout = rpcenv.env_type() == RpcEnvironmentType::CLI;
> >  
> > -- 
> > 2.39.2
> > 
> > 
> > 
> > _______________________________________________
> > pbs-devel mailing list
> > pbs-devel at lists.proxmox.com
> > https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel





More information about the pbs-devel mailing list