From: Peng Tao Date: Thu, 27 Feb 2014 08:07:39 +0000 (+0800) Subject: LU-4689 hsm: count NULL terminator in hai_first/hal_size X-Git-Tag: 2.5.57~36 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=5fe384c7eae8aea1698a9c14b13e79ca4e919d66 LU-4689 hsm: count NULL terminator in hai_first/hal_size If fsname is 8-byte aligned, hai_first fails to count the ending NULL terminator causing hai to directly attached after fsname and future hai_first will return a different position for first hai. Signed-off-by: Peng Tao Change-Id: I5e9e1f48f99b4743b2d5b93397e06f6becabeb26 Reviewed-on: http://review.whamcloud.com/9431 Tested-by: Jenkins Reviewed-by: Andreas Dilger Reviewed-by: Jinshan Xiong Tested-by: Maloo Reviewed-by: Oleg Drokin --- diff --git a/lustre/include/lustre/lustre_user.h b/lustre/include/lustre/lustre_user.h index f0d9c62..4793426 100644 --- a/lustre/include/lustre/lustre_user.h +++ b/lustre/include/lustre/lustre_user.h @@ -1139,9 +1139,10 @@ static inline int cfs_size_round (int val) /* 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))); + return (struct hsm_action_item *)(hal->hal_fsname + + cfs_size_round(strlen(hal-> \ + hal_fsname) + + 1)); } /* Return pointer to next hai */ static inline struct hsm_action_item * hai_next(struct hsm_action_item *hai) @@ -1157,7 +1158,7 @@ static inline size_t hal_size(struct hsm_action_list *hal) size_t sz; struct hsm_action_item *hai; - sz = sizeof(*hal) + cfs_size_round(strlen(hal->hal_fsname)); + sz = sizeof(*hal) + cfs_size_round(strlen(hal->hal_fsname) + 1); hai = hai_first(hal); for (i = 0; i < hal->hal_count ; i++, hai = hai_next(hai)) sz += cfs_size_round(hai->hai_len);