X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Finclude%2Flustre_linkea.h;h=3bf6e2b54fd9b4e86602c93521d327f3faa38253;hb=acd639bf0de0c39419dff94fd6d338283a1ddb24;hp=acb8442930a9725ba90ca58d98b97e54f50c842c;hpb=2f41b688058532248e69ff0194c27616f4dfb6d5;p=fs%2Flustre-release.git diff --git a/lustre/include/lustre_linkea.h b/lustre/include/lustre_linkea.h index acb8442..3bf6e2b 100644 --- a/lustre/include/lustre_linkea.h +++ b/lustre/include/lustre_linkea.h @@ -21,13 +21,24 @@ * GPL HEADER END */ /* - * Copyright (c) 2013, Intel Corporation. + * Copyright (c) 2013, 2017, Intel Corporation. * Use is subject to license terms. * * Author: di wang */ -#define DEFAULT_LINKEA_SIZE 4096 +/* There are several reasons to restrict the linkEA size: + * + * 1. Under DNE mode, if we do not restrict the linkEA size, and if there + * are too many cross-MDTs hard links to the same object, then it will + * casue the llog overflow. + * + * 2. Some backend has limited size for EA. For example, if without large + * EA enabled, the ldiskfs will make all EAs to share one (4K) EA block. + * + * 3. Too many entries in linkEA will seriously affect linkEA performance + * because we only support to locate linkEA entry consecutively. */ +#define MAX_LINKEA_SIZE 4096 struct linkea_data { /** @@ -44,16 +55,41 @@ struct linkea_data { int linkea_data_new(struct linkea_data *ldata, struct lu_buf *buf); int linkea_init(struct linkea_data *ldata); +int linkea_init_with_rec(struct linkea_data *ldata); void linkea_entry_unpack(const struct link_ea_entry *lee, int *reclen, struct lu_name *lname, struct lu_fid *pfid); +int linkea_entry_pack(struct link_ea_entry *lee, const struct lu_name *lname, + const struct lu_fid *pfid); int linkea_add_buf(struct linkea_data *ldata, const struct lu_name *lname, const struct lu_fid *pfid); void linkea_del_buf(struct linkea_data *ldata, const struct lu_name *lname); +int linkea_links_new(struct linkea_data *ldata, struct lu_buf *buf, + const struct lu_name *cname, const struct lu_fid *pfid); +int linkea_overflow_shrink(struct linkea_data *ldata); 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; + } +}