The unified diff between revisions [1b553632..] and [2f19ac58..] is displayed below. It can also be downloaded as a raw diff.

This diff has been restricted to the following files: 'src/store_io.c'

#
#
# patch "src/store_io.c"
#  from [b3189954bb7b33712f066ccf62783d2b0506f710]
#    to [8a31eb00c0678314dbf38b0fa41d2bbd3f96f3b9]
#
============================================================
--- src/store_io.c	b3189954bb7b33712f066ccf62783d2b0506f710
+++ src/store_io.c	8a31eb00c0678314dbf38b0fa41d2bbd3f96f3b9
@@ -7,6 +7,12 @@ static struct {
 	int create_fail;
 	int success;
     } create;
+    struct {
+        int calls;
+        int success;
+        int open_fail;
+        int loadav_fail;
+    } open;
 } store_io_stats;

 OBJH storeIOStats;
@@ -61,8 +67,23 @@ storeOpen(StoreEntry * e, STFNCB * file_
 storeOpen(StoreEntry * e, STFNCB * file_callback, STIOCB * callback,
     void *callback_data)
 {
+    int load;
+    storeIOState *sio;
+
     SwapDir *SD = &Config.cacheSwap.swapDirs[e->swap_dirn];
-    return SD->obj.open(SD, e, file_callback, callback, callback_data);
+    store_io_stats.open.calls++;
+    load = SD->checkload(SD, ST_OP_OPEN);
+    if (load < 0 || load > 1000) {
+        store_io_stats.open.loadav_fail++;
+        return NULL;
+    }
+    sio = SD->obj.open(SD, e, file_callback, callback, callback_data);
+    if (sio == NULL) {
+        store_io_stats.open.open_fail++;
+    } else {
+        store_io_stats.open.success++;
+    }
+    return sio;
 }

 void
@@ -114,4 +135,8 @@ storeIOStats(StoreEntry * sentry)
     storeAppendPrintf(sentry, "create.select_fail %d\n", store_io_stats.create.select_fail);
     storeAppendPrintf(sentry, "create.create_fail %d\n", store_io_stats.create.create_fail);
     storeAppendPrintf(sentry, "create.success %d\n", store_io_stats.create.success);
+    storeAppendPrintf(sentry, "open.calls %d\n", store_io_stats.open.calls);
+    storeAppendPrintf(sentry, "open.success %d\n", store_io_stats.open.success);
+    storeAppendPrintf(sentry, "open.loadav_fail %d\n", store_io_stats.open.loadav_fail);
+    storeAppendPrintf(sentry, "open.open_fail %d\n", store_io_stats.open.open_fail);
 }