]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
osd: only (re)write_meta files if old content is incorrect
authorSage Weil <sage@inktank.com>
Sat, 19 May 2012 20:54:13 +0000 (13:54 -0700)
committerSage Weil <sage@inktank.com>
Wed, 23 May 2012 00:24:10 +0000 (17:24 -0700)
Do nothing if the file already exists with the correct content.

Signed-off-by: Sage Weil <sage@inktank.com>
src/osd/OSD.cc

index cebf502c7bcc7d2920f537e3f353ace7cd9ace85..39d14ab10542aae7aa8ef0b531d9c01b75203abb 100644 (file)
@@ -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);