1 .TH lustreapi 3 "2009 Jul 22" The Lustre user application interface library
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 <lustre/lustreapi.h>
11 .BI "int llapi_file_get_stripe(const char *"path ", void *"lum );
16 .B llapi_file_get_stripe(\|)
17 returns striping information for a file or a directory
21 (which should point to a large enough memory region) in one of the following formats:
24 struct lov_user_md_v1 {
29 __u32 lmm_stripe_size;
30 __u16 lmm_stripe_count;
31 __u16 lmm_stripe_offset;
32 struct lov_user_ost_data_v1 lmm_objects[0];
33 } __attribute__((packed));
35 struct lov_user_md_v3 {
40 __u32 lmm_stripe_size;
41 __u16 lmm_stripe_count;
42 __u16 lmm_stripe_offset;
43 char lmm_pool_name[LOV_MAXPOOLNAME];
44 struct lov_user_ost_data_v1 lmm_objects[0];
45 } __attribute__((packed));
50 specifies the format of the returned striping information.
52 is used for lov_user_md_v1.
54 is used for lov_user_md_v3.
57 holds the striping pattern. Only
59 is possible in this Lustre version.
62 holds the MDS object id.
65 holds the MDS object group.
68 holds the stripe size in bytes.
71 holds the number of OSTs the file is striped across.
74 holds the OST index from which the file starts.
77 holds the OST pool name to which the file belongs.
82 members containing per OST file information in the following format:
85 struct lov_user_ost_data_v1 {
90 } __attribute__((packed));
94 holds the OST object id.
97 holds the OST object group.
100 holds the generation of the OST index.
103 holds the OST index in LOV.
106 .B llapi_file_get_stripe(\|)
115 is set appropriately.
119 failed to allocate memory.
127 does not point to a file or a directory.
131 does not point to a Lustre filesystem.
134 memory region pointed by
136 is not properly mapped.
140 #include <lustre/lustreapi.h>
142 static inline int maxint(int a, int b)
144 return a > b ? a : b;
147 static void *alloc_lum()
151 v1 = sizeof(struct lov_user_md_v1) +
152 LOV_MAX_STRIPE_COUNT * sizeof(struct lov_user_ost_data_v1);
153 v3 = sizeof(struct lov_user_md_v3) +
154 LOV_MAX_STRIPE_COUNT * sizeof(struct lov_user_ost_data_v1);
156 return malloc(maxint(v1, v3));
159 int main(int argc, char** argv)
161 struct lov_user_md *lum_file = NULL;
166 fprintf(stderr, "Usage: %s <filename>\\n", argv[0]);
170 lum_file = alloc_lum();
171 if (lum_file == NULL) {
176 rc = llapi_file_get_stripe(argv[1], lum_file);
182 /* stripe_size stripe_count */
184 lum_file->lmm_stripe_size,
185 lum_file->lmm_stripe_count);
188 if (lum_file != NULL)