Increase accuracy of disk utility percentage
[fio.git] / engines / solarisaio.c
index b519fc54339b0ddde7fb3192db3b6afda9d9d64c..a48ec41825b67ceae574682ba73cc545bcd9156e 100644 (file)
@@ -69,15 +69,11 @@ static void wait_for_event(struct timeval *tv)
         * the ->aio_pending store is seen after the ->aio_events store
         */
        sd->aio_events[sd->aio_pending] = io_u;
+       write_barrier();
        sd->aio_pending++;
        sd->nr--;
 }
 
-static void fio_solarisaio_sigio(int sig)
-{
-       wait_for_event(NULL);
-}
-
 static int fio_solarisaio_getevents(struct thread_data *td, unsigned int min,
                                    unsigned int max, struct timespec *t)
 {
@@ -97,10 +93,10 @@ static int fio_solarisaio_getevents(struct thread_data *td, unsigned int min,
                wait_for_event(&tv);
 
        /*
-        * Needs locking here for SIGIO
+        * should be OK without locking, as int operations should be atomic
         */
        ret = sd->aio_pending;
-       sd->aio_pending = 0;
+       sd->aio_pending -= ret;
        return ret;
 }
 
@@ -161,20 +157,24 @@ static void fio_solarisaio_cleanup(struct thread_data *td)
 }
 
 /*
- * Set USE_SIGNAL_COMPLETIONS to use SIGIO as completion events. Needs
- * locking around ->aio_pending and ->aio_events, see comment
+ * Set USE_SIGNAL_COMPLETIONS to use SIGIO as completion events.
  */
+#ifdef USE_SIGNAL_COMPLETIONS
+static void fio_solarisaio_sigio(int sig)
+{
+       wait_for_event(NULL);
+}
+
 static void fio_solarisaio_init_sigio(void)
 {
-#ifdef USE_SIGNAL_COMPLETIONS
        struct sigaction act;
 
        memset(&act, 0, sizeof(act));
        act.sa_handler = fio_solarisaio_sigio;
        act.sa_flags = SA_RESTART;
        sigaction(SIGIO, &act, NULL);
-#endif
 }
+#endif
 
 static int fio_solarisaio_init(struct thread_data *td)
 {
@@ -193,7 +193,9 @@ static int fio_solarisaio_init(struct thread_data *td)
        memset(sd->aio_events, 0, max_depth * sizeof(struct io_u *));
        sd->max_depth = max_depth;
 
+#ifdef USE_SIGNAL_COMPLETIONS
        fio_solarisaio_init_sigio();
+#endif
 
        td->io_ops->data = sd;
        return 0;
@@ -211,6 +213,7 @@ static struct ioengine_ops ioengine = {
        .cleanup        = fio_solarisaio_cleanup,
        .open_file      = generic_open_file,
        .close_file     = generic_close_file,
+       .get_file_size  = generic_get_file_size,
 };
 
 #else /* FIO_HAVE_SOLARISAIO */