Whamcloud - gitweb
LU-1842 protocol: add support for OBD_IDX_READ
[fs/lustre-release.git] / lustre / include / lustre / lustre_idl.h
index 93c4040..6416808 100644 (file)
@@ -952,7 +952,7 @@ static inline int lu_dirent_size(struct lu_dirent *ent)
 #define LU_PAGE_SIZE  (1UL << LU_PAGE_SHIFT)
 #define LU_PAGE_MASK  (~(LU_PAGE_SIZE - 1))
 
-#define LU_PAGE_COUNT 1 << (CFS_PAGE_SHIFT - LU_PAGE_SHIFT)
+#define LU_PAGE_COUNT (1 << (CFS_PAGE_SHIFT - LU_PAGE_SHIFT))
 
 /** @} lu_dir */
 
@@ -2622,6 +2622,7 @@ typedef enum {
         OBD_PING = 400,
         OBD_LOG_CANCEL,
         OBD_QC_CALLBACK,
+       OBD_IDX_READ,
         OBD_LAST_OPC
 } obd_cmd_t;
 #define OBD_FIRST_OPC OBD_PING
@@ -2977,6 +2978,91 @@ void dump_obdo(struct obdo *oa);
 void dump_ost_body(struct ost_body *ob);
 void dump_rcs(__u32 *rc);
 
+#define IDX_INFO_MAGIC 0x3D37CC37
+
+/* Index file transfer through the network. The server serializes the index into
+ * a byte stream which is sent to the client via a bulk transfer */
+struct idx_info {
+       __u32           ii_magic;
+
+       /* reply: see idx_info_flags below */
+       __u32           ii_flags;
+
+       /* request & reply: number of lu_idxpage (to be) transferred */
+       __u16           ii_count;
+       __u16           ii_pad0;
+
+       /* request: requested attributes passed down to the iterator API */
+       __u32           ii_attrs;
+
+       /* request & reply: index file identifier (FID) */
+       struct lu_fid   ii_fid;
+
+       /* reply: version of the index file before starting to walk the index.
+        * Please note that the version can be modified at any time during the
+        * transfer */
+       __u64           ii_version;
+
+       /* request: hash to start with:
+        * reply: hash of the first entry of the first lu_idxpage and hash
+        *        of the entry to read next if any */
+       __u64           ii_hash_start;
+       __u64           ii_hash_end;
+
+       /* reply: size of keys in lu_idxpages, minimal one if II_FL_VARKEY is
+        * set */
+       __u16           ii_keysize;
+
+       /* reply: size of records in lu_idxpages, minimal one if II_FL_VARREC
+        * is set */
+       __u16           ii_recsize;
+
+       __u32           ii_pad1;
+       __u64           ii_pad2;
+       __u64           ii_pad3;
+};
+extern void lustre_swab_idx_info(struct idx_info *ii);
+
+#define II_END_OFF     MDS_DIR_END_OFF /* all entries have been read */
+
+/* List of flags used in idx_info::ii_flags */
+enum idx_info_flags {
+       II_FL_NOHASH    = 1 << 0, /* client doesn't care about hash value */
+       II_FL_VARKEY    = 1 << 1, /* keys can be of variable size */
+       II_FL_VARREC    = 1 << 2, /* records can be of variable size */
+       II_FL_NONUNQ    = 1 << 3, /* index supports non-unique keys */
+};
+
+#define LIP_MAGIC 0x8A6D6B6C
+
+/* 4KB (= LU_PAGE_SIZE) container gathering key/record pairs */
+struct lu_idxpage {
+       /* 16-byte header */
+       __u32   lip_magic;
+       __u16   lip_flags;
+       __u16   lip_nr;   /* number of entries in the container */
+       __u64   lip_pad0; /* additional padding for future use */
+
+       /* key/record pairs are stored in the remaining 4080 bytes.
+        * depending upon the flags in idx_info::ii_flags, each key/record
+        * pair might be preceded by:
+        * - a hash value
+        * - the key size (II_FL_VARKEY is set)
+        * - the record size (II_FL_VARREC is set)
+        *
+        * For the time being, we only support fixed-size key & record. */
+       char    lip_entries[0];
+};
+
+#define LIP_HDR_SIZE (offsetof(struct lu_idxpage, lip_entries))
+
+/* Gather all possible type associated with a 4KB container */
+union lu_page {
+       struct lu_dirpage       lp_dir; /* for MDS_READPAGE */
+       struct lu_idxpage       lp_idx; /* for OBD_IDX_READ */
+       char                    lp_array[LU_PAGE_SIZE];
+};
+
 /* this will be used when OBD_CONNECT_CHANGE_QS is set */
 struct qunit_data {
         /**