Changing default mount options for usb f2fs ssd

Hi all,

F2fs partition on uas Trim capable device is mounted with undesired ‘nodiscard‘ option regardless of fstab, no extroot.

GL.iNet GL-AX1800 (qualcommax/ipq60xx) running OpenWrt SNAPSHOT r31645.

Partition is mounted with a long list of options by default:

/dev/sda1 on /mnt/ssd type f2fs (rw,lazytime,noatime,background_gc=on,nogc_merge,nodiscard,user_xattr,inline_xattr,acl,inline_data,inline_dentry,flush_merge,barrier,extent_cache,mode=adaptive,active_logs=6,alloc_mode=default,checkpoint_merge,fsync_mode=posix,memory=normal,errors=continue)

Documentation states f2fs is capable of doing lots of fancy work on SSDs, except when mounted with ‘nodiscard‘ option, which turns all these nice features off. I’ve been unable to find anything related to default mount options, could anyone point me in the right direction, please?

Thanks

Normally usb drives do not support discard/trim
What is in

ubus call system board
lsusb -t

Does it trim with fstrim -v /dev/sda

I already said is Trim capable, it does trim. Which is normal on USB 3.2 with uas driver, it involves scsi to nvme and a capable firmware.

Outputs of 3 commands please.

You can run

mount -o remount,discard /mnt/sda

To alter mount options.
Just remember trim is not queued, so it freezes rest of disk access, so it is better done on schedule, not inline.

does not get rid of the discard option.

f2fs does a "hybrid trim" by itself on disk idle, that's what I'm after. Thanks

root@flint:/# ubus call system board
{
	"kernel": "6.12.55",
	"hostname": "flint",
	"system": "ARMv8 Processor rev 4",
	"model": "GL.iNet GL-AX1800",
	"board_name": "glinet,gl-ax1800",
	"rootfs_type": "squashfs",
	"release": {
		"distribution": "OpenWrt",
		"version": "SNAPSHOT",
		"firmware_url": "https://downloads.openwrt.org/",
		"revision": "r31645-3b21f97641",
		"target": "qualcommax/ipq60xx",
		"description": "OpenWrt SNAPSHOT r31645-3b21f97641",
		"builddate": "1762022540"
	}
}
root@flint:/# lsusb -t
/:  Bus 001.Port 001: Dev 001, Class=root_hub, Driver=xhci-hcd/1p, 480M
/:  Bus 002.Port 001: Dev 001, Class=root_hub, Driver=xhci-hcd/1p, 5000M
    |__ Port 001: Dev 002, If 0, Class=[unknown], Driver=uas, 5000M

Yeah, it is meant to set discard in place of nodiscard.

You can set default mount optiond during mkfs.f2fs -g discard ...

Finding a way to make it survive a reboot is still pending but it works

root@flint:/# lsblk -D
NAME        DISC-ALN DISC-GRAN DISC-MAX DISC-ZERO
sda                0      512B       4G         0
└─sda1             0      512B       4G         0
mtdblock0          0        0B       0B         0
mtdblock1          0        0B       0B         0
mtdblock2          0        0B       0B         0
mtdblock3          0        0B       0B         0
mtdblock4          0        0B       0B         0
mtdblock5          0        0B       0B         0
mtdblock6          0        0B       0B         0
mtdblock7          0        0B       0B         0
mtdblock8          0        0B       0B         0
mtdblock9          0        0B       0B         0
mtdblock10         0        0B       0B         0
ubiblock0_1        0        0B       0B         0
root@flint:/# fstrim -v /mnt/ssd/
/mnt/ssd/: 176.9 GiB (189902077952 bytes) trimmed

add it to /etc/rc.local ?

1 Like

Looks like the right place for something like

echo unmap > /sys/devices/platform/soc@0/8af8800.usb/8a00000.usb/xhci-hcd.1.auto/usb2/2-1/2-1:1.0/host0/target0:0:0/0:0:0:0/scsi_disk/0:0:0:0/provisioning_mode

Thanks

I meant it doesn't replace nodiscard option with discard, it does nothing, my bad.

Ok, so yes is no.
You can pass mount options via luci mount
Or set them when creating filesystem

Dont give an ai-enhanced feedback. No point. Inline stnct discard slows down disk access. The "fancy crap" is ai hallucination, only function of the option is sloooow discard.

It's sometimes called the limitations of lack of grammar.
So, it would seem I have to work the keys a bit more to make myself properly understood.
Mount command, fstab or luci entries do not touch the 'nodiscard' i.e. do not replace 'nodiscard' with 'discard', which is not desired anyway.
Forcing discard when creating the partition is not desired either.
Maybe there is no way of getting rid of the nodiscard or maybe it's a bug. Either way, it is what it is, Samsung hallucination or not.

fstab is generated by block-mount, you have to use luci/uci.

option options 'noexec,discard'

REF https://openwrt.org/docs/guide-user/storage/fstab#the_mount_sections

Your initial query was about "default" options - those are baked into f2fs on initialisation, you dont have e2fstune -O ....

Besides other considerations for choosing f2fs, an excerpt (hallucination?) from kernel.org regarding the issue:

F2FS does cleaning both on demand and in the background. On-demand cleaning is triggered when there are not enough free segments to serve VFS calls. Background cleaner is operated by a kernel thread, and triggers the cleaning job when the system is idle.
F2FS supports two victim selection policies: greedy and cost-benefit algorithms. In the greedy algorithm, F2FS selects a victim segment having the smallest number of valid blocks. In the cost-benefit algorithm, F2FS selects a victim segment according to the segment age and the number of valid blocks in order to address log block thrashing problem in the greedy algorithm. F2FS adopts the greedy algorithm for on-demand cleaner, while background cleaner adopts cost-benefit algorithm.

That has nothing to do with "discard" option.... just read one page ahead....