summaryrefslogtreecommitdiff
path: root/sys/dev/dcdr/cache.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/dcdr/cache.c')
-rw-r--r--sys/dev/dcdr/cache.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/sys/dev/dcdr/cache.c b/sys/dev/dcdr/cache.c
index e13c9c7..33f977e 100644
--- a/sys/dev/dcdr/cache.c
+++ b/sys/dev/dcdr/cache.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2023-2024 Ian Marco Moffett and the Osmora Team.
+ * Copyright (c) 2023-2025 Ian Marco Moffett and the Osmora Team.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -126,6 +126,20 @@ struct dcd *
dcdr_cachein(struct dcdr *dcdr, void *block, off_t lba)
{
struct dcd *dcd, *tmp;
+ struct dcdr_lookup check;
+ int status;
+
+ /*
+ * If there is already a block within this
+ * DCDR, then we simply need to copy the
+ * new data into the old DCD.
+ */
+ status = dcdr_lookup(dcdr, lba, &check);
+ if (status == 0) {
+ dcd = check.dcd_res;
+ memcpy(dcd->block, block, dcdr->bsize);
+ return dcd;
+ }
dcd = dynalloc(sizeof(*dcd));
if (dcd == NULL) {