Whamcloud - gitweb
LU-6142 UAPI: replace cfs_size_* macros with __ALIGN_KERNEL 79/30379/6
authorJames Simmons <uja.ornl@yahoo.com>
Mon, 26 Feb 2018 16:11:02 +0000 (11:11 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 6 Mar 2018 19:13:34 +0000 (19:13 +0000)
The lustre specific cfs_size_* macros can be easily replaced with
the __ALIGN_KERNEL macro provided by the linux kernel for our
user land code. This brings us closer to building against the
upstream client.

Change-Id: I5cd261807f60296eaac884b66f084c128adc5b01
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/30379
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Reviewed-by: Ben Evans <bevans@cray.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/uapi/linux/lustre/lustre_user.h
lustre/utils/liblustreapi.c
lustre/utils/obd.c

index ea3282f..1726b92 100644 (file)
@@ -42,6 +42,7 @@
  * @{
  */
 
  * @{
  */
 
+#include <linux/kernel.h>
 #include <linux/types.h>
 
 #ifdef __KERNEL__
 #include <linux/types.h>
 
 #ifdef __KERNEL__
 # include <linux/lustre/lustre_fiemap.h>
 #endif /* __KERNEL__ */
 
 # include <linux/lustre/lustre_fiemap.h>
 #endif /* __KERNEL__ */
 
+/* Handle older distros */
+#ifndef __ALIGN_KERNEL
+# define __ALIGN_KERNEL(x, a)   __ALIGN_KERNEL_MASK(x, (typeof(x))(a) - 1)
+# define __ALIGN_KERNEL_MASK(x, mask)   (((x) + (mask)) & ~(mask))
+#endif
+
 #if defined(__cplusplus)
 extern "C" {
 #endif
 #if defined(__cplusplus)
 extern "C" {
 #endif
@@ -1211,9 +1218,9 @@ enum changelog_send_extra_flag {
        CHANGELOG_EXTRA_FLAG_XATTR  = 0x08,
 };
 
        CHANGELOG_EXTRA_FLAG_XATTR  = 0x08,
 };
 
-#define CR_MAXSIZE cfs_size_round(2 * NAME_MAX + 2 + \
+#define CR_MAXSIZE __ALIGN_KERNEL(2 * NAME_MAX + 2 + \
                                  changelog_rec_offset(CLF_SUPPORTED, \
                                  changelog_rec_offset(CLF_SUPPORTED, \
-                                                       CLFE_SUPPORTED))
+                                                      CLFE_SUPPORTED), 8)
 
 /* 31 usable bytes string + null terminator. */
 #define LUSTRE_JOBID_SIZE      32
 
 /* 31 usable bytes string + null terminator. */
 #define LUSTRE_JOBID_SIZE      32
@@ -1880,27 +1887,20 @@ struct hsm_action_list {
           boundaries. See hai_zero */
 } __attribute__((packed));
 
           boundaries. See hai_zero */
 } __attribute__((packed));
 
-#ifndef HAVE_CFS_SIZE_ROUND
-static inline int cfs_size_round (int val)
-{
-       return (val + 7) & (~0x7);
-}
-#define HAVE_CFS_SIZE_ROUND
-#endif
-
 /* Return pointer to first hai in action list */
 static inline struct hsm_action_item *hai_first(struct hsm_action_list *hal)
 {
 /* Return pointer to first hai in action list */
 static inline struct hsm_action_item *hai_first(struct hsm_action_list *hal)
 {
-       return (struct hsm_action_item *)(hal->hal_fsname +
-                                         cfs_size_round(strlen(hal-> \
-                                                               hal_fsname)
-                                                        + 1));
+       size_t offset = __ALIGN_KERNEL(strlen(hal->hal_fsname) + 1, 8);
+
+       return (struct hsm_action_item *)(hal->hal_fsname + offset);
 }
 }
+
 /* Return pointer to next hai */
 static inline struct hsm_action_item * hai_next(struct hsm_action_item *hai)
 {
 /* Return pointer to next hai */
 static inline struct hsm_action_item * hai_next(struct hsm_action_item *hai)
 {
-       return (struct hsm_action_item *)((char *)hai +
-                                         cfs_size_round(hai->hai_len));
+       size_t offset = __ALIGN_KERNEL(hai->hai_len, 8);
+
+       return (struct hsm_action_item *)((char *)hai + offset);
 }
 
 /* Return size of an hsm_action_list */
 }
 
 /* Return size of an hsm_action_list */
@@ -1910,10 +1910,10 @@ static inline size_t hal_size(struct hsm_action_list *hal)
        size_t sz;
        struct hsm_action_item *hai;
 
        size_t sz;
        struct hsm_action_item *hai;
 
-       sz = sizeof(*hal) + cfs_size_round(strlen(hal->hal_fsname) + 1);
+       sz = sizeof(*hal) + __ALIGN_KERNEL(strlen(hal->hal_fsname) + 1, 8);
        hai = hai_first(hal);
        for (i = 0; i < hal->hal_count ; i++, hai = hai_next(hai))
        hai = hai_first(hal);
        for (i = 0; i < hal->hal_count ; i++, hai = hai_next(hai))
-               sz += cfs_size_round(hai->hai_len);
+               sz += __ALIGN_KERNEL(hai->hai_len, 8);
 
        return sz;
 }
 
        return sz;
 }
index 2c23a1a..1e678b6 100644 (file)
@@ -306,22 +306,22 @@ int llapi_ioctl_pack(struct obd_ioctl_data *data, char **pbuf, int max_len)
        ptr = overlay->ioc_bulk;
        if (data->ioc_inlbuf1) {
                memcpy(ptr, data->ioc_inlbuf1, data->ioc_inllen1);
        ptr = overlay->ioc_bulk;
        if (data->ioc_inlbuf1) {
                memcpy(ptr, data->ioc_inlbuf1, data->ioc_inllen1);
-               ptr += cfs_size_round(data->ioc_inllen1);
+               ptr += __ALIGN_KERNEL(data->ioc_inllen1, 8);
        }
 
        if (data->ioc_inlbuf2) {
                memcpy(ptr, data->ioc_inlbuf2, data->ioc_inllen2);
        }
 
        if (data->ioc_inlbuf2) {
                memcpy(ptr, data->ioc_inlbuf2, data->ioc_inllen2);
-               ptr += cfs_size_round(data->ioc_inllen2);
+               ptr += __ALIGN_KERNEL(data->ioc_inllen2, 8);
        }
 
        if (data->ioc_inlbuf3) {
                memcpy(ptr, data->ioc_inlbuf3, data->ioc_inllen3);
        }
 
        if (data->ioc_inlbuf3) {
                memcpy(ptr, data->ioc_inlbuf3, data->ioc_inllen3);
-               ptr += cfs_size_round(data->ioc_inllen3);
+               ptr += __ALIGN_KERNEL(data->ioc_inllen3, 8);
        }
 
        if (data->ioc_inlbuf4) {
                memcpy(ptr, data->ioc_inlbuf4, data->ioc_inllen4);
        }
 
        if (data->ioc_inlbuf4) {
                memcpy(ptr, data->ioc_inlbuf4, data->ioc_inllen4);
-               ptr += cfs_size_round(data->ioc_inllen4);
+               ptr += __ALIGN_KERNEL(data->ioc_inllen4, 8);
        }
 
        return 0;
        }
 
        return 0;
@@ -348,22 +348,22 @@ int llapi_ioctl_unpack(struct obd_ioctl_data *data, char *pbuf, int max_len)
        ptr = overlay->ioc_bulk;
        if (data->ioc_inlbuf1) {
                memcpy(data->ioc_inlbuf1, ptr, data->ioc_inllen1);
        ptr = overlay->ioc_bulk;
        if (data->ioc_inlbuf1) {
                memcpy(data->ioc_inlbuf1, ptr, data->ioc_inllen1);
-               ptr += cfs_size_round(data->ioc_inllen1);
+               ptr += __ALIGN_KERNEL(data->ioc_inllen1, 8);
        }
 
        if (data->ioc_inlbuf2) {
                memcpy(data->ioc_inlbuf2, ptr, data->ioc_inllen2);
        }
 
        if (data->ioc_inlbuf2) {
                memcpy(data->ioc_inlbuf2, ptr, data->ioc_inllen2);
-               ptr += cfs_size_round(data->ioc_inllen2);
+               ptr += __ALIGN_KERNEL(data->ioc_inllen2, 8);
        }
 
        if (data->ioc_inlbuf3) {
                memcpy(data->ioc_inlbuf3, ptr, data->ioc_inllen3);
        }
 
        if (data->ioc_inlbuf3) {
                memcpy(data->ioc_inlbuf3, ptr, data->ioc_inllen3);
-               ptr += cfs_size_round(data->ioc_inllen3);
+               ptr += __ALIGN_KERNEL(data->ioc_inllen3, 8);
        }
 
        if (data->ioc_inlbuf4) {
                memcpy(data->ioc_inlbuf4, ptr, data->ioc_inllen4);
        }
 
        if (data->ioc_inlbuf4) {
                memcpy(data->ioc_inlbuf4, ptr, data->ioc_inllen4);
-               ptr += cfs_size_round(data->ioc_inllen4);
+               ptr += __ALIGN_KERNEL(data->ioc_inllen4, 8);
        }
 
        return 0;
        }
 
        return 0;
index 4eb8b1d..dc5e151 100644 (file)
@@ -2603,7 +2603,7 @@ int jt_llog_catlist(int argc, char **argv)
 
         memset(&data, 0, sizeof(data));
         data.ioc_dev = cur_device;
 
         memset(&data, 0, sizeof(data));
         data.ioc_dev = cur_device;
-        data.ioc_inllen1 = sizeof(rawbuf) - cfs_size_round(sizeof(data));
+       data.ioc_inllen1 = sizeof(rawbuf) - __ALIGN_KERNEL(sizeof(data), 8);
         memset(buf, 0, sizeof(rawbuf));
        rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
         if (rc) {
         memset(buf, 0, sizeof(rawbuf));
        rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
         if (rc) {
@@ -2634,8 +2634,8 @@ int jt_llog_info(int argc, char **argv)
         data.ioc_dev = cur_device;
         data.ioc_inllen1 = strlen(argv[1]) + 1;
         data.ioc_inlbuf1 = argv[1];
         data.ioc_dev = cur_device;
         data.ioc_inllen1 = strlen(argv[1]) + 1;
         data.ioc_inlbuf1 = argv[1];
-        data.ioc_inllen2 = sizeof(rawbuf) - cfs_size_round(sizeof(data)) -
-                cfs_size_round(data.ioc_inllen1);
+       data.ioc_inllen2 = sizeof(rawbuf) - __ALIGN_KERNEL(sizeof(data), 8) -
+                          __ALIGN_KERNEL(data.ioc_inllen1, 8);
         memset(buf, 0, sizeof(rawbuf));
        rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
         if (rc) {
         memset(buf, 0, sizeof(rawbuf));
        rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
         if (rc) {
@@ -2679,10 +2679,10 @@ int jt_llog_print(int argc, char **argv)
                 data.ioc_inllen3 = strlen(to) + 1;
                 data.ioc_inlbuf3 = to;
         }
                 data.ioc_inllen3 = strlen(to) + 1;
                 data.ioc_inlbuf3 = to;
         }
-        data.ioc_inllen4 = sizeof(rawbuf) - cfs_size_round(sizeof(data)) -
-                cfs_size_round(data.ioc_inllen1) -
-                cfs_size_round(data.ioc_inllen2) -
-                cfs_size_round(data.ioc_inllen3);
+       data.ioc_inllen4 = sizeof(rawbuf) - __ALIGN_KERNEL(sizeof(data), 8) -
+                          __ALIGN_KERNEL(data.ioc_inllen1, 8) -
+                          __ALIGN_KERNEL(data.ioc_inllen2, 8) -
+                          __ALIGN_KERNEL(data.ioc_inllen3, 8);
         memset(buf, 0, sizeof(rawbuf));
        rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
         if (rc) {
         memset(buf, 0, sizeof(rawbuf));
        rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
         if (rc) {
@@ -2837,10 +2837,10 @@ int jt_llog_check(int argc, char **argv)
                 data.ioc_inllen3 = strlen(to) + 1;
                 data.ioc_inlbuf3 = to;
         }
                 data.ioc_inllen3 = strlen(to) + 1;
                 data.ioc_inlbuf3 = to;
         }
-        data.ioc_inllen4 = sizeof(rawbuf) - cfs_size_round(sizeof(data)) -
-                cfs_size_round(data.ioc_inllen1) -
-                cfs_size_round(data.ioc_inllen2) -
-                cfs_size_round(data.ioc_inllen3);
+       data.ioc_inllen4 = sizeof(rawbuf) - __ALIGN_KERNEL(sizeof(data), 8) -
+                          __ALIGN_KERNEL(data.ioc_inllen1, 8) -
+                          __ALIGN_KERNEL(data.ioc_inllen2, 8) -
+                          __ALIGN_KERNEL(data.ioc_inllen3, 8);
         memset(buf, 0, sizeof(rawbuf));
        rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
         if (rc) {
         memset(buf, 0, sizeof(rawbuf));
        rc = llapi_ioctl_pack(&data, &buf, sizeof(rawbuf));
         if (rc) {