Bug 261731 - geom_gate needs to support BIO_ORDERED
Summary: geom_gate needs to support BIO_ORDERED
Status: New
Alias: None
Product: Base System
Classification: Unclassified
Component: kern (show other bugs)
Version: Unspecified
Hardware: Any Any
: --- Affects Only Me
Assignee: freebsd-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-02-05 08:38 UTC by Peter Jeremy
Modified: 2022-02-06 10:27 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Peter Jeremy freebsd_committer freebsd_triage 2022-02-05 08:38:12 UTC
Discussion in the thread beginning https://lists.freebsd.org/archives/freebsd-fs/2022-January/000688.html has revealed that at least UFS relies on support of BIO_ORDERED for correct operation but examination of sys/geom/gate/g_gate.c shows that geom_gate ignores BIO_ORDERED.  This could lead to potential filesystem corruption.

BIO_ORDERED forms a barrier on BIO operations: An operation marked with BIO_ORDERED must not be executed until all prior operations have been retired and no operations after that operation can commence before the BIO_ORDERED operation has been written to stable (non-volatile) storage and retired.  The requirement that the operation be written to stable storage means that the flag must be forwarded to the userland daemon for handling.

There are no other bio_flags that appear to need explicit support within geom_gate.

Fixing this bug therefore requires:
1) An enhancement to struct g_gate_ctl_io to support passing BIO_ORDERED to userland.  This could be achieved by:
   a) Adding a new field.  This would not change the structure size on 64-bit architectures.
   b) Split the existing gctl_cmd field into 2 uint16_t fields (which matches struct bio).  This would not change the structure size.
   c) Treating BIO_ORDERED as a flag that can be OR'd into the existing gctl_cmd field.  This would not change the structure size.
2) Updating userland geom_gate clients, their network protocols and peer daemons.  Within the base system, the clients are hastd, ggatec and ggatel.