Enabling TRIM/discard on external SSD

I have a usb nvme enclosure (SSK, JMicron, 152d:0562)
By default, I can’t use fstrim on it – but there’s a workaround described here.
tl;dr: set provisioning_mode for the corresponding scsi_disk to unmap.

This used to work for me with a udev rule:
ACTION=="add|change", ATTRS{idVendor}=="152d", ATTRS{idProduct}=="0562", SUBSYSTEM=="scsi_disk", ATTR{provisioning_mode}="unmap"

For whatever reason, this is not working anymore. After reading some udev docs, I have a suspicion that udisks is messing this up for me – but it might be a red herring.. Figured it’s easier to just ask here.

Note: used to work on Fedora 30-something series; now on 41 and it’s not working

The jMicron bridge chip 152:562 may not longer be supported. I am using a JMicron 152:580.

JMicron bridge JMS56x series (152d:0562) not supported

That ticket is talking about smartctl functionality. While I’m not happy that it’s not supported, my question is about why my udev rule doesn’t apply.

I forgot to add that I’m able to manually write unmap to the attr:
echo unmap > /sys/devices/pci0000:00/0000:00:14.0/usb3/3-1/3-1:1.0/host6/target6:0:0/6:0:0:0/scsi_disk/6:0:0:0/provisioning_mode – and that makes fstrim work.
This is more or less what I want – except I want this attr to apply automatically when I plug in the device. That’s why I was using udev rule for this..

My JMicron bridge chip 152:580 is old but the 152:562 is really really old.

I don’t know if JMicron supplies support to the Fedora community and I also don’t know if the JMicron 152:560 has reached EOL.

Be that as it may, what’s preventing my udev rule from working?
As I was saying, manually updating the attribute works just fine.

My rule in /etc/rules.d works and it seems similar to what you described where yours has “562” and mine has “580”.

Perhaps Udisks is causing the problem but I cannot comment on that.

I figured it out: I apparently named my new rules file as .conf instead of .rules :person_facepalming:

Sometimes another pair of eyes can be helpful. Glad you got it working.