-#ifdef __KERNEL__
-/*
- * XXX: Functions below logically belong to the fid module, but they are used
- * by dt_store_open(). Put them here until better place is found.
- */
-
-void fid_pack(struct lu_fid_pack *pack, const struct lu_fid *fid,
- struct lu_fid *befider)
-{
- int recsize;
- __u64 seq;
- __u32 oid;
-
- seq = fid_seq(fid);
- oid = fid_oid(fid);
-
- /*
- * Two cases: compact 6 bytes representation for a common case, and
- * full 17 byte representation for "unusual" fid.
- */
-
- /*
- * Check that usual case is really usual.
- */
- CLASSERT(LUSTRE_SEQ_MAX_WIDTH < 0xffffull);
-
- /* fid can be packed in six bytes (first byte as length of packed fid,
- * three bytes of seq and two bytes of oid).
- * this reduces IO overhead specially for OSD Object Index. */
-
- if (seq < FID_SEQ_START ||
- seq > (0xffffffull + FID_SEQ_START) ||
- oid > 0xffff || fid_ver(fid) != 0) {
- fid_cpu_to_be(befider, fid);
- recsize = sizeof *befider;
- } else {
- unsigned char *small_befider;
-
- small_befider = (unsigned char *)befider;
-
- small_befider[0] = seq >> 16;
- small_befider[1] = seq >> 8;
- small_befider[2] = seq;
-
- small_befider[3] = oid >> 8;
- small_befider[4] = oid;
-
- recsize = 5;
- }
- memcpy(pack->fp_area, befider, recsize);
- pack->fp_len = recsize + 1;
-}
-EXPORT_SYMBOL(fid_pack);
-
-int fid_unpack(const struct lu_fid_pack *pack, struct lu_fid *fid)
-{
- int result;
-
- result = 0;
- switch (pack->fp_len) {
- case sizeof *fid + 1:
- memcpy(fid, pack->fp_area, sizeof *fid);
- fid_be_to_cpu(fid, fid);
- break;
- case 6: {
- const unsigned char *area;
-
- area = (unsigned char *)pack->fp_area;
- fid->f_seq = (area[0] << 16) | (area[1] << 8) | area[2];
- fid->f_seq += FID_SEQ_START;
- fid->f_oid = (area[3] << 8) | area[4];
- fid->f_ver = 0;
- break;
- }
- default:
- CERROR("Unexpected packed fid size: %d\n", pack->fp_len);
- result = -EIO;
- }
- return result;
-}
-EXPORT_SYMBOL(fid_unpack);
-#endif /* #ifdef __KERNEL__ */
-