public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
* [rpms/btrfs-backup-ng] rawhide: Fix exclusive lock acquire on btrfs targets
@ 2026-10-22 7:17 Michael Berry
0 siblings, 0 replies; only message in thread
From: Michael Berry @ 2026-10-22 7:17 UTC (permalink / raw)
To: git-commits
A new commit has been pushed.
Repo : rpms/btrfs-backup-ng
Branch : rawhide
Commit : a0ed3e9c91891c75b4ebd9c53105a7bb1ebb5979
Author : Michael Berry <trismegustis@gmail.com>
Date : 2026-10-22T02:45:14-04:00
Stats : +37/-0 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/btrfs-backup-ng/c/a0ed3e9c91891c75b4ebd9c53105a7bb1ebb5979?branch=rawhide
Log:
Fix exclusive lock acquire on btrfs targets
LocalLockManager._take lists the lock directory through a descriptor
opened before it wrote its owner record; on btrfs that listing is empty
until the descriptor is rewound, so the holder gives up the lock it just
took as BUSY. The patch seeks to 0 before listing. Sent upstream.
---
diff --git a/btrfs-backup-ng-0.9.17-lock-rewind-before-listing.patch b/btrfs-backup-ng-0.9.17-lock-rewind-before-listing.patch
new file mode 100644
index 0000000..7abcc19
--- /dev/null
+++ b/btrfs-backup-ng-0.9.17-lock-rewind-before-listing.patch
@@ -0,0 +1,35 @@
+From: Michael Berry <trismegustis@gmail.com>
+Date: Wed, 22 Oct 2026 02:45:00 -0400
+Subject: [PATCH] lock: rewind the lock directory before counting records
+
+On btrfs a directory descriptor lists only the entries that existed when
+it was opened until it is rewound (since kernel 6.6 the last directory
+index is snapshotted at open so a reader always terminates), and
+os.listdir(fd) rewinds only after it has read. LocalLockManager._take
+opens the lock directory, writes its owner record, then lists through the
+same descriptor: on btrfs the record is not seen, the count is 0, the
+holder removes its own record and reports BUSY, so every exclusive
+acquire on a local btrfs target fails. Seek to 0 before listing.
+
+Upstream's suite passes on tmpfs /tmp; it fails wherever tmp_path is on
+btrfs (tests/test_lock_store_never_follows_a_link.py,
+TestTheLocalStoreIsWrittenAsItShouldBe::test_directories_and_records).
+--- a/src/btrfs_backup_ng/sshutil/lock.py 2026-10-22 01:44:01.339704800 -0400
++++ b/src/btrfs_backup_ng/sshutil/lock.py 2026-10-22 02:41:48.017419356 -0400
+@@ -1918,7 +1918,16 @@
+ return ["BUSY"]
+ with os.fdopen(fd, "wb") as f:
+ f.write(payload.encode("utf-8"))
++ # A directory descriptor on btrfs lists only the entries that
++ # existed when it was opened until it is rewound (the kernel
++ # snapshots the last directory index at open, since 6.6, so a
++ # reader always terminates), and os.listdir(fd) rewinds only
++ # AFTER it has read. lock_fd was opened before the record above
++ # was written, so without the rewind the record just written is
++ # not listed, the count below is 0, and the lock this holder has
++ # just taken is given up as BUSY.
+ try:
++ os.lseek(lock_fd, 0, os.SEEK_SET)
+ entries = os.listdir(lock_fd)
+ except OSError:
+ entries = []
diff --git a/btrfs-backup-ng.spec b/btrfs-backup-ng.spec
index e7af3b4..393f8c1 100644
--- a/btrfs-backup-ng.spec
+++ b/btrfs-backup-ng.spec
@@ -6,6 +6,8 @@ Summary: Btrfs backups with snapshots, incremental transfers and restore
License: MIT
URL: https://github.com/berrym/btrfs-backup-ng
Source: %{pypi_source btrfs_backup_ng}
+# Fix exclusive lock acquire on btrfs; sent upstream.
+Patch0: btrfs-backup-ng-0.9.17-lock-rewind-before-listing.patch
BuildArch: noarch
BuildRequires: python3-devel
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-22 7:17 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-22 7:17 [rpms/btrfs-backup-ng] rawhide: Fix exclusive lock acquire on btrfs targets Michael Berry
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox