Whamcloud - gitweb
LU-6401 headers: move lu_fid, ost_id funcs out of lustre_idl.h 12/22712/10
authorBen Evans <bevans@cray.com>
Mon, 24 Oct 2016 16:48:26 +0000 (12:48 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Sun, 1 Jan 2017 02:00:12 +0000 (02:00 +0000)
Move lu_fid functions into lustre/lustre_fid.h
Move ost_id functions into lustre/lustre_ostid.h
Fix indenting, include new headers as needed

Signed-off-by: Ben Evans <bevans@cray.com>
Change-Id: Idcbb95f614829b434c48a476172eedb421fe488f
Reviewed-on: https://review.whamcloud.com/22712
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-by: Frank Zago <fzago@cray.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
23 files changed:
lustre/include/lustre/Makefile.am
lustre/include/lustre/lustre_fid.h [new file with mode: 0644]
lustre/include/lustre/lustre_idl.h
lustre/include/lustre/lustre_ostid.h [new file with mode: 0644]
lustre/include/lustre_fid.h
lustre/include/lustre_log_user.h
lustre/ldlm/ldlm_lockd.c
lustre/ldlm/ldlm_request.c
lustre/mdc/mdc_request.c
lustre/mdt/mdt_hsm.c
lustre/tests/group_lock_test.c
lustre/tests/multiop.c
lustre/tests/sendfile_grouplock.c
lustre/tests/swap_lock_test.c
lustre/utils/lctl.c
lustre/utils/lhsmtool_posix.c
lustre/utils/liblustreapi.c
lustre/utils/liblustreapi_ladvise.c
lustre/utils/ll_decode_linkea.c
lustre/utils/llog_reader.c
lustre/utils/lustre_cfg.c
lustre/utils/mount_lustre.c
lustre/utils/obd.c

index c54df80..f9aa8c2 100644 (file)
@@ -36,5 +36,13 @@ if UTILS
 pkginclude_HEADERS = lustreapi.h lustre_user.h liblustreapi.h ll_fiemap.h
 endif
 
-EXTRA_DIST = lustreapi.h lustre_idl.h lustre_user.h liblustreapi.h \
-       libiam.h ll_fiemap.h lustre_lfsck_user.h lustre_errno.h
+EXTRA_DIST = libiam.h \
+       liblustreapi.h \
+       ll_fiemap.h \
+       lustre_errno.h \
+       lustre_fid.h \
+       lustre_idl.h \
+       lustre_lfsck_user.h \
+       lustre_ostid.h \
+       lustre_user.h \
+       lustreapi.h
diff --git a/lustre/include/lustre/lustre_fid.h b/lustre/include/lustre/lustre_fid.h
new file mode 100644 (file)
index 0000000..cb6afa5
--- /dev/null
@@ -0,0 +1,353 @@
+/*
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.gnu.org/licenses/gpl-2.0.html
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2014, Intel Corporation.
+ *
+ * Copyright 2016 Cray Inc, all rights reserved.
+ * Author: Ben Evans.
+ *
+ * all fid manipulation functions go here
+ *
+ * FIDS are globally unique within a Lustre filessytem, and are made up
+ * of three parts: sequence, Object ID, and version.
+ *
+ */
+#ifndef _LUSTRE_LUSTRE_FID_H_
+#define _LUSTRE_LUSTRE_FID_H_
+
+#include <lustre/lustre_idl.h>
+
+/** returns fid object sequence */
+static inline __u64 fid_seq(const struct lu_fid *fid)
+{
+       return fid->f_seq;
+}
+
+/** returns fid object id */
+static inline __u32 fid_oid(const struct lu_fid *fid)
+{
+       return fid->f_oid;
+}
+
+/** returns fid object version */
+static inline __u32 fid_ver(const struct lu_fid *fid)
+{
+       return fid->f_ver;
+}
+
+static inline void fid_zero(struct lu_fid *fid)
+{
+       memset(fid, 0, sizeof(*fid));
+}
+
+static inline __u64 fid_ver_oid(const struct lu_fid *fid)
+{
+       return (__u64)fid_ver(fid) << 32 | fid_oid(fid);
+}
+
+static inline bool fid_seq_is_mdt0(__u64 seq)
+{
+       return seq == FID_SEQ_OST_MDT0;
+}
+
+static inline bool fid_seq_is_mdt(__u64 seq)
+{
+       return seq == FID_SEQ_OST_MDT0 || seq >= FID_SEQ_NORMAL;
+};
+
+static inline bool fid_seq_is_echo(__u64 seq)
+{
+       return seq == FID_SEQ_ECHO;
+}
+
+static inline bool fid_is_echo(const struct lu_fid *fid)
+{
+       return fid_seq_is_echo(fid_seq(fid));
+}
+
+static inline bool fid_seq_is_llog(__u64 seq)
+{
+       return seq == FID_SEQ_LLOG;
+}
+
+static inline bool fid_is_llog(const struct lu_fid *fid)
+{
+       /* file with OID == 0 is not llog but contains last oid */
+       return fid_seq_is_llog(fid_seq(fid)) && fid_oid(fid) > 0;
+}
+
+static inline bool fid_seq_is_rsvd(__u64 seq)
+{
+       return seq > FID_SEQ_OST_MDT0 && seq <= FID_SEQ_RSVD;
+};
+
+static inline bool fid_seq_is_special(__u64 seq)
+{
+       return seq == FID_SEQ_SPECIAL;
+};
+
+static inline bool fid_seq_is_local_file(__u64 seq)
+{
+       return seq == FID_SEQ_LOCAL_FILE ||
+              seq == FID_SEQ_LOCAL_NAME;
+};
+
+static inline bool fid_seq_is_root(__u64 seq)
+{
+       return seq == FID_SEQ_ROOT;
+}
+
+static inline bool fid_seq_is_dot(__u64 seq)
+{
+       return seq == FID_SEQ_DOT_LUSTRE;
+}
+
+static inline bool fid_seq_is_default(__u64 seq)
+{
+       return seq == FID_SEQ_LOV_DEFAULT;
+}
+
+static inline bool fid_is_mdt0(const struct lu_fid *fid)
+{
+       return fid_seq_is_mdt0(fid_seq(fid));
+}
+
+static inline void lu_root_fid(struct lu_fid *fid)
+{
+       fid->f_seq = FID_SEQ_ROOT;
+       fid->f_oid = FID_OID_ROOT;
+       fid->f_ver = 0;
+}
+
+static inline void lu_echo_root_fid(struct lu_fid *fid)
+{
+       fid->f_seq = FID_SEQ_ROOT;
+       fid->f_oid = FID_OID_ECHO_ROOT;
+       fid->f_ver = 0;
+}
+
+static inline void lu_update_log_fid(struct lu_fid *fid, __u32 index)
+{
+       fid->f_seq = FID_SEQ_UPDATE_LOG;
+       fid->f_oid = index;
+       fid->f_ver = 0;
+}
+
+static inline void lu_update_log_dir_fid(struct lu_fid *fid, __u32 index)
+{
+       fid->f_seq = FID_SEQ_UPDATE_LOG_DIR;
+       fid->f_oid = index;
+       fid->f_ver = 0;
+}
+
+/**
+ * Check if a fid is igif or not.
+ * \param fid the fid to be tested.
+ * \return true if the fid is an igif; otherwise false.
+ */
+static inline bool fid_seq_is_igif(__u64 seq)
+{
+       return seq >= FID_SEQ_IGIF && seq <= FID_SEQ_IGIF_MAX;
+}
+
+static inline bool fid_is_igif(const struct lu_fid *fid)
+{
+       return fid_seq_is_igif(fid_seq(fid));
+}
+
+/**
+ * Check if a fid is idif or not.
+ * \param fid the fid to be tested.
+ * \return true if the fid is an idif; otherwise false.
+ */
+static inline bool fid_seq_is_idif(__u64 seq)
+{
+       return seq >= FID_SEQ_IDIF && seq <= FID_SEQ_IDIF_MAX;
+}
+
+static inline bool fid_is_idif(const struct lu_fid *fid)
+{
+       return fid_seq_is_idif(fid_seq(fid));
+}
+
+static inline bool fid_is_local_file(const struct lu_fid *fid)
+{
+       return fid_seq_is_local_file(fid_seq(fid));
+}
+
+static inline bool fid_seq_is_norm(__u64 seq)
+{
+       return (seq >= FID_SEQ_NORMAL);
+}
+
+static inline bool fid_is_norm(const struct lu_fid *fid)
+{
+       return fid_seq_is_norm(fid_seq(fid));
+}
+
+static inline int fid_is_layout_rbtree(const struct lu_fid *fid)
+{
+       return fid_seq(fid) == FID_SEQ_LAYOUT_RBTREE;
+}
+
+static inline bool fid_seq_is_update_log(__u64 seq)
+{
+       return seq == FID_SEQ_UPDATE_LOG;
+}
+
+static inline bool fid_is_update_log(const struct lu_fid *fid)
+{
+       return fid_seq_is_update_log(fid_seq(fid));
+}
+
+static inline bool fid_seq_is_update_log_dir(__u64 seq)
+{
+       return seq == FID_SEQ_UPDATE_LOG_DIR;
+}
+
+static inline bool fid_is_update_log_dir(const struct lu_fid *fid)
+{
+       return fid_seq_is_update_log_dir(fid_seq(fid));
+}
+
+/* convert an OST objid into an IDIF FID SEQ number */
+static inline __u64 fid_idif_seq(__u64 id, __u32 ost_idx)
+{
+       return FID_SEQ_IDIF | (ost_idx << 16) | ((id >> 32) & 0xffff);
+}
+
+/* convert a packed IDIF FID into an OST objid */
+static inline __u64 fid_idif_id(__u64 seq, __u32 oid, __u32 ver)
+{
+       return ((__u64)ver << 48) | ((seq & 0xffff) << 32) | oid;
+}
+
+static inline __u32 idif_ost_idx(__u64 seq)
+{
+       return (seq >> 16) & 0xffff;
+}
+
+/* extract ost index from IDIF FID */
+static inline __u32 fid_idif_ost_idx(const struct lu_fid *fid)
+{
+       return idif_ost_idx(fid_seq(fid));
+}
+
+/* Check whether the fid is for LAST_ID */
+static inline bool fid_is_last_id(const struct lu_fid *fid)
+{
+       return !fid_oid(fid) && fid_seq(fid) != FID_SEQ_UPDATE_LOG &&
+              fid_seq(fid) != FID_SEQ_UPDATE_LOG_DIR;
+}
+
+/**
+ * Get inode number from an igif.
+ * \param fid an igif to get inode number from.
+ * \return inode number for the igif.
+ */
+static inline ino_t lu_igif_ino(const struct lu_fid *fid)
+{
+       return fid_seq(fid);
+}
+
+/**
+ * Get inode generation from an igif.
+ * \param fid an igif to get inode generation from.
+ * \return inode generation for the igif.
+ */
+static inline __u32 lu_igif_gen(const struct lu_fid *fid)
+{
+       return fid_oid(fid);
+}
+
+/**
+ * Build igif from the inode number/generation.
+ */
+static inline void lu_igif_build(struct lu_fid *fid, __u32 ino, __u32 gen)
+{
+       fid->f_seq = ino;
+       fid->f_oid = gen;
+       fid->f_ver = 0;
+}
+
+/*
+ * Fids are transmitted across network (in the sender byte-ordering),
+ * and stored on disk in big-endian order.
+ */
+static inline void fid_cpu_to_le(struct lu_fid *dst, const struct lu_fid *src)
+{
+       dst->f_seq = __cpu_to_le64(fid_seq(src));
+       dst->f_oid = __cpu_to_le32(fid_oid(src));
+       dst->f_ver = __cpu_to_le32(fid_ver(src));
+}
+
+static inline void fid_le_to_cpu(struct lu_fid *dst, const struct lu_fid *src)
+{
+       dst->f_seq = __le64_to_cpu(fid_seq(src));
+       dst->f_oid = __le32_to_cpu(fid_oid(src));
+       dst->f_ver = __le32_to_cpu(fid_ver(src));
+}
+
+static inline void fid_cpu_to_be(struct lu_fid *dst, const struct lu_fid *src)
+{
+       dst->f_seq = __cpu_to_be64(fid_seq(src));
+       dst->f_oid = __cpu_to_be32(fid_oid(src));
+       dst->f_ver = __cpu_to_be32(fid_ver(src));
+}
+
+static inline void fid_be_to_cpu(struct lu_fid *dst, const struct lu_fid *src)
+{
+       dst->f_seq = __be64_to_cpu(fid_seq(src));
+       dst->f_oid = __be32_to_cpu(fid_oid(src));
+       dst->f_ver = __be32_to_cpu(fid_ver(src));
+}
+
+static inline bool fid_is_sane(const struct lu_fid *fid)
+{
+       return fid && ((fid_seq(fid) >= FID_SEQ_START && !fid_ver(fid)) ||
+                       fid_is_igif(fid) || fid_is_idif(fid) ||
+                       fid_seq_is_rsvd(fid_seq(fid)));
+}
+
+static inline bool lu_fid_eq(const struct lu_fid *f0, const struct lu_fid *f1)
+{
+       return !memcmp(f0, f1, sizeof(*f0));
+}
+
+static inline int lu_fid_cmp(const struct lu_fid *f0,
+                            const struct lu_fid *f1)
+{
+       if (fid_seq(f0) != fid_seq(f1))
+               return fid_seq(f0) > fid_seq(f1) ? 1 : -1;
+
+       if (fid_oid(f0) != fid_oid(f1))
+               return fid_oid(f0) > fid_oid(f1) ? 1 : -1;
+
+       if (fid_ver(f0) != fid_ver(f1))
+               return fid_ver(f0) > fid_ver(f1) ? 1 : -1;
+
+       return 0;
+}
+#endif
index aa8853f..a5bef55 100644 (file)
@@ -75,7 +75,6 @@
 #include <libcfs/libcfs.h>
 #include <lnet/types.h>
 #include <lustre/lustre_user.h> /* Defn's shared with user-space. */
-#include <lustre/lustre_errno.h>
 #include <lustre_ver.h>
 
 /*
@@ -237,34 +236,6 @@ enum {
         LUSTRE_FID_INIT_OID  = 1UL
 };
 
-/** returns fid object sequence */
-static inline __u64 fid_seq(const struct lu_fid *fid)
-{
-        return fid->f_seq;
-}
-
-/** returns fid object id */
-static inline __u32 fid_oid(const struct lu_fid *fid)
-{
-        return fid->f_oid;
-}
-
-/** returns fid object version */
-static inline __u32 fid_ver(const struct lu_fid *fid)
-{
-        return fid->f_ver;
-}
-
-static inline void fid_zero(struct lu_fid *fid)
-{
-        memset(fid, 0, sizeof(*fid));
-}
-
-static inline __u64 fid_ver_oid(const struct lu_fid *fid)
-{
-        return ((__u64)fid_ver(fid) << 32 | fid_oid(fid));
-}
-
 /**
  * Note that reserved SEQ numbers below 12 will conflict with ldiskfs
  * inodes in the IGIF namespace, so these reserved SEQ numbers can be
@@ -337,509 +308,6 @@ enum root_oid {
        FID_OID_ECHO_ROOT       = 2UL,
 };
 
-static inline bool fid_seq_is_mdt0(__u64 seq)
-{
-       return seq == FID_SEQ_OST_MDT0;
-}
-
-static inline bool fid_seq_is_mdt(__u64 seq)
-{
-       return seq == FID_SEQ_OST_MDT0 || seq >= FID_SEQ_NORMAL;
-};
-
-static inline bool fid_seq_is_echo(__u64 seq)
-{
-       return seq == FID_SEQ_ECHO;
-}
-
-static inline bool fid_is_echo(const struct lu_fid *fid)
-{
-       return fid_seq_is_echo(fid_seq(fid));
-}
-
-static inline bool fid_seq_is_llog(__u64 seq)
-{
-       return seq == FID_SEQ_LLOG;
-}
-
-static inline bool fid_is_llog(const struct lu_fid *fid)
-{
-       /* file with OID == 0 is not llog but contains last oid */
-       return fid_seq_is_llog(fid_seq(fid)) && fid_oid(fid) > 0;
-}
-
-static inline bool fid_seq_is_rsvd(__u64 seq)
-{
-       return seq > FID_SEQ_OST_MDT0 && seq <= FID_SEQ_RSVD;
-};
-
-static inline bool fid_seq_is_special(__u64 seq)
-{
-       return seq == FID_SEQ_SPECIAL;
-};
-
-static inline bool fid_seq_is_local_file(__u64 seq)
-{
-       return seq == FID_SEQ_LOCAL_FILE ||
-              seq == FID_SEQ_LOCAL_NAME;
-};
-
-static inline bool fid_seq_is_root(__u64 seq)
-{
-       return seq == FID_SEQ_ROOT;
-}
-
-static inline bool fid_seq_is_dot(__u64 seq)
-{
-       return seq == FID_SEQ_DOT_LUSTRE;
-}
-
-static inline bool fid_seq_is_default(__u64 seq)
-{
-       return seq == FID_SEQ_LOV_DEFAULT;
-}
-
-static inline bool fid_is_mdt0(const struct lu_fid *fid)
-{
-       return fid_seq_is_mdt0(fid_seq(fid));
-}
-
-static inline void lu_root_fid(struct lu_fid *fid)
-{
-       fid->f_seq = FID_SEQ_ROOT;
-       fid->f_oid = FID_OID_ROOT;
-       fid->f_ver = 0;
-}
-
-static inline void lu_echo_root_fid(struct lu_fid *fid)
-{
-       fid->f_seq = FID_SEQ_ROOT;
-       fid->f_oid = FID_OID_ECHO_ROOT;
-       fid->f_ver = 0;
-}
-
-static inline void lu_update_log_fid(struct lu_fid *fid, __u32 index)
-{
-       fid->f_seq = FID_SEQ_UPDATE_LOG;
-       fid->f_oid = index;
-       fid->f_ver = 0;
-}
-
-static inline void lu_update_log_dir_fid(struct lu_fid *fid, __u32 index)
-{
-       fid->f_seq = FID_SEQ_UPDATE_LOG_DIR;
-       fid->f_oid = index;
-       fid->f_ver = 0;
-}
-
-/**
- * Check if a fid is igif or not.
- * \param fid the fid to be tested.
- * \return true if the fid is an igif; otherwise false.
- */
-static inline bool fid_seq_is_igif(__u64 seq)
-{
-       return seq >= FID_SEQ_IGIF && seq <= FID_SEQ_IGIF_MAX;
-}
-
-static inline bool fid_is_igif(const struct lu_fid *fid)
-{
-       return fid_seq_is_igif(fid_seq(fid));
-}
-
-/**
- * Check if a fid is idif or not.
- * \param fid the fid to be tested.
- * \return true if the fid is an idif; otherwise false.
- */
-static inline bool fid_seq_is_idif(__u64 seq)
-{
-       return seq >= FID_SEQ_IDIF && seq <= FID_SEQ_IDIF_MAX;
-}
-
-static inline bool fid_is_idif(const struct lu_fid *fid)
-{
-       return fid_seq_is_idif(fid_seq(fid));
-}
-
-static inline bool fid_is_local_file(const struct lu_fid *fid)
-{
-       return fid_seq_is_local_file(fid_seq(fid));
-}
-
-static inline bool fid_seq_is_norm(__u64 seq)
-{
-       return (seq >= FID_SEQ_NORMAL);
-}
-
-static inline bool fid_is_norm(const struct lu_fid *fid)
-{
-       return fid_seq_is_norm(fid_seq(fid));
-}
-
-static inline int fid_is_layout_rbtree(const struct lu_fid *fid)
-{
-       return fid_seq(fid) == FID_SEQ_LAYOUT_RBTREE;
-}
-
-static inline bool fid_seq_is_update_log(__u64 seq)
-{
-       return seq == FID_SEQ_UPDATE_LOG;
-}
-
-static inline bool fid_is_update_log(const struct lu_fid *fid)
-{
-       return fid_seq_is_update_log(fid_seq(fid));
-}
-
-static inline bool fid_seq_is_update_log_dir(__u64 seq)
-{
-       return seq == FID_SEQ_UPDATE_LOG_DIR;
-}
-
-static inline bool fid_is_update_log_dir(const struct lu_fid *fid)
-{
-       return fid_seq_is_update_log_dir(fid_seq(fid));
-}
-
-/* convert an OST objid into an IDIF FID SEQ number */
-static inline __u64 fid_idif_seq(__u64 id, __u32 ost_idx)
-{
-       return FID_SEQ_IDIF | (ost_idx << 16) | ((id >> 32) & 0xffff);
-}
-
-/* convert a packed IDIF FID into an OST objid */
-static inline __u64 fid_idif_id(__u64 seq, __u32 oid, __u32 ver)
-{
-       return ((__u64)ver << 48) | ((seq & 0xffff) << 32) | oid;
-}
-
-static inline __u32 idif_ost_idx(__u64 seq)
-{
-       return (seq >> 16) & 0xffff;
-}
-
-/* extract ost index from IDIF FID */
-static inline __u32 fid_idif_ost_idx(const struct lu_fid *fid)
-{
-       return idif_ost_idx(fid_seq(fid));
-}
-
-/* extract OST sequence (group) from a wire ost_id (id/seq) pair */
-static inline __u64 ostid_seq(const struct ost_id *ostid)
-{
-       if (fid_seq_is_mdt0(ostid->oi.oi_seq))
-               return FID_SEQ_OST_MDT0;
-
-       if (unlikely(fid_seq_is_default(ostid->oi.oi_seq)))
-               return FID_SEQ_LOV_DEFAULT;
-
-       if (fid_is_idif(&ostid->oi_fid))
-               return FID_SEQ_OST_MDT0;
-
-       return fid_seq(&ostid->oi_fid);
-}
-
-/* extract OST objid from a wire ost_id (id/seq) pair */
-static inline __u64 ostid_id(const struct ost_id *ostid)
-{
-       if (fid_seq_is_mdt0(ostid->oi.oi_seq))
-               return ostid->oi.oi_id & IDIF_OID_MASK;
-
-       if (unlikely(fid_seq_is_default(ostid->oi.oi_seq)))
-               return ostid->oi.oi_id;
-
-       if (fid_is_idif(&ostid->oi_fid))
-               return fid_idif_id(fid_seq(&ostid->oi_fid),
-                                  fid_oid(&ostid->oi_fid), 0);
-
-       return fid_oid(&ostid->oi_fid);
-}
-
-static inline void ostid_set_seq(struct ost_id *oi, __u64 seq)
-{
-       if (fid_seq_is_mdt0(seq) || fid_seq_is_default(seq)) {
-               oi->oi.oi_seq = seq;
-       } else {
-               oi->oi_fid.f_seq = seq;
-               /* Note: if f_oid + f_ver is zero, we need init it
-                * to be 1, otherwise, ostid_seq will treat this
-                * as old ostid (oi_seq == 0) */
-               if (oi->oi_fid.f_oid == 0 && oi->oi_fid.f_ver == 0)
-                       oi->oi_fid.f_oid = LUSTRE_FID_INIT_OID;
-       }
-}
-
-static inline void ostid_set_seq_mdt0(struct ost_id *oi)
-{
-       ostid_set_seq(oi, FID_SEQ_OST_MDT0);
-}
-
-static inline void ostid_set_seq_echo(struct ost_id *oi)
-{
-       ostid_set_seq(oi, FID_SEQ_ECHO);
-}
-
-static inline void ostid_set_seq_llog(struct ost_id *oi)
-{
-       ostid_set_seq(oi, FID_SEQ_LLOG);
-}
-
-/**
- * Note: we need check oi_seq to decide where to set oi_id,
- * so oi_seq should always be set ahead of oi_id.
- */
-static inline void ostid_set_id(struct ost_id *oi, __u64 oid)
-{
-       if (fid_seq_is_mdt0(oi->oi.oi_seq)) {
-               if (oid >= IDIF_MAX_OID) {
-                       CERROR("Too large OID %#llx to set MDT0 "DOSTID"\n",
-                              (unsigned long long)oid, POSTID(oi));
-                       return;
-               }
-               oi->oi.oi_id = oid;
-       } else if (fid_is_idif(&oi->oi_fid)) {
-               if (oid >= IDIF_MAX_OID) {
-                       CERROR("Too large OID %#llx to set IDIF "DOSTID"\n",
-                              (unsigned long long)oid, POSTID(oi));
-                       return;
-               }
-               oi->oi_fid.f_seq = fid_idif_seq(oid,
-                                               fid_idif_ost_idx(&oi->oi_fid));
-               oi->oi_fid.f_oid = oid;
-               oi->oi_fid.f_ver = oid >> 48;
-       } else {
-               if (oid > OBIF_MAX_OID) {
-                       CERROR("Too large oid %#llx to set REG "DOSTID"\n",
-                              (unsigned long long)oid, POSTID(oi));
-                       return;
-               }
-               oi->oi_fid.f_oid = oid;
-       }
-}
-
-static inline int fid_set_id(struct lu_fid *fid, __u64 oid)
-{
-       if (unlikely(fid_seq_is_igif(fid->f_seq))) {
-               CERROR("bad IGIF, "DFID"\n", PFID(fid));
-               return -EBADF;
-       }
-
-       if (fid_is_idif(fid)) {
-               if (oid >= IDIF_MAX_OID) {
-                       CERROR("Too large OID %#llx to set IDIF "DFID"\n",
-                              (unsigned long long)oid, PFID(fid));
-                       return -EBADF;
-               }
-               fid->f_seq = fid_idif_seq(oid, fid_idif_ost_idx(fid));
-               fid->f_oid = oid;
-               fid->f_ver = oid >> 48;
-       } else {
-               if (oid > OBIF_MAX_OID) {
-                       CERROR("Too large OID %#llx to set REG "DFID"\n",
-                              (unsigned long long)oid, PFID(fid));
-                       return -EBADF;
-               }
-               fid->f_oid = oid;
-       }
-       return 0;
-}
-
-/**
- * Unpack an OST object id/seq (group) into a FID.  This is needed for
- * converting all obdo, lmm, lsm, etc. 64-bit id/seq pairs into proper
- * FIDs.  Note that if an id/seq is already in FID/IDIF format it will
- * be passed through unchanged.  Only legacy OST objects in "group 0"
- * will be mapped into the IDIF namespace so that they can fit into the
- * struct lu_fid fields without loss.  For reference see:
- * http://arch.lustre.org/index.php?title=Interoperability_fids_zfs
- */
-static inline int ostid_to_fid(struct lu_fid *fid, const struct ost_id *ostid,
-                              __u32 ost_idx)
-{
-       __u64 seq = ostid_seq(ostid);
-
-       if (ost_idx > 0xffff) {
-               CERROR("bad ost_idx, "DOSTID" ost_idx:%u\n", POSTID(ostid),
-                      ost_idx);
-               return -EBADF;
-       }
-
-       if (fid_seq_is_mdt0(seq)) {
-               __u64 oid = ostid_id(ostid);
-
-               /* This is a "legacy" (old 1.x/2.early) OST object in "group 0"
-                * that we map into the IDIF namespace.  It allows up to 2^48
-                * objects per OST, as this is the object namespace that has
-                * been in production for years.  This can handle create rates
-                * of 1M objects/s/OST for 9 years, or combinations thereof. */
-               if (oid >= IDIF_MAX_OID) {
-                       CERROR("bad MDT0 id(1), "DOSTID" ost_idx:%u\n",
-                              POSTID(ostid), ost_idx);
-                       return -EBADF;
-               }
-               fid->f_seq = fid_idif_seq(oid, ost_idx);
-               /* truncate to 32 bits by assignment */
-               fid->f_oid = oid;
-               /* in theory, not currently used */
-               fid->f_ver = oid >> 48;
-       } else if (likely(!fid_seq_is_default(seq)))
-               /* if (fid_seq_is_idif(seq) || fid_seq_is_norm(seq)) */ {
-               /* This is either an IDIF object, which identifies objects
-                * across all OSTs, or a regular FID.  The IDIF namespace maps
-                * legacy OST objects into the FID namespace.  In both cases,
-                * we just pass the FID through, no conversion needed. */
-               if (ostid->oi_fid.f_ver != 0) {
-                       CERROR("bad MDT0 id(2), "DOSTID" ost_idx:%u\n",
-                               POSTID(ostid), ost_idx);
-                       return -EBADF;
-               }
-               *fid = ostid->oi_fid;
-       }
-
-       return 0;
-}
-
-/* pack any OST FID into an ostid (id/seq) for the wire/disk */
-static inline int fid_to_ostid(const struct lu_fid *fid, struct ost_id *ostid)
-{
-       if (unlikely(fid_seq_is_igif(fid->f_seq))) {
-               CERROR("bad IGIF, "DFID"\n", PFID(fid));
-               return -EBADF;
-       }
-
-       if (fid_is_idif(fid)) {
-               ostid_set_seq_mdt0(ostid);
-               ostid_set_id(ostid, fid_idif_id(fid_seq(fid), fid_oid(fid),
-                                               fid_ver(fid)));
-       } else {
-               ostid->oi_fid = *fid;
-       }
-
-       return 0;
-}
-
-/* Check whether the fid is for LAST_ID */
-static inline bool fid_is_last_id(const struct lu_fid *fid)
-{
-       return fid_oid(fid) == 0 && fid_seq(fid) != FID_SEQ_UPDATE_LOG &&
-              fid_seq(fid) != FID_SEQ_UPDATE_LOG_DIR;
-}
-
-/**
- * Get inode number from an igif.
- * \param fid an igif to get inode number from.
- * \return inode number for the igif.
- */
-static inline ino_t lu_igif_ino(const struct lu_fid *fid)
-{
-        return fid_seq(fid);
-}
-
-/**
- * Get inode generation from an igif.
- * \param fid an igif to get inode generation from.
- * \return inode generation for the igif.
- */
-static inline __u32 lu_igif_gen(const struct lu_fid *fid)
-{
-        return fid_oid(fid);
-}
-
-/**
- * Build igif from the inode number/generation.
- */
-static inline void lu_igif_build(struct lu_fid *fid, __u32 ino, __u32 gen)
-{
-       fid->f_seq = ino;
-       fid->f_oid = gen;
-       fid->f_ver = 0;
-}
-
-/*
- * Fids are transmitted across network (in the sender byte-ordering),
- * and stored on disk in big-endian order.
- */
-static inline void fid_cpu_to_le(struct lu_fid *dst, const struct lu_fid *src)
-{
-       dst->f_seq = __cpu_to_le64(fid_seq(src));
-       dst->f_oid = __cpu_to_le32(fid_oid(src));
-       dst->f_ver = __cpu_to_le32(fid_ver(src));
-}
-
-static inline void fid_le_to_cpu(struct lu_fid *dst, const struct lu_fid *src)
-{
-       dst->f_seq = __le64_to_cpu(fid_seq(src));
-       dst->f_oid = __le32_to_cpu(fid_oid(src));
-       dst->f_ver = __le32_to_cpu(fid_ver(src));
-}
-
-static inline void fid_cpu_to_be(struct lu_fid *dst, const struct lu_fid *src)
-{
-       dst->f_seq = __cpu_to_be64(fid_seq(src));
-       dst->f_oid = __cpu_to_be32(fid_oid(src));
-       dst->f_ver = __cpu_to_be32(fid_ver(src));
-}
-
-static inline void fid_be_to_cpu(struct lu_fid *dst, const struct lu_fid *src)
-{
-       dst->f_seq = __be64_to_cpu(fid_seq(src));
-       dst->f_oid = __be32_to_cpu(fid_oid(src));
-       dst->f_ver = __be32_to_cpu(fid_ver(src));
-}
-
-static inline bool fid_is_sane(const struct lu_fid *fid)
-{
-       return fid != NULL &&
-              ((fid_seq(fid) >= FID_SEQ_START && fid_ver(fid) == 0) ||
-               fid_is_igif(fid) || fid_is_idif(fid) ||
-               fid_seq_is_rsvd(fid_seq(fid)));
-}
-
-static inline bool lu_fid_eq(const struct lu_fid *f0, const struct lu_fid *f1)
-{
-       return memcmp(f0, f1, sizeof *f0) == 0;
-}
-
-#define __diff_normalize(val0, val1)                            \
-({                                                              \
-        typeof(val0) __val0 = (val0);                           \
-        typeof(val1) __val1 = (val1);                           \
-                                                                \
-        (__val0 == __val1 ? 0 : __val0 > __val1 ? +1 : -1);     \
-})
-
-static inline int lu_fid_cmp(const struct lu_fid *f0,
-                             const struct lu_fid *f1)
-{
-        return
-                __diff_normalize(fid_seq(f0), fid_seq(f1)) ?:
-                __diff_normalize(fid_oid(f0), fid_oid(f1)) ?:
-                __diff_normalize(fid_ver(f0), fid_ver(f1));
-}
-
-static inline void ostid_cpu_to_le(const struct ost_id *src_oi,
-                                  struct ost_id *dst_oi)
-{
-       if (fid_seq_is_mdt0(src_oi->oi.oi_seq)) {
-               dst_oi->oi.oi_id = __cpu_to_le64(src_oi->oi.oi_id);
-               dst_oi->oi.oi_seq = __cpu_to_le64(src_oi->oi.oi_seq);
-       } else {
-               fid_cpu_to_le(&dst_oi->oi_fid, &src_oi->oi_fid);
-       }
-}
-
-static inline void ostid_le_to_cpu(const struct ost_id *src_oi,
-                                  struct ost_id *dst_oi)
-{
-       if (fid_seq_is_mdt0(src_oi->oi.oi_seq)) {
-               dst_oi->oi.oi_id = __le64_to_cpu(src_oi->oi.oi_id);
-               dst_oi->oi.oi_seq = __le64_to_cpu(src_oi->oi.oi_seq);
-       } else {
-               fid_le_to_cpu(&dst_oi->oi_fid, &src_oi->oi_fid);
-       }
-}
-
 struct lu_orphan_rec {
        /* The MDT-object's FID referenced by the orphan OST-object */
        struct lu_fid   lor_fid;
@@ -1524,71 +992,6 @@ struct lov_mds_md_v1 {            /* LOV EA mds/wire data (little-endian) */
        struct lov_ost_data_v1 lmm_objects[0]; /* per-stripe data */
 };
 
-/**
- * Sigh, because pre-2.4 uses
- * struct lov_mds_md_v1 {
- *     ........
- *     __u64 lmm_object_id;
- *     __u64 lmm_object_seq;
- *      ......
- *      }
- * to identify the LOV(MDT) object, and lmm_object_seq will
- * be normal_fid, which make it hard to combine these conversion
- * to ostid_to FID. so we will do lmm_oi/fid conversion separately
- *
- * We can tell the lmm_oi by this way,
- * 1.8: lmm_object_id = {inode}, lmm_object_gr = 0
- * 2.1: lmm_object_id = {oid < 128k}, lmm_object_seq = FID_SEQ_NORMAL
- * 2.4: lmm_oi.f_seq = FID_SEQ_NORMAL, lmm_oi.f_oid = {oid < 128k},
- *      lmm_oi.f_ver = 0
- *
- * But currently lmm_oi/lsm_oi does not have any "real" usages,
- * except for printing some information, and the user can always
- * get the real FID from LMA, besides this multiple case check might
- * make swab more complicate. So we will keep using id/seq for lmm_oi.
- */
-
-static inline void fid_to_lmm_oi(const struct lu_fid *fid,
-                                struct ost_id *oi)
-{
-       oi->oi.oi_id = fid_oid(fid);
-       oi->oi.oi_seq = fid_seq(fid);
-}
-
-static inline void lmm_oi_set_seq(struct ost_id *oi, __u64 seq)
-{
-       oi->oi.oi_seq = seq;
-}
-
-static inline void lmm_oi_set_id(struct ost_id *oi, __u64 oid)
-{
-       oi->oi.oi_id = oid;
-}
-
-static inline __u64 lmm_oi_id(const struct ost_id *oi)
-{
-       return oi->oi.oi_id;
-}
-
-static inline __u64 lmm_oi_seq(const struct ost_id *oi)
-{
-       return oi->oi.oi_seq;
-}
-
-static inline void lmm_oi_le_to_cpu(struct ost_id *dst_oi,
-                                   const struct ost_id *src_oi)
-{
-       dst_oi->oi.oi_id = __le64_to_cpu(src_oi->oi.oi_id);
-       dst_oi->oi.oi_seq = __le64_to_cpu(src_oi->oi.oi_seq);
-}
-
-static inline void lmm_oi_cpu_to_le(struct ost_id *dst_oi,
-                                   const struct ost_id *src_oi)
-{
-       dst_oi->oi.oi_id = __cpu_to_le64(src_oi->oi.oi_id);
-       dst_oi->oi.oi_seq = __cpu_to_le64(src_oi->oi.oi_seq);
-}
-
 #define MAX_MD_SIZE (sizeof(struct lov_mds_md) + 4 * sizeof(struct lov_ost_data))
 #define MIN_MD_SIZE (sizeof(struct lov_mds_md) + 1 * sizeof(struct lov_ost_data))
 
diff --git a/lustre/include/lustre/lustre_ostid.h b/lustre/include/lustre/lustre_ostid.h
new file mode 100644 (file)
index 0000000..5a5d3bc
--- /dev/null
@@ -0,0 +1,242 @@
+/*
+ * GPL HEADER START
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 only,
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License version 2 for more details (a copy is included
+ * in the LICENSE file that accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License
+ * version 2 along with this program; If not, see
+ * http://www.gnu.org/licenses/gpl-2.0.html
+ *
+ * GPL HEADER END
+ */
+/*
+ * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Use is subject to license terms.
+ *
+ * Copyright (c) 2011, 2014, Intel Corporation.
+ *
+ * Copyright 2015 Cray Inc, all rights reserved.
+ * Author: Ben Evans.
+ *
+ * Define ost_id  associated functions
+ */
+
+#ifndef _LUSTRE_OSTID_H_
+#define _LUSTRE_OSTID_H_
+
+#include <libcfs/libcfs.h>
+#include <lustre/lustre_fid.h>
+#include <lustre/lustre_idl.h>
+
+static inline __u64 lmm_oi_id(const struct ost_id *oi)
+{
+       return oi->oi.oi_id;
+}
+
+static inline __u64 lmm_oi_seq(const struct ost_id *oi)
+{
+       return oi->oi.oi_seq;
+}
+
+static inline void lmm_oi_set_seq(struct ost_id *oi, __u64 seq)
+{
+       oi->oi.oi_seq = seq;
+}
+
+static inline void lmm_oi_set_id(struct ost_id *oi, __u64 oid)
+{
+       oi->oi.oi_id = oid;
+}
+
+static inline void lmm_oi_le_to_cpu(struct ost_id *dst_oi,
+                                   const struct ost_id *src_oi)
+{
+       dst_oi->oi.oi_id = __le64_to_cpu(src_oi->oi.oi_id);
+       dst_oi->oi.oi_seq = __le64_to_cpu(src_oi->oi.oi_seq);
+}
+
+static inline void lmm_oi_cpu_to_le(struct ost_id *dst_oi,
+                                   const struct ost_id *src_oi)
+{
+       dst_oi->oi.oi_id = __cpu_to_le64(src_oi->oi.oi_id);
+       dst_oi->oi.oi_seq = __cpu_to_le64(src_oi->oi.oi_seq);
+}
+
+/* extract OST sequence (group) from a wire ost_id (id/seq) pair */
+static inline __u64 ostid_seq(const struct ost_id *ostid)
+{
+       if (fid_seq_is_mdt0(ostid->oi.oi_seq))
+               return FID_SEQ_OST_MDT0;
+
+       if (unlikely(fid_seq_is_default(ostid->oi.oi_seq)))
+               return FID_SEQ_LOV_DEFAULT;
+
+       if (fid_is_idif(&ostid->oi_fid))
+               return FID_SEQ_OST_MDT0;
+
+       return fid_seq(&ostid->oi_fid);
+}
+
+/* extract OST objid from a wire ost_id (id/seq) pair */
+static inline __u64 ostid_id(const struct ost_id *ostid)
+{
+       if (fid_seq_is_mdt0(ostid->oi.oi_seq))
+               return ostid->oi.oi_id & IDIF_OID_MASK;
+
+       if (unlikely(fid_seq_is_default(ostid->oi.oi_seq)))
+               return ostid->oi.oi_id;
+
+       if (fid_is_idif(&ostid->oi_fid))
+               return fid_idif_id(fid_seq(&ostid->oi_fid),
+                                  fid_oid(&ostid->oi_fid), 0);
+
+       return fid_oid(&ostid->oi_fid);
+}
+
+static inline void ostid_set_seq(struct ost_id *oi, __u64 seq)
+{
+       if (fid_seq_is_mdt0(seq) || fid_seq_is_default(seq)) {
+               oi->oi.oi_seq = seq;
+       } else {
+               oi->oi_fid.f_seq = seq;
+               /*
+                * Note: if f_oid + f_ver is zero, we need init it
+                * to be 1, otherwise, ostid_seq will treat this
+                * as old ostid (oi_seq == 0)
+                */
+               if (!oi->oi_fid.f_oid && !oi->oi_fid.f_ver)
+                       oi->oi_fid.f_oid = LUSTRE_FID_INIT_OID;
+       }
+}
+
+static inline void ostid_set_seq_mdt0(struct ost_id *oi)
+{
+       ostid_set_seq(oi, FID_SEQ_OST_MDT0);
+}
+
+static inline void ostid_set_seq_echo(struct ost_id *oi)
+{
+       ostid_set_seq(oi, FID_SEQ_ECHO);
+}
+
+static inline void ostid_set_seq_llog(struct ost_id *oi)
+{
+       ostid_set_seq(oi, FID_SEQ_LLOG);
+}
+
+/**
+ * Note: we need check oi_seq to decide where to set oi_id,
+ * so oi_seq should always be set ahead of oi_id.
+ */
+static inline void ostid_set_id(struct ost_id *oi, __u64 oid)
+{
+       if (fid_seq_is_mdt0(oi->oi.oi_seq)) {
+               if (oid >= IDIF_MAX_OID) {
+                       CERROR("Bad %llu to set "DOSTID"\n",
+                               (unsigned long long)oid, POSTID(oi));
+                       return;
+               }
+               oi->oi.oi_id = oid;
+       } else if (fid_is_idif(&oi->oi_fid)) {
+               if (oid >= IDIF_MAX_OID) {
+                       CERROR("Bad %llu to set "DOSTID"\n",
+                               (unsigned long long)oid, POSTID(oi));
+                       return;
+               }
+               oi->oi_fid.f_seq = fid_idif_seq(oid,
+                                               fid_idif_ost_idx(&oi->oi_fid));
+               oi->oi_fid.f_oid = oid;
+               oi->oi_fid.f_ver = oid >> 48;
+       } else {
+               if (oid > OBIF_MAX_OID) {
+                       CERROR("Bad %llu to set "DOSTID"\n",
+                               (unsigned long long)oid, POSTID(oi));
+                       return;
+               }
+               oi->oi_fid.f_oid = oid;
+       }
+}
+
+static inline void ostid_cpu_to_le(const struct ost_id *src_oi,
+                                  struct ost_id *dst_oi)
+{
+       if (fid_seq_is_mdt0(src_oi->oi.oi_seq)) {
+               dst_oi->oi.oi_id = __cpu_to_le64(src_oi->oi.oi_id);
+               dst_oi->oi.oi_seq = __cpu_to_le64(src_oi->oi.oi_seq);
+       } else {
+               fid_cpu_to_le(&dst_oi->oi_fid, &src_oi->oi_fid);
+       }
+}
+
+static inline void ostid_le_to_cpu(const struct ost_id *src_oi,
+                                  struct ost_id *dst_oi)
+{
+       if (fid_seq_is_mdt0(src_oi->oi.oi_seq)) {
+               dst_oi->oi.oi_id = __le64_to_cpu(src_oi->oi.oi_id);
+               dst_oi->oi.oi_seq = __le64_to_cpu(src_oi->oi.oi_seq);
+       } else {
+               fid_le_to_cpu(&dst_oi->oi_fid, &src_oi->oi_fid);
+       }
+}
+
+/* pack any OST FID into an ostid (id/seq) for the wire/disk */
+static inline int fid_to_ostid(const struct lu_fid *fid, struct ost_id *ostid)
+{
+       if (unlikely(fid_seq_is_igif(fid->f_seq))) {
+               CERROR("bad IGIF, "DFID"\n", PFID(fid));
+               return -EBADF;
+       }
+
+       if (fid_is_idif(fid)) {
+               ostid_set_seq_mdt0(ostid);
+               ostid_set_id(ostid, fid_idif_id(fid_seq(fid), fid_oid(fid),
+                                               fid_ver(fid)));
+       } else {
+               ostid->oi_fid = *fid;
+       }
+
+       return 0;
+}
+
+/**
+ * Sigh, because pre-2.4 uses
+ * struct lov_mds_md_v1 {
+ *     ........
+ *     __u64 lmm_object_id;
+ *     __u64 lmm_object_seq;
+ *      ......
+ *      }
+ * to identify the LOV(MDT) object, and lmm_object_seq will
+ * be normal_fid, which make it hard to combine these conversion
+ * to ostid_to FID. so we will do lmm_oi/fid conversion separately
+ *
+ * We can tell the lmm_oi by this way,
+ * 1.8: lmm_object_id = {inode}, lmm_object_gr = 0
+ * 2.1: lmm_object_id = {oid < 128k}, lmm_object_seq = FID_SEQ_NORMAL
+ * 2.4: lmm_oi.f_seq = FID_SEQ_NORMAL, lmm_oi.f_oid = {oid < 128k},
+ *      lmm_oi.f_ver = 0
+ *
+ * But currently lmm_oi/lsm_oi does not have any "real" usages,
+ * except for printing some information, and the user can always
+ * get the real FID from LMA, besides this multiple case check might
+ * make swab more complicate. So we will keep using id/seq for lmm_oi.
+ */
+
+static inline void fid_to_lmm_oi(const struct lu_fid *fid,
+                                struct ost_id *oi)
+{
+       oi->oi.oi_id = fid_oid(fid);
+       oi->oi.oi_seq = fid_seq(fid);
+}
+
+#endif
index 4123706..9021834 100644 (file)
  */
 
 #include <libcfs/libcfs.h>
+#include <lustre/lustre_fid.h>
 #include <lustre/lustre_idl.h>
+#include <lustre/lustre_ostid.h>
 
 struct lu_env;
 struct lu_site;
@@ -659,6 +661,62 @@ static inline void ost_fid_build_resid(const struct lu_fid *fid,
        }
 }
 
+/**
+ * Unpack an OST object id/seq (group) into a FID.  This is needed for
+ * converting all obdo, lmm, lsm, etc. 64-bit id/seq pairs into proper
+ * FIDs.  Note that if an id/seq is already in FID/IDIF format it will
+ * be passed through unchanged.  Only legacy OST objects in "group 0"
+ * will be mapped into the IDIF namespace so that they can fit into the
+ * struct lu_fid fields without loss.  For reference see:
+ * http://arch.lustre.org/index.php?title=Interoperability_fids_zfs
+ */
+static inline int ostid_to_fid(struct lu_fid *fid, const struct ost_id *ostid,
+                              u32 ost_idx)
+{
+       u64 seq = ostid_seq(ostid);
+
+       if (ost_idx > 0xffff) {
+               CERROR("bad ost_idx, "DOSTID" ost_idx:%u\n", POSTID(ostid),
+                      ost_idx);
+               return -EBADF;
+       }
+
+       if (fid_seq_is_mdt0(seq)) {
+               u64 oid = ostid_id(ostid);
+
+               /* This is a "legacy" (old 1.x/2.early) OST object in "group 0"
+                * that we map into the IDIF namespace.  It allows up to 2^48
+                * objects per OST, as this is the object namespace that has
+                * been in production for years.  This can handle create rates
+                * of 1M objects/s/OST for 9 years, or combinations thereof.
+                */
+               if (oid >= IDIF_MAX_OID) {
+                       CERROR("bad MDT0 id(1), "DOSTID" ost_idx:%u\n",
+                              POSTID(ostid), ost_idx);
+                       return -EBADF;
+               }
+               fid->f_seq = fid_idif_seq(oid, ost_idx);
+               /* truncate to 32 bits by assignment */
+               fid->f_oid = oid;
+               /* in theory, not currently used */
+               fid->f_ver = oid >> 48;
+       } else if (likely(!fid_seq_is_default(seq))) {
+               /* This is either an IDIF object, which identifies objects
+                * across all OSTs, or a regular FID.  The IDIF namespace
+                * maps legacy OST objects into the FID namespace.  In both
+                * cases, we just pass the FID through, no conversion needed.
+                */
+               if (ostid->oi_fid.f_ver) {
+                       CERROR("bad MDT0 id(2), "DOSTID" ost_idx:%u\n",
+                              POSTID(ostid), ost_idx);
+                       return -EBADF;
+               }
+               *fid = ostid->oi_fid;
+       }
+
+       return 0;
+}
+
 static inline void ost_fid_from_resid(struct lu_fid *fid,
                                      const struct ldlm_res_id *name,
                                      int ost_idx)
@@ -749,6 +807,33 @@ lu_fid_diff(const struct lu_fid *fid1, const struct lu_fid *fid2)
        return fid_oid(fid1) - fid_oid(fid2);
 }
 
+static inline int fid_set_id(struct lu_fid *fid, u64 oid)
+{
+       if (unlikely(fid_seq_is_igif(fid->f_seq))) {
+               CERROR("bad IGIF, "DFID"\n", PFID(fid));
+               return -EBADF;
+       }
+
+       if (fid_is_idif(fid)) {
+               if (oid >= IDIF_MAX_OID) {
+                       CERROR("Too large OID %#llx to set IDIF "DFID"\n",
+                              (unsigned long long)oid, PFID(fid));
+                       return -EBADF;
+               }
+               fid->f_seq = fid_idif_seq(oid, fid_idif_ost_idx(fid));
+               fid->f_oid = oid;
+               fid->f_ver = oid >> 48;
+       } else {
+               if (oid > OBIF_MAX_OID) {
+                       CERROR("Too large OID %#llx to set REG "DFID"\n",
+                              (unsigned long long)oid, PFID(fid));
+                       return -EBADF;
+               }
+               fid->f_oid = oid;
+       }
+       return 0;
+}
+
 #define LUSTRE_SEQ_SRV_NAME "seq_srv"
 #define LUSTRE_SEQ_CTL_NAME "seq_ctl"
 
index 68e51df..b28fd26 100644 (file)
@@ -38,6 +38,8 @@
 #ifndef _LUSTRE_LOG_USER_H
 #define _LUSTRE_LOG_USER_H
 
+#include <lustre/lustre_fid.h>
+
 /*  Lustre logs use FIDs constructed from oi_id and oi_seq directly,
  *  without attempting to use the IGIF and IDIF ranges as is done
  *  elsewhere, because of compatibility concerns (see lu-2888).
index 7649bae..94fb81f 100644 (file)
@@ -40,6 +40,7 @@
 #include <linux/kthread.h>
 #include <linux/list.h>
 #include <libcfs/libcfs.h>
+#include <lustre/lustre_errno.h>
 #include <lustre_dlm.h>
 #include <obd_class.h>
 #include "ldlm_internal.h"
index 754633f..e24ed73 100644 (file)
@@ -57,6 +57,8 @@
 
 #define DEBUG_SUBSYSTEM S_LDLM
 
+#include <lustre/lustre_errno.h>
+
 #include <lustre_dlm.h>
 #include <obd_class.h>
 #include <obd.h>
index 86f89be..e129d3b 100644 (file)
@@ -43,6 +43,8 @@
 # include <linux/uidgid.h>
 #endif
 
+#include <lustre/lustre_errno.h>
+
 #include <cl_object.h>
 #include <llog_swab.h>
 #include <lprocfs_status.h>
index b21cf64..58a106d 100644 (file)
@@ -37,6 +37,7 @@
 
 #define DEBUG_SUBSYSTEM S_MDS
 
+#include <lustre/lustre_errno.h>
 #include "mdt_internal.h"
 
 /* Max allocation to satisfy single HSM RPC. */
index 24562e2..35bde28 100644 (file)
@@ -43,7 +43,6 @@
 #include <poll.h>
 
 #include <lustre/lustreapi.h>
-#include <lustre/lustre_idl.h>
 
 #define ERROR(fmt, ...)                                                        \
        fprintf(stderr, "%s: %s:%d: %s: " fmt "\n",                     \
index a7c0225..7d284f9 100644 (file)
@@ -52,7 +52,6 @@
 #include <time.h>
 #include <err.h>
 
-#include <lustre/lustre_idl.h>
 #include <lustre/lustreapi.h>
 
 #define T1 "write data before unlink\n"
index 5cd8d5e..2cdc479 100644 (file)
@@ -66,7 +66,6 @@
 #include <sys/sendfile.h>
 
 #include <lustre/lustreapi.h>
-#include <lustre/lustre_idl.h>
 
 #define ERROR(fmt, ...)                                                        \
        fprintf(stderr, "%s: %s:%d: %s: " fmt "\n",                     \
index 5ec64e5..2bd3e2f 100644 (file)
@@ -43,7 +43,6 @@
 #include <time.h>
 
 #include <lustre/lustreapi.h>
-#include <lustre/lustre_idl.h>
 
 #define ERROR(fmt, ...)                                                        \
        fprintf(stderr, "%s: %s:%d: %s: " fmt "\n",                     \
index 05b400c..f81ad85 100644 (file)
@@ -44,7 +44,7 @@
 #include <libcfs/util/parser.h>
 #include <lnet/lnetctl.h>
 #include "obdctl.h"
-#include <lustre/lustre_idl.h>
+#include <lustre_ver.h>
 
 static int jt_noop(int argc, char **argv) {
         return 0;
index 32579c6..fa9f009 100644 (file)
@@ -57,7 +57,7 @@
 #include <sys/types.h>
 
 #include <libcfs/util/string.h>
-#include <lustre/lustre_idl.h>
+#include <lustre/lustre_fid.h>
 #include <lustre/lustreapi.h>
 
 /* Progress reporting period */
index c1fab34..8db34b3 100644 (file)
@@ -72,6 +72,7 @@
 #include <libcfs/util/string.h>
 #include <lnet/lnetctl.h>
 #include <lustre/lustreapi.h>
+#include <lustre/lustre_ostid.h>
 #include <lustre_ioctl.h>
 #include "lustreapi_internal.h"
 
index b606dfe..445c145 100644 (file)
@@ -38,7 +38,6 @@
 #include <errno.h>
 
 #include <lustre/lustreapi.h>
-#include <lustre/lustre_idl.h>
 #include "lustreapi_internal.h"
 
 /*
index 337c1b9..01ae43e 100644 (file)
@@ -38,8 +38,7 @@
 #include <limits.h>
 #include <sys/types.h>
 #include <sys/xattr.h>
-#include <lustre/lustre_idl.h>
-#include <lustre/lustre_user.h>
+#include <lustre/lustre_fid.h>
 
 #define BUFFER_SIZE 65536
 
index 074684b..890de00 100644 (file)
@@ -53,7 +53,8 @@
 #include <errno.h>
 #include <time.h>
 #include <lnet/nidstr.h>
-#include <lustre/lustre_idl.h>
+#include <lustre/lustre_fid.h>
+#include <lustre/lustre_ostid.h>
 #include <lustre/lustreapi.h>
 #include <lustre_log_user.h>
 #include <lustre_cfg.h>
index edaf64d..2e0b2bd 100644 (file)
@@ -56,7 +56,6 @@
 #include <lnet/nidstr.h>
 #include <lustre_cfg.h>
 #include <lustre_ioctl.h>
-#include <lustre/lustre_idl.h>
 #include <lustre_ver.h>
 
 #include <sys/un.h>
index 2ae59dd..75d17b2 100644 (file)
@@ -52,7 +52,6 @@
 #include <ctype.h>
 #include <limits.h>
 #include <lnet/nidstr.h>
-#include <lustre/lustre_idl.h>
 #include <libcfs/util/string.h>
 
 #include "obdctl.h"
index 7482a1f..663b5ec 100644 (file)
@@ -67,7 +67,7 @@
 #include <libcfs/util/string.h>
 
 #include <lnet/nidstr.h>
-#include <lustre/lustre_idl.h>
+#include <lustre/lustre_ostid.h>
 #include <lustre_cfg.h>
 #include <lustre_ioctl.h>
 #include <lustre_ver.h>