4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2013, 2014, Intel Corporation.
24 * Use is subject to license terms.
26 * Author: di wang <di.wang@intel.com>
29 #define DEFAULT_LINKEA_SIZE 4096
33 * Buffer to keep link EA body.
35 struct lu_buf *ld_buf;
37 * The matched header, entry and its length in the EA
39 struct link_ea_header *ld_leh;
40 struct link_ea_entry *ld_lee;
44 int linkea_data_new(struct linkea_data *ldata, struct lu_buf *buf);
45 int linkea_init(struct linkea_data *ldata);
46 void linkea_entry_unpack(const struct link_ea_entry *lee, int *reclen,
47 struct lu_name *lname, struct lu_fid *pfid);
48 int linkea_entry_pack(struct link_ea_entry *lee, const struct lu_name *lname,
49 const struct lu_fid *pfid);
50 int linkea_add_buf(struct linkea_data *ldata, const struct lu_name *lname,
51 const struct lu_fid *pfid);
52 void linkea_del_buf(struct linkea_data *ldata, const struct lu_name *lname);
53 int linkea_links_find(struct linkea_data *ldata, const struct lu_name *lname,
54 const struct lu_fid *pfid);
56 static inline void linkea_first_entry(struct linkea_data *ldata)
59 LASSERT(ldata->ld_leh);
61 if (ldata->ld_leh->leh_reccount == 0)
64 ldata->ld_lee = (struct link_ea_entry *)(ldata->ld_leh + 1);
67 static inline void linkea_next_entry(struct linkea_data *ldata)
70 LASSERT(ldata->ld_leh);
73 ldata->ld_lee = (struct link_ea_entry *)((char *)ldata->ld_lee +
75 if ((char *)ldata->ld_lee >= ((char *)ldata->ld_leh +
76 ldata->ld_leh->leh_len))