[Bug 261731] geom_gate needs to support BIO_ORDERED

From: <bugzilla-noreply_at_freebsd.org>
Date: Sat, 05 Feb 2022 08:38:12 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=261731

            Bug ID: 261731
           Summary: geom_gate needs to support BIO_ORDERED
           Product: Base System
           Version: Unspecified
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: kern
          Assignee: bugs@FreeBSD.org
          Reporter: peterj@FreeBSD.org

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.

-- 
You are receiving this mail because:
You are the assignee for the bug.