4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License version 2 for more details. A copy is
14 * included in the COPYING file that accompanied this code.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 * Copyright (c) 2013, Intel Corporation.
26 * lustre/include/lustre_lmv.h
28 * Lustre LMV structures and functions.
30 * Author: Di Wang <di.wang@intel.com>
35 #include <lustre/lustre_idl.h>
38 struct lu_fid lmo_fid;
40 struct inode *lmo_root;
43 struct lmv_stripe_md {
45 __u32 lsm_md_stripe_count;
46 __u32 lsm_md_master_mdt_index;
47 __u32 lsm_md_hash_type;
48 __u32 lsm_md_layout_version;
49 __u32 lsm_md_default_count;
50 __u32 lsm_md_default_index;
51 char lsm_md_pool_name[LOV_MAXPOOLNAME];
52 struct lmv_oinfo lsm_md_oinfo[0];
56 lsm_md_eq(const struct lmv_stripe_md *lsm1, const struct lmv_stripe_md *lsm2)
60 if (lsm1->lsm_md_magic != lsm2->lsm_md_magic ||
61 lsm1->lsm_md_stripe_count != lsm2->lsm_md_stripe_count ||
62 lsm1->lsm_md_master_mdt_index !=
63 lsm2->lsm_md_master_mdt_index ||
64 lsm1->lsm_md_hash_type != lsm2->lsm_md_hash_type ||
65 lsm1->lsm_md_layout_version !=
66 lsm2->lsm_md_layout_version ||
67 strcmp(lsm1->lsm_md_pool_name,
68 lsm2->lsm_md_pool_name) != 0)
71 for (idx = 0; idx < lsm1->lsm_md_stripe_count; idx++) {
72 if (!lu_fid_eq(&lsm1->lsm_md_oinfo[idx].lmo_fid,
73 &lsm2->lsm_md_oinfo[idx].lmo_fid))
81 int lmv_pack_md(union lmv_mds_md **lmmp, const struct lmv_stripe_md *lsm,
83 int lmv_alloc_md(union lmv_mds_md **lmmp, int stripe_count);
84 void lmv_free_md(union lmv_mds_md *lmm);
85 int lmv_alloc_memmd(struct lmv_stripe_md **lsmp, int stripe_count);
86 void lmv_free_memmd(struct lmv_stripe_md *lsm);
88 int lmvea_load_shards(const struct lu_env *env, struct dt_object *obj,
89 struct lu_dirent *ent, struct lu_buf *buf,
92 static inline void lmv1_le_to_cpu(struct lmv_mds_md_v1 *lmv_dst,
93 const struct lmv_mds_md_v1 *lmv_src)
97 lmv_dst->lmv_magic = le32_to_cpu(lmv_src->lmv_magic);
98 lmv_dst->lmv_stripe_count = le32_to_cpu(lmv_src->lmv_stripe_count);
99 lmv_dst->lmv_master_mdt_index =
100 le32_to_cpu(lmv_src->lmv_master_mdt_index);
101 lmv_dst->lmv_hash_type = le32_to_cpu(lmv_src->lmv_hash_type);
102 lmv_dst->lmv_layout_version = le32_to_cpu(lmv_src->lmv_layout_version);
103 for (i = 0; i < lmv_src->lmv_stripe_count; i++)
104 fid_le_to_cpu(&lmv_dst->lmv_stripe_fids[i],
105 &lmv_src->lmv_stripe_fids[i]);
108 static inline void lmv_le_to_cpu(union lmv_mds_md *lmv_dst,
109 const union lmv_mds_md *lmv_src)
111 switch (le32_to_cpu(lmv_src->lmv_magic)) {
113 lmv1_le_to_cpu(&lmv_dst->lmv_md_v1, &lmv_src->lmv_md_v1);