4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 * Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
24 * Use is subject to license terms.
26 * Copyright (c) 2011, 2017, Intel Corporation.
29 * This file is part of Lustre, http://www.lustre.org/
31 /** \defgroup llog_reader Lustre Log Reader
33 * Interpret llogs used for storing configuration and changelog data
44 #include <sys/types.h>
52 #include <linux/magic.h>
55 #include <linux/lnet/nidstr.h>
56 #include <linux/lustre/lustre_cfg.h>
57 #include <linux/lustre/lustre_fid.h>
58 #include <linux/lustre/lustre_ostid.h>
59 #include <linux/lustre/lustre_log_user.h>
60 #include <lustre/lustreapi.h>
62 static inline int ext2_test_bit(int nr, const void *addr)
64 #if __BYTE_ORDER == __BIG_ENDIAN
65 const unsigned char *tmp = addr;
67 return (tmp[nr >> 3] >> (nr & 7)) & 1;
69 const unsigned long *tmp = addr;
71 return ((1UL << (nr & (__WORDSIZE - 1))) &
72 ((tmp)[nr / __WORDSIZE])) != 0;
76 int llog_pack_buffer(int fd, struct llog_log_hdr **llog_buf,
77 struct llog_rec_hdr ***recs, int *recs_number);
79 void print_llog_header(struct llog_log_hdr *llog_buf);
80 static void print_records(struct llog_rec_hdr **recs_buf,
81 int rec_number, int is_ext);
82 void llog_unpack_buffer(int fd, struct llog_log_hdr *llog_buf,
83 struct llog_rec_hdr **recs_buf);
85 #define CANCELLED 0x678
87 #define PTL_CMD_BASE 100
88 char *portals_command[17] = {
108 int is_fstype_ext(int fd)
113 rc = fstatfs(fd, &st);
115 llapi_error(LLAPI_MSG_ERROR, rc, "Got statfs error.");
119 return (st.f_type == EXT4_SUPER_MAGIC);
123 * Attempt to display a path to the object (file) containing changelog entries,
124 * referred to by this changelog_catalog record.
126 * This path depends on the implementation of the OSD device; zfs-osd and
127 * ldiskfs-osd are different.
129 * Assumes that if the file system containing the changelog_catalog is
130 * ext{2,3,4}, the backend is ldiskfs-osd; otherwise it is either zfs-osd or at
131 * least names objects based on FID and the zfs-osd path (which includes the
132 * FID) will be sufficient.
134 * The Object ID stored in the record is also displayed untranslated.
136 #define OSD_OI_FID_NR (1UL << 7)
137 static void print_log_path(struct llog_logid_rec *lid, int is_ext)
139 char object_path[255];
140 struct lu_fid fid_from_logid;
142 logid_to_fid(&lid->lid_id, &fid_from_logid);
145 snprintf(object_path, sizeof(object_path),
146 "O/%ju/d%u/%u", (uintmax_t)fid_from_logid.f_seq,
147 fid_from_logid.f_oid % 32,
148 fid_from_logid.f_oid);
150 snprintf(object_path, sizeof(object_path),
151 "oi.%ju/"DFID_NOBRACE,
152 (uintmax_t)(fid_from_logid.f_seq &
153 (OSD_OI_FID_NR - 1)),
154 PFID(&fid_from_logid));
156 printf("id="DFID":%x path=%s\n",
157 PFID(&lid->lid_id.lgl_oi.oi_fid), lid->lid_id.lgl_ogen,
161 int main(int argc, char **argv)
166 struct llog_log_hdr *llog_buf = NULL;
167 struct llog_rec_hdr **recs_buf = NULL;
172 printf("Usage: llog_reader filename\n");
176 fd = open(argv[1], O_RDONLY);
179 llapi_error(LLAPI_MSG_ERROR, rc, "Could not open the file %s.",
184 is_ext = is_fstype_ext(fd);
187 llapi_error(LLAPI_MSG_ERROR, -rc,
188 "Unable to determine filesystem type for %s",
193 rc = llog_pack_buffer(fd, &llog_buf, &recs_buf, &rec_number);
195 llapi_error(LLAPI_MSG_ERROR, rc, "Could not pack buffer.");
200 print_llog_header(llog_buf);
202 print_records(recs_buf, rec_number, is_ext);
203 llog_unpack_buffer(fd, llog_buf, recs_buf);
211 int llog_pack_buffer(int fd, struct llog_log_hdr **llog,
212 struct llog_rec_hdr ***recs,
215 int rc = 0, recs_num, rd = 0;
218 char *file_buf = NULL, *recs_buf = NULL;
219 struct llog_rec_hdr **recs_pr = NULL;
227 llapi_error(LLAPI_MSG_ERROR, rc, "Got file stat error.");
231 file_size = st.st_size;
232 if (file_size < sizeof(**llog)) {
233 llapi_error(LLAPI_MSG_ERROR, rc,
234 "File too small for llog header: want=%zd got=%lld",
235 sizeof(**llog), file_size);
240 file_buf = malloc(file_size);
243 llapi_error(LLAPI_MSG_ERROR, rc, "Memory Alloc for file_buf.");
246 *llog = (struct llog_log_hdr *)file_buf;
249 rc = read(fd, file_buf + rd, file_size - rd);
252 } while (rc > 0 && rd < file_size);
254 if (rd < file_size) {
255 rc = rc < 0 ? -errno : -EIO;
256 llapi_error(LLAPI_MSG_ERROR, rc,
257 "Error reading llog header: need %zd, got %d",
262 count = __le32_to_cpu((*llog)->llh_count);
265 llapi_error(LLAPI_MSG_ERROR, rc,
266 "corrupted llog: negative record number %d",
269 } else if (count == 0) {
270 llapi_printf(LLAPI_MSG_NORMAL,
271 "uninitialized llog: zero record number\n");
275 /* the llog header not countable here.*/
276 recs_num = count - 1;
278 recs_buf = calloc(recs_num, sizeof(**recs_pr));
281 llapi_error(LLAPI_MSG_ERROR, rc,
282 "Error allocating %zd bytes for recs_buf",
283 recs_num * sizeof(**recs_pr));
286 recs_pr = (struct llog_rec_hdr **)recs_buf;
288 ptr = file_buf + __le32_to_cpu((*llog)->llh_hdr.lrh_len);
292 while (ptr < (file_buf + file_size)) {
293 struct llog_rec_hdr *cur_rec;
295 unsigned long offset;
297 if (ptr + sizeof(**recs_pr) > file_buf + file_size) {
299 llapi_error(LLAPI_MSG_ERROR, rc,
300 "The log is corrupt (too big at %d)", i);
304 cur_rec = (struct llog_rec_hdr *)ptr;
305 idx = __le32_to_cpu(cur_rec->lrh_index);
306 recs_pr[i] = cur_rec;
307 offset = (unsigned long)ptr - (unsigned long)file_buf;
308 if (cur_rec->lrh_len == 0 ||
309 cur_rec->lrh_len > (*llog)->llh_hdr.lrh_len) {
310 cur_rec->lrh_len = (*llog)->llh_hdr.lrh_len -
311 offset % (*llog)->llh_hdr.lrh_len;
312 printf("off %lu skip %u to next chunk.\n", offset,
315 } else if (ext2_test_bit(idx, LLOG_HDR_BITMAP(*llog))) {
316 printf("rec #%d type=%x len=%u offset %lu\n", idx,
317 cur_rec->lrh_type, cur_rec->lrh_len, offset);
319 cur_rec->lrh_id = CANCELLED;
320 if (cur_rec->lrh_type == LLOG_PAD_MAGIC &&
321 ((offset + cur_rec->lrh_len) & 0x7) != 0)
322 printf("rec #%d wrong padding len=%u offset %lu to 0x%lx\n",
323 idx, cur_rec->lrh_len, offset,
324 offset + cur_rec->lrh_len);
325 /* The header counts only set records */
328 if (last_idx + 1 != idx) {
329 printf("Previous index is %d, current %d, offset %lu\n",
330 last_idx, idx, offset);
334 ptr += __le32_to_cpu(cur_rec->lrh_len);
335 if ((ptr - file_buf) > file_size) {
336 printf("The log is corrupt (too big at %d)\n", i);
344 *recs_number = recs_num;
359 void llog_unpack_buffer(int fd, struct llog_log_hdr *llog_buf,
360 struct llog_rec_hdr **recs_buf)
368 void print_llog_header(struct llog_log_hdr *llog_buf)
371 unsigned int lrh_len = __le32_to_cpu(llog_buf->llh_hdr.lrh_len);
372 struct llog_rec_tail *tail = ((struct llog_rec_tail *)((char *)llog_buf+
373 lrh_len - sizeof(llog_buf->llh_tail)));
375 printf("Header size : %u\t llh_size : %u\n", lrh_len,
376 __le32_to_cpu(llog_buf->llh_size));
378 t = __le64_to_cpu(llog_buf->llh_timestamp);
379 printf("Time : %s", ctime(&t));
381 printf("Number of records: %u\tcat_idx: %u\tlast_idx: %u\n",
382 __le32_to_cpu(llog_buf->llh_count)-1,
383 __le32_to_cpu(llog_buf->llh_cat_idx),
384 __le32_to_cpu(tail->lrt_index));
386 printf("Target uuid : %s\n",
387 (char *)(&llog_buf->llh_tgtuuid));
389 /* Add the other info you want to view here */
391 printf("-----------------------\n");
394 static void print_1_cfg(struct lustre_cfg *lcfg)
399 printf("nid=%s(%#jx) ", libcfs_nid2str(lcfg->lcfg_nid),
400 (uintmax_t)lcfg->lcfg_nid);
402 printf("nal=%d ", lcfg->lcfg_nal);
403 for (i = 0; i < lcfg->lcfg_bufcount; i++)
404 printf("%d:%.*s ", i, lcfg->lcfg_buflens[i],
405 (char *)lustre_cfg_buf(lcfg, i));
408 static char *lustre_cfg_string(struct lustre_cfg *lcfg, __u32 index)
412 if (lcfg->lcfg_buflens[index] == 0)
415 s = lustre_cfg_buf(lcfg, index);
420 * make sure it's NULL terminated, even if this kills a char
421 * of data. Try to use the padding first though.
423 if (s[lcfg->lcfg_buflens[index] - 1] != '\0') {
424 size_t last = __ALIGN_KERNEL(lcfg->lcfg_buflens[index], 8) - 1;
427 /* Use the smaller value */
428 if (last > lcfg->lcfg_buflens[index])
429 last = lcfg->lcfg_buflens[index];
435 "Truncated buf %d to '%s' (lost '%c'...)\n",
442 static void print_setup_cfg(struct lustre_cfg *lcfg)
444 struct lov_desc *desc;
446 if ((lcfg->lcfg_bufcount == 2) &&
447 (lcfg->lcfg_buflens[1] == sizeof(*desc))) {
448 printf("lov_setup ");
449 printf("0:%s ", lustre_cfg_string(lcfg, 0));
450 printf("1:(struct lov_desc)\n");
451 desc = (struct lov_desc *)(lustre_cfg_string(lcfg, 1));
452 printf("\t\tuuid=%s ", (char *)desc->ld_uuid.uuid);
453 printf("stripe:cnt=%u ", desc->ld_default_stripe_count);
454 printf("size=%ju ", (uintmax_t)desc->ld_default_stripe_size);
455 printf("offset=%ju ",
456 (uintmax_t)desc->ld_default_stripe_offset);
457 printf("pattern=%#x", desc->ld_pattern);
464 void print_lustre_cfg(struct lustre_cfg *lcfg, int *skip)
466 enum lcfg_command_type cmd = __le32_to_cpu(lcfg->lcfg_command);
478 print_setup_cfg(lcfg);
491 case(LCFG_ADD_UUID):{
496 case(LCFG_DEL_UUID):{
501 case(LCFG_ADD_CONN):{
506 case(LCFG_DEL_CONN):{
511 case(LCFG_LOV_ADD_OBD):{
512 printf("lov_modify_tgts add ");
516 case(LCFG_LOV_DEL_OBD):{
517 printf("lov_modify_tgts del ");
522 printf("modify_mdc_tgts add ");
527 printf("modify_mdc_tgts del ");
531 case(LCFG_MOUNTOPT):{
532 printf("mount_option ");
536 case(LCFG_DEL_MOUNTOPT):{
537 printf("del_mount_option ");
541 case(LCFG_SET_TIMEOUT):{
542 printf("set_timeout=%d ", lcfg->lcfg_num);
545 case(LCFG_SET_LDLM_TIMEOUT):{
546 printf("set_ldlm_timeout=%d ", lcfg->lcfg_num);
549 case(LCFG_SET_UPCALL):{
550 printf("set_lustre_upcall ");
559 case(LCFG_SET_PARAM):{
560 printf("set_param ");
564 case(LCFG_SPTLRPC_CONF):{
565 printf("sptlrpc_conf ");
570 struct cfg_marker *marker = lustre_cfg_buf(lcfg, 1);
571 char createtime[26], canceltime[26] = "";
574 if (marker->cm_flags & CM_START &&
575 marker->cm_flags & CM_SKIP) {
576 printf("SKIP START ");
578 } else if (marker->cm_flags & CM_END) {
583 if (marker->cm_flags & CM_EXCLUDE) {
584 if (marker->cm_flags & CM_START)
585 printf("EXCLUDE START ");
587 printf("EXCLUDE END ");
591 * Handle overflow of 32-bit time_t gracefully.
592 * The copy to time_tmp is needed in any case to
593 * keep the pointer happy, even on 64-bit systems.
595 time_tmp = marker->cm_createtime;
596 if (time_tmp == marker->cm_createtime) {
597 ctime_r(&time_tmp, createtime);
598 createtime[strlen(createtime) - 1] = 0;
600 strcpy(createtime, "in the distant future");
603 if (marker->cm_canceltime) {
605 * Like cm_createtime, we try to handle overflow of
606 * 32-bit time_t gracefully. The copy to time_tmp
607 * is also needed on 64-bit systems to keep the
608 * pointer happy, see bug 16771
610 time_tmp = marker->cm_canceltime;
611 if (time_tmp == marker->cm_canceltime) {
612 ctime_r(&time_tmp, canceltime);
613 canceltime[strlen(canceltime) - 1] = 0;
615 strcpy(canceltime, "in the distant future");
619 printf("marker %3d (flags=%#04x, v%d.%d.%d.%d) %-15s '%s' %s-%s",
620 marker->cm_step, marker->cm_flags,
621 OBD_OCD_VERSION_MAJOR(marker->cm_vers),
622 OBD_OCD_VERSION_MINOR(marker->cm_vers),
623 OBD_OCD_VERSION_PATCH(marker->cm_vers),
624 OBD_OCD_VERSION_FIX(marker->cm_vers),
625 marker->cm_tgtname, marker->cm_comment,
626 createtime, canceltime);
629 case(LCFG_POOL_NEW):{
634 case(LCFG_POOL_ADD):{
639 case(LCFG_POOL_REM):{
640 printf("pool remove ");
644 case(LCFG_POOL_DEL):{
645 printf("pool destroy ");
650 printf("unsupported cmd_code = %x\n", cmd);
655 static void print_hsm_action(struct llog_agent_req_rec *larr)
660 sz = larr->arr_hai.hai_len - sizeof(larr->arr_hai);
661 printf("lrh=[type=%X len=%d idx=%d] fid="DFID" compound/cookie=%#llx/%#llx status=%s action=%s archive#=%d flags=%#llx create=%llu change=%llu extent=%#llx-%#llx gid=%#llx datalen=%d data=[%s]\n",
662 larr->arr_hdr.lrh_type,
663 larr->arr_hdr.lrh_len, larr->arr_hdr.lrh_index,
664 PFID(&larr->arr_hai.hai_fid),
665 (unsigned long long)larr->arr_compound_id,
666 (unsigned long long)larr->arr_hai.hai_cookie,
667 agent_req_status2name(larr->arr_status),
668 hsm_copytool_action2name(larr->arr_hai.hai_action),
669 larr->arr_archive_id,
670 (unsigned long long)larr->arr_flags,
671 (unsigned long long)larr->arr_req_create,
672 (unsigned long long)larr->arr_req_change,
673 (unsigned long long)larr->arr_hai.hai_extent.offset,
674 (unsigned long long)larr->arr_hai.hai_extent.length,
675 (unsigned long long)larr->arr_hai.hai_gid, sz,
676 hai_dump_data_field(&larr->arr_hai, buf, sizeof(buf)));
679 void print_changelog_rec(struct llog_changelog_rec *rec)
684 secs = __le64_to_cpu(rec->cr.cr_time) >> 30;
685 gmtime_r(&secs, &ts);
686 printf("changelog record id:0x%x index:%llu cr_flags:0x%x cr_type:%s(0x%x) date:'%02d:%02d:%02d.%09d %04d.%02d.%02d' target:"DFID,
687 __le32_to_cpu(rec->cr_hdr.lrh_id),
688 (unsigned long long)__le64_to_cpu(rec->cr.cr_index),
689 __le32_to_cpu(rec->cr.cr_flags),
690 changelog_type2str(__le32_to_cpu(rec->cr.cr_type)),
691 __le32_to_cpu(rec->cr.cr_type),
692 ts.tm_hour, ts.tm_min, ts.tm_sec,
693 (int)(__le64_to_cpu(rec->cr.cr_time) & ((1 << 30) - 1)),
694 ts.tm_year + 1900, ts.tm_mon + 1, ts.tm_mday,
695 PFID(&rec->cr.cr_tfid));
697 if (rec->cr.cr_flags & CLF_JOBID) {
698 struct changelog_ext_jobid *jid =
699 changelog_rec_jobid(&rec->cr);
701 if (jid->cr_jobid[0] != '\0')
702 printf(" jobid:%s", jid->cr_jobid);
705 if (rec->cr.cr_flags & CLF_EXTRA_FLAGS) {
706 struct changelog_ext_extra_flags *ef =
707 changelog_rec_extra_flags(&rec->cr);
709 printf(" cr_extra_flags:0x%llx",
710 (unsigned long long)__le64_to_cpu(ef->cr_extra_flags));
712 if (ef->cr_extra_flags & CLFE_UIDGID) {
713 struct changelog_ext_uidgid *uidgid =
714 changelog_rec_uidgid(&rec->cr);
716 printf(" user:%u:%u",
717 __le32_to_cpu(uidgid->cr_uid),
718 __le32_to_cpu(uidgid->cr_gid));
720 if (ef->cr_extra_flags & CLFE_NID) {
721 struct changelog_ext_nid *nid =
722 changelog_rec_nid(&rec->cr);
725 libcfs_nid2str(nid->cr_nid));
728 if (ef->cr_extra_flags & CLFE_OPEN) {
729 struct changelog_ext_openmode *omd =
730 changelog_rec_openmode(&rec->cr);
733 /* exec mode must be exclusive */
734 if (__le32_to_cpu(omd->cr_openflags) & MDS_FMODE_EXEC) {
737 if (__le32_to_cpu(omd->cr_openflags) &
740 if (__le32_to_cpu(omd->cr_openflags) &
741 (MDS_FMODE_WRITE | MDS_OPEN_TRUNC | MDS_OPEN_APPEND))
745 if (strcmp(mode, "---") != 0)
746 printf(" mode:%s", mode);
749 if (ef->cr_extra_flags & CLFE_XATTR) {
750 struct changelog_ext_xattr *xattr =
751 changelog_rec_xattr(&rec->cr);
753 if (xattr->cr_xattr[0] != '\0')
754 printf(" xattr:%s", xattr->cr_xattr);
758 if (rec->cr.cr_namelen)
759 printf(" parent:"DFID" name:%.*s", PFID(&rec->cr.cr_pfid),
760 __le32_to_cpu(rec->cr.cr_namelen),
761 changelog_rec_name(&rec->cr));
763 if (rec->cr.cr_flags & CLF_RENAME) {
764 struct changelog_ext_rename *rnm =
765 changelog_rec_rename(&rec->cr);
767 if (!fid_is_zero(&rnm->cr_sfid))
768 printf(" source_fid:"DFID" source_parent_fid:"DFID
771 PFID(&rnm->cr_spfid),
773 changelog_rec_snamelen(&rec->cr)),
774 changelog_rec_sname(&rec->cr));
779 static void lustre_swab_lu_fid(struct lu_fid *fid)
781 fid->f_seq = __swab64(fid->f_seq);
782 fid->f_oid = __swab32(fid->f_oid);
783 fid->f_ver = __swab32(fid->f_ver);
787 update_op_size(unsigned int param_count)
789 return offsetof(struct update_op, uop_params_off[param_count]);
793 static inline struct update_op *
794 update_op_next_op(const struct update_op *uop)
796 return (struct update_op *)((char *)uop +
797 update_op_size(uop->uop_param_count));
800 static void lustre_swab_update_ops(struct update_ops *uops,
801 unsigned int op_count)
806 struct update_op *op =
807 (struct update_op *)((char *)&uops->uops_op[0]);
809 for (i = 0; i < op_count; i++, op = update_op_next_op(op)) {
810 lustre_swab_lu_fid(&op->uop_fid);
811 op->uop_type = __swab16(op->uop_type);
812 op->uop_param_count = __swab16(op->uop_param_count);
813 for (j = 0; j < op->uop_param_count; j++)
814 op->uop_params_off[j] = __swab16(op->uop_params_off[j]);
817 static const char *update_op_str(__u16 opc)
819 static const char *opc_str[] = {
820 [OUT_START] = "start",
821 [OUT_CREATE] = "create",
822 [OUT_DESTROY] = "destroy",
823 [OUT_REF_ADD] = "ref_add",
824 [OUT_REF_DEL] = "ref_del",
825 [OUT_ATTR_SET] = "attr_set",
826 [OUT_ATTR_GET] = "attr_get",
827 [OUT_XATTR_SET] = "xattr_set",
828 [OUT_XATTR_GET] = "xattr_get",
829 [OUT_XATTR_LIST] = "xattr_list",
830 [OUT_INDEX_LOOKUP] = "lookup",
831 [OUT_INDEX_INSERT] = "insert",
832 [OUT_INDEX_DELETE] = "delete",
833 [OUT_WRITE] = "write",
834 [OUT_XATTR_DEL] = "xattr_del",
835 [OUT_PUNCH] = "punch",
840 if (opc < (sizeof(opc_str) / sizeof((opc_str)[0])) &&
841 opc_str[opc] != NULL)
847 char *buf2str(void *buf, unsigned int size)
849 const char *hex = "0123456789ABCDEF";
851 static char string[128];
853 bool format_hex = false;
855 if (size > 0 && buf_c[size - 1] == 0)
857 for (i = 0; i < size; i++) {
858 if (buf_c[i] >= 0x20 && buf_c[i] <= 0x7E) {
859 string[j++] = buf_c[i];
861 } else if (j < sizeof(string) - 6) {
867 string[j++] = hex[(buf_c[i] >> 4) & 0xF];
868 string[j++] = hex[buf_c[i] & 0xF];
872 if (j == sizeof(string) - 2)
879 void print_update_rec(struct llog_update_record *lur)
881 struct update_records *rec = &lur->lur_update_rec;
882 unsigned int i, j, up_count, pm_count;
883 struct update_op *op;
884 struct object_update_param *pm;
886 up_count = __le32_to_cpu(rec->ur_update_count);
887 pm_count = __le32_to_cpu(rec->ur_param_count);
888 printf("updatelog record master_transno:%llu batchid:%llu flags:0x%x u_index:%d u_count:%d p_count:%d\n",
889 (unsigned long long)__le64_to_cpu(rec->ur_master_transno),
890 (unsigned long long)__le64_to_cpu(rec->ur_batchid),
891 __le32_to_cpu(rec->ur_flags),
892 __le32_to_cpu(rec->ur_index),
896 op = (struct update_op *)((char *)&rec->ur_ops.uops_op[0] + 0);
897 if (op->uop_type != __le16_to_cpu(op->uop_type))
898 lustre_swab_update_ops(&rec->ur_ops, up_count);
900 for (i = 0; i < up_count; i++, op = update_op_next_op(op)) {
901 printf("\t"DFID" type:%s/%d params:%d ",
902 PFID(&op->uop_fid), update_op_str(op->uop_type),
903 op->uop_type, op->uop_param_count);
904 for (j = 0; j < op->uop_param_count; j++)
905 printf("p_%d:%d ", j, op->uop_params_off[j]);
908 pm = (struct object_update_param *) op;
909 for (i = 0; i < pm_count; i++) {
910 printf("\tp_%d - %d/%s\n", i, pm->oup_len,
911 buf2str(pm->oup_buf, pm->oup_len));
912 pm = (struct object_update_param *)((char *)(pm + 1) +
919 static void print_unlink_rec(struct llog_unlink_rec *lur)
921 printf("unlink record id:0x%x target %llx:%x:%x\n",
922 __le32_to_cpu(lur->lur_hdr.lrh_id),
923 __le64_to_cpu(lur->lur_oid),
924 __le32_to_cpu(lur->lur_oseq),
925 __le32_to_cpu(lur->lur_count));
928 static void print_unlink64_rec(struct llog_unlink64_rec *lur)
930 printf("unlink64 record id:0x%x target "DFID"\n",
931 __le32_to_cpu(lur->lur_hdr.lrh_id),
932 PFID(&lur->lur_fid));
935 static void print_setattr64_rec(struct llog_setattr64_rec *lsr)
937 printf("setattr64 record id:0x%x target "DFID" valid %llx uid %u:%u gid %u:%u\n",
938 __le32_to_cpu(lsr->lsr_hdr.lrh_id),
939 PFID(&lsr->lsr_oi.oi_fid),
940 __le64_to_cpu(lsr->lsr_valid),
941 __le32_to_cpu(lsr->lsr_uid_h),
942 __le32_to_cpu(lsr->lsr_uid),
943 __le32_to_cpu(lsr->lsr_gid_h),
944 __le32_to_cpu(lsr->lsr_gid));
947 static void print_setattr64_rec_v2(struct llog_setattr64_rec_v2 *lsr)
949 printf("setattr64 v2 record id:0x%x target "DFID" valid %llx uid %u:%u gid %u:%u prj %u\n",
950 __le32_to_cpu(lsr->lsr_hdr.lrh_id),
951 PFID(&lsr->lsr_oi.oi_fid),
952 __le64_to_cpu(lsr->lsr_valid),
953 __le32_to_cpu(lsr->lsr_uid_h),
954 __le32_to_cpu(lsr->lsr_uid),
955 __le32_to_cpu(lsr->lsr_gid_h),
956 __le32_to_cpu(lsr->lsr_gid),
957 __le32_to_cpu(lsr->lsr_projid));
961 static void print_records(struct llog_rec_hdr **recs,
962 int rec_number, int is_ext)
967 for (i = 0; i < rec_number; i++) {
969 llapi_printf(LLAPI_MSG_NORMAL,
970 "uninitialized llog record at index %d\n",
974 printf("#%.2d (%.3d)", __le32_to_cpu(recs[i]->lrh_index),
975 __le32_to_cpu(recs[i]->lrh_len));
977 lopt = __le32_to_cpu(recs[i]->lrh_type);
979 if (recs[i]->lrh_id == CANCELLED)
985 (struct lustre_cfg *)((char *)(recs[i]) +
986 sizeof(struct llog_rec_hdr)), &skip);
991 case LLOG_LOGID_MAGIC:
992 print_log_path((struct llog_logid_rec *)recs[i],
996 print_hsm_action((struct llog_agent_req_rec *)recs[i]);
999 print_changelog_rec((struct llog_changelog_rec *)
1002 case CHANGELOG_USER_REC:
1003 case CHANGELOG_USER_REC2:
1004 printf("changelog_user record id:0x%x\n",
1005 __le32_to_cpu(recs[i]->lrh_id));
1008 print_update_rec((struct llog_update_record *)recs[i]);
1010 case MDS_UNLINK_REC:
1011 print_unlink_rec((struct llog_unlink_rec *)recs[i]);
1013 case MDS_UNLINK64_REC:
1014 print_unlink64_rec((struct llog_unlink64_rec *)recs[i]);
1016 case MDS_SETATTR64_REC:
1017 if (__le32_to_cpu(recs[i]->lrh_len) >
1018 sizeof(struct llog_setattr64_rec)) {
1019 print_setattr64_rec_v2(
1020 (struct llog_setattr64_rec_v2 *)recs[i]);
1022 print_setattr64_rec(
1023 (struct llog_setattr64_rec *)recs[i]);
1027 printf("unknown type %x\n", lopt);
1033 /** @} llog_reader */