public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Michael Berry <trismegustis@gmail.com>
To: git-commits@fedoraproject.org
Subject: [rpms/btrfs-backup-ng] f45: Fix exclusive lock acquire on btrfs targets
Date: Thu, 22 Oct 2026 08:45:19 GMT	[thread overview]
Message-ID: <179265871995.1.6031425020884351301.rpms-btrfs-backup-ng-a0ed3e9c9189@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/btrfs-backup-ng
            Branch : f45
            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=f45

            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

                 reply	other threads:[~2026-10-22  8:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=179265871995.1.6031425020884351301.rpms-btrfs-backup-ng-a0ed3e9c9189@fedoraproject.org \
    --to=trismegustis@gmail.com \
    --cc=git-commits@fedoraproject.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox