CLASSERT||BUILD_BUG_ON()
msecs_to_jiffies||cfs_time_seconds
DEFINE_TIMER||CFS_DEFINE_TIMER
+container_of0||container_of_safe
DN_MAX_BONUSLEN||DN_BONUS_SIZE(dnodesize)
DN_OLD_MAX_BONUSLEN||DN_BONUS_SIZE(DNODE_MIN_SIZE)
from_timer||cfs_from_timer
int libcfs_ioctl_data_adjust(struct libcfs_ioctl_data *data);
-/* container_of depends on "likely" which is defined in libcfs_private.h */
-static inline void *__container_of(const void *ptr, unsigned long shift)
-{
- if (unlikely(IS_ERR(ptr) || ptr == NULL))
- return ERR_CAST(ptr);
- else
- return (char *)ptr - shift;
-}
-
-#define container_of0(ptr, type, member) \
- ((type *)__container_of((ptr), offsetof(type, member)))
+#define container_of0(ptr, type, member) container_of_safe(ptr, type, member)
extern struct workqueue_struct *cfs_rehash_wq;
void cfs_arch_init(void);
+#ifndef container_of_safe
+/**
+ * container_of_safe - cast a member of a structure out to the containing structure
+ * @ptr: the pointer to the member.
+ * @type: the type of the container struct this is embedded in.
+ * @member: the name of the member within the struct.
+ *
+ * If IS_ERR_OR_NULL(ptr), ptr is returned unchanged.
+ *
+ * Note: Copied from Linux 5.6, with BUILD_BUG_ON_MSG section removed.
+ */
+#define container_of_safe(ptr, type, member) ({ \
+ void *__mptr = (void *)(ptr); \
+ IS_ERR_OR_NULL(__mptr) ? ERR_CAST(__mptr) : \
+ ((type *)(__mptr - offsetof(type, member))); })
+#endif
+
#endif /* __LIBCFS_LINUX_MISC_H__ */
#endif /* HAVE_FILLDIR_USE_CTX */
/*
* It is hack to access lde_fid for comparison with lgd_fid.
- * So the input 'name' must be part of the 'lu_dirent'.
+ * So the input 'name' must be part of the 'lu_dirent', and
+ * so must appear to be a non-const pointer to an empty array.
*/
- struct lu_dirent *lde = container_of0(name, struct lu_dirent, lde_name);
+ char (*n)[0] = (void *)name;
+ struct lu_dirent *lde = container_of0(n, struct lu_dirent, lde_name);
struct lu_fid fid;
fid_le_to_cpu(&fid, &lde->lde_fid);