Provided by: lustre-utils_1.8.5+dfsg-3ubuntu1_amd64 bug

NAME

       llapi_file_get_stripe  -  get  striping  information for a file or a directory on a Lustre
       filesystem

SYNOPSIS

       #include <sys/types.h>
       #include <sys/stat.h>
       #include <fcntl.h>
       #include <liblustre.h>
       #include <lustre/lustre_idl.h>
       #include <lustre/liblustreapi.h>
       #include <lustre/lustre_user.h>

       int llapi_file_get_stripe(const char *path, void *lum);

DESCRIPTION

       llapi_file_get_stripe() returns striping information for a file or a directory path in lum
       (which should point to a large enough memory region) in one of the following formats:

       struct lov_user_md_v1 {
               __u32 lmm_magic;
               __u32 lmm_pattern;
               __u64 lmm_object_id;
               __u64 lmm_object_gr;
               __u32 lmm_stripe_size;
               __u16 lmm_stripe_count;
               __u16 lmm_stripe_offset;
               struct lov_user_ost_data_v1 lmm_objects[0];
       } __attribute__((packed));

       struct lov_user_md_v3 {
               __u32 lmm_magic;
               __u32 lmm_pattern;
               __u64 lmm_object_id;
               __u64 lmm_object_gr;
               __u32 lmm_stripe_size;
               __u16 lmm_stripe_count;
               __u16 lmm_stripe_offset;
               char  lmm_pool_name[LOV_MAXPOOLNAME];
               struct lov_user_ost_data_v1 lmm_objects[0];
       } __attribute__((packed));

       struct lov_user_md_join {
               __u32 lmm_magic;
               __u32 lmm_pattern;
               __u64 lmm_object_id;
               __u64 lmm_object_gr;
               __u32 lmm_stripe_size;
               __u32 lmm_stripe_count;
               __u32 lmm_extent_count;
               __u64 lmm_tree_id;
               __u64 lmm_tree_gen;
               struct llog_logid lmm_array_id;
               struct lov_user_ost_data_join lmm_objects[0];
       } __attribute__((packed));

       lmm_magic           specifies   the   format   of   the   returned  striping  information.
                           LOV_MAGIC_V1 is used for lov_user_md_v1.   LOV_MAGIC_V3  is  used  for
                           lov_user_md_v3.  LOV_MAGIC_JOIN is used for lov_user_md_join.

       lmm_pattern         holds the striping pattern. Only LOV_PATTERN_RAID0 is possible in this
                           Lustre version.

       lmm_object_id       holds the MDS object id.

       lmm_object_gr       holds the MDS object group.

       lmm_stripe_size     holds the stripe size in bytes.

       lmm_stripe_count    holds the number of OSTs the file is striped across.

       lmm_stripe_offset   holds the OST index from which the file starts.

       lmm_pool_name       holds the OST pool name to which the file belongs.

       lmm_objects         is an array  of  lmm_stripe_count  members  containing  per  OST  file
                           information in the following format:

                           struct lov_user_ost_data_v1 {
                                   __u64 l_object_id;
                                   __u64 l_object_gr;
                                   __u32 l_ost_gen;
                                   __u32 l_ost_idx;
                           } __attribute__((packed));

       l_object_id         holds the OST object id.

       l_object_gr         holds the OST object group.

       l_ost_gen           holds the generation of the OST index.

       l_ost_idx           holds the OST index in LOV.

RETURN VALUES

       llapi_file_get_stripe() returns:

       0      on success

       != 0   on failure, errno is set appropriately.

ERRORS

       ENOMEM         failed to allocate memory.

       ENAMETOOLONG   path was too long.

       ENOENT         path does not point to a file or a directory.

       ENOTTY         path does not point to a Lustre filesystem.

       EFAULT         memory region pointed by lum is not properly mapped.

EXAMPLE

       #include <sys/vfs.h>
       #include <liblustre.h>
       #include <lnet/lnetctl.h>
       #include <obd.h>
       #include <lustre_lib.h>
       #include <lustre/liblustreapi.h>
       #include <obd_lov.h>

       static inline int maxint(int a, int b)
       {
               return a > b ? a : b;
       }

       static void *alloc_lum()
       {
               int v1, v3, join;

               v1 = sizeof(struct lov_user_md_v1) +
                    LOV_MAX_STRIPE_COUNT * sizeof(struct lov_user_ost_data_v1);
               v3 = sizeof(struct lov_user_md_v3) +
                    LOV_MAX_STRIPE_COUNT * sizeof(struct lov_user_ost_data_v1);
               join = sizeof(struct lov_user_md_join) +
                    LOV_MAX_STRIPE_COUNT * sizeof(struct lov_user_ost_data_join);

               return malloc(maxint(maxint(v1, v3), join));
       }

       int main(int argc, char** argv)
       {
               struct lov_user_md *lum_file = NULL;
               int rc;
               int lum_size;

               if (argc != 2) {
                       fprintf(stderr, "Usage: %s <filename>\n", argv[0]);
                       return 1;
               }

               lum_file = alloc_lum();
               if (lum_file == NULL) {
                       rc = ENOMEM;
                       goto cleanup;
               }

               rc = llapi_file_get_stripe(argv[1], lum_file);
               if (rc) {
                       rc = errno;
                       goto cleanup;
               }

               /* stripe_size stripe_count */
               printf("%d %d\n",
                      lum_file->lmm_stripe_size,
                      lum_file->lmm_stripe_count);

       cleanup:
               if (lum_file != NULL)
                       free(lum_file);

               return rc;
       }

SEE ALSO

       lustre(7), liblustreapi(7)