From acee97ba2a6aacc0acf4e5dc35dca9f16c45e25a Mon Sep 17 00:00:00 2001 From: Zach Brown Date: Thu, 8 Dec 2016 23:37:31 -0800 Subject: [PATCH] Fix tail ring entry zeroing The space calculation didn't include the terminating zero entry. That ensured that the space for the netry would never be consumed. But the remaining space was used to zero the end of the block so the final entry wasn't being zeroed. So have the space remaining include the terminating entry and factor that into the space consumption of each entry being appended. Signed-off-by: Zach Brown --- kmod/src/ring.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/kmod/src/ring.c b/kmod/src/ring.c index 7b9bc6c4..bc5e7db7 100644 --- a/kmod/src/ring.c +++ b/kmod/src/ring.c @@ -68,7 +68,7 @@ void scoutfs_ring_append(struct super_block *sb, struct scoutfs_ring_block *ring = rinf->ring; unsigned int len = le16_to_cpu(eh->len); - if (rinf->space < len) { + if (rinf->space < (len + sizeof(struct scoutfs_ring_entry_header))) { if (rinf->space) finish_block(ring, rinf->space); ring = scoutfs_page_block_address(rinf->pages, rinf->nr_blocks); @@ -79,8 +79,7 @@ void scoutfs_ring_append(struct super_block *sb, rinf->nr_blocks++; rinf->next_eh = ring->entries; rinf->space = SCOUTFS_BLOCK_SIZE - - offsetof(struct scoutfs_ring_block, entries) - - sizeof(struct scoutfs_ring_entry_header); + offsetof(struct scoutfs_ring_block, entries); } memcpy(rinf->next_eh, eh, len);