*/
/*
* This file is part of Lustre, http://www.lustre.org/
- * Lustre is a trademark of Sun Microsystems, Inc.
*
* lustre/lod/lod_internal.h
*
/* number of allocated array items */
unsigned int lag_oaa_size;
/* bitmap of OSTs avoid guidance */
- struct cfs_bitmap *lag_ost_avoid_bitmap;
+ unsigned long *lag_ost_avoid_bitmap;
+ u32 lag_ost_avoid_size;
/* how many OSTs are available for alloc */
__u32 lag_ost_avail;
};
__u32 lds_dir_def_stripe_count;
__u32 lds_dir_def_stripe_offset;
__u32 lds_dir_def_hash_type;
+ __u8 lds_dir_def_max_inherit;
+ __u8 lds_dir_def_max_inherit_rr;
/* default file striping flags (LOV) */
__u32 lds_def_striping_set:1,
lds_def_striping_is_composite:1,
lds_dir_def_striping_set:1;
};
+static inline __u8 lmv_inherit_next(__u8 inherit)
+{
+ if (inherit == LMV_INHERIT_END || inherit == LMV_INHERIT_NONE)
+ return LMV_INHERIT_NONE;
+
+ if (inherit == LMV_INHERIT_UNLIMITED || inherit > LMV_INHERIT_MAX)
+ return inherit;
+
+ return inherit - 1;
+}
+
+static inline __u8 lmv_inherit_rr_next(__u8 inherit_rr)
+{
+ if (inherit_rr == LMV_INHERIT_RR_NONE ||
+ inherit_rr == LMV_INHERIT_RR_UNLIMITED ||
+ inherit_rr > LMV_INHERIT_RR_MAX)
+ return inherit_rr;
+
+ return inherit_rr - 1;
+}
+
struct lod_mirror_entry {
__u16 lme_stale:1,
- lme_primary:1;
+ lme_prefer:1;
/* mirror id */
__u16 lme_id;
/* start,end index of this mirror in ldo_comp_entries */
__u16 ldo_mirror_count;
struct lod_mirror_entry *ldo_mirrors;
__u32 ldo_is_composite:1,
- ldo_flr_state:2,
+ ldo_flr_state:4,
ldo_comp_cached:1,
ldo_is_foreign:1;
};
};
};
+#define ldo_dir_split_offset ldo_dir_migrate_offset
+#define ldo_dir_split_hash ldo_dir_migrate_hash
+
#define lod_foreach_mirror_comp(comp, lo, mirror_idx) \
for (comp = &lo->ldo_comp_entries[lo->ldo_mirrors[mirror_idx].lme_start]; \
comp <= &lo->ldo_comp_entries[lo->ldo_mirrors[mirror_idx].lme_end]; \
return (lo->ldo_flr_state & LCM_FL_FLR_MASK) != LCM_FL_NONE;
}
+static inline bool lod_is_splitting(const struct lod_object *lo)
+{
+ return lmv_hash_is_splitting(lo->ldo_dir_hash_type);
+}
+
+static inline bool lod_is_migrating(const struct lod_object *lo)
+{
+ return lmv_hash_is_migrating(lo->ldo_dir_hash_type);
+}
+
+static inline bool lod_is_layout_changing(const struct lod_object *lo)
+{
+ return lmv_hash_is_layout_changing(lo->ldo_dir_hash_type);
+}
+
static inline int lod_set_pool(char **pool, const char *new_pool)
{
int len;
/* object allocation avoid guide info */
struct lod_avoid_guide lti_avoid;
union lmv_mds_md lti_lmv;
+ struct dt_allocation_hint lti_ah;
};
extern const struct lu_device_operations lod_lu_ops;
static inline struct lod_device* lu2lod_dev(struct lu_device *d)
{
LASSERT(lu_device_is_lod(d));
- return container_of0(d, struct lod_device, lod_dt_dev.dd_lu_dev);
+ return container_of_safe(d, struct lod_device, lod_dt_dev.dd_lu_dev);
}
static inline struct lu_device *lod2lu_dev(struct lod_device *d)
static inline struct lod_device *dt2lod_dev(struct dt_device *d)
{
LASSERT(lu_device_is_lod(&d->dd_lu_dev));
- return container_of0(d, struct lod_device, lod_dt_dev);
+ return container_of(d, struct lod_device, lod_dt_dev);
}
static inline struct lod_object *lu2lod_obj(struct lu_object *o)
{
LASSERT(ergo(o != NULL, lu_device_is_lod(o->lo_dev)));
- return container_of0(o, struct lod_object, ldo_obj.do_lu);
+ return container_of_safe(o, struct lod_object, ldo_obj.do_lu);
}
static inline struct lu_object *lod2lu_obj(struct lod_object *obj)
static inline struct lod_object *lod_obj(const struct lu_object *o)
{
LASSERT(lu_device_is_lod(o->lo_dev));
- return container_of0(o, struct lod_object, ldo_obj.do_lu);
+ return container_of(o, struct lod_object, ldo_obj.do_lu);
}
static inline struct lod_object *lod_dt_obj(const struct dt_object *d)
static inline struct dt_object* lod_object_child(struct lod_object *o)
{
- return container_of0(lu_object_next(lod2lu_obj(o)),
- struct dt_object, do_lu);
+ return container_of(lu_object_next(lod2lu_obj(o)),
+ struct dt_object, do_lu);
}
static inline bool lod_obj_is_striped(struct dt_object *dt)
{
struct lod_object *lo = lod_dt_obj(dt);
int i;
+ bool rc = false;
if (!dt_object_exists(dt_object_child(dt)))
return false;
- if (S_ISDIR(dt->do_lu.lo_header->loh_attr))
- return lo->ldo_dir_stripe_count != 0;
-
- if (lo->ldo_is_foreign)
- return false;
-
- for (i = 0; i < lo->ldo_comp_cnt; i++) {
- if (lo->ldo_comp_entries[i].llc_stripe == NULL)
- continue;
- LASSERT(lo->ldo_comp_entries[i].llc_stripe_count > 0);
- return true;
+ mutex_lock(&lo->ldo_layout_mutex);
+
+ if (S_ISDIR(dt->do_lu.lo_header->loh_attr)) {
+ rc = lo->ldo_dir_stripe_count != 0;
+ } else if (lo->ldo_is_foreign) {
+ rc = false;
+ } else {
+ for (i = 0; i < lo->ldo_comp_cnt; i++) {
+ if (lo->ldo_comp_entries[i].llc_stripe == NULL)
+ continue;
+ LASSERT(lo->ldo_comp_entries[i].llc_stripe_count > 0);
+ rc = true;
+ break;
+ }
}
- return false;
+
+ mutex_unlock(&lo->ldo_layout_mutex);
+ return rc;
}
extern struct lu_context_key lod_thread_key;
int lod_del_device(const struct lu_env *env, struct lod_device *lod,
struct lod_tgt_descs *ltd, char *osp, unsigned int idx,
unsigned int gen);
+int validate_lod_and_idx(struct lod_device *lod, __u32 idx);
int lod_fini_tgt(const struct lu_env *env, struct lod_device *lod,
struct lod_tgt_descs *ltd);
int lod_striping_load(const struct lu_env *env, struct lod_object *lo);
int lod_fill_mirrors(struct lod_object *lo);
/* lod_pool.c */
-int lod_tgt_pool_init(struct lu_tgt_pool *op, unsigned int count);
-int lod_tgt_pool_free(struct lu_tgt_pool *op);
-int lod_tgt_pool_add(struct lu_tgt_pool *op, __u32 idx, unsigned int min_count);
-int lod_tgt_pool_remove(struct lu_tgt_pool *op, __u32 idx);
-int lod_tgt_pool_extend(struct lu_tgt_pool *op, unsigned int min_count);
struct pool_desc *lod_find_pool(struct lod_device *lod, char *poolname);
void lod_pool_putref(struct pool_desc *pool);
int lod_pool_del(struct obd_device *obd, char *poolname);
const struct lu_buf *buf);
int lod_qos_prep_create(const struct lu_env *env, struct lod_object *lo,
struct lu_attr *attr, struct thandle *th,
- int comp_idx);
+ int comp_idx, __u64 reserve);
__u16 lod_comp_entry_stripe_count(struct lod_object *lo,
- struct lod_layout_component *entry,
- bool is_dir);
+ int comp_idx, bool is_dir);
__u16 lod_get_stripe_count(struct lod_device *lod, struct lod_object *lo,
- __u16 stripe_count, bool overstriping);
+ int comp_idx, __u16 stripe_count, bool overstriping);
void lod_qos_statfs_update(const struct lu_env *env, struct lod_device *lod,
struct lu_tgt_descs *ltd);
void lod_procfs_fini(struct lod_device *lod);
/* lod_object.c */
-extern struct dt_object_operations lod_obj_ops;
-extern struct lu_object_operations lod_lu_obj_ops;
+extern const struct dt_object_operations lod_obj_ops;
+extern const struct lu_object_operations lod_lu_obj_ops;
int lod_load_lmv_shards(const struct lu_env *env, struct lod_object *lo,
struct lu_buf *buf, bool resize);