]> granicus.if.org Git - zfs/commitdiff
OpenZFS 7531 - Assign correct flags to prefetched buffers
authorbenrubson <ben.rubson@gmail.com>
Thu, 2 Nov 2017 15:01:56 +0000 (16:01 +0100)
committerBrian Behlendorf <behlendorf1@llnl.gov>
Sun, 12 Nov 2017 04:24:34 +0000 (20:24 -0800)
Reviewed by: Matthew Ahrens <mahrens@delphix.com>
Reviewed by: Prakash Surya <prakash.surya@delphix.com>
Authored by: abraunegg <alex.braunegg@gmail.com>
Approved by: Dan McDonald <danmcd@joyent.com>
Ported-by: Brian Behlendorf <behlendorf1@llnl.gov>
OpenZFS-issue: https://www.illumos.org/issues/7531
OpenZFS-commit: https://github.com/openzfs/openzfs/commit/468008cb

include/sys/dbuf.h
module/zfs/dbuf.c

index 5ee2d9ef8a03f61a0c9cbbd4312163697c8d2ac2..633dfd25aa17834db1843bf93fe6884e4b53cd7f 100644 (file)
@@ -350,6 +350,12 @@ boolean_t dbuf_is_metadata(dmu_buf_impl_t *db);
        (dbuf_is_metadata(_db) &&                                       \
        ((_db)->db_objset->os_secondary_cache == ZFS_CACHE_METADATA)))
 
+#define        DNODE_LEVEL_IS_L2CACHEABLE(_dn, _level)                         \
+       ((_dn)->dn_objset->os_secondary_cache == ZFS_CACHE_ALL ||       \
+       (((_level) > 0 ||                                               \
+       DMU_OT_IS_METADATA((_dn)->dn_handle->dnh_dnode->dn_type)) &&    \
+       ((_dn)->dn_objset->os_secondary_cache == ZFS_CACHE_METADATA)))
+
 #ifdef ZFS_DEBUG
 
 /*
index b1e1b76228f61a59fa3050cb7bcc9e13a95205ab..64c1a68af28c1de10030a1c6b6ece696ec1c69ed 100644 (file)
@@ -2567,6 +2567,10 @@ dbuf_prefetch_indirect_done(zio_t *zio, int err, arc_buf_t *abuf, void *private)
                arc_flags_t iter_aflags = ARC_FLAG_NOWAIT;
                zbookmark_phys_t zb;
 
+               /* flag if L2ARC eligible, l2arc_noprefetch then decides */
+               if (dpa->dpa_aflags & ARC_FLAG_L2CACHE)
+                       iter_aflags |= ARC_FLAG_L2CACHE;
+
                ASSERT3U(dpa->dpa_curlevel, ==, BP_GET_LEVEL(bp));
 
                SET_BOOKMARK(&zb, dpa->dpa_zb.zb_objset,
@@ -2677,6 +2681,10 @@ dbuf_prefetch(dnode_t *dn, int64_t level, uint64_t blkid, zio_priority_t prio,
        dpa->dpa_epbs = epbs;
        dpa->dpa_zio = pio;
 
+       /* flag if L2ARC eligible, l2arc_noprefetch then decides */
+       if (DNODE_LEVEL_IS_L2CACHEABLE(dn, level))
+               dpa->dpa_aflags |= ARC_FLAG_L2CACHE;
+
        /*
         * If we have the indirect just above us, no need to do the asynchronous
         * prefetch chain; we'll just run the last step ourselves.  If we're at
@@ -2692,6 +2700,10 @@ dbuf_prefetch(dnode_t *dn, int64_t level, uint64_t blkid, zio_priority_t prio,
                arc_flags_t iter_aflags = ARC_FLAG_NOWAIT;
                zbookmark_phys_t zb;
 
+               /* flag if L2ARC eligible, l2arc_noprefetch then decides */
+               if (DNODE_LEVEL_IS_L2CACHEABLE(dn, level))
+                       iter_aflags |= ARC_FLAG_L2CACHE;
+
                SET_BOOKMARK(&zb, ds != NULL ? ds->ds_object : DMU_META_OBJSET,
                    dn->dn_object, curlevel, curblkid);
                (void) arc_read(dpa->dpa_zio, dpa->dpa_spa,