Print this page
3741 zfs needs better comments
Submitted by:   Will Andrews <willa@spectralogic.com>
Submitted by:   Justin Gibbs <justing@spectralogic.com>
Submitted by:   Alan Somers <alans@spectralogic.com>
Reviewed by:    Matthew Ahrens <mahrens@delphix.com>

@@ -46,15 +46,15 @@
 uint32_t        zfetch_block_cap = 256;
 /* number of bytes in a array_read at which we stop prefetching (1Mb) */
 uint64_t        zfetch_array_rd_sz = 1024 * 1024;
 
 /* forward decls for static routines */
-static int              dmu_zfetch_colinear(zfetch_t *, zstream_t *);
+static boolean_t        dmu_zfetch_colinear(zfetch_t *, zstream_t *);
 static void             dmu_zfetch_dofetch(zfetch_t *, zstream_t *);
 static uint64_t         dmu_zfetch_fetch(dnode_t *, uint64_t, uint64_t);
 static uint64_t         dmu_zfetch_fetchsz(dnode_t *, uint64_t, uint64_t);
-static int              dmu_zfetch_find(zfetch_t *, zstream_t *, int);
+static boolean_t        dmu_zfetch_find(zfetch_t *, zstream_t *, int);
 static int              dmu_zfetch_stream_insert(zfetch_t *, zstream_t *);
 static zstream_t        *dmu_zfetch_stream_reclaim(zfetch_t *);
 static void             dmu_zfetch_stream_remove(zfetch_t *, zstream_t *);
 static int              dmu_zfetch_streams_equal(zstream_t *, zstream_t *);
 

@@ -102,13 +102,13 @@
  * In other words: if we find two sequential access streams that are
  * the same length and distance N appart, and this read is N from the
  * last stream, then we are probably in a strided access pattern.  So
  * combine the two sequential streams into a single strided stream.
  *
- * If no co-linear streams are found, return NULL.
+ * Returns whether co-linear streams were found.
  */
-static int
+static boolean_t
 dmu_zfetch_colinear(zfetch_t *zf, zstream_t *zh)
 {
         zstream_t       *z_walk;
         zstream_t       *z_comp;
 

@@ -324,11 +324,11 @@
 /*
  * given a zfetch and a zstream structure, see if there is an associated zstream
  * for this block read.  If so, it starts a prefetch for the stream it
  * located and returns true, otherwise it returns false
  */
-static int
+static boolean_t
 dmu_zfetch_find(zfetch_t *zf, zstream_t *zh, int prefetched)
 {
         zstream_t       *zs;
         int64_t         diff;
         int             reset = !prefetched;

@@ -637,11 +637,11 @@
 void
 dmu_zfetch(zfetch_t *zf, uint64_t offset, uint64_t size, int prefetched)
 {
         zstream_t       zst;
         zstream_t       *newstream;
-        int             fetched;
+        boolean_t       fetched;
         int             inserted;
         unsigned int    blkshft;
         uint64_t        blksz;
 
         if (zfs_prefetch_disable)

@@ -663,11 +663,12 @@
         fetched = dmu_zfetch_find(zf, &zst, prefetched);
         if (fetched) {
                 ZFETCHSTAT_BUMP(zfetchstat_hits);
         } else {
                 ZFETCHSTAT_BUMP(zfetchstat_misses);
-                if (fetched = dmu_zfetch_colinear(zf, &zst)) {
+                fetched = dmu_zfetch_colinear(zf, &zst);
+                if (fetched) {
                         ZFETCHSTAT_BUMP(zfetchstat_colinear_hits);
                 } else {
                         ZFETCHSTAT_BUMP(zfetchstat_colinear_misses);
                 }
         }