struct nodemap_global_rec ngr;
};
+/* This is the lu_ladvise struct which goes out on the wire.
+ * Corresponds to the userspace arg llapi_lu_ladvise.
+ * value[1-4] are unspecified fields, used differently by different advices */
+struct lu_ladvise {
+ __u16 lla_advice; /* advice type */
+ __u16 lla_value1; /* values for different advice types */
+ __u32 lla_value2;
+ __u64 lla_start; /* first byte of extent for advice */
+ __u64 lla_end; /* last byte of extent for advice */
+ __u32 lla_value3;
+ __u32 lla_value4;
+};
+
+/* This is the ladvise_hdr which goes on the wire, corresponds to the userspace
+ * arg llapi_ladvise_hdr.
+ * value[1-3] are unspecified fields, used differently by different advices */
+struct ladvise_hdr {
+ __u32 lah_magic; /* LADVISE_MAGIC */
+ __u32 lah_count; /* number of advices */
+ __u64 lah_flags; /* from enum ladvise_flag */
+ __u32 lah_value1; /* unused */
+ __u32 lah_value2; /* unused */
+ __u64 lah_value3; /* unused */
+ struct lu_ladvise lah_advise[0]; /* advices in this header */
+};
+
#endif
/** @} lustreidl */
#define LL_IOC_MIGRATE _IOR('f', 247, int)
#define LL_IOC_FID2MDTIDX _IOWR('f', 248, struct lu_fid)
#define LL_IOC_GETPARENT _IOWR('f', 249, struct getparent)
-#define LL_IOC_LADVISE _IOR('f', 250, struct lu_ladvise)
+#define LL_IOC_LADVISE _IOR('f', 250, struct llapi_lu_ladvise)
/* Lease types for use as arg and return of LL_IOC_{GET,SET}_LEASE ioctl. */
enum ll_lease_type {
#define LU_LADVISE_NAMES { \
}
-struct lu_ladvise {
- __u64 lla_advice;
- __u64 lla_start;
- __u64 lla_end;
- __u64 lla_padding;
+/* This is the userspace argument for ladvise. It is currently the same as
+ * what goes on the wire (struct lu_ladvise), but is defined separately as we
+ * may need info which is only used locally. */
+struct llapi_lu_ladvise {
+ __u16 lla_advice; /* advice type */
+ __u16 lla_value1; /* values for different advice types */
+ __u32 lla_value2;
+ __u64 lla_start; /* first byte of extent for advice */
+ __u64 lla_end; /* last byte of extent for advice */
+ __u32 lla_value3;
+ __u32 lla_value4;
};
enum ladvise_flag {
#define LADVISE_MAGIC 0x1ADF1CE0
#define LF_MASK LF_ASYNC
-struct ladvise_hdr {
+/* This is the userspace argument for ladvise, corresponds to ladvise_hdr which
+ * is used on the wire. It is defined separately as we may need info which is
+ * only used locally. */
+struct llapi_ladvise_hdr {
__u32 lah_magic; /* LADVISE_MAGIC */
__u32 lah_count; /* number of advices */
__u64 lah_flags; /* from enum ladvise_flag */
- __u64 lah_padding1; /* unused */
- __u64 lah_padding2; /* unused */
- struct lu_ladvise lah_advise[0];
+ __u32 lah_value1; /* unused */
+ __u32 lah_value2; /* unused */
+ __u64 lah_value3; /* unused */
+ struct llapi_lu_ladvise lah_advise[0]; /* advices in this header */
};
#define LAH_COUNT_MAX (1024)
/* Ladvise */
int llapi_ladvise(int fd, unsigned long long flags, int num_advise,
- struct lu_ladvise *ladvise);
+ struct llapi_lu_ladvise *ladvise);
/** @} llapi */
/* llapi_layout user interface */
* much more data being sent to the client.
*/
static int ll_ladvise(struct inode *inode, struct file *file, __u64 flags,
- struct lu_ladvise *ladvise)
+ struct llapi_lu_ladvise *ladvise)
{
struct lu_env *env;
struct cl_io *io;
RETURN(ll_file_futimes_3(file, &lfu));
}
case LL_IOC_LADVISE: {
- struct ladvise_hdr *ladvise_hdr;
+ struct llapi_ladvise_hdr *ladvise_hdr;
int i;
int num_advise;
int alloc_size = sizeof(*ladvise_hdr);
RETURN(-ENOMEM);
if (copy_from_user(ladvise_hdr,
- (const struct ladvise_hdr __user *)arg,
+ (const struct llapi_ladvise_hdr __user *)arg,
alloc_size))
GOTO(out_ladvise, rc = -EFAULT);
* TODO: submit multiple advices to one server in a single RPC
*/
if (copy_from_user(ladvise_hdr,
- (const struct ladvise_hdr __user *)arg,
+ (const struct llapi_ladvise_hdr __user *)arg,
alloc_size))
GOTO(out_ladvise, rc = -EFAULT);
void lustre_swab_ladvise(struct lu_ladvise *ladvise)
{
+ __swab16s(&ladvise->lla_advice);
+ __swab16s(&ladvise->lla_value1);
+ __swab32s(&ladvise->lla_value2);
__swab64s(&ladvise->lla_start);
__swab64s(&ladvise->lla_end);
- __swab64s(&ladvise->lla_advice);
- CLASSERT(offsetof(typeof(*ladvise), lla_padding) != 0);
+ __swab32s(&ladvise->lla_value3);
+ __swab32s(&ladvise->lla_value4);
}
EXPORT_SYMBOL(lustre_swab_ladvise);
__swab32s(&ladvise_hdr->lah_magic);
__swab32s(&ladvise_hdr->lah_count);
__swab64s(&ladvise_hdr->lah_flags);
- CLASSERT(offsetof(typeof(*ladvise_hdr), lah_padding1) != 0);
- CLASSERT(offsetof(typeof(*ladvise_hdr), lah_padding2) != 0);
+ __swab32s(&ladvise_hdr->lah_value1);
+ __swab32s(&ladvise_hdr->lah_value2);
+ __swab64s(&ladvise_hdr->lah_value3);
}
EXPORT_SYMBOL(lustre_swab_ladvise_hdr);
(long long)(int)sizeof(struct lu_ladvise));
LASSERTF((int)offsetof(struct lu_ladvise, lla_advice) == 0, "found %lld\n",
(long long)(int)offsetof(struct lu_ladvise, lla_advice));
- LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_advice) == 8, "found %lld\n",
+ LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_advice) == 2, "found %lld\n",
(long long)(int)sizeof(((struct lu_ladvise *)0)->lla_advice));
+ LASSERTF((int)offsetof(struct lu_ladvise, lla_value1) == 2, "found %lld\n",
+ (long long)(int)offsetof(struct lu_ladvise, lla_value1));
+ LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_value1) == 2, "found %lld\n",
+ (long long)(int)sizeof(((struct lu_ladvise *)0)->lla_value1));
+ LASSERTF((int)offsetof(struct lu_ladvise, lla_value2) == 4, "found %lld\n",
+ (long long)(int)offsetof(struct lu_ladvise, lla_value2));
+ LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_value2) == 4, "found %lld\n",
+ (long long)(int)sizeof(((struct lu_ladvise *)0)->lla_value2));
LASSERTF((int)offsetof(struct lu_ladvise, lla_start) == 8, "found %lld\n",
(long long)(int)offsetof(struct lu_ladvise, lla_start));
LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_start) == 8, "found %lld\n",
(long long)(int)offsetof(struct lu_ladvise, lla_end));
LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_end) == 8, "found %lld\n",
(long long)(int)sizeof(((struct lu_ladvise *)0)->lla_end));
- LASSERTF((int)offsetof(struct lu_ladvise, lla_padding) == 24, "found %lld\n",
- (long long)(int)offsetof(struct lu_ladvise, lla_padding));
- LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_padding) == 8, "found %lld\n",
- (long long)(int)sizeof(((struct lu_ladvise *)0)->lla_padding));
+ LASSERTF((int)offsetof(struct lu_ladvise, lla_value3) == 24, "found %lld\n",
+ (long long)(int)offsetof(struct lu_ladvise, lla_value3));
+ LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_value3) == 4, "found %lld\n",
+ (long long)(int)sizeof(((struct lu_ladvise *)0)->lla_value3));
+ LASSERTF((int)offsetof(struct lu_ladvise, lla_value4) == 28, "found %lld\n",
+ (long long)(int)offsetof(struct lu_ladvise, lla_value4));
+ LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_value4) == 4, "found %lld\n",
+ (long long)(int)sizeof(((struct lu_ladvise *)0)->lla_value4));
/* Checks for struct ladvise_hdr */
LASSERTF(LADVISE_MAGIC == 0x1ADF1CE0, "found 0x%.8x\n",
(long long)(int)offsetof(struct ladvise_hdr, lah_flags));
LASSERTF((int)sizeof(((struct ladvise_hdr *)0)->lah_flags) == 8, "found %lld\n",
(long long)(int)sizeof(((struct ladvise_hdr *)0)->lah_flags));
- LASSERTF((int)offsetof(struct ladvise_hdr, lah_padding1) == 16, "found %lld\n",
- (long long)(int)offsetof(struct ladvise_hdr, lah_padding1));
- LASSERTF((int)sizeof(((struct ladvise_hdr *)0)->lah_padding1) == 8, "found %lld\n",
- (long long)(int)sizeof(((struct ladvise_hdr *)0)->lah_padding1));
- LASSERTF((int)offsetof(struct ladvise_hdr, lah_padding2) == 24, "found %lld\n",
- (long long)(int)offsetof(struct ladvise_hdr, lah_padding2));
- LASSERTF((int)sizeof(((struct ladvise_hdr *)0)->lah_padding2) == 8, "found %lld\n",
- (long long)(int)sizeof(((struct ladvise_hdr *)0)->lah_padding2));
+ LASSERTF((int)offsetof(struct ladvise_hdr, lah_value1) == 16, "found %lld\n",
+ (long long)(int)offsetof(struct ladvise_hdr, lah_value1));
+ LASSERTF((int)sizeof(((struct ladvise_hdr *)0)->lah_value1) == 4, "found %lld\n",
+ (long long)(int)sizeof(((struct ladvise_hdr *)0)->lah_value1));
+ LASSERTF((int)offsetof(struct ladvise_hdr, lah_value2) == 20, "found %lld\n",
+ (long long)(int)offsetof(struct ladvise_hdr, lah_value2));
+ LASSERTF((int)sizeof(((struct ladvise_hdr *)0)->lah_value2) == 4, "found %lld\n",
+ (long long)(int)sizeof(((struct ladvise_hdr *)0)->lah_value2));
+ LASSERTF((int)offsetof(struct ladvise_hdr, lah_value3) == 24, "found %lld\n",
+ (long long)(int)offsetof(struct ladvise_hdr, lah_value3));
+ LASSERTF((int)sizeof(((struct ladvise_hdr *)0)->lah_value3) == 8, "found %lld\n",
+ (long long)(int)sizeof(((struct ladvise_hdr *)0)->lah_value3));
LASSERTF((int)offsetof(struct ladvise_hdr, lah_advise) == 32, "found %lld\n",
(long long)(int)offsetof(struct ladvise_hdr, lah_advise));
LASSERTF((int)sizeof(((struct ladvise_hdr *)0)->lah_advise) == 0, "found %lld\n",
int rc = 0;
const char *path;
int fd;
- struct lu_ladvise advice;
+ struct llapi_lu_ladvise advice;
enum lu_ladvise_type advice_type = LU_LADVISE_INVALID;
unsigned long long start = 0;
unsigned long long end = LUSTRE_EOF;
advice.lla_start = start;
advice.lla_end = end;
advice.lla_advice = advice_type;
- advice.lla_padding = 0;
+ advice.lla_value1 = 0;
+ advice.lla_value2 = 0;
+ advice.lla_value3 = 0;
+ advice.lla_value4 = 0;
rc2 = llapi_ladvise(fd, flags, 1, &advice);
close(fd);
if (rc2 < 0) {
* \param ladvise Advice to give.
*
* \retval 0 on success.
- * \retval -errno on failure.
+ * \retval -1 on failure, errno set
*/
int llapi_ladvise(int fd, unsigned long long flags, int num_advise,
- struct lu_ladvise *ladvise)
+ struct llapi_lu_ladvise *ladvise)
{
int rc;
- struct ladvise_hdr *ladvise_hdr;
+ struct llapi_ladvise_hdr *ladvise_hdr;
if (num_advise < 1 || num_advise >= LAH_COUNT_MAX) {
errno = EINVAL;
{
BLANK_LINE();
CHECK_STRUCT(lu_ladvise);
+ CHECK_MEMBER(lu_ladvise, lla_advice);
+ CHECK_MEMBER(lu_ladvise, lla_value1);
+ CHECK_MEMBER(lu_ladvise, lla_value2);
CHECK_MEMBER(lu_ladvise, lla_start);
CHECK_MEMBER(lu_ladvise, lla_end);
- CHECK_MEMBER(lu_ladvise, lla_advice);
- CHECK_MEMBER(lu_ladvise, lla_padding);
+ CHECK_MEMBER(lu_ladvise, lla_value3);
+ CHECK_MEMBER(lu_ladvise, lla_value4);
+
+ CHECK_VALUE(LF_ASYNC);
+ CHECK_VALUE(LADVISE_MAGIC);
}
static void
(long long)(int)sizeof(struct lu_ladvise));
LASSERTF((int)offsetof(struct lu_ladvise, lla_advice) == 0, "found %lld\n",
(long long)(int)offsetof(struct lu_ladvise, lla_advice));
- LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_advice) == 8, "found %lld\n",
+ LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_advice) == 2, "found %lld\n",
(long long)(int)sizeof(((struct lu_ladvise *)0)->lla_advice));
+ LASSERTF((int)offsetof(struct lu_ladvise, lla_value1) == 2, "found %lld\n",
+ (long long)(int)offsetof(struct lu_ladvise, lla_value1));
+ LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_value1) == 2, "found %lld\n",
+ (long long)(int)sizeof(((struct lu_ladvise *)0)->lla_value1));
+ LASSERTF((int)offsetof(struct lu_ladvise, lla_value2) == 4, "found %lld\n",
+ (long long)(int)offsetof(struct lu_ladvise, lla_value2));
+ LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_value2) == 4, "found %lld\n",
+ (long long)(int)sizeof(((struct lu_ladvise *)0)->lla_value2));
LASSERTF((int)offsetof(struct lu_ladvise, lla_start) == 8, "found %lld\n",
(long long)(int)offsetof(struct lu_ladvise, lla_start));
LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_start) == 8, "found %lld\n",
(long long)(int)offsetof(struct lu_ladvise, lla_end));
LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_end) == 8, "found %lld\n",
(long long)(int)sizeof(((struct lu_ladvise *)0)->lla_end));
- LASSERTF((int)offsetof(struct lu_ladvise, lla_padding) == 24, "found %lld\n",
- (long long)(int)offsetof(struct lu_ladvise, lla_padding));
- LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_padding) == 8, "found %lld\n",
- (long long)(int)sizeof(((struct lu_ladvise *)0)->lla_padding));
+ LASSERTF((int)offsetof(struct lu_ladvise, lla_value3) == 24, "found %lld\n",
+ (long long)(int)offsetof(struct lu_ladvise, lla_value3));
+ LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_value3) == 4, "found %lld\n",
+ (long long)(int)sizeof(((struct lu_ladvise *)0)->lla_value3));
+ LASSERTF((int)offsetof(struct lu_ladvise, lla_value4) == 28, "found %lld\n",
+ (long long)(int)offsetof(struct lu_ladvise, lla_value4));
+ LASSERTF((int)sizeof(((struct lu_ladvise *)0)->lla_value4) == 4, "found %lld\n",
+ (long long)(int)sizeof(((struct lu_ladvise *)0)->lla_value4));
/* Checks for struct ladvise_hdr */
LASSERTF(LADVISE_MAGIC == 0x1ADF1CE0, "found 0x%.8x\n",
(long long)(int)offsetof(struct ladvise_hdr, lah_flags));
LASSERTF((int)sizeof(((struct ladvise_hdr *)0)->lah_flags) == 8, "found %lld\n",
(long long)(int)sizeof(((struct ladvise_hdr *)0)->lah_flags));
- LASSERTF((int)offsetof(struct ladvise_hdr, lah_padding1) == 16, "found %lld\n",
- (long long)(int)offsetof(struct ladvise_hdr, lah_padding1));
- LASSERTF((int)sizeof(((struct ladvise_hdr *)0)->lah_padding1) == 8, "found %lld\n",
- (long long)(int)sizeof(((struct ladvise_hdr *)0)->lah_padding1));
- LASSERTF((int)offsetof(struct ladvise_hdr, lah_padding2) == 24, "found %lld\n",
- (long long)(int)offsetof(struct ladvise_hdr, lah_padding2));
- LASSERTF((int)sizeof(((struct ladvise_hdr *)0)->lah_padding2) == 8, "found %lld\n",
- (long long)(int)sizeof(((struct ladvise_hdr *)0)->lah_padding2));
+ LASSERTF((int)offsetof(struct ladvise_hdr, lah_value1) == 16, "found %lld\n",
+ (long long)(int)offsetof(struct ladvise_hdr, lah_value1));
+ LASSERTF((int)sizeof(((struct ladvise_hdr *)0)->lah_value1) == 4, "found %lld\n",
+ (long long)(int)sizeof(((struct ladvise_hdr *)0)->lah_value1));
+ LASSERTF((int)offsetof(struct ladvise_hdr, lah_value2) == 20, "found %lld\n",
+ (long long)(int)offsetof(struct ladvise_hdr, lah_value2));
+ LASSERTF((int)sizeof(((struct ladvise_hdr *)0)->lah_value2) == 4, "found %lld\n",
+ (long long)(int)sizeof(((struct ladvise_hdr *)0)->lah_value2));
+ LASSERTF((int)offsetof(struct ladvise_hdr, lah_value3) == 24, "found %lld\n",
+ (long long)(int)offsetof(struct ladvise_hdr, lah_value3));
+ LASSERTF((int)sizeof(((struct ladvise_hdr *)0)->lah_value3) == 8, "found %lld\n",
+ (long long)(int)sizeof(((struct ladvise_hdr *)0)->lah_value3));
LASSERTF((int)offsetof(struct ladvise_hdr, lah_advise) == 32, "found %lld\n",
(long long)(int)offsetof(struct ladvise_hdr, lah_advise));
LASSERTF((int)sizeof(((struct ladvise_hdr *)0)->lah_advise) == 0, "found %lld\n",