Whamcloud - gitweb
LU-5946 lprocfs: free expired jobstats after /proc read
[fs/lustre-release.git] / lustre / obdclass / linkea.c
index eed6fd2..910efb9 100644 (file)
@@ -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 <di.wang@intel.com>
@@ -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);