aboutsummaryrefslogtreecommitdiffstats
path: root/include/sys/dbuf.h
diff options
context:
space:
mode:
authorMatthew Macy <[email protected]>2020-02-05 11:07:19 -0800
committerGitHub <[email protected]>2020-02-05 11:07:19 -0800
commitcccbed9f98597c2c354b218b0578625cc26358aa (patch)
treee4b47c15e228b3e85cb3dcb8f90a255cd96e67c9 /include/sys/dbuf.h
parent741db5a3466236620612772319c3401171d3f2b6 (diff)
Convert dbuf dirty record record list to a list_t
Additionally pull in state machine comments about upcoming async cow work. Reviewed-by: Brian Behlendorf <[email protected]> Reviewed-by: Matt Ahrens <[email protected]> Signed-off-by: Matt Macy <[email protected]> Closes #9902
Diffstat (limited to 'include/sys/dbuf.h')
-rw-r--r--include/sys/dbuf.h31
1 files changed, 27 insertions, 4 deletions
diff --git a/include/sys/dbuf.h b/include/sys/dbuf.h
index 53f9020f9..f6880cdb2 100644
--- a/include/sys/dbuf.h
+++ b/include/sys/dbuf.h
@@ -127,8 +127,8 @@ typedef struct dbuf_dirty_record {
/* pointer back to our dbuf */
struct dmu_buf_impl *dr_dbuf;
- /* pointer to next dirty record */
- struct dbuf_dirty_record *dr_next;
+ /* list link for dbuf dirty records */
+ list_node_t dr_dbuf_node;
/* pointer to parent dirty record */
struct dbuf_dirty_record *dr_parent;
@@ -257,8 +257,8 @@ typedef struct dmu_buf_impl {
kcondvar_t db_changed;
dbuf_dirty_record_t *db_data_pending;
- /* pointer to most recent dirty record for this buffer */
- dbuf_dirty_record_t *db_last_dirty;
+ /* List of dirty records for the buffer sorted newest to oldest. */
+ list_t db_dirty_records;
/*
* Our link on the owner dnodes's dn_dbufs list.
@@ -379,6 +379,29 @@ void dbuf_fini(void);
boolean_t dbuf_is_metadata(dmu_buf_impl_t *db);
+static inline dbuf_dirty_record_t *
+dbuf_find_dirty_lte(dmu_buf_impl_t *db, uint64_t txg)
+{
+ dbuf_dirty_record_t *dr;
+
+ for (dr = list_head(&db->db_dirty_records);
+ dr != NULL && dr->dr_txg > txg;
+ dr = list_next(&db->db_dirty_records, dr))
+ continue;
+ return (dr);
+}
+
+static inline dbuf_dirty_record_t *
+dbuf_find_dirty_eq(dmu_buf_impl_t *db, uint64_t txg)
+{
+ dbuf_dirty_record_t *dr;
+
+ dr = dbuf_find_dirty_lte(db, txg);
+ if (dr && dr->dr_txg == txg)
+ return (dr);
+ return (NULL);
+}
+
#define DBUF_GET_BUFC_TYPE(_db) \
(dbuf_is_metadata(_db) ? ARC_BUFC_METADATA : ARC_BUFC_DATA)