On Thu, Sep 25, 2025, 10:43 Zhao Liu <zhao1....@intel.com> wrote:

> > +    fn snapshot_migration_state(&self, target: &mut Self::Migrated) ->
> Result<(), InvalidError> {
> > +        self.lock().unwrap().snapshot_migration_state(target)
> > +    }
>
> Or maybe your previous sentence is worth commenting on here:
>
> // For non-BQL-protected device we cannot know that another
> // thread isn't taking the lock. So, always acquire the lock.
>

I don't think here there's any alternative, that is a way to write code
without taking the lock. However...

>
> > +    fn restore_migrated_state_mut(
> > +        &mut self,
> > +        source: Self::Migrated,
> > +        version_id: u8,
> > +    ) -> Result<(), InvalidError> {
> > +        self.restore_migrated_state(source, version_id)
>

... this could use get_mut().

Paolo

> +    }
> > +}
> > +
> > +impl<T: ToMigrationState> ToMigrationStateShared for Mutex<T> {
> > +    fn restore_migrated_state(
> > +        &self,
> > +        source: Self::Migrated,
> > +        version_id: u8,
> > +    ) -> Result<(), InvalidError> {
> > +        self.lock()
> > +            .unwrap()
> > +            .restore_migrated_state_mut(source, version_id)
> > +    }
> > +}
> > +
>
>

Reply via email to