Whamcloud - gitweb
LU-1330 obdclass: add obd_target.h
[fs/lustre-release.git] / lustre / include / lustre_linkea.h
index 5790be9..1e07f3a 100644 (file)
@@ -27,6 +27,8 @@
  * Author: di wang <di.wang@intel.com>
  */
 
+#define DEFAULT_LINKEA_SIZE    4096
+
 struct linkea_data {
        /**
         * Buffer to keep link EA body.
@@ -50,8 +52,27 @@ void linkea_del_buf(struct linkea_data *ldata, const struct lu_name *lname);
 int linkea_links_find(struct linkea_data *ldata, const struct lu_name *lname,
                      const struct lu_fid  *pfid);
 
-#define LINKEA_NEXT_ENTRY(ldata)       \
-       (struct link_ea_entry *)((char *)ldata.ld_lee + ldata.ld_reclen)
+static inline void linkea_first_entry(struct linkea_data *ldata)
+{
+       LASSERT(ldata != NULL);
+       LASSERT(ldata->ld_leh != NULL);
+
+       if (ldata->ld_leh->leh_reccount == 0)
+               ldata->ld_lee = NULL;
+       else
+               ldata->ld_lee = (struct link_ea_entry *)(ldata->ld_leh + 1);
+}
+
+static inline void linkea_next_entry(struct linkea_data *ldata)
+{
+       LASSERT(ldata != NULL);
+       LASSERT(ldata->ld_leh != NULL);
 
-#define LINKEA_FIRST_ENTRY(ldata)      \
-       (struct link_ea_entry *)(ldata.ld_leh + 1)
+       if (ldata->ld_lee != NULL) {
+               ldata->ld_lee = (struct link_ea_entry *)((char *)ldata->ld_lee +
+                                                        ldata->ld_reclen);
+               if ((char *)ldata->ld_lee >= ((char *)ldata->ld_leh +
+                                             ldata->ld_leh->leh_len))
+                       ldata->ld_lee = NULL;
+       }
+}