From: "Fabian Grünbichler" <f.gruenbichler@proxmox.com>
To: Proxmox Backup Server development discussion
<pbs-devel@lists.proxmox.com>
Subject: Re: [pbs-devel] [PATCH proxmox-backup] tape: media_catalog: replace deprecated flock() with Flock
Date: Thu, 20 Nov 2025 10:32:57 +0100 [thread overview]
Message-ID: <1763631151.kdxvxoqlpo.astroid@yuna.none> (raw)
In-Reply-To: <20251120081205.52642-1-h.laimer@proxmox.com>
accidentally sent again?
https://lore.proxmox.com/pbs-devel/1763022246.tus7z1wzjz.astroid@yuna.none/T/#t
On November 20, 2025 9:12 am, Hannes Laimer wrote:
> nix 0.28.0 deprecated fcntl::flock() in favor of fcntl::Flock.
> In commit() lock a cloned fd to avoid moving self.file
>
> No functional change intended. Fixes deprecation warnings.
>
> Signed-off-by: Hannes Laimer <h.laimer@proxmox.com>
> ---
> src/tape/media_catalog.rs | 27 ++++++++++++++++++---------
> 1 file changed, 18 insertions(+), 9 deletions(-)
>
> diff --git a/src/tape/media_catalog.rs b/src/tape/media_catalog.rs
> index 63329a65..7307ca0f 100644
> --- a/src/tape/media_catalog.rs
> +++ b/src/tape/media_catalog.rs
> @@ -9,6 +9,7 @@ use endian_trait::Endian;
>
> use proxmox_sys::fs::read_subdir;
>
> +use nix::fcntl;
> use proxmox_io::{ReadExt, WriteExt};
> use proxmox_sys::fs::{create_path, fchown, CreateOptions};
> use proxmox_uuid::Uuid;
> @@ -194,7 +195,7 @@ impl MediaCatalog {
> let me = proxmox_lang::try_block!({
> Self::create_basedir(base_path)?;
>
> - let mut file = std::fs::OpenOptions::new()
> + let file = std::fs::OpenOptions::new()
> .read(true)
> .write(write)
> .create(create)
> @@ -219,9 +220,12 @@ impl MediaCatalog {
> };
>
> // Note: lock file, to get a consistent view with load_catalog
> - nix::fcntl::flock(file.as_raw_fd(), nix::fcntl::FlockArg::LockExclusive)?;
> - let result = me.load_catalog(&mut file, media_id.media_set_label.as_ref());
> - nix::fcntl::flock(file.as_raw_fd(), nix::fcntl::FlockArg::Unlock)?;
> + let mut locked = fcntl::Flock::lock(file, nix::fcntl::FlockArg::LockExclusive)
> + .map_err(|(_, e)| format_err!("flock failed - {}", e))?;
> + let result = me.load_catalog(&mut locked, media_id.media_set_label.as_ref());
> + let file = locked
> + .unlock()
> + .map_err(|(_, e)| format_err!("flock unlock failed - {}", e))?;
>
> let (found_magic_number, _) = result?;
>
> @@ -371,14 +375,19 @@ impl MediaCatalog {
> Some(ref mut file) => {
> let pending = &self.pending;
> // Note: lock file, to get a consistent view with load_catalog
> - nix::fcntl::flock(file.as_raw_fd(), nix::fcntl::FlockArg::LockExclusive)?;
> + let file_clone = file.try_clone()?;
> + let mut locked =
> + fcntl::Flock::lock(file_clone, nix::fcntl::FlockArg::LockExclusive)
> + .map_err(|(_, e)| format_err!("flock failed - {}", e))?;
> let result: Result<(), Error> = proxmox_lang::try_block!({
> - file.write_all(pending)?;
> - file.flush()?;
> - file.sync_data()?;
> + locked.write_all(pending)?;
> + locked.flush()?;
> + locked.sync_data()?;
> Ok(())
> });
> - nix::fcntl::flock(file.as_raw_fd(), nix::fcntl::FlockArg::Unlock)?;
> + let _ = locked
> + .unlock()
> + .map_err(|(_, e)| format_err!("flock unlock failed - {}", e))?;
>
> result?;
> }
> --
> 2.47.3
>
>
>
> _______________________________________________
> pbs-devel mailing list
> pbs-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
>
>
>
_______________________________________________
pbs-devel mailing list
pbs-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pbs-devel
next prev parent reply other threads:[~2025-11-20 9:32 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-20 8:12 Hannes Laimer
2025-11-20 9:32 ` Fabian Grünbichler [this message]
2025-11-20 9:35 ` Hannes Laimer
-- strict thread matches above, loose matches on Subject: below --
2025-11-12 9:18 Hannes Laimer
2025-11-13 8:39 ` Fabian Grünbichler
2025-11-20 10:11 ` Hannes Laimer
2025-11-20 10:34 ` Fabian Grünbichler
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1763631151.kdxvxoqlpo.astroid@yuna.none \
--to=f.gruenbichler@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.