A background scrub start creates and binds the progress socket, then
forks. The child scrubs and answers on the socket, but the parent
leaves through the common exit path, which closes the socket and
removes it from the file system. Nothing can connect to the child
after that: "btrfs scrub status" falls back to the status file, which
is written every 5 seconds, and the check for a running scrub in
another "btrfs scrub start -f" does not see the background scrub.
Close the parent's copy of the socket without removing it. The child
removes it when the scrub is finished.
Fixes: 4ba165318745 ("btrfs-progs: scrub userland implementation")
Assisted-by: Claude:claude-opus-5-5
/* The child scrubs and restores the old limits. */
for (i = 0; i < fi_args.num_devices; ++i)
sp[i].limit_changed = false;
+
+ /*
+ * The child serves the progress socket and removes it
+ * when the scrub is finished. Close the parent's copy
+ * without removing it, or nothing can connect to the
+ * child.
+ */
+ if (prg_fd > -1) {
+ close(prg_fd);
+ prg_fd = -1;
+ }
scrub_handle_sigint_parent();
pr_default("scrub %s on %s, fsid %s (pid=%d)\n",
n_start ? "started" : "resumed",