diff options
author | Ian Moffett <ian@osmora.org> | 2025-05-22 21:29:44 -0400 |
---|---|---|
committer | Ian Moffett <ian@osmora.org> | 2025-05-22 21:29:44 -0400 |
commit | c8503e1a71ab992e46940ee5482db01235100d4b (patch) | |
tree | 410811f2ee02f162b72b4e0d6ff1c739004ab88a | |
parent | 92e385d64d9883896b4cf55e7e0d5e110621cb0c (diff) |
kernel: dcdr: Overwrite existing DCDs if required
When writing to a drive, existing cached entries must be written through
so DCD reads don't give stale data.
Signed-off-by: Ian Moffett <ian@osmora.org>
-rw-r--r-- | sys/dev/dcdr/cache.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/sys/dev/dcdr/cache.c b/sys/dev/dcdr/cache.c index c44c8ea..33f977e 100644 --- a/sys/dev/dcdr/cache.c +++ b/sys/dev/dcdr/cache.c @@ -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) { |