X-Git-Url: https://git.whamcloud.com/?a=blobdiff_plain;f=lustre%2Fobdclass%2Flinkea.c;h=910efb98d00a8c598fc896aed4d4e64cd67d46ed;hb=dd99ddf9f22921535c3f083e91bfc06a566e382b;hp=eed6fd21dad1a18ef0bb6c1d213d12ec1a85d124;hpb=1b2547843817b4b7adbeb87ea9b070d9cac35c90;p=fs%2Flustre-release.git diff --git a/lustre/obdclass/linkea.c b/lustre/obdclass/linkea.c index eed6fd2..910efb9 100644 --- a/lustre/obdclass/linkea.c +++ b/lustre/obdclass/linkea.c @@ -21,7 +21,7 @@ * GPL HEADER END */ /* - * Copyright (c) 2013, Intel Corporation. + * Copyright (c) 2013, 2014, Intel Corporation. * Use is subject to license terms. * * Author: Di Wang @@ -72,16 +72,18 @@ EXPORT_SYMBOL(linkea_init); * Numbers are always big-endian * \retval record length */ -static int linkea_entry_pack(struct link_ea_entry *lee, - const struct lu_name *lname, - const struct lu_fid *pfid) +int linkea_entry_pack(struct link_ea_entry *lee, const struct lu_name *lname, + const struct lu_fid *pfid) { struct lu_fid tmpfid; int reclen; - fid_cpu_to_be(&tmpfid, pfid); + tmpfid = *pfid; + if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_MUL_REF)) + tmpfid.f_oid--; if (OBD_FAIL_CHECK(OBD_FAIL_LFSCK_LINKEA_CRASH)) tmpfid.f_ver = ~0; + fid_cpu_to_be(&tmpfid, &tmpfid); memcpy(&lee->lee_parent_fid, &tmpfid, sizeof(tmpfid)); memcpy(lee->lee_name, lname->ln_name, lname->ln_namelen); reclen = sizeof(struct link_ea_entry) + lname->ln_namelen; @@ -90,6 +92,7 @@ static int linkea_entry_pack(struct link_ea_entry *lee, lee->lee_reclen[1] = reclen & 0xff; return reclen; } +EXPORT_SYMBOL(linkea_entry_pack); void linkea_entry_unpack(const struct link_ea_entry *lee, int *reclen, struct lu_name *lname, struct lu_fid *pfid) @@ -97,8 +100,10 @@ void linkea_entry_unpack(const struct link_ea_entry *lee, int *reclen, *reclen = (lee->lee_reclen[0] << 8) | lee->lee_reclen[1]; memcpy(pfid, &lee->lee_parent_fid, sizeof(*pfid)); fid_be_to_cpu(pfid, pfid); - lname->ln_name = lee->lee_name; - lname->ln_namelen = *reclen - sizeof(struct link_ea_entry); + if (lname != NULL) { + lname->ln_name = lee->lee_name; + lname->ln_namelen = *reclen - sizeof(struct link_ea_entry); + } } EXPORT_SYMBOL(linkea_entry_unpack);