Package: release.debian.org
Severity: normal
Tags: trixie
X-Debbugs-Cc: [email protected]
Control: affects -1 + src:xfsprogs
User: [email protected]
Usertags: pu

[ Reason ]
Fix #1149535, which documents a deadlock, by applying an upstream commit.

[ Impact ]
The parent waits for lsblk to terminate before consuming stdout. If lsblk
produces enough JSON output to fill the pipe, lsblk blocks waiting for the
parent to consume stdout, while the parent blocks waiting for lsblk to exit.

[ Tests ]
I have only compiled the package and have started xfs_scrub_all once.

[ Risks ]
Code is a 6-line change that gets rid of the wait()

[ Checklist ]
  [x] *all* changes are documented in the d/changelog
  [x] I reviewed all changes and I approve them
  [x] attach debdiff against the package in (old)stable
  [x] the issue is verified as fixed in unstable

[ Changes ]
Applies one upstream commit that was identified by the reporter to fix
the deadlock issue.
diff -Nru xfsprogs-6.13.0/debian/changelog xfsprogs-6.13.0/debian/changelog
--- xfsprogs-6.13.0/debian/changelog    2026-03-04 12:28:29.000000000 +0100
+++ xfsprogs-6.13.0/debian/changelog    2026-09-30 16:16:52.000000000 +0200
@@ -1,3 +1,10 @@
+xfsprogs (6.13.0-2+deb13u2) trixie; urgency=medium
+
+  * Apply upstream patch (Closes: #1149535):
+    "xfs_scrub_all: fix deadlock if lsblk produces a lot of output"
+
+ -- Bastian Germann <[email protected]>  Wed, 30 Sep 2026 16:16:52 +0200
+
 xfsprogs (6.13.0-2+deb13u1) trixie; urgency=medium
 
   * xfs_scrub_fail: reduce security lockdowns to avoid postfix problems
diff -Nru xfsprogs-6.13.0/debian/patches/series 
xfsprogs-6.13.0/debian/patches/series
--- xfsprogs-6.13.0/debian/patches/series       2026-03-04 12:28:29.000000000 
+0100
+++ xfsprogs-6.13.0/debian/patches/series       2026-09-30 16:14:42.000000000 
+0200
@@ -1,3 +1,4 @@
 mkfs-Correct-filesize-declaration.patch
 xfs_scrub_fail-reduce-security-lockdowns.patch
 reduce-security-lockdowns-to-avoid-postfix-problems.patch
+xfs_scrub_all-fix-deadlock.patch
diff -Nru xfsprogs-6.13.0/debian/patches/xfs_scrub_all-fix-deadlock.patch 
xfsprogs-6.13.0/debian/patches/xfs_scrub_all-fix-deadlock.patch
--- xfsprogs-6.13.0/debian/patches/xfs_scrub_all-fix-deadlock.patch     
1970-01-01 01:00:00.000000000 +0100
+++ xfsprogs-6.13.0/debian/patches/xfs_scrub_all-fix-deadlock.patch     
2026-09-30 16:16:08.000000000 +0200
@@ -0,0 +1,48 @@
+Origin: upstream, 1c52b36e3234aedaaa4b467f64c01636e96c1946
+From: "Darrick J. Wong" <[email protected]>
+Date: Thu, 30 Apr 2026 08:54:06 -0700
+Subject: xfs_scrub_all: fix deadlock if lsblk produces a lot of output
+
+Patrick Fischer reported a deadlock in find_mounts() that is the result
+of lsblk producing so much output that it fills the pipe buffer.  When
+this happens, lsblk blocks on write()ing the pipe, at which point
+waiting for lsblk to exit will also block forever.
+
+Now that we can be reasonably assured that everyone has Python 3.5
+(because RHEL6 is long dead), we can replace this whole mess with a call
+to subprocess.run that captures the output.  The json library can
+convert a byte array directly to a python dict, which means we don't
+need to concatenate iterated lines or any of that stuff anymore.
+
+Reported-by: [email protected]
+Link: 
https://lore.kernel.org/linux-xfs/[email protected]/
+Cc: <[email protected]> # v4.15.0
+Fixes: f1dca11cad1308 ("xfs_scrub: create a script to scrub all xfs 
filesystems")
+Signed-off-by: "Darrick J. Wong" <[email protected]>
+Reviewed-by: Andrey Albershteyn <[email protected]>
+---
+--- a/scrub/xfs_scrub_all.in
++++ b/scrub/xfs_scrub_all.in
+@@ -53,15 +53,16 @@ def find_mounts():
+ 
+       fs = {}
+       cmd=['lsblk', '-o', 'NAME,KNAME,TYPE,FSTYPE,MOUNTPOINT', '-J']
+-      result = subprocess.Popen(cmd, stdout=subprocess.PIPE)
+-      result.wait()
+-      if result.returncode != 0:
++      try:
++              proc = subprocess.run(cmd, capture_output = True, text = True, 
check = True)
++      except Exception as e:
++              print(e)
++              return fs
++      if proc.returncode != 0:
+               return fs
+-      sarray = [x.decode(sys.stdout.encoding) for x in 
result.stdout.readlines()]
+-      output = ' '.join(sarray)
+-      bdevdata = json.loads(output)
+ 
+       # The lsblk output had better be in disks-then-partitions order
++      bdevdata = json.loads(proc.stdout)
+       for bdev in bdevdata['blockdevices']:
+               lastdisk = bdev['kname']
+               find_xfs_mounts(bdev, fs, lastdisk)

Reply via email to