1 .TH llapi_file_get_stripe 3 "2009 Jul 22" Lustre liblustreapi
3 llapi_file_get_stripe \- get striping information for a file or a directory on a Lustre filesystem
6 .B #include <sys/types.h>
7 .B #include <sys/stat.h>
9 .B #include <liblustre.h>
10 .B #include <lustre/lustre_idl.h>
11 .B #include <lustre/liblustreapi.h>
12 .B #include <lustre/lustre_user.h>
14 .BI "int llapi_file_get_stripe(const char *"path ", void *"lum );
19 .B llapi_file_get_stripe(\|)
20 returns striping information for a file or a directory
24 (which should point to a large enough memory region) in one of the following formats:
27 struct lov_user_md_v1 {
32 __u32 lmm_stripe_size;
33 __u16 lmm_stripe_count;
34 __u16 lmm_stripe_offset;
35 struct lov_user_ost_data_v1 lmm_objects[0];
36 } __attribute__((packed));
38 struct lov_user_md_v3 {
43 __u32 lmm_stripe_size;
44 __u16 lmm_stripe_count;
45 __u16 lmm_stripe_offset;
46 char lmm_pool_name[LOV_MAXPOOLNAME];
47 struct lov_user_ost_data_v1 lmm_objects[0];
48 } __attribute__((packed));
50 struct lov_user_md_join {
55 __u32 lmm_stripe_size;
56 __u32 lmm_stripe_count;
57 __u32 lmm_extent_count;
60 struct llog_logid lmm_array_id;
61 struct lov_user_ost_data_join lmm_objects[0];
62 } __attribute__((packed));
67 specifies the format of the returned striping information.
69 is used for lov_user_md_v1.
71 is used for lov_user_md_v3.
73 is used for lov_user_md_join.
76 holds the striping pattern. Only
78 is possible in this Lustre version.
81 holds the MDS object id.
84 holds the MDS object group.
87 holds the stripe size in bytes.
90 holds the number of OSTs the file is striped across.
93 holds the OST index from which the file starts.
96 holds the OST pool name to which the file belongs.
101 members containing per OST file information in the following format:
104 struct lov_user_ost_data_v1 {
109 } __attribute__((packed));
113 holds the OST object id.
116 holds the OST object group.
119 holds the generation of the OST index.
122 holds the OST index in LOV.
125 .B llapi_file_get_stripe(\|)
134 is set appropriately.
138 failed to allocate memory.
146 does not point to a file or a directory.
150 does not point to a Lustre filesystem.
153 memory region pointed by
155 is not properly mapped.
159 #include <liblustre.h>
160 #include <lnet/lnetctl.h>
162 #include <lustre_lib.h>
163 #include <lustre/liblustreapi.h>
166 static inline int maxint(int a, int b)
168 return a > b ? a : b;
171 static void *alloc_lum()
175 v1 = sizeof(struct lov_user_md_v1) +
176 LOV_MAX_STRIPE_COUNT * sizeof(struct lov_user_ost_data_v1);
177 v3 = sizeof(struct lov_user_md_v3) +
178 LOV_MAX_STRIPE_COUNT * sizeof(struct lov_user_ost_data_v1);
179 join = sizeof(struct lov_user_md_join) +
180 LOV_MAX_STRIPE_COUNT * sizeof(struct lov_user_ost_data_join);
182 return malloc(maxint(maxint(v1, v3), join));
185 int main(int argc, char** argv)
187 struct lov_user_md *lum_file = NULL;
192 fprintf(stderr, "Usage: %s <filename>\\n", argv[0]);
196 lum_file = alloc_lum();
197 if (lum_file == NULL) {
202 rc = llapi_file_get_stripe(argv[1], lum_file);
208 /* stripe_size stripe_count */
210 lum_file->lmm_stripe_size,
211 lum_file->lmm_stripe_count);
214 if (lum_file != NULL)