1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37#ifndef __LUSTRE_LU_OBJECT_H
38#define __LUSTRE_LU_OBJECT_H
39
40#include <stdarg.h>
41#include <linux/libcfs/libcfs.h>
42#include <lustre/lustre_idl.h>
43#include <lu_ref.h>
44
45struct seq_file;
46struct proc_dir_entry;
47struct lustre_cfg;
48struct lprocfs_stats;
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99struct lu_site;
100struct lu_object;
101struct lu_device;
102struct lu_object_header;
103struct lu_context;
104struct lu_env;
105
106
107
108
109struct lu_device_operations {
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142 struct lu_object *(*ldo_object_alloc)(const struct lu_env *env,
143 const struct lu_object_header *h,
144 struct lu_device *d);
145
146
147
148 int (*ldo_process_config)(const struct lu_env *env,
149 struct lu_device *, struct lustre_cfg *);
150 int (*ldo_recovery_complete)(const struct lu_env *,
151 struct lu_device *);
152
153
154
155
156
157
158
159 int (*ldo_prepare)(const struct lu_env *,
160 struct lu_device *parent,
161 struct lu_device *dev);
162
163};
164
165
166
167
168typedef enum {
169
170
171 LOC_F_NEW = 0x00000001,
172} loc_flags_t;
173
174
175
176
177
178
179struct lu_object_conf {
180
181
182
183 loc_flags_t loc_flags;
184};
185
186
187
188
189
190
191
192
193typedef int (*lu_printer_t)(const struct lu_env *env,
194 void *cookie, const char *format, ...)
195 __attribute__ ((format (printf, 3, 4)));
196
197
198
199
200struct lu_object_operations {
201
202
203
204
205
206
207
208
209
210
211 int (*loo_object_init)(const struct lu_env *env,
212 struct lu_object *o,
213 const struct lu_object_conf *conf);
214
215
216
217
218
219 int (*loo_object_start)(const struct lu_env *env,
220 struct lu_object *o);
221
222
223
224
225
226 void (*loo_object_delete)(const struct lu_env *env,
227 struct lu_object *o);
228
229
230
231
232 void (*loo_object_free)(const struct lu_env *env,
233 struct lu_object *o);
234
235
236
237
238 void (*loo_object_release)(const struct lu_env *env,
239 struct lu_object *o);
240
241
242
243 int (*loo_object_print)(const struct lu_env *env, void *cookie,
244 lu_printer_t p, const struct lu_object *o);
245
246
247
248
249 int (*loo_object_invariant)(const struct lu_object *o);
250};
251
252
253
254
255struct lu_device_type;
256
257
258
259
260struct lu_device {
261
262
263
264
265
266
267 atomic_t ld_ref;
268
269
270
271 struct lu_device_type *ld_type;
272
273
274
275 const struct lu_device_operations *ld_ops;
276
277
278
279 struct lu_site *ld_site;
280 struct proc_dir_entry *ld_proc_entry;
281
282
283 struct obd_device *ld_obd;
284
285
286
287 struct lu_ref ld_reference;
288
289
290
291 struct list_head ld_linkage;
292};
293
294struct lu_device_type_operations;
295
296
297
298
299
300enum lu_device_tag {
301
302 LU_DEVICE_MD = (1 << 0),
303
304 LU_DEVICE_DT = (1 << 1),
305
306 LU_DEVICE_CL = (1 << 2)
307};
308
309
310
311
312struct lu_device_type {
313
314
315
316 __u32 ldt_tags;
317
318
319
320 char *ldt_name;
321
322
323
324 const struct lu_device_type_operations *ldt_ops;
325
326
327
328 struct obd_type *ldt_obd_type;
329
330
331
332 __u32 ldt_ctx_tags;
333
334
335
336 unsigned ldt_device_nr;
337
338
339
340
341
342 struct list_head ldt_linkage;
343};
344
345
346
347
348struct lu_device_type_operations {
349
350
351
352 struct lu_device *(*ldto_device_alloc)(const struct lu_env *env,
353 struct lu_device_type *t,
354 struct lustre_cfg *lcfg);
355
356
357
358
359
360 struct lu_device *(*ldto_device_free)(const struct lu_env *,
361 struct lu_device *);
362
363
364
365
366 int (*ldto_device_init)(const struct lu_env *env,
367 struct lu_device *, const char *,
368 struct lu_device *);
369
370
371
372
373
374 struct lu_device *(*ldto_device_fini)(const struct lu_env *env,
375 struct lu_device *);
376
377
378
379 int (*ldto_init)(struct lu_device_type *t);
380
381
382
383
384 void (*ldto_fini)(struct lu_device_type *t);
385
386
387
388 void (*ldto_start)(struct lu_device_type *t);
389
390
391
392 void (*ldto_stop)(struct lu_device_type *t);
393};
394
395static inline int lu_device_is_md(const struct lu_device *d)
396{
397 return ergo(d != NULL, d->ld_type->ldt_tags & LU_DEVICE_MD);
398}
399
400
401
402
403enum lu_object_flags {
404
405
406
407
408 LU_OBJECT_ALLOCATED = (1 << 0)
409};
410
411
412
413
414struct lu_attr {
415
416 __u64 la_size;
417
418 obd_time la_mtime;
419
420 obd_time la_atime;
421
422 obd_time la_ctime;
423
424 __u64 la_blocks;
425
426 __u32 la_mode;
427
428 __u32 la_uid;
429
430 __u32 la_gid;
431
432 __u32 la_flags;
433
434 __u32 la_nlink;
435
436 __u32 la_blkbits;
437
438 __u32 la_blksize;
439
440 __u32 la_rdev;
441
442
443
444
445
446 __u64 la_valid;
447};
448
449
450enum la_valid {
451 LA_ATIME = 1 << 0,
452 LA_MTIME = 1 << 1,
453 LA_CTIME = 1 << 2,
454 LA_SIZE = 1 << 3,
455 LA_MODE = 1 << 4,
456 LA_UID = 1 << 5,
457 LA_GID = 1 << 6,
458 LA_BLOCKS = 1 << 7,
459 LA_TYPE = 1 << 8,
460 LA_FLAGS = 1 << 9,
461 LA_NLINK = 1 << 10,
462 LA_RDEV = 1 << 11,
463 LA_BLKSIZE = 1 << 12,
464 LA_KILL_SUID = 1 << 13,
465 LA_KILL_SGID = 1 << 14,
466};
467
468
469
470
471struct lu_object {
472
473
474
475 struct lu_object_header *lo_header;
476
477
478
479 struct lu_device *lo_dev;
480
481
482
483 const struct lu_object_operations *lo_ops;
484
485
486
487 struct list_head lo_linkage;
488
489
490
491 int lo_depth;
492
493
494
495 __u32 lo_flags;
496
497
498
499 struct lu_ref_link *lo_dev_ref;
500};
501
502enum lu_object_header_flags {
503
504
505
506
507
508 LU_OBJECT_HEARD_BANSHEE = 0,
509
510
511
512 LU_OBJECT_UNHASHED = 1
513};
514
515enum lu_object_header_attr {
516 LOHA_EXISTS = 1 << 0,
517 LOHA_REMOTE = 1 << 1,
518
519
520
521 LOHA_FT_START = 001 << 12,
522 LOHA_FT_END = 017 << 12,
523};
524
525
526
527
528
529
530
531
532
533
534
535
536struct lu_object_header {
537
538
539
540
541 unsigned long loh_flags;
542
543
544
545 atomic_t loh_ref;
546
547
548
549 struct lu_fid loh_fid;
550
551
552
553
554 __u32 loh_attr;
555
556
557
558 struct hlist_node loh_hash;
559
560
561
562 struct list_head loh_lru;
563
564
565
566
567 struct list_head loh_layers;
568
569
570
571 struct lu_ref loh_reference;
572};
573
574struct fld;
575
576struct lu_site_bkt_data {
577
578
579
580 long lsb_busy;
581
582
583
584
585
586
587
588
589 struct list_head lsb_lru;
590
591
592
593
594
595
596
597
598 wait_queue_head_t lsb_marche_funebre;
599};
600
601enum {
602 LU_SS_CREATED = 0,
603 LU_SS_CACHE_HIT,
604 LU_SS_CACHE_MISS,
605 LU_SS_CACHE_RACE,
606 LU_SS_CACHE_DEATH_RACE,
607 LU_SS_LRU_PURGED,
608 LU_SS_LAST_STAT
609};
610
611
612
613
614
615
616
617
618
619
620
621struct lu_site {
622
623
624
625 cfs_hash_t *ls_obj_hash;
626
627
628
629 int ls_purge_start;
630
631
632
633 struct lu_device *ls_top_dev;
634
635
636
637 struct lu_device *ls_bottom_dev;
638
639
640
641 struct list_head ls_linkage;
642
643
644
645
646 struct list_head ls_ld_linkage;
647 spinlock_t ls_ld_lock;
648
649
650
651
652 struct lprocfs_stats *ls_stats;
653
654
655
656 struct seq_server_site *ld_seq_site;
657};
658
659static inline struct lu_site_bkt_data *
660lu_site_bkt_from_fid(struct lu_site *site, struct lu_fid *fid)
661{
662 cfs_hash_bd_t bd;
663
664 cfs_hash_bd_get(site->ls_obj_hash, fid, &bd);
665 return cfs_hash_bd_extra_get(site->ls_obj_hash, &bd);
666}
667
668
669
670
671
672
673int lu_site_init (struct lu_site *s, struct lu_device *d);
674void lu_site_fini (struct lu_site *s);
675int lu_site_init_finish (struct lu_site *s);
676void lu_stack_fini (const struct lu_env *env, struct lu_device *top);
677void lu_device_get (struct lu_device *d);
678void lu_device_put (struct lu_device *d);
679int lu_device_init (struct lu_device *d, struct lu_device_type *t);
680void lu_device_fini (struct lu_device *d);
681int lu_object_header_init(struct lu_object_header *h);
682void lu_object_header_fini(struct lu_object_header *h);
683int lu_object_init (struct lu_object *o,
684 struct lu_object_header *h, struct lu_device *d);
685void lu_object_fini (struct lu_object *o);
686void lu_object_add_top (struct lu_object_header *h, struct lu_object *o);
687void lu_object_add (struct lu_object *before, struct lu_object *o);
688
689void lu_dev_add_linkage(struct lu_site *s, struct lu_device *d);
690void lu_dev_del_linkage(struct lu_site *s, struct lu_device *d);
691
692
693
694
695
696int lu_device_type_init(struct lu_device_type *ldt);
697void lu_device_type_fini(struct lu_device_type *ldt);
698void lu_types_stop(void);
699
700
701
702
703
704
705
706
707
708
709
710
711
712static inline void lu_object_get(struct lu_object *o)
713{
714 LASSERT(atomic_read(&o->lo_header->loh_ref) > 0);
715 atomic_inc(&o->lo_header->loh_ref);
716}
717
718
719
720
721
722static inline int lu_object_is_dying(const struct lu_object_header *h)
723{
724 return test_bit(LU_OBJECT_HEARD_BANSHEE, &h->loh_flags);
725}
726
727void lu_object_put(const struct lu_env *env, struct lu_object *o);
728void lu_object_put_nocache(const struct lu_env *env, struct lu_object *o);
729void lu_object_unhash(const struct lu_env *env, struct lu_object *o);
730
731int lu_site_purge(const struct lu_env *env, struct lu_site *s, int nr);
732
733void lu_site_print(const struct lu_env *env, struct lu_site *s, void *cookie,
734 lu_printer_t printer);
735struct lu_object *lu_object_find(const struct lu_env *env,
736 struct lu_device *dev, const struct lu_fid *f,
737 const struct lu_object_conf *conf);
738struct lu_object *lu_object_find_at(const struct lu_env *env,
739 struct lu_device *dev,
740 const struct lu_fid *f,
741 const struct lu_object_conf *conf);
742struct lu_object *lu_object_find_slice(const struct lu_env *env,
743 struct lu_device *dev,
744 const struct lu_fid *f,
745 const struct lu_object_conf *conf);
746
747
748
749
750
751
752
753
754
755
756static inline struct lu_object *lu_object_top(struct lu_object_header *h)
757{
758 LASSERT(!list_empty(&h->loh_layers));
759 return container_of0(h->loh_layers.next, struct lu_object, lo_linkage);
760}
761
762
763
764
765static inline struct lu_object *lu_object_next(const struct lu_object *o)
766{
767 return container_of0(o->lo_linkage.next, struct lu_object, lo_linkage);
768}
769
770
771
772
773static inline const struct lu_fid *lu_object_fid(const struct lu_object *o)
774{
775 return &o->lo_header->loh_fid;
776}
777
778
779
780
781static const inline struct lu_device_operations *
782lu_object_ops(const struct lu_object *o)
783{
784 return o->lo_dev->ld_ops;
785}
786
787
788
789
790
791struct lu_object *lu_object_locate(struct lu_object_header *h,
792 const struct lu_device_type *dtype);
793
794
795
796
797int lu_cdebug_printer(const struct lu_env *env,
798 void *cookie, const char *format, ...);
799
800
801
802
803#define LU_OBJECT_DEBUG(mask, env, object, format, ...) \
804do { \
805 LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, mask, NULL); \
806 \
807 if (cfs_cdebug_show(mask, DEBUG_SUBSYSTEM)) { \
808 lu_object_print(env, &msgdata, lu_cdebug_printer, object);\
809 CDEBUG(mask, format , ## __VA_ARGS__); \
810 } \
811} while (0)
812
813
814
815
816#define LU_OBJECT_HEADER(mask, env, object, format, ...) \
817do { \
818 LIBCFS_DEBUG_MSG_DATA_DECL(msgdata, mask, NULL); \
819 \
820 if (cfs_cdebug_show(mask, DEBUG_SUBSYSTEM)) { \
821 lu_object_header_print(env, &msgdata, lu_cdebug_printer,\
822 (object)->lo_header); \
823 lu_cdebug_printer(env, &msgdata, "\n"); \
824 CDEBUG(mask, format , ## __VA_ARGS__); \
825 } \
826} while (0)
827
828void lu_object_print (const struct lu_env *env, void *cookie,
829 lu_printer_t printer, const struct lu_object *o);
830void lu_object_header_print(const struct lu_env *env, void *cookie,
831 lu_printer_t printer,
832 const struct lu_object_header *hdr);
833
834
835
836
837int lu_object_invariant(const struct lu_object *o);
838
839
840
841
842
843
844
845#define lu_object_exists(o) ((o)->lo_header->loh_attr & LOHA_EXISTS)
846
847
848
849
850#define lu_object_remote(o) unlikely((o)->lo_header->loh_attr & LOHA_REMOTE)
851
852static inline int lu_object_assert_exists(const struct lu_object *o)
853{
854 return lu_object_exists(o);
855}
856
857static inline int lu_object_assert_not_exists(const struct lu_object *o)
858{
859 return !lu_object_exists(o);
860}
861
862
863
864
865static inline __u32 lu_object_attr(const struct lu_object *o)
866{
867 LASSERT(lu_object_exists(o) != 0);
868 return o->lo_header->loh_attr;
869}
870
871static inline struct lu_ref_link *lu_object_ref_add(struct lu_object *o,
872 const char *scope,
873 const void *source)
874{
875 return lu_ref_add(&o->lo_header->loh_reference, scope, source);
876}
877
878static inline void lu_object_ref_del(struct lu_object *o,
879 const char *scope, const void *source)
880{
881 lu_ref_del(&o->lo_header->loh_reference, scope, source);
882}
883
884static inline void lu_object_ref_del_at(struct lu_object *o,
885 struct lu_ref_link *link,
886 const char *scope, const void *source)
887{
888 lu_ref_del_at(&o->lo_header->loh_reference, link, scope, source);
889}
890
891
892struct lu_rdpg {
893
894 __u64 rp_hash;
895
896 unsigned int rp_count;
897
898 unsigned int rp_npages;
899
900 __u32 rp_attrs;
901
902 struct page **rp_pages;
903};
904
905enum lu_xattr_flags {
906 LU_XATTR_REPLACE = (1 << 0),
907 LU_XATTR_CREATE = (1 << 1)
908};
909
910
911
912
913
914
915
916enum lu_context_state {
917 LCS_INITIALIZED = 1,
918 LCS_ENTERED,
919 LCS_LEFT,
920 LCS_FINALIZED
921};
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944struct lu_context {
945
946
947
948
949
950
951
952
953
954
955 __u32 lc_tags;
956 enum lu_context_state lc_state;
957
958
959
960
961 struct ptlrpc_thread *lc_thread;
962
963
964
965
966 void **lc_value;
967
968
969
970
971
972 struct list_head lc_remember;
973
974
975
976
977 unsigned lc_version;
978
979
980
981 unsigned lc_cookie;
982};
983
984
985
986
987
988enum lu_context_tag {
989
990
991
992 LCT_MD_THREAD = 1 << 0,
993
994
995
996 LCT_DT_THREAD = 1 << 1,
997
998
999
1000 LCT_TX_HANDLE = 1 << 2,
1001
1002
1003
1004 LCT_CL_THREAD = 1 << 3,
1005
1006
1007
1008
1009 LCT_SESSION = 1 << 4,
1010
1011
1012
1013 LCT_OSP_THREAD = 1 << 5,
1014
1015
1016
1017 LCT_MG_THREAD = 1 << 6,
1018
1019
1020
1021 LCT_LOCAL = 1 << 7,
1022
1023
1024
1025
1026
1027 LCT_HAS_EXIT = 1 << 28,
1028
1029
1030
1031
1032 LCT_NOREF = 1 << 29,
1033
1034
1035
1036 LCT_QUIESCENT = 1 << 30,
1037
1038
1039
1040 LCT_REMEMBER = 1 << 31,
1041
1042
1043
1044 LCT_SHRINKER = LCT_MD_THREAD|LCT_DT_THREAD|LCT_CL_THREAD|LCT_NOREF
1045};
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083struct lu_context_key {
1084
1085
1086
1087 __u32 lct_tags;
1088
1089
1090
1091
1092 void *(*lct_init)(const struct lu_context *ctx,
1093 struct lu_context_key *key);
1094
1095
1096
1097
1098
1099 void (*lct_fini)(const struct lu_context *ctx,
1100 struct lu_context_key *key, void *data);
1101
1102
1103
1104
1105
1106 void (*lct_exit)(const struct lu_context *ctx,
1107 struct lu_context_key *key, void *data);
1108
1109
1110
1111
1112 int lct_index;
1113
1114
1115
1116
1117 atomic_t lct_used;
1118
1119
1120
1121 module_t *lct_owner;
1122
1123
1124
1125 struct lu_ref lct_reference;
1126};
1127
1128#define LU_KEY_INIT(mod, type) \
1129 static void* mod##_key_init(const struct lu_context *ctx, \
1130 struct lu_context_key *key) \
1131 { \
1132 type *value; \
1133 \
1134 CLASSERT(PAGE_CACHE_SIZE >= sizeof (*value)); \
1135 \
1136 OBD_ALLOC_PTR(value); \
1137 if (value == NULL) \
1138 value = ERR_PTR(-ENOMEM); \
1139 \
1140 return value; \
1141 } \
1142 struct __##mod##__dummy_init {;}
1143
1144#define LU_KEY_FINI(mod, type) \
1145 static void mod##_key_fini(const struct lu_context *ctx, \
1146 struct lu_context_key *key, void* data) \
1147 { \
1148 type *info = data; \
1149 \
1150 OBD_FREE_PTR(info); \
1151 } \
1152 struct __##mod##__dummy_fini {;}
1153
1154#define LU_KEY_INIT_FINI(mod, type) \
1155 LU_KEY_INIT(mod,type); \
1156 LU_KEY_FINI(mod,type)
1157
1158#define LU_CONTEXT_KEY_DEFINE(mod, tags) \
1159 struct lu_context_key mod##_thread_key = { \
1160 .lct_tags = tags, \
1161 .lct_init = mod##_key_init, \
1162 .lct_fini = mod##_key_fini \
1163 }
1164
1165#define LU_CONTEXT_KEY_INIT(key) \
1166do { \
1167 (key)->lct_owner = THIS_MODULE; \
1168} while (0)
1169
1170int lu_context_key_register(struct lu_context_key *key);
1171void lu_context_key_degister(struct lu_context_key *key);
1172void *lu_context_key_get (const struct lu_context *ctx,
1173 const struct lu_context_key *key);
1174void lu_context_key_quiesce (struct lu_context_key *key);
1175void lu_context_key_revive (struct lu_context_key *key);
1176
1177
1178
1179
1180
1181
1182
1183#define LU_KEY_INIT_GENERIC(mod) \
1184 static void mod##_key_init_generic(struct lu_context_key *k, ...) \
1185 { \
1186 struct lu_context_key *key = k; \
1187 va_list args; \
1188 \
1189 va_start(args, k); \
1190 do { \
1191 LU_CONTEXT_KEY_INIT(key); \
1192 key = va_arg(args, struct lu_context_key *); \
1193 } while (key != NULL); \
1194 va_end(args); \
1195 }
1196
1197#define LU_TYPE_INIT(mod, ...) \
1198 LU_KEY_INIT_GENERIC(mod) \
1199 static int mod##_type_init(struct lu_device_type *t) \
1200 { \
1201 mod##_key_init_generic(__VA_ARGS__, NULL); \
1202 return lu_context_key_register_many(__VA_ARGS__, NULL); \
1203 } \
1204 struct __##mod##_dummy_type_init {;}
1205
1206#define LU_TYPE_FINI(mod, ...) \
1207 static void mod##_type_fini(struct lu_device_type *t) \
1208 { \
1209 lu_context_key_degister_many(__VA_ARGS__, NULL); \
1210 } \
1211 struct __##mod##_dummy_type_fini {;}
1212
1213#define LU_TYPE_START(mod, ...) \
1214 static void mod##_type_start(struct lu_device_type *t) \
1215 { \
1216 lu_context_key_revive_many(__VA_ARGS__, NULL); \
1217 } \
1218 struct __##mod##_dummy_type_start {;}
1219
1220#define LU_TYPE_STOP(mod, ...) \
1221 static void mod##_type_stop(struct lu_device_type *t) \
1222 { \
1223 lu_context_key_quiesce_many(__VA_ARGS__, NULL); \
1224 } \
1225 struct __##mod##_dummy_type_stop {;}
1226
1227
1228
1229#define LU_TYPE_INIT_FINI(mod, ...) \
1230 LU_TYPE_INIT(mod, __VA_ARGS__); \
1231 LU_TYPE_FINI(mod, __VA_ARGS__); \
1232 LU_TYPE_START(mod, __VA_ARGS__); \
1233 LU_TYPE_STOP(mod, __VA_ARGS__)
1234
1235int lu_context_init (struct lu_context *ctx, __u32 tags);
1236void lu_context_fini (struct lu_context *ctx);
1237void lu_context_enter (struct lu_context *ctx);
1238void lu_context_exit (struct lu_context *ctx);
1239int lu_context_refill(struct lu_context *ctx);
1240
1241
1242
1243
1244
1245
1246int lu_context_key_register_many(struct lu_context_key *k, ...);
1247void lu_context_key_degister_many(struct lu_context_key *k, ...);
1248void lu_context_key_revive_many (struct lu_context_key *k, ...);
1249void lu_context_key_quiesce_many (struct lu_context_key *k, ...);
1250
1251
1252
1253
1254void lu_context_tags_update(__u32 tags);
1255void lu_context_tags_clear(__u32 tags);
1256void lu_session_tags_update(__u32 tags);
1257void lu_session_tags_clear(__u32 tags);
1258
1259
1260
1261
1262struct lu_env {
1263
1264
1265
1266 struct lu_context le_ctx;
1267
1268
1269
1270 struct lu_context *le_ses;
1271};
1272
1273int lu_env_init (struct lu_env *env, __u32 tags);
1274void lu_env_fini (struct lu_env *env);
1275int lu_env_refill(struct lu_env *env);
1276int lu_env_refill_by_tags(struct lu_env *env, __u32 ctags, __u32 stags);
1277
1278
1279
1280
1281
1282
1283
1284int lu_site_stats_print(const struct lu_site *s, struct seq_file *m);
1285
1286
1287
1288
1289struct lu_name {
1290 const char *ln_name;
1291 int ln_namelen;
1292};
1293
1294
1295
1296
1297
1298struct lu_buf {
1299 void *lb_buf;
1300 ssize_t lb_len;
1301};
1302
1303#define DLUBUF "(%p %zu)"
1304#define PLUBUF(buf) (buf)->lb_buf, (buf)->lb_len
1305
1306
1307
1308
1309
1310
1311
1312
1313int lu_global_init(void);
1314
1315
1316
1317
1318void lu_global_fini(void);
1319
1320struct lu_kmem_descr {
1321 struct kmem_cache **ckd_cache;
1322 const char *ckd_name;
1323 const size_t ckd_size;
1324};
1325
1326int lu_kmem_init(struct lu_kmem_descr *caches);
1327void lu_kmem_fini(struct lu_kmem_descr *caches);
1328
1329void lu_object_assign_fid(const struct lu_env *env, struct lu_object *o,
1330 const struct lu_fid *fid);
1331struct lu_object *lu_object_anon(const struct lu_env *env,
1332 struct lu_device *dev,
1333 const struct lu_object_conf *conf);
1334
1335
1336extern struct lu_buf LU_BUF_NULL;
1337
1338void lu_buf_free(struct lu_buf *buf);
1339void lu_buf_alloc(struct lu_buf *buf, int size);
1340void lu_buf_realloc(struct lu_buf *buf, int size);
1341
1342int lu_buf_check_and_grow(struct lu_buf *buf, int len);
1343struct lu_buf *lu_buf_check_and_alloc(struct lu_buf *buf, int len);
1344
1345
1346#endif
1347