james harvey wrote:
Running ntfs-3g 2017.3.23 on Arch Linux.  fstrim (util-linux) 2.33.

I see ntfs-3g gained discard support quite some time ago, but haven't
been able to get it to work.
[...]

# umount /mnt
# lvcreate --virtualsize 10G --thin lvm/thinpool --name ntfs
# mkfs.ntfs /dev/lvm/ntfs
# mount /dev/lvm/ntfs /mnt
# fstrim -v /mnt/ntfs
fstrim: /mnt: the discard operation is not supported

strace shows it's running ioctl(3, FITRIM...) and getting "-1
EOPNOTSUPP (Operation not supported)".  You can see one of the straces
I ran here: https://termbin.com/zhzu
In the trace, I see :

openat(AT_FDCWD, "/mnt/ntf", O_RDONLY)  = 3
fstat(3, {st_mode=S_IFDIR|0777, st_size=4096, ...}) = 0
ioctl(3, FITRIM, {start=0, len=0xffffffffffffffff, minlen=0}) = -1 EOPNOTSUPP 
(Operation not supported)

This surprises me, because the volume is apparently
open as "/mnt/ntf" (not /mnt/ntfs), moreover this
designates a directory (st_mode=S_IFDIR|0777), not
a block device, as ntfs-3g expects.

Would you please try having some control on what is
requested from ntfs-3g, first by defining an explicit
mount point :

mkdir /tmp/ntfs
ntfs-3g /dev/lvm/ntfs /tmp/ntfs
strace fstrim -v /tmp/ntfs
umount /tmp/ntfs

Moreover, to be sure that the mentioned error is
issued by ntfs-3g (rather than ntfs-3g forwarding an
error received from a lower layer), please record the
calls to ntfs-3g :

ntfs-3g -o debug /dev/lvm/ntfs /tmp/ntfs 2> ntfslog
strace fstrim -v /tmp/ntfs
umount /tmp/ntfs
(and make ntfslog available).

Also, on a thin device, I do not know how lvm reacts
to trimming a block which does not exist. ntfs-3g
forwards the trimming request irrespective of block
allocations on a thin device.
It's because of this ioctl that I'm starting here rather than
util-linux.  It makes me think "fstrim" is at least attempting to give
"ntfs-3g" the trim command.

I saw that ntfs-3g doesn't support old Windows (before ~2008)
partitions.

Where did you get this from ? ntfs-3g is supposed to
support all ntfs partitions since NT4.

Note : I personally do not have any ssd and I do not
use lvm, so I will have to rely on you for tests, and to
do that you may have to compile ntfs-3g with some
patches.




_______________________________________________
ntfs-3g-devel mailing list
ntfs-3g-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ntfs-3g-devel

Reply via email to