Replies to BOTH of your emails are below.  Links to new output are at
the very bottom.


On Tue, Jan 8, 2019 at 4:04 AM Jean-Pierre André
<jean-pierre.an...@wanadoo.fr> wrote:
>
> 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.
> [...]
> 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.

Understood, thanks for mentioning.  I'm thinking fstrim with btrfs
would probably act the same way.  I don't think btrfs is aware of
what's allocated on an underlying LVM thin volume, so I think however
LVM handles this is OK.

> > 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.

That's totally fine by me.

Arch uses the source from here:
https://tuxera.com/opensource/ntfs-3g_ntfsprogs-2017.3.23.tgz

The only modification Arch makes is applying your patch "[PATCH]
Stopped checking matches of MFTMirr against MFT at record 16" visible
here: 
https://git.archlinux.org/svntogit/packages.git/tree/trunk/mftmirr.patch?h=packages/ntfs-3g

The steps Arch uses to make the package are visible here:
https://git.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/ntfs-3g

An Arch PKGBUILD is easily read like a bash script, and its build
system call the provided bash functions "prepare()", "build()", and
"package_ntfs-3g()".

If you send any patches, please let me know if you'd like me to apply
them on top of this released source, or if you'd like me to use a
developmental version, such as from a git (or other VCS) repo.  If a
developmental version, please let me know where it's at.  I couldn't
find a repo for ntfs-3g.  And, if any of the developmental version
commits require a change in the build process.

On Tue, Jan 8, 2019 at 5:39 AM Jean-Pierre André
<jean-pierre.an...@wanadoo.fr> wrote:
>
> More on this :
>
> Jean-Pierre André wrote:
> > james harvey wrote:
>
> [...]
>
> > 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.
>
> Actually this is correct : ntfs-3g receive a path to a file
> or directory and it translates the path to the underlying
> device . This underlying device has to be a block device
> (nevertheless "/mnt/ntf" is unexpected).
>
> So what does "stat /dev/lvm/ntfs" return ?

# stat /dev/lvm/ntfs
  File: /dev/lvm/ntfs -> ../dm-12
  Size: 8               Blocks: 0          IO Block: 4096   symbolic link
Device: 6h/6d   Inode: 19698944    Links: 1
Access: (0777/lrwxrwxrwx)  Uid: (    0/    root)   Gid: (    0/    root)
Access: 2019-01-08 19:24:02.738191553 -0500
Modify: 2019-01-08 19:24:02.738191553 -0500
Change: 2019-01-08 19:24:02.738191553 -0500
 Birth: -

$ ls -la /dev/mapper/ | grep dm-12
lrwxrwxrwx  1 root root        8 Jan  8 19:24 lvm-ntfs -> ../dm-12

# stat /dev/dm-12
  File: /dev/dm-12
  Size: 0               Blocks: 0          IO Block: 4096   block special file
Device: 6h/6d   Inode: 19689157    Links: 1     Device type: fe,c
Access: (0660/brw-rw----)  Uid: (    0/    root)   Gid: (  994/    disk)
Access: 2019-01-08 19:44:59.103746094 -0500
Modify: 2019-01-08 19:44:59.103746094 -0500
Change: 2019-01-08 19:44:59.103746094 -0500
 Birth: -

I initially hoped this has shed light on what was causing the problem,
as LVM uses device mapper and then creates symlinks to them using the
user-provided names.

Unfortunately, mounting "/dev/dm-12" instead of "/dev/lvm/ntfs" still
failed.  Links to the mounting and strace output are below in the next
sectional reply, both for using "/dev/lvm/ntfs" and "/dev/dm-12".

> > 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).
>
> Actually there is a bug in ntfs-3g leading to the result
> of ioctl() not to be logged. Use lowntfs-3g instead :
>
> lowntfs-3g -o debug /dev/lvm/ntfs /tmp/ntfs 2> ntfslog
> strace fstrim -v /tmp/ntfs
> umount /tmp/ntfs

Sure, sorry for any confusion from my original message.  From scratch:

# lvcreate --virtualsize 10G --thin lvm/thinpool --name ntfs
  Logical volume "ntfs" created.
# mkfs.ntfs /dev/lvm/ntfs
Cluster size has been automatically set to 4096 bytes.
Initializing device with zeroes: 100% - Done.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.
# mkdir /tmp/ntfs
# lowntfs-3g -o debug /dev/lvm/ntfs /tmp/ntfs 2> ntfslog
# strace fstrim -v /tmp/ntfs 2> strace.fstrim
# umount /tmp/ntfs
$ cat ntfslog | netcat termbin.com 9999
https://termbin.com/bo5n
$ cat strace.fstrim | netcat termbin.com 9999
https://termbin.com/sbnm
# ntfs-3g -o debug /dev/dm-12 /tmp/ntfs 2> ntfslog.dm
# strace fstrim -v /tmp/ntfs 2> strace.fstrim.dm
# umount /tmp/ntfs
$ cat ntfslog.dm | netcat termbin.com 9999
https://termbin.com/8yf9l
$ cat strace.fstrim.dm | netcat termbin.com 9999
https://termbin.com/defd2


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

Reply via email to