From: Sage Weil Date: Sat, 27 Oct 2012 22:36:27 +0000 (-0700) Subject: os/FileStore: recast _setattrs() on top of chain_f* methods X-Git-Tag: v0.55~188^2~9 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=6a6699bd1aaf350a65e11e961933b703c5cc95dd;p=ceph.git os/FileStore: recast _setattrs() on top of chain_f* methods This lets us open an fd once and use that. Signed-off-by: Sage Weil --- diff --git a/src/os/FileStore.cc b/src/os/FileStore.cc index 705b5e5dd7e..96a5620796f 100644 --- a/src/os/FileStore.cc +++ b/src/os/FileStore.cc @@ -3803,15 +3803,14 @@ int FileStore::_setattrs(coll_t cid, const hobject_t& oid, map set omap_remove; map inline_set; int r = 0; + int fd = lfn_open(cid, oid, 0); + if (fd < 0) { + r = -errno; + goto out; + } if (g_conf->filestore_xattr_use_omap) { - int fd = lfn_open(cid, oid, 0); - if (fd < 0) { - r = -errno; - goto out; - } r = _fgetattrs(fd, inline_set, false); assert(!m_filestore_fail_eio || r != -EIO); - TEMP_FAILURE_RETRY(::close(fd)); } dout(15) << "setattrs " << cid << "/" << oid << dendl; r = 0; @@ -3824,7 +3823,7 @@ int FileStore::_setattrs(coll_t cid, const hobject_t& oid, map if (p->second.length() > g_conf->filestore_max_inline_xattr_size) { if (inline_set.count(p->first)) { inline_set.erase(p->first); - r = lfn_removexattr(cid, oid, n); + r = chain_fremovexattr(fd, n); if (r < 0) return r; } @@ -3836,7 +3835,7 @@ int FileStore::_setattrs(coll_t cid, const hobject_t& oid, map inline_set.size() >= g_conf->filestore_max_inline_xattrs) { if (inline_set.count(p->first)) { inline_set.erase(p->first); - r = lfn_removexattr(cid, oid, n); + r = chain_fremovexattr(fd, n); if (r < 0) return r; } @@ -3853,7 +3852,7 @@ int FileStore::_setattrs(coll_t cid, const hobject_t& oid, map else val = ""; // ??? Why do we skip setting all the other attrs if one fails? - r = lfn_setxattr(cid, oid, n, val, p->second.length()); + r = chain_fsetxattr(fd, n, val, p->second.length()); if (r < 0) { derr << "FileStore::_setattrs: chain_setxattr returned " << r << dendl; break; @@ -3880,6 +3879,7 @@ int FileStore::_setattrs(coll_t cid, const hobject_t& oid, map return r; } } + TEMP_FAILURE_RETRY(::close(fd)); out: dout(10) << "setattrs " << cid << "/" << oid << " = " << r << dendl; return r;