1 /* SPDX-License-Identifier: GPL-2.0 */
4 * Copyright 2009 Sun Microsystems, Inc. All rights reserved
5 * Use is subject to license terms.
7 * Copyright (c) 2012, 2017, Intel Corporation.
11 * This file is part of Lustre, http://www.lustre.org/
13 * Author: Alex Zhuravlev <alexey.zhuravlev@intel.com>
14 * Author: Mikhail Pershin <mike.pershin@intel.com>
17 #ifndef _LOD_INTERNAL_H
18 #define _LOD_INTERNAL_H
20 #include <libcfs/libcfs.h>
21 #include <uapi/linux/lustre/lustre_cfg.h>
23 #include <dt_object.h>
26 LOD_USES_ASSIGNED_STRIPE = 0,
27 LOD_USES_DEFAULT_STRIPE,
30 /* Special values to remove LOV EA from disk */
31 #define LOVEA_DELETE_VALUES(size, count, offset, pool) \
32 ((size) == 0 && (count) == 0 && \
33 (offset) == (typeof(offset))(-1) && (pool) == NULL)
35 #define LMVEA_DELETE_VALUES(count, offset) \
36 ((count) == 0 && (offset) == (typeof(offset))(-1))
38 struct lod_pool_desc {
39 char pool_name[LOV_MAXPOOLNAME + 1];
40 struct lu_tgt_pool pool_obds; /* pool members */
41 struct kref pool_refcount;
42 struct lu_qos_rr pool_rr;
43 struct rhash_head pool_hash; /* access by poolname */
44 struct list_head pool_list;
45 struct rcu_head pool_rcu;
46 struct proc_dir_entry *pool_proc_entry;
47 struct obd_device *pool_lobd; /* owner */
48 time64_t pool_spill_expire;
49 struct proc_dir_entry *pool_spill_proc_entry;
50 bool pool_spill_is_active;
51 unsigned int pool_spill_threshold_pct;
52 atomic_t pool_spill_hit;
53 char pool_spill_target[LOV_MAXPOOLNAME + 1];
54 bool pool_same_space; /* targets in pool balanced*/
55 time64_t pool_same_space_expire; /*uses ld_qos_maxage*/
56 struct dentry *pool_debugfs;
60 int lod_pool_hash_init(struct rhashtable *tbl);
61 void lod_pool_hash_destroy(struct rhashtable *tbl);
62 bool lod_pool_exists(struct lod_device *lod, char *poolname);
64 #define pool_tgt_count(p) ((p)->pool_obds.op_count)
65 #define pool_tgt_array(p) ((p)->pool_obds.op_array)
66 #define pool_tgt_rw_sem(p) ((p)->pool_obds.op_rw_sem)
68 #define lod_tgt_desc lu_tgt_desc
69 #define lod_tgt_descs lu_tgt_descs
71 #define OST_TGT(lod, index) LTD_TGT(&lod->lod_ost_descs, index)
72 #define MDT_TGT(lod, index) LTD_TGT(&lod->lod_mdt_descs, index)
74 struct lod_avoid_guide {
75 /* ids of OSSs avoid guidance */
76 __u32 *lag_oss_avoid_array;
77 /* number of filled array items */
78 unsigned int lag_oaa_count;
79 /* number of allocated array items */
80 unsigned int lag_oaa_size;
81 /* bitmap of OSTs avoid guidance */
82 unsigned long *lag_ost_avoid_bitmap;
83 u32 lag_ost_avoid_size;
84 /* how many OSTs are available for alloc */
88 #define LOD_DOM_MIN_SIZE_KB (LOV_MIN_STRIPE_SIZE >> 10)
89 #define LOD_DOM_SFS_MAX_AGE 10
92 struct dt_device lod_dt_dev;
93 struct obd_export *lod_child_exp;
94 struct dt_device *lod_child;
95 struct lprocfs_stats *lod_stats;
96 spinlock_t lod_connects_lock;
98 unsigned int lod_recovery_completed:1,
101 lod_child_got_update_log:1,
102 lod_dist_txn_check_space:1;
104 /* protect ld_active_tgt_count, ltd_active and lod_md_root */
107 /* Description of OST */
108 struct lod_tgt_descs lod_ost_descs;
109 /* Description of MDT */
110 struct lod_tgt_descs lod_mdt_descs;
112 /* Recovery thread for lod_child */
113 struct task_struct *lod_child_recovery_task;
115 /* maximum EA size underlied OSD may have */
116 unsigned int lod_osd_max_easize;
117 /* maximum size of MDT stripe for Data-on-MDT files. */
118 unsigned int lod_dom_stripesize_max_kb;
119 /* current DOM default stripe size adjusted by threshold */
120 unsigned int lod_dom_stripesize_cur_kb;
121 /* Threshold at which DOM default stripe will start decreasing */
122 __u64 lod_dom_threshold_free_mb;
124 /* Local OSD statfs cache */
125 spinlock_t lod_lsfs_lock;
126 time64_t lod_lsfs_age;
127 __u64 lod_lsfs_total_mb;
128 __u64 lod_lsfs_free_mb;
132 struct rhashtable lod_pools_hash_body; /* used for key access */
133 struct list_head lod_pool_list; /* used for sequential access */
134 struct proc_dir_entry *lod_pool_proc_entry;
135 struct proc_dir_entry *lod_spill_proc_entry;
137 enum lustre_sec_part lod_sp_me;
139 struct proc_dir_entry *lod_symlink;
140 struct dentry *lod_debugfs;
141 struct dentry *lod_pool_debugfs;
143 /* ROOT object, used to fetch FS default striping */
144 struct lod_object *lod_md_root;
146 /* max stripe count if stripe count is set to -1. 0 means unlimited */
147 unsigned int lod_max_stripecount;
148 unsigned int lod_max_mdt_stripecount;
149 /* valid range: [1, LMV_MAX_STRIPES_PER_MDT] */
150 unsigned int lod_max_stripes_per_mdt;
153 #define lod_ost_bitmap lod_ost_descs.ltd_tgt_bitmap
154 #define lod_ost_count lod_ost_descs.ltd_lov_desc.ld_tgt_count
155 #define lod_ost_active_count lod_ost_descs.ltd_lov_desc.ld_active_tgt_count
156 #define lod_remote_mdt_count lod_mdt_descs.ltd_lmv_desc.ld_tgt_count
158 struct lod_layout_component {
159 struct lu_extent llc_extent;
163 __u64 llc_timestamp; /* snapshot time */
165 struct { /* plain layout V1/V3. */
167 __u32 llc_stripe_size;
168 __u16 llc_layout_gen;
169 __u16 llc_stripe_offset;
170 __u16 llc_stripe_count;
171 __u16 llc_stripes_allocated;
173 /* ost list specified by LOV_USER_MAGIC_SPECIFIC lum */
174 struct lu_tgt_pool llc_ostlist;
175 struct dt_object **llc_stripe;
176 __u32 *llc_ost_indices;
178 struct { /* Foreign mirror layout component */
181 __u32 llc_foreign_flags;
183 /* Basic HSM layout information */
184 struct lov_hsm_base llc_hsm;
185 /* Other kinds of foreign types (i.e. DAOS) */
192 struct lod_default_striping {
194 /* current layout component count */
195 __u16 lds_def_comp_cnt;
196 __u16 lds_def_mirror_cnt;
197 /* the largest comp count ever used */
198 __u32 lds_def_comp_size_cnt;
199 struct lod_layout_component *lds_def_comp_entries;
201 __u32 lds_dir_def_stripe_count;
202 __u32 lds_dir_def_stripe_offset;
203 __u32 lds_dir_def_hash_type;
204 __u8 lds_dir_def_max_inherit;
205 __u8 lds_dir_def_max_inherit_rr;
206 /* default file striping flags (LOV) */
207 __u32 lds_def_striping_set:1,
208 lds_def_striping_is_composite:1,
209 /* default dir striping flags (LMV) */
210 lds_dir_def_striping_set:1;
213 enum layout_verify_flags {
214 LVF_ALL_STALE = BIT(0), /* check not all stale mirrors */
217 struct lod_mirror_entry {
224 __u16 lme_preference;
225 /* start,end index of this mirror in ldo_comp_entries */
231 /* common fields for both files and directories */
232 struct dt_object ldo_obj;
233 struct mutex ldo_layout_mutex;
234 /* foreign file/directory */
235 __u32 ldo_is_foreign:1;
237 /* file stripe (LOV) */
239 __u32 ldo_layout_gen;
240 /* Layout component count for a regular file.
241 * It equals to 1 for non-composite layout. */
243 /* Layout mirror count for a PFLR file.
244 * It's 0 for files with non-composite layout. */
245 __u16 ldo_mirror_count;
246 struct lod_mirror_entry *ldo_mirrors;
247 __u32 ldo_is_composite:1,
251 /* directory stripe (LMV) */
253 /* Slave stripe count for striped directory. */
254 __u16 ldo_dir_stripe_count;
255 /* How many stripes allocated for a striped directory */
256 __u16 ldo_dir_stripes_allocated;
257 __u32 ldo_dir_stripe_offset;
258 __u32 ldo_dir_hash_type;
259 __u32 ldo_dir_migrate_offset;
260 __u32 ldo_dir_migrate_hash;
261 __u32 ldo_dir_layout_version;
262 /* Is a slave stripe of striped directory? */
263 __u32 ldo_dir_slave_stripe:1,
265 /* the stripe has been loaded */
266 ldo_dir_stripe_loaded:1;
268 * This default LMV is parent default LMV, which will be
269 * used in child creation, and it's not cached, so this
270 * field is invalid after create, make sure it's used by
271 * lod_dir_striping_create_internal() only.
273 struct lod_default_striping *ldo_def_striping;
278 /* foreign/raw format LOV */
279 char *ldo_foreign_lov;
280 size_t ldo_foreign_lov_size;
283 /* foreign/raw format LMV */
284 char *ldo_foreign_lmv;
285 size_t ldo_foreign_lmv_size;
288 /* file stripe (LOV) */
289 struct lod_layout_component *ldo_comp_entries;
290 /* slave stripes of striped directory (LMV) */
291 struct dt_object **ldo_stripe;
296 #define ldo_dir_split_offset ldo_dir_migrate_offset
297 #define ldo_dir_split_hash ldo_dir_migrate_hash
299 #define lod_foreach_mirror_comp(comp, lo, mirror_idx) \
300 for (comp = &lo->ldo_comp_entries[lo->ldo_mirrors[mirror_idx].lme_start]; \
301 comp <= &lo->ldo_comp_entries[lo->ldo_mirrors[mirror_idx].lme_end]; \
304 static inline bool lod_is_flr(const struct lod_object *lo)
306 if (!lo->ldo_is_composite)
309 return (lo->ldo_flr_state & LCM_FL_FLR_MASK) != LCM_FL_NONE;
312 static inline bool lod_is_hsm(const struct lod_layout_component *lod_comp)
314 return lod_comp->llc_magic == LOV_MAGIC_FOREIGN &&
315 lov_hsm_type_supported(lod_comp->llc_type);
318 static inline bool lod_is_splitting(const struct lod_object *lo)
320 return lmv_hash_is_splitting(lo->ldo_dir_hash_type);
323 static inline bool lod_is_migrating(const struct lod_object *lo)
325 return lmv_hash_is_migrating(lo->ldo_dir_hash_type);
328 static inline bool lod_is_layout_changing(const struct lod_object *lo)
330 return lmv_hash_is_layout_changing(lo->ldo_dir_hash_type);
333 static inline int lod_set_pool(char **pool, const char *new_pool)
337 if (*pool == new_pool)
341 len = strlen(*pool) + 1;
342 OBD_FREE(*pool, len);
345 if (new_pool != NULL) {
346 len = strlen(new_pool) + 1;
347 OBD_ALLOC(*pool, len);
350 strscpy(*pool, new_pool, len);
355 static inline int lod_obj_set_pool(struct lod_object *lo, int i,
356 const char *new_pool)
358 return lod_set_pool(&lo->ldo_comp_entries[i].llc_pool, new_pool);
362 * Create new layout generation.
364 * The only requirement for layout generation is that it changes when
365 * the layout is modified, so a circular counter is sufficient for the
366 * low rate of layout modifications.
368 * Layout generation is also used to generate unique component ID.
369 * To detect generation overflow, we preserve the highest bit of the
370 * generation when it wrapped.
372 static inline void lod_obj_inc_layout_gen(struct lod_object *lo)
374 __u32 preserve = lo->ldo_layout_gen & ~LCME_ID_MASK;
375 lo->ldo_layout_gen++;
376 lo->ldo_layout_gen |= preserve;
377 /* Zero is not a valid generation */
378 if (unlikely((lo->ldo_layout_gen & LCME_ID_MASK) == 0)) {
379 lo->ldo_layout_gen++;
380 lo->ldo_layout_gen &= ~LU_LAYOUT_RESYNC;
385 struct dt_object *lit_obj; /* object from the layer below */
386 /* stripe offset of iteration */
387 __u32 lit_stripe_index;
389 struct dt_it *lit_it; /* iterator from the layer below */
392 #define LOD_OBJS_INTRANS 4
393 struct lod_thread_info {
394 /* per-thread buffer for LOV EA, may be vmalloc'd */
395 struct lu_buf lti_ea_buf;
396 /* per-thread buffer for LMV EA */
397 struct lu_buf lti_buf;
398 struct ost_id lti_ostid;
399 struct lu_fid lti_fid;
400 struct obd_statfs lti_osfs;
401 struct lu_attr lti_attr;
402 struct lod_it lti_it;
403 struct ldlm_res_id lti_res_id;
404 /* used to hold lu_dirent, sizeof(struct lu_dirent) + NAME_MAX */
405 char lti_key[sizeof(struct lu_dirent) +
407 struct dt_object_format lti_format;
408 struct lu_name lti_name;
409 struct lu_buf lti_linkea_buf;
410 struct dt_insert_rec lti_dt_rec;
411 struct llog_catid lti_cid;
412 struct llog_cookie lti_cookie;
413 struct lustre_cfg lti_lustre_cfg;
414 /* used to store parent default striping in create */
415 struct lod_default_striping lti_def_striping;
416 struct filter_fid lti_ff;
418 size_t lti_comp_size;
420 struct lu_attr lti_layout_attr;
421 /* object allocation avoid guide info */
422 struct lod_avoid_guide lti_avoid;
423 union lmv_mds_md lti_lmv;
424 struct dt_allocation_hint lti_ah;
426 struct lod_object *lti_obj[LOD_OBJS_INTRANS];
427 __u32 lti_gen[LOD_OBJS_INTRANS];
430 #define lti_ea_store lti_ea_buf.lb_buf
431 #define lti_ea_store_size lti_ea_buf.lb_len
434 * \retval 0 object's layout hasn't changed in the transaction
435 * \retval > 0 object's layout has changed
436 * \retval -ENOENT object's layout gen hasn't saved in transatoin
440 lod_check_layout_gen_intrans(struct lod_thread_info *info,
441 struct lod_object *lo)
446 for (i = 0; i < info->lti_obj_count; i++) {
447 if (info->lti_obj[i] != lo)
450 if (info->lti_gen[i] == lo->ldo_layout_gen)
461 lod_save_layout_gen_intrans(struct lod_thread_info *info, struct lod_object *lo)
463 struct lu_object *luo = &lo->ldo_obj.do_lu;
466 rc = lod_check_layout_gen_intrans(info, lo);
471 "%s: obj %p gen changed from %d to %d in trans declaration\n",
472 luo->lo_dev->ld_obd->obd_name, lo, info->lti_gen[rc - 1],
477 if (unlikely(info->lti_obj_count == LOD_OBJS_INTRANS)) {
479 " save too many lod_object (%d) in one transaction, use bigger LOD_OBJS_INTRANS: rc = %d\n",
480 luo->lo_dev->ld_obd->obd_name,
481 PFID(lu_object_fid(luo)), LOD_OBJS_INTRANS, -E2BIG);
485 info->lti_obj[info->lti_obj_count] = lo;
486 info->lti_gen[info->lti_obj_count] = lo->ldo_layout_gen;
487 info->lti_obj_count++;
492 extern const struct lu_device_operations lod_lu_ops;
494 static inline int lu_device_is_lod(struct lu_device *d)
496 return ergo(d != NULL && d->ld_ops != NULL, d->ld_ops == &lod_lu_ops);
499 static inline struct lod_device* lu2lod_dev(struct lu_device *d)
501 LASSERT(lu_device_is_lod(d));
502 return container_of_safe(d, struct lod_device, lod_dt_dev.dd_lu_dev);
505 static inline struct lu_device *lod2lu_dev(struct lod_device *d)
507 return &d->lod_dt_dev.dd_lu_dev;
510 static inline struct obd_device *lod2obd(struct lod_device *d)
512 return d->lod_dt_dev.dd_lu_dev.ld_obd;
515 static inline struct lod_device *dt2lod_dev(struct dt_device *d)
517 LASSERT(lu_device_is_lod(&d->dd_lu_dev));
518 return container_of(d, struct lod_device, lod_dt_dev);
521 static inline struct lod_object *lu2lod_obj(struct lu_object *o)
523 LASSERT(ergo(o != NULL, lu_device_is_lod(o->lo_dev)));
524 return container_of_safe(o, struct lod_object, ldo_obj.do_lu);
527 static inline struct lu_object *lod2lu_obj(struct lod_object *obj)
529 return &obj->ldo_obj.do_lu;
532 static inline const struct lu_fid *lod_object_fid(struct lod_object *obj)
534 return lu_object_fid(lod2lu_obj(obj));
537 static inline struct lod_object *lod_obj(const struct lu_object *o)
539 LASSERT(lu_device_is_lod(o->lo_dev));
540 return container_of(o, struct lod_object, ldo_obj.do_lu);
543 static inline struct lod_object *lod_dt_obj(const struct dt_object *d)
545 return lod_obj(&d->do_lu);
548 static inline struct dt_object* lod_object_child(struct lod_object *o)
550 return container_of(lu_object_next(lod2lu_obj(o)),
551 struct dt_object, do_lu);
554 static inline bool lod_obj_is_striped(struct dt_object *dt)
556 struct lod_object *lo = lod_dt_obj(dt);
560 if (!dt_object_exists(dt_object_child(dt)))
563 mutex_lock(&lo->ldo_layout_mutex);
565 if (S_ISDIR(dt->do_lu.lo_header->loh_attr)) {
566 rc = lo->ldo_dir_stripe_count != 0;
567 } else if (lo->ldo_is_foreign) {
570 for (i = 0; i < lo->ldo_comp_cnt; i++) {
571 if (lo->ldo_comp_entries[i].llc_magic ==
574 if (lo->ldo_comp_entries[i].llc_stripe == NULL)
576 LASSERT(lo->ldo_comp_entries[i].llc_stripe_count > 0);
582 mutex_unlock(&lo->ldo_layout_mutex);
586 extern struct lu_context_key lod_thread_key;
588 static inline struct lod_thread_info *lod_env_info(const struct lu_env *env)
590 struct lod_thread_info *info;
591 info = lu_context_key_get(&env->le_ctx, &lod_thread_key);
596 static inline struct lu_name *
597 lod_name_get(const struct lu_env *env, const void *area, int len)
599 struct lu_name *lname;
601 lname = &lod_env_info(env)->lti_name;
602 lname->ln_name = area;
603 lname->ln_namelen = len;
607 static inline struct lod_default_striping *
608 lod_lds_buf_get(const struct lu_env *env)
610 struct lod_thread_info *info = lod_env_info(env);
612 info->lti_def_striping.lds_def_striping_set = 0;
613 info->lti_def_striping.lds_dir_def_striping_set = 0;
614 return &info->lti_def_striping;
617 static inline void lod_layout_get_pool(struct lod_layout_component *entries,
618 int count, char *pool, int len)
622 for (i = 0; i < count; i++) {
623 if (entries[i].llc_magic == LOV_MAGIC_FOREIGN)
625 if (entries[i].llc_pool != NULL) {
626 strscpy(pool, entries[i].llc_pool, len);
632 #define lod_foreach_mdt(lod, mdt) ltd_foreach_tgt(&(lod)->lod_mdt_descs, mdt)
633 #define lod_foreach_ost(lod, ost) ltd_foreach_tgt(&(lod)->lod_ost_descs, ost)
636 extern struct kmem_cache *lod_object_kmem;
637 int lod_fld_lookup(const struct lu_env *env, struct lod_device *lod,
638 const struct lu_fid *fid, __u32 *tgt, int *flags);
639 int lod_sub_init_llog(const struct lu_env *env, struct lod_device *lod,
640 struct dt_device *dt);
641 void lod_sub_fini_llog(const struct lu_env *env,
642 struct dt_device *dt, struct task_struct **taskp);
643 int lodname2mdt_index(char *lodname, __u32 *mdt_index);
646 void lod_getref(struct lod_tgt_descs *ltd);
647 void lod_putref(struct lod_device *lod, struct lod_tgt_descs *ltd);
648 int lod_add_device(const struct lu_env *env, struct lod_device *lod,
649 char *osp, unsigned index, unsigned gen, int mdt_index,
650 char *type, int active);
651 int lod_del_device(const struct lu_env *env, struct lod_device *lod,
652 struct lod_tgt_descs *ltd, char *osp, unsigned int idx,
654 int validate_lod_and_idx(struct lod_device *lod, __u32 idx);
655 int lod_fini_tgt(const struct lu_env *env, struct lod_device *lod,
656 struct lod_tgt_descs *ltd);
657 int lod_striping_load(const struct lu_env *env, struct lod_object *lo);
658 int lod_striping_reload(const struct lu_env *env, struct lod_object *lo,
659 const struct lu_buf *buf, enum layout_verify_flags lvf);
660 void lod_dom_stripesize_recalc(struct lod_device *d);
662 int lod_get_ea(const struct lu_env *env, struct lod_object *lo,
665 lod_get_lov_ea(const struct lu_env *env, struct lod_object *lo)
667 return lod_get_ea(env, lo, XATTR_NAME_LOV);
671 lod_get_lmv_ea(const struct lu_env *env, struct lod_object *lo)
673 return lod_get_ea(env, lo, XATTR_NAME_LMV);
677 lod_get_default_lmv_ea(const struct lu_env *env, struct lod_object *lo)
679 return lod_get_ea(env, lo, XATTR_NAME_DEFAULT_LMV);
683 lod_comp_set_init(struct lod_layout_component *entry)
685 entry->llc_flags |= LCME_FL_INIT;
689 lod_comp_unset_init(struct lod_layout_component *entry)
691 entry->llc_flags &= ~LCME_FL_INIT;
695 lod_comp_inited(const struct lod_layout_component *entry)
697 return entry->llc_flags & LCME_FL_INIT;
701 * For a PFL file, some of its component could be un-instantiated, so
702 * that their lov_ost_data_v1 array is not needed, we'd use this function
703 * to reduce the LOVEA buffer size.
705 * Note: if llc_ostlist contains value, we'd need lov_ost_data_v1 array to
706 * save the specified OST index list.
709 lod_comp_shrink_stripe_count(struct lod_layout_component *lod_comp,
713 * Need one lov_ost_data_v1 to store invalid ost_idx, please refer to
714 * lod_parse_striping()
716 if (!lod_comp_inited(lod_comp) && lod_comp->llc_ostlist.op_count == 0)
720 void lod_fix_desc(struct lov_desc *desc);
721 void lod_fix_desc_qos_maxage(__u32 *val);
722 void lod_fix_desc_pattern(__u32 *val);
723 void lod_fix_desc_stripe_count(__u32 *val);
724 void lod_fix_desc_stripe_size(__u64 *val);
725 void lod_fix_lmv_desc_pattern(__u32 *val);
726 int lod_pools_init(struct lod_device *m, struct lustre_cfg *cfg);
727 int lod_pools_fini(struct lod_device *m);
728 int lod_parse_striping(const struct lu_env *env, struct lod_object *mo,
729 const struct lu_buf *buf, enum layout_verify_flags lvf);
730 int lod_parse_dir_striping(const struct lu_env *env, struct lod_object *lo,
731 const struct lu_buf *buf);
732 int lod_initialize_objects(const struct lu_env *env, struct lod_object *mo,
733 struct lov_ost_data_v1 *objs, int index);
734 int lod_verify_striping(const struct lu_env *env, struct lod_device *d,
735 struct lod_object *lo, const struct lu_buf *buf,
737 int lod_generate_lovea(const struct lu_env *env, struct lod_object *lo,
738 struct lov_mds_md *lmm, int *lmm_size, bool is_dir);
739 int lod_ea_store_resize(struct lod_thread_info *info, size_t size);
740 int lod_def_striping_comp_resize(struct lod_default_striping *lds, __u16 count);
741 void lod_free_def_comp_entries(struct lod_default_striping *lds);
742 void lod_free_comp_entries(struct lod_object *lo);
743 int lod_alloc_comp_entries(struct lod_object *lo, int mirror_cnt, int comp_cnt);
744 int lod_fill_mirrors(struct lod_object *lo);
745 int lod_init_comp_foreign(struct lod_layout_component *lod_comp, void *lmm);
748 struct lod_pool_desc *lod_find_pool(struct lod_device *lod, const char *poolname);
749 void lod_pool_putref(struct lod_pool_desc *pool);
750 int lod_pool_del(struct obd_device *obd, char *poolname);
751 int lod_check_index_in_pool(__u32 idx, struct lod_pool_desc *pool);
752 int lod_pool_new(struct obd_device *obd, char *poolname);
753 int lod_pool_add(struct obd_device *obd, char *poolname, char *ostname);
754 int lod_pool_remove(struct obd_device *obd, char *poolname, char *ostname);
756 struct lod_obj_stripe_cb_data;
757 typedef int (*lod_obj_stripe_cb_t)(const struct lu_env *env,
758 struct lod_object *lo, struct dt_object *dt,
760 int comp_idx, int stripe_idx,
761 struct lod_obj_stripe_cb_data *data);
762 typedef bool (*lod_obj_comp_skip_cb_t)(const struct lu_env *env,
763 struct lod_object *lo, int comp_idx,
764 struct lod_obj_stripe_cb_data *data);
765 typedef int (*lod_obj_comp_cb_t)(const struct lu_env *env,
766 struct lod_object *lo, int comp_idx,
767 struct lod_obj_stripe_cb_data *data);
768 struct lod_obj_stripe_cb_data {
770 const struct lu_attr *locd_attr;
772 const struct lu_buf *locd_buf;
774 lod_obj_stripe_cb_t locd_stripe_cb;
775 lod_obj_comp_skip_cb_t locd_comp_skip_cb;
776 lod_obj_comp_cb_t locd_comp_cb;
781 int lod_mdt_alloc_qos(const struct lu_env *env, struct lod_object *lo,
782 struct dt_object **stripes, u32 stripe_idx,
784 int lod_mdt_alloc_rr(const struct lu_env *env, struct lod_object *lo,
785 struct dt_object **stripes, u32 stripe_idx,
787 int lod_prepare_create(const struct lu_env *env, struct lod_object *lo,
788 struct lu_attr *attr, const struct lu_buf *buf,
790 int lod_use_defined_striping(const struct lu_env *, struct lod_object *,
791 const struct lu_buf *);
792 int lod_qos_parse_config(const struct lu_env *env, struct lod_object *lo,
793 const struct lu_buf *buf);
794 void lod_qos_set_pool(struct lod_object *lo, int pos, const char *pool_name);
795 int lod_qos_prep_create(const struct lu_env *env, struct lod_object *lo,
796 struct lu_attr *attr, struct thandle *th,
797 int comp_idx, __u64 reserve);
798 __u16 lod_comp_entry_stripe_count(struct lod_object *lo,
799 int comp_idx, bool is_dir);
800 __u16 lod_get_stripe_count_plain(struct lod_device *lod, struct lod_object *lo,
801 __u16 stripe_count, bool overstriping,
802 enum lod_uses_hint *flags);
803 __u16 lod_get_stripe_count(struct lod_device *lod, struct lod_object *lo,
804 int comp_idx, __u16 stripe_count, bool overstriping,
805 enum lod_uses_hint *flags);
806 void lod_qos_statfs_update(const struct lu_env *env, struct lod_device *lod,
807 struct lu_tgt_descs *ltd);
810 int lod_procfs_init(struct lod_device *lod);
811 void lod_procfs_fini(struct lod_device *lod);
814 extern const struct dt_object_operations lod_obj_ops;
815 extern const struct lu_object_operations lod_lu_obj_ops;
817 int lod_load_lmv_shards(const struct lu_env *env, struct lod_object *lo,
818 struct lu_buf *buf, bool resize);
819 int lod_declare_striped_create(const struct lu_env *env, struct dt_object *dt,
820 struct lu_attr *attr,
821 const struct lu_buf *lovea, struct thandle *th);
822 int lod_striped_create(const struct lu_env *env, struct dt_object *dt,
823 struct lu_attr *attr, struct dt_object_format *dof,
825 int lod_alloc_foreign_lov(struct lod_object *lo, size_t size);
826 void lod_free_foreign_lov(struct lod_object *lo);
827 void lod_striping_free_nolock(const struct lu_env *env, struct lod_object *lo);
828 void lod_striping_free(const struct lu_env *env, struct lod_object *lo);
830 int lod_obj_for_each_stripe(const struct lu_env *env, struct lod_object *lo,
832 struct lod_obj_stripe_cb_data *data);
833 int lod_comp_copy_ost_lists(struct lod_layout_component *lod_comp,
834 struct lov_user_md_v3 *v3);
835 void lod_adjust_stripe_size(struct lod_layout_component *comp,
836 __u32 def_stripe_size);
838 /* lod_sub_object.c */
839 struct thandle *lod_sub_get_thandle(const struct lu_env *env,
841 const struct dt_object *sub_obj,
842 bool *record_update);
843 int lod_sub_declare_create(const struct lu_env *env, struct dt_object *dt,
844 struct lu_attr *attr,
845 struct dt_allocation_hint *hint,
846 struct dt_object_format *dof, struct thandle *th);
847 int lod_sub_create(const struct lu_env *env, struct dt_object *dt,
848 struct lu_attr *attr, struct dt_allocation_hint *hint,
849 struct dt_object_format *dof, struct thandle *th);
850 int lod_sub_declare_ref_add(const struct lu_env *env, struct dt_object *dt,
852 int lod_sub_ref_add(const struct lu_env *env, struct dt_object *dt,
854 int lod_sub_declare_ref_del(const struct lu_env *env, struct dt_object *dt,
856 int lod_sub_ref_del(const struct lu_env *env, struct dt_object *dt,
858 int lod_sub_declare_destroy(const struct lu_env *env, struct dt_object *dt,
860 int lod_sub_destroy(const struct lu_env *env, struct dt_object *dt,
862 int lod_sub_declare_insert(const struct lu_env *env, struct dt_object *dt,
863 const struct dt_rec *rec, const struct dt_key *key,
865 int lod_sub_insert(const struct lu_env *env, struct dt_object *dt,
866 const struct dt_rec *rec, const struct dt_key *key,
868 int lod_sub_declare_delete(const struct lu_env *env, struct dt_object *dt,
869 const struct dt_key *key, struct thandle *th);
870 int lod_sub_delete(const struct lu_env *env, struct dt_object *dt,
871 const struct dt_key *name, struct thandle *th);
872 int lod_sub_declare_xattr_set(const struct lu_env *env, struct dt_object *dt,
873 const struct lu_buf *buf, const char *name,
874 int fl, struct thandle *th);
875 int lod_sub_xattr_set(const struct lu_env *env, struct dt_object *dt,
876 const struct lu_buf *buf, const char *name, int fl,
878 int lod_sub_declare_attr_set(const struct lu_env *env, struct dt_object *dt,
879 const struct lu_attr *attr, struct thandle *th);
880 int lod_sub_attr_set(const struct lu_env *env, struct dt_object *dt,
881 const struct lu_attr *attr, struct thandle *th);
882 int lod_sub_declare_xattr_del(const struct lu_env *env, struct dt_object *dt,
883 const char *name, struct thandle *th);
884 int lod_sub_xattr_del(const struct lu_env *env, struct dt_object *dt,
885 const char *name, struct thandle *th);
886 int lod_sub_declare_write(const struct lu_env *env, struct dt_object *dt,
887 const struct lu_buf *buf, loff_t pos,
889 ssize_t lod_sub_write(const struct lu_env *env, struct dt_object *dt,
890 const struct lu_buf *buf, loff_t *pos,
892 int lod_sub_declare_punch(const struct lu_env *env, struct dt_object *dt,
893 __u64 start, __u64 end, struct thandle *th);
894 int lod_sub_punch(const struct lu_env *env, struct dt_object *dt,
895 __u64 start, __u64 end, struct thandle *th);
897 int lod_sub_prep_llog(const struct lu_env *env, struct lod_device *lod,
898 struct dt_device *dt, int index);
899 void lod_check_and_spill_pool(const struct lu_env *env, struct lod_device *lod,
901 void lod_spill_target_refresh(const struct lu_env *env, struct lod_device *lod,
902 struct lod_pool_desc *pool);
903 struct lod_pool_desc *lod_pool_find(struct lod_device *lod, const char *poolname);
904 int lod_tgt_weights_seq_show(struct seq_file *m, struct lod_device *lod,
905 struct lu_tgt_pool *tgts, bool mdt);
906 int lod_tgt_weights_seq_write(struct seq_file *m, const char __user *buf,
907 size_t count, struct lod_device *lod,
908 struct lu_tgt_pool *tgts, bool is_mdt);
909 extern struct lprocfs_vars lprocfs_lod_spill_vars[];