From: Sage Weil Date: Sat, 19 May 2012 20:54:13 +0000 (-0700) Subject: osd: only (re)write_meta files if old content is incorrect X-Git-Tag: v0.48argonaut~151^2~26^2~19 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=17c4624e9398cdadd8822dc1eef28ea601e08bc0;p=ceph.git osd: only (re)write_meta files if old content is incorrect Do nothing if the file already exists with the correct content. Signed-off-by: Sage Weil --- diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc index cebf502c7bcc..39d14ab10542 100644 --- a/src/osd/OSD.cc +++ b/src/osd/OSD.cc @@ -428,6 +428,12 @@ int OSD::write_meta(const std::string &base, const std::string &file, char tmp[PATH_MAX]; int fd; + // does the file already have correct content? + char oldval[80]; + ret = read_meta(base, file, oldval, sizeof(oldval)); + if (ret == (int)vallen && memcmp(oldval, val, vallen) == 0) + return 0; // yes. + snprintf(fn, sizeof(fn), "%s/%s", base.c_str(), file.c_str()); snprintf(tmp, sizeof(tmp), "%s/%s.tmp", base.c_str(), file.c_str()); fd = ::open(tmp, O_WRONLY|O_CREAT|O_TRUNC, 0644);