#define task_is_running(task) (task->state == TASK_RUNNING)
#endif
+#ifndef memset_startat
+/** from linux 5.19 include/linux/string.h: */
+#define memset_startat(obj, v, member) \
+({ \
+ u8 *__ptr = (u8 *)(obj); \
+ typeof(v) __val = (v); \
+ memset(__ptr + offsetof(typeof(*(obj)), member), __val, \
+ sizeof(*(obj)) - offsetof(typeof(*(obj)), member)); \
+})
+#endif /* memset_startat() */
+
#ifdef HAVE_KALLSYMS_LOOKUP_NAME
static inline void *cfs_kallsyms_lookup_name(const char *name)
{
#include <linux/spinlock.h>
#include <linux/wait.h>
#include <linux/pagevec.h>
+#include <libcfs/linux/linux-misc.h>
#include <lustre_dlm.h>
struct obd_info;
void cl_io_print(const struct lu_env *env, void *cookie,
lu_printer_t printer, const struct cl_io *io);
-#define CL_IO_SLICE_CLEAN(foo_io, base) \
-do { \
- typeof(foo_io) __foo_io = (foo_io); \
- \
- memset(&__foo_io->base, 0, \
- sizeof(*__foo_io) - offsetof(typeof(*__foo_io), base)); \
-} while (0)
+#define CL_IO_SLICE_CLEAN(obj, base) memset_startat(obj, 0, base)
/** @} cl_io */
__u32 qc_stat;
struct obd_dqinfo qc_dqinfo;
struct obd_dqblk qc_dqblk;
- char qc_poolname[0];
+ char qc_poolname[];
};
#define Q_COPY(out, in, member) (out)->member = (in)->member
-#define __QCTL_COPY(out, in, need_pname) \
-do { \
- Q_COPY(out, in, qc_cmd); \
- Q_COPY(out, in, qc_type); \
- Q_COPY(out, in, qc_id); \
- Q_COPY(out, in, qc_stat); \
- Q_COPY(out, in, qc_dqinfo); \
- Q_COPY(out, in, qc_dqblk); \
- if (need_pname && LUSTRE_Q_CMD_IS_POOL(in->qc_cmd)) \
- memcpy(out->qc_poolname, \
- in->qc_poolname, \
- LOV_MAXPOOLNAME + 1); \
+/* NOTE:
+ * - in and out maybe a type of struct if_quotactl or struct obd_quotactl
+ * - in and out need not be of the same type.
+ */
+#define __QCTL_COPY(out, in, need_pname) \
+do { \
+ Q_COPY(out, in, qc_cmd); \
+ Q_COPY(out, in, qc_type); \
+ Q_COPY(out, in, qc_id); \
+ Q_COPY(out, in, qc_stat); \
+ Q_COPY(out, in, qc_dqinfo); \
+ Q_COPY(out, in, qc_dqblk); \
+ if (need_pname && LUSTRE_Q_CMD_IS_POOL(in->qc_cmd)) { \
+ size_t len = strnlen(in->qc_poolname, LOV_MAXPOOLNAME); \
+ \
+ memcpy(out->qc_poolname, in->qc_poolname, len); \
+ out->qc_poolname[len] = '\0'; \
+ } \
} while (0)
#define QCTL_COPY(out, in) __QCTL_COPY(out, in, true)
{
BUILD_BUG_ON(sizeof(*loa) != LMA_OLD_SIZE);
- memset(&loa->loa_parent_fid, 0,
- sizeof(*loa) - offsetof(typeof(*loa), loa_parent_fid));
+ memset_startat(loa, 0, loa_parent_fid);
lustre_lma_init(&loa->loa_lma, fid, compat, incompat);
}
EXPORT_SYMBOL(lustre_loa_init);