compute swap_file_sz before packing it

From: Alex Rousskov <rousskov_at_measurement-factory.com>
Date: Mon, 14 Sep 2009 02:04:00 -0600 (MDT)

Hello,

     A few weeks ago, I stumbled upon swap entry size calculation and
store dir selection bug. I found more problems with the related code.
One of them is discussed in this email.

Apparently, we are packing StoreEntry.swap_file_sz into the stored
entry header before we compute its value. This happens because to
compute swap_file_sz, we need to know swap_hdr_sz, the size of the
stored entry header. To compute swap_hdr_sz, we need to pack the
header, but we cannot pack the header because swap_file_sz field has
not been computed yet. Chicken and egg, hidden behind a bunch of void*
memcopies.

We have not noticed the problem because UFS ignores swap_file_sz (or
supplies its own) in most contexts and COSS simply lacks the part of
the code that would expose the bug (no store rebuilding from the
disk db file).

The attached patch is a "work in progress" hack to facilitate the
discussion. The patch computes the future swap_hdr_sz without packing
the header, sets swap_file_sz, and then packs the header. It is not
very efficient but appears to work.

If I am on the wrong path here, please shout.

Thank you,

Alex.

Received on Mon Sep 14 2009 - 08:04:04 MDT

This archive was generated by hypermail 2.2.0 : Tue Sep 15 2009 - 12:00:04 MDT