]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: define end/complete in readdir reply as single u16 flags
authorYan, Zheng <zyan@redhat.com>
Thu, 21 Apr 2016 09:31:10 +0000 (17:31 +0800)
committerGreg Farnum <gfarnum@redhat.com>
Sun, 12 Jun 2016 21:10:08 +0000 (14:10 -0700)
so that we can introduce new flags for readdir reply.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
(cherry picked from commit 92cfbdf526d1030891da366299b635e589dd5f8e)

Signed-off-by: Greg Farnum <gfarnum@redhat.com
src/client/Client.cc
src/include/ceph_fs.h
src/mds/Server.cc

index a3e29e31dfea21bc7abb597500e6eb29ba4b58b9..bf6b3d69573a674c21bcb4fdf081e125521f4fd7 100644 (file)
@@ -1107,10 +1107,11 @@ void Client::insert_readdir_results(MetaRequest *request, MetaSession *session,
     // dirstat
     DirStat dst(p);
     __u32 numdn;
-    __u8 complete, end;
+    __u16 flags;
     ::decode(numdn, p);
-    ::decode(end, p);
-    ::decode(complete, p);
+    ::decode(flags, p);
+
+    bool end = ((unsigned)flags & CEPH_READDIR_FRAG_END);
 
     frag_t fg = (unsigned)request->head.args.readdir.frag;
     uint64_t readdir_offset = dirp->next_offset;
@@ -1124,7 +1125,7 @@ void Client::insert_readdir_results(MetaRequest *request, MetaSession *session,
       dirp->offset = dir_result_t::make_fpos(fg, readdir_offset);
     }
 
-    ldout(cct, 10) << __func__ << " " << numdn << " readdir items, end=" << (int)end
+    ldout(cct, 10) << __func__ << " " << numdn << " readdir items, end=" << end
                   << ", offset " << readdir_offset
                   << ", readdir_start " << readdir_start << dendl;
 
@@ -6943,6 +6944,7 @@ int Client::_readdir_get_frag(dir_result_t *dirp)
   req->set_filepath(path); 
   req->set_inode(diri.get());
   req->head.args.readdir.frag = fg;
+  req->head.args.readdir.flags = CEPH_READDIR_REPLY_BITFLAGS;
   if (dirp->last_name.length()) {
     req->path2.set_path(dirp->last_name.c_str());
   }
index 70f83e3d2b9947041254baf04914def5280069c8..fb426bf5e803bca000a462c4704c77c2c87c1447 100644 (file)
@@ -387,6 +387,17 @@ extern const char *ceph_mds_op_name(int op);
 #define CEPH_XATTR_REPLACE (1 << 1)
 #define CEPH_XATTR_REMOVE  (1 << 31)
 
+/*
+ * readdir request flags;
+ */
+#define CEPH_READDIR_REPLY_BITFLAGS    (1<<0)
+
+/*
+ * readdir reply flags.
+ */
+#define CEPH_READDIR_FRAG_END          (1<<0)
+#define CEPH_READDIR_FRAG_COMPLETE     (1<<8)
+
 union ceph_mds_request_args {
        struct {
                __le32 mask;                 /* CEPH_CAP_* */
@@ -404,6 +415,7 @@ union ceph_mds_request_args {
                __le32 frag;                 /* which dir fragment */
                __le32 max_entries;          /* how many dentries to grab */
                __le32 max_bytes;
+               __le16 flags;
        } __attribute__ ((packed)) readdir;
        struct {
                __le32 mode;
index d303b531f280de5df2b05ccd0e65442f60101f59..0fb53e3b70f7e3fa097f22e004674b77b6d888ef 100644 (file)
@@ -3274,6 +3274,7 @@ void Server::handle_client_readdir(MDRequestRef& mdr)
 
   // which frag?
   frag_t fg = (__u32)req->head.args.readdir.frag;
+  unsigned req_flags = (__u32)req->head.args.readdir.flags;
   string offset_str = req->get_path2();
   dout(10) << " frag " << fg << " offset '" << offset_str << "'" << dendl;
 
@@ -3342,7 +3343,7 @@ void Server::handle_client_readdir(MDRequestRef& mdr)
   // build dir contents
   bufferlist dnbl;
   __u32 numfiles = 0;
-  __u8 end = (dir->begin() == dir->end());
+  bool end = (dir->begin() == dir->end());
   for (CDir::map_t::iterator it = dir->begin();
        !end && numfiles < max;
        end = (it == dir->end())) {
@@ -3435,12 +3436,21 @@ void Server::handle_client_readdir(MDRequestRef& mdr)
     mdcache->lru.lru_touch(dn);
   }
   
-  __u8 complete = (end && offset_str.empty());  // FIXME: what purpose does this serve
+  bool complete = false;
+  __u16 flags = 0;
+  if (end) {
+    flags = CEPH_READDIR_FRAG_END;
+    complete = offset_str.empty(); // FIXME: what purpose does this serve
+    if (complete)
+      flags |= CEPH_READDIR_FRAG_COMPLETE;
+  }
+  // client only understand END and COMPLETE flags ?
+  if (req_flags & CEPH_READDIR_REPLY_BITFLAGS) {
+  }
   
   // finish final blob
   ::encode(numfiles, dirbl);
-  ::encode(end, dirbl);
-  ::encode(complete, dirbl);
+  ::encode(flags, dirbl);
   dirbl.claim_append(dnbl);
   
   // yay, reply
@@ -7895,10 +7905,13 @@ void Server::handle_client_lssnap(MDRequestRef& mdr)
   }
 
   ::encode(num, dirbl);
-  __u8 end = (p == infomap.end());
-  ::encode(end, dirbl);  // end
-  __u8 complete = end && last_snapid == 0;
-  ::encode(complete, dirbl);  // complete
+  __u16 flags = 0;
+  if (p == infomap.end()) {
+    flags = CEPH_READDIR_FRAG_END;
+    if (last_snapid == 0)
+      flags |= CEPH_READDIR_FRAG_COMPLETE;
+  }
+  ::encode(flags, dirbl);
   dirbl.claim_append(dnbl);
   
   mdr->reply_extra_bl = dirbl;