Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.
Bug 1926954 - virt-sparsify of NTFS image in-place fails with FITRIM ioctl failed: Device or resource busy
Summary: virt-sparsify of NTFS image in-place fails with FITRIM ioctl failed: Device o...
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: kernel
Version: 33
Hardware: x86_64
OS: Linux
unspecified
unspecified
Target Milestone: ---
Assignee: Kernel Maintainer List
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
: 1922857 (view as bug list)
Depends On:
Blocks: TRACKER-bugs-affecting-libguestfs 1927184
TreeView+ depends on / blocked
 
Reported: 2021-02-09 18:04 UTC by Andrew M.
Modified: 2021-04-30 21:03 UTC (History)
28 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 1927184 (view as bug list)
Environment:
Last Closed:
Type: Bug
Embargoed:


Attachments (Terms of Use)
virt-sparsify-debug.log (67.88 KB, text/plain)
2021-02-09 18:04 UTC, Andrew M.
no flags Details


Links
System ID Private Priority Status Summary Last Updated
Linux Kernel 211167 0 None None None 2021-02-09 21:33:53 UTC

Description Andrew M. 2021-02-09 18:04:36 UTC
Created attachment 1755998 [details]
virt-sparsify-debug.log

Description of problem:

Attempting to in-place sparsify an NTFS image fails.


Version-Release number of selected component (if applicable):
libguestfs-1:1.43.2-2.fc33.x86_64
libguestfs-tools-1:1.43.2-2.fc33.noarch

How reproducible:
Always


Steps to Reproduce:
1. Create NTFS qcow2 image
```
guestfish <<EOF
disk-create test.qcow2 qcow2 1G
add test.qcow2
run
part-disk /dev/sda gpt
mkfs ntfs /dev/sda1
EOF
```
2. virt-sparsify --in-place -x -v test.qcow2

(this also occurs on a qcow2 image from a clean Windows install)

Actual results:

virt-sparsify: error: libguestfs error: fstrim: fstrim: /sysroot/: FITRIM 
ioctl failed: Device or resource busy


Expected results:

Sparsify in-place operation completed with no errors


Additional info:
- Omitting `--in-place` and specifying a destination image works.
- Tested with vfat and ext4 instead of ntfs; both were successful with in-place.
- Debug log is attached
- libguestfs-test-tool reports OK

Comment 1 Richard W.M. Jones 2021-02-09 18:33:20 UTC
I can reproduce the bug.  It fails in the same way in virt-rescue too:

$ virt-rescue --ro -a test.qcow2 
><rescue> mount -o discard /dev/sda1 /sysroot/
><rescue> fstrim -v /sysroot/
fstrim: /sysroot/: FITRIM ioctl failed: Device or resource busy

Comment 2 Richard W.M. Jones 2021-02-09 18:38:07 UTC
With ntfs-3g option -o debug enabled:

unique: 4, opcode: GETATTR (3), nodeid: 1, insize: 56
   unique: 4, error: 0 (Success), outsize: 120
unique: 6, opcode: GETATTR (3), nodeid: 1, insize: 56
   unique: 6, error: 0 (Success), outsize: 120
unique: 8, opcode: GETATTR (3), nodeid: 1, insize: 56
   unique: 8, error: 0 (Success), outsize: 120
unique: 10, opcode: ACCESS (34), nodeid: 1, insize: 48
ACCESS / 00
   unique: 10, error: 0 (Success), outsize: 16
unique: 12, opcode: OPENDIR (27), nodeid: 1, insize: 48
   unique: 12, error: 0 (Success), outsize: 32
unique: 14, opcode: IOCTL (39), nodeid: 1, insize: 96
   unique: 14, error: 0 (Success), outsize: 56
fstrim: /sysroot/: FITRIM ioctl failed: Device or resource busy
unique: 16, opcode: RELEASEDIR (29), nodeid: 1, insize: 64
   unique: 16, error: 0 (Success), outsize: 16

Which makes me think the error must actually be coming from FUSE or the
host kernel.  (Note that the ioctl call succeeds according to ntfs-3g.)

Comment 4 Richard W.M. Jones 2021-02-09 21:33:54 UTC
I have bisected this in the kernel.  Please see my comments
on the upstream bug:
https://bugzilla.kernel.org/show_bug.cgi?id=211167

Comment 5 Richard W.M. Jones 2021-02-09 21:34:16 UTC
*** Bug 1922857 has been marked as a duplicate of this bug. ***

Comment 6 Andrew M. 2021-04-30 21:03:37 UTC
Upstream Kernel bug linked above indicates this is resolved, and my test case succeeds now in Fedora using Kernel 5.11.16-300.fc34.x86_64.


Note You need to log in before you can comment on or make changes to this bug.