Skip to content

Commit 26a453f

Browse files
committed
Adressing some recent review feedback.
Signed-off-by: Don Brady <[email protected]>
1 parent 6a18dd9 commit 26a453f

File tree

3 files changed

+18
-29
lines changed

3 files changed

+18
-29
lines changed

include/sys/arc.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ extern "C" {
6363
(hdr)->b_psize = ((x) >> SPA_MINBLOCKSHIFT); \
6464
} while (0)
6565

66-
/* The asize in the header is only used by L2 cache */
67-
#define HDR_SET_ASIZE(hdr, x) do { \
66+
/* The l2size in the header is only used by L2 cache */
67+
#define HDR_SET_L2SIZE(hdr, x) do { \
6868
ASSERT(IS_P2ALIGNED((x), 1U << SPA_MINBLOCKSHIFT)); \
69-
(hdr)->b_asize = ((x) >> SPA_MINBLOCKSHIFT); \
69+
(hdr)->b_l2size = ((x) >> SPA_MINBLOCKSHIFT); \
7070
} while (0)
7171

7272
#define HDR_GET_LSIZE(hdr) ((hdr)->b_lsize << SPA_MINBLOCKSHIFT)
7373
#define HDR_GET_PSIZE(hdr) ((hdr)->b_psize << SPA_MINBLOCKSHIFT)
74-
#define HDR_GET_ASIZE(hdr) ((hdr)->b_asize << SPA_MINBLOCKSHIFT)
74+
#define HDR_GET_L2SIZE(hdr) ((hdr)->b_l2size << SPA_MINBLOCKSHIFT)
7575

7676
typedef struct arc_buf_hdr arc_buf_hdr_t;
7777
typedef struct arc_buf arc_buf_t;

include/sys/arc_impl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ struct arc_buf_hdr {
476476
arc_buf_contents_t b_type;
477477
uint8_t b_complevel;
478478
uint8_t b_reserved1; /* used for 4 byte alignment */
479-
uint16_t b_asize; /* alignment or L2-only asize */
479+
uint16_t b_l2size; /* alignment or L2-only size */
480480
arc_buf_hdr_t *b_hash_next;
481481
arc_flags_t b_flags;
482482

module/zfs/arc.c

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,7 +1728,7 @@ arc_buf_try_copy_decompressed_data(arc_buf_t *buf)
17281728
*/
17291729
static arc_buf_hdr_t *
17301730
arc_buf_alloc_l2only(size_t size, arc_buf_contents_t type, l2arc_dev_t *dev,
1731-
dva_t dva, uint64_t daddr, int32_t psize, uint64_t birth,
1731+
dva_t dva, uint64_t daddr, int32_t psize, uint64_t asize, uint64_t birth,
17321732
enum zio_compress compress, uint8_t complevel, boolean_t protected,
17331733
boolean_t prefetch, arc_state_type_t arcs_state)
17341734
{
@@ -1744,7 +1744,7 @@ arc_buf_alloc_l2only(size_t size, arc_buf_contents_t type, l2arc_dev_t *dev,
17441744
arc_hdr_set_flags(hdr, arc_bufc_to_flags(type) | ARC_FLAG_HAS_L2HDR);
17451745
HDR_SET_LSIZE(hdr, size);
17461746
HDR_SET_PSIZE(hdr, psize);
1747-
HDR_SET_ASIZE(hdr, vdev_psize_to_asize(dev->l2ad_vdev, psize));
1747+
HDR_SET_L2SIZE(hdr, asize);
17481748
arc_hdr_set_compress(hdr, compress);
17491749
hdr->b_complevel = complevel;
17501750
if (protected)
@@ -3534,13 +3534,13 @@ l2arc_hdr_arcstats_update(arc_buf_hdr_t *hdr, boolean_t incr,
35343534
{
35353535
uint64_t lsize = HDR_GET_LSIZE(hdr);
35363536
uint64_t psize = HDR_GET_PSIZE(hdr);
3537-
uint64_t asize = HDR_GET_ASIZE(hdr);
3537+
uint64_t asize = HDR_GET_L2SIZE(hdr);
35383538
arc_buf_contents_t type = hdr->b_type;
35393539
int64_t lsize_s;
35403540
int64_t psize_s;
35413541
int64_t asize_s;
35423542

3543-
/* For L2 we expect the header's b_asize to be valid */
3543+
/* For L2 we expect the header's b_l2size to be valid */
35443544
ASSERT3U(asize, >=, psize);
35453545

35463546
if (incr) {
@@ -3612,7 +3612,7 @@ arc_hdr_l2hdr_destroy(arc_buf_hdr_t *hdr)
36123612

36133613
l2arc_hdr_arcstats_decrement(hdr);
36143614
if (dev->l2ad_vdev != NULL) {
3615-
uint64_t asize = HDR_GET_ASIZE(hdr);
3615+
uint64_t asize = HDR_GET_L2SIZE(hdr);
36163616
vdev_space_update(dev->l2ad_vdev, -asize, 0, 0);
36173617
}
36183618

@@ -4501,15 +4501,8 @@ arc_flush_async(spa_t *spa)
45014501
uint64_t spa_guid = spa_load_guid(spa);
45024502
arc_async_flush_t *af = arc_async_flush_add(spa_guid, 1);
45034503

4504-
/*
4505-
* Note that arc_flush_task() needs arc_async_flush_lock to remove af
4506-
* list node. So by holding the lock we avoid a race for af removal
4507-
* with our use here.
4508-
*/
4509-
mutex_enter(&arc_async_flush_lock);
45104504
taskq_dispatch_ent(arc_flush_taskq, arc_flush_task,
45114505
af, TQ_SLEEP, &af->af_tqent);
4512-
mutex_exit(&arc_async_flush_lock);
45134506
}
45144507

45154508
/*
@@ -7876,8 +7869,8 @@ arc_init(void)
78767869
list_create(&arc_async_flush_list, sizeof (arc_async_flush_t),
78777870
offsetof(arc_async_flush_t, af_node));
78787871
mutex_init(&arc_async_flush_lock, NULL, MUTEX_DEFAULT, NULL);
7879-
arc_flush_taskq = taskq_create("arc_flush", 75, defclsyspri,
7880-
1, INT_MAX, TASKQ_DYNAMIC | TASKQ_THREADS_CPU_PCT);
7872+
arc_flush_taskq = taskq_create("arc_flush", MIN(boot_ncpus, 4),
7873+
defclsyspri, 1, INT_MAX, TASKQ_DYNAMIC);
78817874

78827875
arc_ksp = kstat_create("zfs", 0, "arcstats", "misc", KSTAT_TYPE_NAMED,
78837876
sizeof (arc_stats) / sizeof (kstat_named_t), KSTAT_FLAG_VIRTUAL);
@@ -9442,7 +9435,7 @@ l2arc_write_buffers(spa_t *spa, l2arc_dev_t *dev, uint64_t target_sz)
94429435
hdr->b_l2hdr.b_arcs_state =
94439436
hdr->b_l1hdr.b_state->arcs_state;
94449437
/* l2arc_hdr_arcstats_update() expects a valid asize */
9445-
HDR_SET_ASIZE(hdr, asize);
9438+
HDR_SET_L2SIZE(hdr, asize);
94469439
arc_hdr_set_flags(hdr, ARC_FLAG_HAS_L2HDR |
94479440
ARC_FLAG_L2_WRITING);
94489441

@@ -9609,10 +9602,8 @@ l2arc_feed_thread(void *unused)
96099602
* held to prevent device removal. l2arc_dev_get_next()
96109603
* will grab and release l2arc_dev_mtx.
96119604
*/
9612-
if ((dev = l2arc_dev_get_next()) == NULL ||
9613-
dev->l2ad_spa == NULL) {
9605+
if ((dev = l2arc_dev_get_next()) == NULL)
96149606
continue;
9615-
}
96169607

96179608
spa = dev->l2ad_spa;
96189609
ASSERT3P(spa, !=, NULL);
@@ -10573,7 +10564,8 @@ l2arc_hdr_restore(const l2arc_log_ent_phys_t *le, l2arc_dev_t *dev)
1057310564
arc_buf_hdr_t *hdr, *exists;
1057410565
kmutex_t *hash_lock;
1057510566
arc_buf_contents_t type = L2BLK_GET_TYPE((le)->le_prop);
10576-
uint64_t asize;
10567+
uint64_t asize = vdev_psize_to_asize(dev->l2ad_vdev,
10568+
L2BLK_GET_PSIZE((le)->le_prop));
1057710569

1057810570
/*
1057910571
* Do all the allocation before grabbing any locks, this lets us
@@ -10582,14 +10574,11 @@ l2arc_hdr_restore(const l2arc_log_ent_phys_t *le, l2arc_dev_t *dev)
1058210574
*/
1058310575
hdr = arc_buf_alloc_l2only(L2BLK_GET_LSIZE((le)->le_prop), type,
1058410576
dev, le->le_dva, le->le_daddr,
10585-
L2BLK_GET_PSIZE((le)->le_prop), le->le_birth,
10577+
L2BLK_GET_PSIZE((le)->le_prop), asize, le->le_birth,
1058610578
L2BLK_GET_COMPRESS((le)->le_prop), le->le_complevel,
1058710579
L2BLK_GET_PROTECTED((le)->le_prop),
1058810580
L2BLK_GET_PREFETCH((le)->le_prop),
1058910581
L2BLK_GET_STATE((le)->le_prop));
10590-
asize = vdev_psize_to_asize(dev->l2ad_vdev,
10591-
L2BLK_GET_PSIZE((le)->le_prop));
10592-
ASSERT3U(asize, ==, HDR_GET_ASIZE(hdr));
1059310582

1059410583
/*
1059510584
* vdev_space_update() has to be called before arc_hdr_destroy() to
@@ -10620,7 +10609,7 @@ l2arc_hdr_restore(const l2arc_log_ent_phys_t *le, l2arc_dev_t *dev)
1062010609
exists->b_l2hdr.b_arcs_state =
1062110610
L2BLK_GET_STATE((le)->le_prop);
1062210611
/* l2arc_hdr_arcstats_update() expects a valid asize */
10623-
HDR_SET_ASIZE(exists, asize);
10612+
HDR_SET_L2SIZE(exists, asize);
1062410613
mutex_enter(&dev->l2ad_mtx);
1062510614
list_insert_tail(&dev->l2ad_buflist, exists);
1062610615
(void) zfs_refcount_add_many(&dev->l2ad_alloc,

0 commit comments

Comments
 (0)