Page MenuHomeFreeBSD

D18351.id65732.diff
No OneTemporary

D18351.id65732.diff

Index: head/sys/geom/geom.h
===================================================================
--- head/sys/geom/geom.h
+++ head/sys/geom/geom.h
@@ -343,6 +343,7 @@
int g_io_getattr(const char *attr, struct g_consumer *cp, int *len, void *ptr);
int g_io_zonecmd(struct disk_zone_args *zone_args, struct g_consumer *cp);
int g_io_flush(struct g_consumer *cp);
+int g_io_speedup(size_t shortage, u_int flags, size_t *resid, struct g_consumer *cp);
int g_register_classifier(struct g_classifier_hook *hook);
void g_unregister_classifier(struct g_classifier_hook *hook);
void g_io_request(struct bio *bp, struct g_consumer *cp);
Index: head/sys/geom/geom_io.c
===================================================================
--- head/sys/geom/geom_io.c
+++ head/sys/geom/geom_io.c
@@ -340,6 +340,42 @@
return (error);
}
+/*
+ * Send a BIO_SPEEDUP down the stack. This is used to tell the lower layers that
+ * the upper layers have detected a resource shortage. The lower layers are
+ * advised to stop delaying I/O that they might be holding for performance
+ * reasons and to schedule it (non-trims) or complete it successfully (trims) as
+ * quickly as it can. bio_length is the amount of the shortage. This call
+ * should be non-blocking. bio_resid is used to communicate back if the lower
+ * layers couldn't find bio_length worth of I/O to schedule or discard. A length
+ * of 0 means to do as much as you can (schedule the h/w queues full, discard
+ * all trims). flags are a hint from the upper layers to the lower layers what
+ * operation should be done.
+ */
+int
+g_io_speedup(size_t shortage, u_int flags, size_t *resid, struct g_consumer *cp)
+{
+ struct bio *bp;
+ int error;
+
+ KASSERT((flags & (BIO_SPEEDUP_TRIM | BIO_SPEEDUP_WRITE)) != 0,
+ ("Invalid flags passed to g_io_speedup: %#x", flags));
+ g_trace(G_T_BIO, "bio_speedup(%s, %zu, %#x)", cp->provider->name,
+ shortage, flags);
+ bp = g_new_bio();
+ if (bp == NULL)
+ return (ENOMEM);
+ bp->bio_cmd = BIO_SPEEDUP;
+ bp->bio_length = shortage;
+ bp->bio_done = NULL;
+ bp->bio_flags |= flags;
+ g_io_request(bp, cp);
+ error = biowait(bp, "gflush");
+ *resid = bp->bio_resid;
+ g_destroy_bio(bp);
+ return (error);
+}
+
int
g_io_flush(struct g_consumer *cp)
{
Index: head/sys/sys/bio.h
===================================================================
--- head/sys/sys/bio.h
+++ head/sys/sys/bio.h
@@ -53,6 +53,7 @@
#define BIO_CMD1 0x07 /* Available for local hacks */
#define BIO_CMD2 0x08 /* Available for local hacks */
#define BIO_ZONE 0x09 /* Zone command */
+#define BIO_SPEEDUP 0x0a /* Upper layers face shortage */
/* bio_flags */
#define BIO_ERROR 0x01 /* An error occurred processing this bio. */
@@ -69,6 +70,9 @@
#define PRINT_BIO_FLAGS "\20\7vlist\6transient_mapping\5unmapped" \
"\4ordered\3onqueue\2done\1error"
+
+#define BIO_SPEEDUP_WRITE 0x4000 /* Resource shortage at upper layers */
+#define BIO_SPEEDUP_TRIM 0x8000 /* Resource shortage at upper layers */
#ifdef _KERNEL
struct disk;

File Metadata

Mime Type
text/plain
Expires
Sat, Jan 31, 2:47 PM (4 h, 18 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28119185
Default Alt Text
D18351.id65732.diff (2 KB)

Event Timeline