#include <string.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <sys/param.h>
#ifdef HAVE_ENDIAN_H
# include <endian.h>
#endif
static void lustre_swab_lu_fid(struct lu_fid *fid)
{
- __swab64s(&fid->f_seq);
- __swab32s(&fid->f_oid);
- __swab32s(&fid->f_ver);
+ fid->f_seq = __swab64(fid->f_seq);
+ fid->f_oid = __swab32(fid->f_oid);
+ fid->f_ver = __swab32(fid->f_ver);
}
static inline size_t
for (i = 0; i < op_count; i++, op = update_op_next_op(op)) {
lustre_swab_lu_fid(&op->uop_fid);
- __swab16s(&op->uop_type);
- __swab16s(&op->uop_param_count);
+ op->uop_type = __swab16(op->uop_type);
+ op->uop_param_count = __swab16(op->uop_param_count);
for (j = 0; j < op->uop_param_count; j++)
- __swab16s(&op->uop_params_off[j]);
+ op->uop_params_off[j] = __swab16(op->uop_params_off[j]);
}
}
static const char *update_op_str(__u16 opc)
return string;
}
+static inline size_t
+object_update_param_size(const struct object_update_param *param)
+{
+ return roundup(sizeof(*param) + param->oup_len, sizeof(__u64));
+}
+
void print_update_rec(struct llog_update_record *lur)
{
struct update_records *rec = &lur->lur_update_rec;
up_count = __le32_to_cpu(rec->ur_update_count);
pm_count = __le32_to_cpu(rec->ur_param_count);
printf("updatelog record master_transno:%llu batchid:%llu flags:0x%x u_index:%d u_count:%d p_count:%d\n",
- __le64_to_cpu(rec->ur_master_transno),
- __le64_to_cpu(rec->ur_batchid),
+ (unsigned long long)__le64_to_cpu(rec->ur_master_transno),
+ (unsigned long long)__le64_to_cpu(rec->ur_batchid),
__le32_to_cpu(rec->ur_flags),
__le32_to_cpu(rec->ur_index),
up_count,
for (i = 0; i < pm_count; i++) {
printf("\tp_%d - %d/%s\n", i, pm->oup_len,
buf2str(pm->oup_buf, pm->oup_len));
- pm = (struct object_update_param *)((char *)(pm + 1) +
- pm->oup_len);
+ pm = (struct object_update_param *)((char *)pm +
+ object_update_param_size(pm));
}
printf("\n");
}
+static void print_unlink_rec(struct llog_unlink_rec *lur)
+{
+ printf("unlink record id:0x%x target %llx:%x:%x\n",
+ __le32_to_cpu(lur->lur_hdr.lrh_id),
+ (unsigned long long)__le64_to_cpu(lur->lur_oid),
+ __le32_to_cpu(lur->lur_oseq),
+ __le32_to_cpu(lur->lur_count));
+}
+
+static void print_unlink64_rec(struct llog_unlink64_rec *lur)
+{
+ printf("unlink64 record id:0x%x target "DFID"\n",
+ __le32_to_cpu(lur->lur_hdr.lrh_id),
+ PFID(&lur->lur_fid));
+}
+
+static void print_setattr64_rec(struct llog_setattr64_rec *lsr)
+{
+ printf("setattr64 record id:0x%x target "DFID" valid %llx uid %u:%u gid %u:%u\n",
+ __le32_to_cpu(lsr->lsr_hdr.lrh_id),
+ PFID(&lsr->lsr_oi.oi_fid),
+ (unsigned long long)__le64_to_cpu(lsr->lsr_valid),
+ __le32_to_cpu(lsr->lsr_uid_h),
+ __le32_to_cpu(lsr->lsr_uid),
+ __le32_to_cpu(lsr->lsr_gid_h),
+ __le32_to_cpu(lsr->lsr_gid));
+}
+
+static void print_setattr64_rec_v2(struct llog_setattr64_rec_v2 *lsr)
+{
+ printf("setattr64 v2 record id:0x%x target "DFID" valid %llx uid %u:%u gid %u:%u prj %u\n",
+ __le32_to_cpu(lsr->lsr_hdr.lrh_id),
+ PFID(&lsr->lsr_oi.oi_fid),
+ (unsigned long long)__le64_to_cpu(lsr->lsr_valid),
+ __le32_to_cpu(lsr->lsr_uid_h),
+ __le32_to_cpu(lsr->lsr_uid),
+ __le32_to_cpu(lsr->lsr_gid_h),
+ __le32_to_cpu(lsr->lsr_gid),
+ __le32_to_cpu(lsr->lsr_projid));
+}
+
+
static void print_records(struct llog_rec_hdr **recs,
int rec_number, int is_ext)
{
recs[i]);
break;
case CHANGELOG_USER_REC:
+ case CHANGELOG_USER_REC2:
printf("changelog_user record id:0x%x\n",
__le32_to_cpu(recs[i]->lrh_id));
break;
case UPDATE_REC:
print_update_rec((struct llog_update_record *)recs[i]);
break;
+ case MDS_UNLINK_REC:
+ print_unlink_rec((struct llog_unlink_rec *)recs[i]);
+ break;
+ case MDS_UNLINK64_REC:
+ print_unlink64_rec((struct llog_unlink64_rec *)recs[i]);
+ break;
+ case MDS_SETATTR64_REC:
+ if (__le32_to_cpu(recs[i]->lrh_len) >
+ sizeof(struct llog_setattr64_rec)) {
+ print_setattr64_rec_v2(
+ (struct llog_setattr64_rec_v2 *)recs[i]);
+ } else {
+ print_setattr64_rec(
+ (struct llog_setattr64_rec *)recs[i]);
+ }
+ break;
default:
printf("unknown type %x\n", lopt);
break;