]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os/FileStore: force any new xattr into omap on E2BIG
authorSage Weil <sage@redhat.com>
Thu, 7 Aug 2014 00:04:02 +0000 (17:04 -0700)
committerSage Weil <sage@redhat.com>
Thu, 7 Aug 2014 00:45:03 +0000 (17:45 -0700)
If we have a huge xattr (or many little ones), the _fgetattrs() for the
inline_set will fail with E2BIG.  The conditions later where we decide
whether to clean up the old xattr will then also fail.  Will *will* put
the xattr in omap, but the non-omap version isn't cleaned up.

Fix this by setting a flag if we get E2BIG that the inline_set is known
to be incomplete.  In that case, take the conservative step of assuming
the xattr might be present and chain_fremovexattr().  Ignore any error
because it might not be there.

This is clearly harmless in the general case because it won't be there.  If
it is, we will hopefully remove enough xattrs that the E2BIG condition
will go away (usually by removing some really big chained xattr).

See bug #7779.

This is a backport of 26750fcfe8d766874513e57981565adde2e6d8c7.

Reviewed-by: Yehuda Sadeh <yehuda@inktank.com>
Reviewed-by: Samuel Just <sam.just@inktank.com>
Signed-off-by: Sage Weil <sage@redhat.com>
src/os/FileStore.cc

index 58b23f204af3b7d8c9b8454877fc1d0a1fd5c4d3..247a80b196dd7e70d710f465e83125dd3c9907b5 100644 (file)
@@ -4065,14 +4065,18 @@ int FileStore::_setattrs(coll_t cid, const hobject_t& oid, map<string,bufferptr>
   set<string> omap_remove;
   map<string, bufferptr> inline_set;
   map<string, bufferptr> inline_to_set;
+  bool incomplete_inline = false;
   FDRef fd;
   int r = lfn_open(cid, oid, false, &fd);
   if (r < 0) {
     goto out;
   }
   r = _fgetattrs(**fd, inline_set, false);
+  incomplete_inline = (r == -E2BIG);
   assert(!m_filestore_fail_eio || r != -EIO);
-  dout(15) << "setattrs " << cid << "/" << oid << dendl;
+  dout(15) << "setattrs " << cid << "/" << oid
+          << (incomplete_inline ? " (incomplete_inline, forcing omap)" : "")
+          << dendl;
   r = 0;
   for (map<string,bufferptr>::iterator p = aset.begin();
        p != aset.end();
@@ -4080,6 +4084,12 @@ int FileStore::_setattrs(coll_t cid, const hobject_t& oid, map<string,bufferptr>
     char n[CHAIN_XATTR_MAX_NAME_LEN];
     get_attrname(p->first.c_str(), n, CHAIN_XATTR_MAX_NAME_LEN);
 
+    if (incomplete_inline) {
+      chain_fremovexattr(**fd, n); // ignore any error
+      omap_set[p->first].push_back(p->second);
+      continue;
+    }
+
     if (p->second.length() > g_conf->filestore_max_inline_xattr_size) {
        if (inline_set.count(p->first)) {
          inline_set.erase(p->first);