Skip to content

Commit

Permalink
bios: Don't keep sending BIO_FLUSH after first ENOTSUPP.
Browse files Browse the repository at this point in the history
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: #710
  • Loading branch information
santhoshkumar-mani authored and bsdimp committed Jul 1, 2023
1 parent 6f9388d commit d3eb9d3
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sys/geom/geom_disk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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*/
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit d3eb9d3

Please sign in to comment.