Whamcloud - gitweb
LU-12635 build: Support for gcc -Wimplicit-fallthrough
[fs/lustre-release.git] / lustre / utils / liblustreapi_ladvise.c
index 85083f1..c098889 100644 (file)
@@ -38,7 +38,6 @@
 #include <errno.h>
 
 #include <lustre/lustreapi.h>
-#include <lustre/lustre_idl.h>
 #include "lustreapi_internal.h"
 
 /*
  * \param ladvise  Advice to give.
  *
  * \retval 0 on success.
- * \retval -errno on failure.
+ * \retval -1 on failure, errno set
  */
 int llapi_ladvise(int fd, unsigned long long flags, int num_advise,
-                 struct lu_ladvise *ladvise)
+                 struct llapi_lu_ladvise *ladvise)
 {
+       struct llapi_ladvise_hdr *ladvise_hdr;
        int rc;
-       struct ladvise_hdr *ladvise_hdr;
+       int i;
 
        if (num_advise < 1 || num_advise >= LAH_COUNT_MAX) {
                errno = EINVAL;
@@ -80,6 +80,18 @@ int llapi_ladvise(int fd, unsigned long long flags, int num_advise,
                llapi_error(LLAPI_MSG_ERROR, -errno, "cannot give advice");
                return -1;
        }
+
+       /* Copy results back in to caller provided structs */
+       for (i = 0; i < num_advise; i++) {
+               struct llapi_lu_ladvise *ladvise_iter;
+
+               ladvise_iter = &ladvise_hdr->lah_advise[i];
+
+               if (ladvise_iter->lla_advice == LU_LADVISE_LOCKAHEAD)
+                       ladvise[i].lla_lockahead_result =
+                                       ladvise_iter->lla_lockahead_result;
+       }
+
        return 0;
 }