]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
os: add a field indicate xattr only one chunk for set xattr. 6244/head
authorJianpeng Ma <jianpeng.ma@intel.com>
Tue, 13 Oct 2015 06:32:48 +0000 (14:32 +0800)
committerJianpeng Ma <jianpeng.ma@intel.com>
Tue, 13 Oct 2015 06:32:48 +0000 (14:32 +0800)
Because the limit of osd backend, we split xattr into a lot of small
pieces. When set xatt, it should remove the old pieces.
But for some xattr especially for inline xattr, we know it only
one chunk. So it can skip this remove operation.

Signed-off-by: Jianpeng Ma <jianpeng.ma@intel.com>
src/os/FileStore.cc
src/os/IndexManager.cc
src/os/chain_xattr.cc
src/os/chain_xattr.h

index 2483bd93a656503d89139c1b901a07ae6b9b9a5c..c1bd571f7127ed38d1fc8a2a972f1c1f284ccb6b 100644 (file)
@@ -297,7 +297,7 @@ int FileStore::lfn_open(coll_t cid,
       goto fail;
     }
     r = chain_fsetxattr(fd, XATTR_SPILL_OUT_NAME,
-                        XATTR_NO_SPILL_OUT, sizeof(XATTR_NO_SPILL_OUT));
+                        XATTR_NO_SPILL_OUT, sizeof(XATTR_NO_SPILL_OUT), true);
     if (r < 0) {
       VOID_TEMP_FAILURE_RETRY(::close(fd));
       derr << "error setting spillout xattr for oid " << oid << " (" << (*path)->path()
@@ -2110,7 +2110,7 @@ void FileStore::_set_global_replay_guard(coll_t cid,
   // then record that we did it
   bufferlist v;
   ::encode(spos, v);
-  int r = chain_fsetxattr(fd, GLOBAL_REPLAY_GUARD_XATTR, v.c_str(), v.length());
+  int r = chain_fsetxattr(fd, GLOBAL_REPLAY_GUARD_XATTR, v.c_str(), v.length(), true);
   if (r < 0) {
     derr << __func__ << ": fsetxattr " << GLOBAL_REPLAY_GUARD_XATTR
         << " got " << cpp_strerror(r) << dendl;
@@ -2203,7 +2203,7 @@ void FileStore::_set_replay_guard(int fd,
   bufferlist v(40);
   ::encode(spos, v);
   ::encode(in_progress, v);
-  int r = chain_fsetxattr(fd, REPLAY_GUARD_XATTR, v.c_str(), v.length());
+  int r = chain_fsetxattr(fd, REPLAY_GUARD_XATTR, v.c_str(), v.length(), true);
   if (r < 0) {
     derr << "fsetxattr " << REPLAY_GUARD_XATTR << " got " << cpp_strerror(r) << dendl;
     assert(0 == "fsetxattr failed");
@@ -2246,7 +2246,7 @@ void FileStore::_close_replay_guard(int fd, const SequencerPosition& spos)
   ::encode(spos, v);
   bool in_progress = false;
   ::encode(in_progress, v);
-  int r = chain_fsetxattr(fd, REPLAY_GUARD_XATTR, v.c_str(), v.length());
+  int r = chain_fsetxattr(fd, REPLAY_GUARD_XATTR, v.c_str(), v.length(), true);
   if (r < 0) {
     derr << "fsetxattr " << REPLAY_GUARD_XATTR << " got " << cpp_strerror(r) << dendl;
     assert(0 == "fsetxattr failed");
@@ -3302,10 +3302,10 @@ int FileStore::_clone(coll_t cid, const ghobject_t& oldoid, const ghobject_t& ne
     r = chain_fgetxattr(**o, XATTR_SPILL_OUT_NAME, buf, sizeof(buf));
     if (r >= 0 && !strncmp(buf, XATTR_NO_SPILL_OUT, sizeof(XATTR_NO_SPILL_OUT))) {
       r = chain_fsetxattr(**n, XATTR_SPILL_OUT_NAME, XATTR_NO_SPILL_OUT,
-                          sizeof(XATTR_NO_SPILL_OUT));
+                          sizeof(XATTR_NO_SPILL_OUT), true);
     } else {
       r = chain_fsetxattr(**n, XATTR_SPILL_OUT_NAME, XATTR_SPILL_OUT,
-                          sizeof(XATTR_SPILL_OUT));
+                          sizeof(XATTR_SPILL_OUT), true);
     }
     if (r < 0)
       goto out3;
index 6a9f040d106a9dd38adeeecb79aef2be21fb7289..1415939f92db376086a9423ee2df1508f8bfa164 100644 (file)
@@ -37,7 +37,7 @@ static int set_version(const char *path, uint32_t version) {
   bufferlist bl;
   ::encode(version, bl);
   return chain_setxattr(path, "user.cephos.collection_version", bl.c_str(), 
-                    bl.length());
+                    bl.length(), true);
 }
 
 static int get_version(const char *path, uint32_t *version) {
index 1bb652af4d15509fb4b0d3a551c341fe484eb6b8..5351abf440b4cb1aa6d01c13ff05fad1dfebff92 100644 (file)
@@ -256,7 +256,7 @@ static int get_xattr_block_size(size_t size)
   return CHAIN_XATTR_MAX_BLOCK_LEN;
 }
 
-int chain_setxattr(const char *fn, const char *name, const void *val, size_t size)
+int chain_setxattr(const char *fn, const char *name, const void *val, size_t size, bool onechunk)
 {
   int i = 0, pos = 0;
   char raw_name[CHAIN_XATTR_MAX_NAME_LEN * 2 + 16];
@@ -278,7 +278,7 @@ int chain_setxattr(const char *fn, const char *name, const void *val, size_t siz
     i++;
   } while (size);
 
-  if (ret >= 0 ) {
+  if (ret >= 0 && !onechunk) {
     int r;
     do {
       get_raw_xattr_name(name, i, raw_name, sizeof(raw_name));
@@ -292,7 +292,7 @@ int chain_setxattr(const char *fn, const char *name, const void *val, size_t siz
   return ret;
 }
 
-int chain_fsetxattr(int fd, const char *name, const void *val, size_t size)
+int chain_fsetxattr(int fd, const char *name, const void *val, size_t size, bool onechunk)
 {
   int i = 0, pos = 0;
   char raw_name[CHAIN_XATTR_MAX_NAME_LEN * 2 + 16];
@@ -314,7 +314,7 @@ int chain_fsetxattr(int fd, const char *name, const void *val, size_t size)
     i++;
   } while (size);
 
-  if (ret >= 0) {
+  if (ret >= 0 && !onechunk) {
     int r;
     do {
       get_raw_xattr_name(name, i, raw_name, sizeof(raw_name));
index b994d5209b837b18c707006e874375c3f60c4f2c..5ecfd40bbc12b91274b441808a9922c24f1e303b 100644 (file)
@@ -78,8 +78,8 @@ static inline int sys_fremovexattr(int fd, const char *name)
 
 int chain_getxattr(const char *fn, const char *name, void *val, size_t size);
 int chain_fgetxattr(int fd, const char *name, void *val, size_t size);
-int chain_setxattr(const char *fn, const char *name, const void *val, size_t size);
-int chain_fsetxattr(int fd, const char *name, const void *val, size_t size);
+int chain_setxattr(const char *fn, const char *name, const void *val, size_t size, bool onechunk=false);
+int chain_fsetxattr(int fd, const char *name, const void *val, size_t size, bool onechunk=false);
 int chain_listxattr(const char *fn, char *names, size_t len);
 int chain_flistxattr(int fd, char *names, size_t len);
 int chain_removexattr(const char *fn, const char *name);