The branch main has been updated by imp:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=d3eb9d3db3aa36df13f96c48bff8acdf626464c5

commit d3eb9d3db3aa36df13f96c48bff8acdf626464c5
Author:     santhoshkumar-mani <[email protected]>
AuthorDate: 2023-07-01 17:11:57 +0000
Commit:     Warner Losh <[email protected]>
CommitDate: 2023-07-01 17:14:49 +0000

    bios: Don't keep sending BIO_FLUSH after first ENOTSUPP.
    
    When a storage device reports that it does not support cache flush, the
    GEOM disk layer by default returns ENOTSUPP in response to a BIO_FLUSH
    command.
    
    On AWS, local volumes do not advertise themselves as having write-cache
    enabled.  When they are selected for L3 on all HDD nodes, the L3
    subsystem may inadvertently kick these L3 devices if a BIO_FLUSH command
    fails with an ENOTSUPP return code.  The fix is to make GEOM disk return
    success (0) when this condition occurs and add a sysctl to make this
    error handling config-driven
    
    Reviewed by: imp
    Pull Request: https://github.com/freebsd/freebsd-src/pull/710
---
 sys/geom/geom_disk.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sys/geom/geom_disk.c b/sys/geom/geom_disk.c
index 90fe0216dd8b..a000dfe6c4f2 100644
--- a/sys/geom/geom_disk.c
+++ b/sys/geom/geom_disk.c
@@ -71,6 +71,7 @@ struct g_disk_softc {
        char                    led[64];
        uint32_t                state;
        struct mtx               done_mtx;
+       bool                    flush_notsup_succeed;
 };
 
 static g_access_t g_disk_access;
@@ -539,7 +540,7 @@ g_disk_start(struct bio *bp)
                g_trace(G_T_BIO, "g_disk_flushcache(%s)",
                    bp->bio_to->name);
                if (!(dp->d_flags & DISKFLAG_CANFLUSHCACHE)) {
-                       error = EOPNOTSUPP;
+                       error = (sc->flush_notsup_succeed) ? 0 : EOPNOTSUPP;
                        break;
                }
                /*FALLTHROUGH*/
@@ -760,6 +761,10 @@ g_disk_create(void *arg, int flag)
                    SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, "flags",
                    CTLTYPE_STRING | CTLFLAG_RD | CTLFLAG_MPSAFE, dp, 0,
                    g_disk_sysctl_flags, "A", "Report disk flags");
+               SYSCTL_ADD_BOOL(&sc->sysctl_ctx,
+                   SYSCTL_CHILDREN(sc->sysctl_tree), OID_AUTO, 
"flush_notsup_succeed",
+                   CTLFLAG_RWTUN, &sc->flush_notsup_succeed, 
sizeof(sc->flush_notsup_succeed),
+                   "Do not return EOPNOTSUPP if there is no cache to flush");
        }
        pp->private = sc;
        dp->d_geom = gp;

Reply via email to