There are a couple of off-by-one errors when calculating the required
buffer size in oxe_can_hold(), which can cause the xattr entry to be
reallocated unnecessarily.
HPE-bug-id: LUS-11423
Fixes:
a1c5adf7f466 ("LU-14607 osp: separate buffer for large XATTR")
Change-Id: I486963066d7f8783ad64f1ea110fb73db0a8274b
Signed-off-by: Nikitas Angelinas <nikitas.angelinas@hpe.com>
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49617
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Lai Siyao <lai.siyao@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
return oxe;
}
-/* whether \a oxe is large enough to hold XATTR value */
+/**
+ * Check whether \a oxe is large enough to hold the xattr value
+ *
+ * \param[in] oxe pointer to the OSP object attributes cache xattr entry
+ * \param[in] len xattr value size in bytes
+ *
+ * \retval true if xattr can fit in \a oxe
+ * \retval false if xattr can not fit in \a oxe
+ */
static inline bool oxe_can_hold(struct osp_xattr_entry *oxe, size_t len)
{
if (unlikely(oxe->oxe_largebuf))
- return oxe->oxe_buflen > len;
+ return oxe->oxe_buflen >= len;
- return oxe->oxe_buflen - oxe->oxe_namelen - 1 - sizeof(*oxe) > len;
+ return oxe->oxe_buflen - oxe->oxe_namelen - 1 - sizeof(*oxe) >= len;
}
/**