Re: [PATCH] f2fs: sync pending discards before reserving device alias

From: Wenjie Qi

Date: Fri Aug 28 2026 - 23:18:43 EST


Hi Daeho,

Thanks for the review.

I agree that walking the range block by block is too expensive. I have
reworked v3 to walk overlapping discard commands, cancel prepared
intervals in bulk, and wait for each submitted command only once.

Regarding the synchronization point, my understanding of the documented
ownership model is:

- reserve: In-service to Aliased, handing the range to external use
- release: Aliased to In-service, returning the range to F2FS allocation

Therefore, external raw-device I/O should stop before release and start
again only after reserve succeeds. While the range is released and owned
by F2FS, normal block allocation already waits for a pending discard
before reusing each block.

Also, cleaning the range only after the release checkpoint would not
cover new discard commands generated while F2FS owns the range before a
later reserve. For that reason, v3 keeps the final range synchronization
under sentry_lock at the reserve boundary, before marking the range
valid.

I have sent v3 separately with the command-range implementation. Does
this match the intended ownership contract?

Thanks,
Wenjie