Wait ... as far as I remember, the trim command trims the whole device, not just the parts that are not allocated by the file system! I think you really don't want that. And the "permission denied" error is probably that you can't use state-changing commands on devices that have mounted file systems.
If these partitions have file systems on them, you need to do the proper trick to enable trim. For UFS, that's tunefs to enable trim (look at the man page), followed by a special command line option to fsck_ufs (again, easy to find in the manpage) that trims stuff that had been deleted earlier. For ZFS, I don't know how to do it, but I vaguely remember discussions here on the forum about it.