From 98f72a539c8ca2ba1ca7fc8cac44018ade96065c Mon Sep 17 00:00:00 2001 From: Brian Behlendorf Date: Thu, 26 Aug 2010 10:26:44 -0700 Subject: [PATCH] Fix list handling to only use the API Remove all instances of list handling where the API is not used and instead list data members are directly accessed. Doing this sort of thing is bad for portability. Additionally, ensure that list_link_init() is called on newly created list nodes. This ensures the node is properly initialized and does not rely on the assumption that zero'ing the list_node_t via kmem_zalloc() is the same as proper initialization. Signed-off-by: Brian Behlendorf --- module/zfs/arc.c | 3 +++ module/zfs/dbuf.c | 2 ++ module/zfs/dsl_dataset.c | 1 + module/zfs/vdev.c | 2 ++ 4 files changed, 8 insertions(+) diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 1d7fd9e4cc07..3b76d1fbf18d 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -794,6 +794,8 @@ hdr_cons(void *vbuf, void *unused, int kmflag) refcount_create(&buf->b_refcnt); cv_init(&buf->b_cv, NULL, CV_DEFAULT, NULL); mutex_init(&buf->b_freeze_lock, NULL, MUTEX_DEFAULT, NULL); + list_link_init(&buf->b_arc_node); + list_link_init(&buf->b_l2node); arc_space_consume(sizeof (arc_buf_hdr_t), ARC_SPACE_HDRS); return (0); @@ -4537,6 +4539,7 @@ l2arc_add_vdev(spa_t *spa, vdev_t *vd) adddev->l2ad_evict = adddev->l2ad_start; adddev->l2ad_first = B_TRUE; adddev->l2ad_writing = B_FALSE; + list_link_init(&adddev->l2ad_node); ASSERT3U(adddev->l2ad_write, >, 0); /* diff --git a/module/zfs/dbuf.c b/module/zfs/dbuf.c index 55326c49815e..d08359156d56 100644 --- a/module/zfs/dbuf.c +++ b/module/zfs/dbuf.c @@ -55,6 +55,7 @@ dbuf_cons(void *vdb, void *unused, int kmflag) mutex_init(&db->db_mtx, NULL, MUTEX_DEFAULT, NULL); cv_init(&db->db_changed, NULL, CV_DEFAULT, NULL); refcount_create(&db->db_holds); + list_link_init(&db->db_link); return (0); } @@ -1136,6 +1137,7 @@ dbuf_dirty(dmu_buf_impl_t *db, dmu_tx_t *tx) * transaction group won't leak out when we sync the older txg. */ dr = kmem_zalloc(sizeof (dbuf_dirty_record_t), KM_SLEEP); + list_link_init(&dr->dr_dirty_node); if (db->db_level == 0) { void *data_old = db->db_buf; diff --git a/module/zfs/dsl_dataset.c b/module/zfs/dsl_dataset.c index 226e9882816c..f6f198791797 100644 --- a/module/zfs/dsl_dataset.c +++ b/module/zfs/dsl_dataset.c @@ -393,6 +393,7 @@ dsl_dataset_get_ref(dsl_pool_t *dp, uint64_t dsobj, void *tag, ds->ds_dbuf = dbuf; ds->ds_object = dsobj; ds->ds_phys = dbuf->db_data; + list_link_init(&ds->ds_synced_link); mutex_init(&ds->ds_lock, NULL, MUTEX_DEFAULT, NULL); mutex_init(&ds->ds_recvlock, NULL, MUTEX_DEFAULT, NULL); diff --git a/module/zfs/vdev.c b/module/zfs/vdev.c index 7a16a9865c52..17b45b0e828d 100644 --- a/module/zfs/vdev.c +++ b/module/zfs/vdev.c @@ -317,6 +317,8 @@ vdev_alloc_common(spa_t *spa, uint_t id, uint64_t guid, vdev_ops_t *ops) vd->vdev_state = VDEV_STATE_CLOSED; vd->vdev_ishole = (ops == &vdev_hole_ops); + list_link_init(&vd->vdev_config_dirty_node); + list_link_init(&vd->vdev_state_dirty_node); mutex_init(&vd->vdev_dtl_lock, NULL, MUTEX_DEFAULT, NULL); mutex_init(&vd->vdev_stat_lock, NULL, MUTEX_DEFAULT, NULL); mutex_init(&vd->vdev_probe_lock, NULL, MUTEX_DEFAULT, NULL);