From f8f789b8cdb35bcc9974c644ffe9c901618b6a2f Mon Sep 17 00:00:00 2001 From: Masaori Koshiba Date: Thu, 16 Dec 2021 14:40:30 +0900 Subject: [PATCH] Clear random header value by AIO read error --- iocore/cache/CacheDisk.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/iocore/cache/CacheDisk.cc b/iocore/cache/CacheDisk.cc index c2a3a92b3e6..c9b1c75d3a4 100644 --- a/iocore/cache/CacheDisk.cc +++ b/iocore/cache/CacheDisk.cc @@ -97,7 +97,7 @@ CacheDisk::open(char *s, off_t blocks, off_t askip, int ahw_sector_size, int fil } } - // + // read disk header SET_HANDLER(&CacheDisk::openStart); io.aiocb.aio_offset = skip; io.aiocb.aio_buf = reinterpret_cast(header); @@ -165,6 +165,10 @@ CacheDisk::openStart(int event, void * /* data ATS_UNUSED */) if (io.aiocb.aio_nbytes != static_cast(io.aio_result)) { Warning("could not read disk header for disk %s: declaring disk bad", path); + + // the header could have random values by the AIO read error + memset(header, 0, header_len); + incrErrors(&io); SET_DISK_BAD(this); SET_HANDLER(&CacheDisk::openDone);