]> git.apps.os.sepia.ceph.com Git - ceph.git/commit
mon/MonitorStore: always O_TRUNC when writing states
authorSage Weil <sage@inktank.com>
Mon, 16 Jul 2012 03:30:34 +0000 (20:30 -0700)
committerSage Weil <sage@inktank.com>
Mon, 16 Jul 2012 17:58:01 +0000 (10:58 -0700)
commitbcb1073f9171253adc37b67ee8d302932ba1667b
treee9e2259c6ec07395f9101c3a755f3044b8b5ad3a
parent41a570778a51fe9a36a5b67a177d173889e58363
mon/MonitorStore: always O_TRUNC when writing states

It is possible for a .new file to already exist, potentially with a
larger size.  This would happen if:

 - we were proposing a different value
 - we crashed (or were stopped) before it got renamed into place
 - after restarting, a different value was proposed and accepted.

This isn't so unlikely for the log state machine, where we're
aggregating random messages.  O_TRUNC ensure we avoid getting the tail
end of some previous junk.

I observed #2593 and found that a logm state value had a larger size on
one mon (after slurping) than the others, pointing to put_bl_sn_map().

While we are at it, O_TRUNC put_int() too; the same type of bug is
possible there, too.

Fixes: #2593
Signed-off-by: Sage Weil <sage@inktank.com>
src/mon/MonitorStore.cc