ceph: define 'end/complete' in readdir reply as bit flags
authorYan, Zheng <zyan@redhat.com>
Wed, 27 Apr 2016 09:48:30 +0000 (17:48 +0800)
committerIlya Dryomov <idryomov@gmail.com>
Wed, 25 May 2016 23:15:35 +0000 (01:15 +0200)
Set a flag in readdir request, which indicates that client interprets
'end/complete' as bit flags. So that mds can reply additional flags in
readdir reply.

Signed-off-by: Yan, Zheng <zyan@redhat.com>
fs/ceph/dir.c
fs/ceph/mds_client.c
fs/ceph/mds_client.h
include/linux/ceph/ceph_fs.h

index 68530acea2c8688c1ac8f2cc4995c03ae510f14a..ebcbd1c946b4c387e9fd59e43bd4943efcaf9ba1 100644 (file)
@@ -365,6 +365,8 @@ more:
                req->r_readdir_cache_idx = fi->readdir_cache_idx;
                req->r_readdir_offset = fi->next_offset;
                req->r_args.readdir.frag = cpu_to_le32(frag);
+               req->r_args.readdir.flags =
+                               cpu_to_le16(CEPH_READDIR_REPLY_BITFLAGS);
 
                req->r_inode = inode;
                ihold(inode);
index 6220d3caf7aba0c9f8ece32710bc0713c9852ae3..1c2befcd24fb378e03a9a3844e97fb47bbad1871 100644 (file)
@@ -181,8 +181,11 @@ static int parse_reply_info_dir(void **p, void *end,
 
        ceph_decode_need(p, end, sizeof(num) + 2, bad);
        num = ceph_decode_32(p);
-       info->dir_end = ceph_decode_8(p);
-       info->dir_complete = ceph_decode_8(p);
+       {
+               u16 flags = ceph_decode_16(p);
+               info->dir_end = !!(flags & CEPH_READDIR_FRAG_END);
+               info->dir_complete = !!(flags & CEPH_READDIR_FRAG_COMPLETE);
+       }
        if (num == 0)
                goto done;
 
index 0b84f9c0afa30ab4610603677033899ef4135d23..2a865812a41b49005caaf435edd9446055c36192 100644 (file)
@@ -80,7 +80,7 @@ struct ceph_mds_reply_info_parsed {
                        struct ceph_mds_reply_dirfrag *dir_dir;
                        size_t                        dir_buf_size;
                        int                           dir_nr;
-                       u8                            dir_complete, dir_end;
+                       bool                          dir_complete, dir_end;
                        struct ceph_mds_reply_dir_entry  *dir_entries;
                };
 
index bae833d0d05550dc03c5bb15fda1686e56b8379c..a811c5e98bfa37425dc46df0eed5bc10761e1583 100644 (file)
@@ -347,6 +347,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_* */
@@ -364,6 +375,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;