diff options
author | Sam Lang <sam.lang@inktank.com> | 2012-11-27 14:36:15 -0600 |
---|---|---|
committer | Sam Lang <sam.lang@inktank.com> | 2012-11-27 15:01:51 -0600 |
commit | da32c596e245de5e4324ac3b36e3596cea588415 (patch) | |
tree | 5c6ead558e487512a3b070b0a52a12c029d72868 | |
parent | 9c76ed6244107a083c454e98a4a0b90d195e6dd1 (diff) | |
download | ceph-da32c596e245de5e4324ac3b36e3596cea588415.tar.gz |
client: Always increment mtime
Cases where the mds clock was a few seconds ahead
of the client would cause the mtime of files to
be set backward, because the mtime set on create
is from the mds, and updates on writes are from the
client. This patch prevents mtime from going
backward by comparing the current mtime with the
client's time, and incrementing by one nanosecond
if the mtime > client.
Signed-off-by: Sam Lang <sam.lang@inktank.com>
-rw-r--r-- | src/client/Client.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/client/Client.cc b/src/client/Client.cc index 641aba170d7..a316c29d1e7 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -5766,7 +5766,13 @@ int Client::_write(Fh *f, int64_t offset, uint64_t size, const char *buf) } // mtime - in->mtime = ceph_clock_now(cct); + utime_t curtime = ceph_clock_now(cct); + if (in->mtime > curtime) { + // can't go backwards, increment mtime by 1 nanosec + in->mtime += 0.000000001; + } else { + in->mtime = curtime; + } mark_caps_dirty(in, CEPH_CAP_FILE_WR); put_cap_ref(in, CEPH_CAP_FILE_WR); |