From: Eugene Syromyatnikov Date: Mon, 27 Aug 2018 20:17:17 +0000 (+0200) Subject: aio: assorted iocb decoder updates X-Git-Tag: v5.3~119 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=dbbf02e8ec156024558db64b99841d2deab5cc12;p=strace aio: assorted iocb decoder updates * xlat/aio_iocb_flags.in: New file. * defs.h (pollflags, rwf_flags): New declarations. * configure.ac (AC_CHECK_MEMBERS): Check for aio_flags and aio_rw_flags fields of struct iocb. * aio.c [HAVE_STRUCT_IOCB_AIO_FLAGS]: Include "xlat/aio_iocb_flags.h". (AIO_RW_FLAGS_FIELD): New macro definition, defined based on the presence of HAVE_STRUCT_IOCB_AIO_RW_FLAGS macro. (iocb_sub): Add SUB_POLL. (tprint_lio_opcode): Change IOCB_CMD_POLL subtype to SUB_POLL. (print_common_flags): Conditionalize on HAVE_STRUCT_IOCB_AIO_FLAGS instead of IOCB_FLAG_RESFD. Print aio_flags using aio_iocb_flags xlat. (print_iocb_header): Always print aio_data. Print aio_rw_flags if it is non-zero. Print aio_reqprio based on the presence of IOCB_FLAG_IOPRIO flag in aio_flags (use print_ioprio if it set and print as a signed integer otherwise). (print_iocb): Decode SUB_POLL subtype. * tests/aio.c: Update expected output. Co-Authored-by: Dmitry V. Levin --- diff --git a/aio.c b/aio.c index a825cae3..190ab35e 100644 --- a/aio.c +++ b/aio.c @@ -15,6 +15,16 @@ #include "xlat/aio_cmds.h" +#ifdef HAVE_STRUCT_IOCB_AIO_FLAGS +# include "xlat/aio_iocb_flags.h" +#endif + +#ifdef HAVE_STRUCT_IOCB_AIO_RW_FLAGS +# define AIO_RW_FLAGS_FIELD aio_rw_flags +#else +# define AIO_RW_FLAGS_FIELD aio_reserved1 +#endif + SYS_FUNC(io_setup) { if (entering(tcp)) @@ -32,7 +42,7 @@ SYS_FUNC(io_destroy) } enum iocb_sub { - SUB_NONE, SUB_COMMON, SUB_VECTOR + SUB_NONE, SUB_COMMON, SUB_VECTOR, SUB_POLL }; static enum iocb_sub @@ -44,7 +54,7 @@ tprint_lio_opcode(unsigned int cmd) [IOCB_CMD_FSYNC] = SUB_NONE, [IOCB_CMD_FDSYNC] = SUB_NONE, [IOCB_CMD_PREADX] = SUB_NONE, - [IOCB_CMD_POLL] = SUB_NONE, + [IOCB_CMD_POLL] = SUB_POLL, [IOCB_CMD_NOOP] = SUB_NONE, [IOCB_CMD_PREADV] = SUB_VECTOR, [IOCB_CMD_PWRITEV] = SUB_VECTOR, @@ -59,13 +69,16 @@ tprint_lio_opcode(unsigned int cmd) static void print_common_flags(struct tcb *tcp, const struct iocb *cb) { -/* IOCB_FLAG_RESFD is available since v2.6.22-rc1~47 */ -#ifdef IOCB_FLAG_RESFD +/* aio_flags and aio_resfd fields are available since v2.6.22-rc1~47 */ +#ifdef HAVE_STRUCT_IOCB_AIO_FLAGS + if (cb->aio_flags) + PRINT_FIELD_FLAGS(", ", *cb, aio_flags, aio_iocb_flags, + "IOCB_FLAG_???"); + if (cb->aio_flags & IOCB_FLAG_RESFD) PRINT_FIELD_FD(", ", *cb, aio_resfd, tcp); - - if (cb->aio_flags & ~IOCB_FLAG_RESFD) - PRINT_FIELD_X(", ", *cb, aio_flags); + else if (cb->aio_resfd) + PRINT_FIELD_X(", ", *cb, aio_resfd); #endif } @@ -82,20 +95,25 @@ print_iocb_header(struct tcb *tcp, const struct iocb *cb) { enum iocb_sub sub; - if (cb->aio_data){ - PRINT_FIELD_X("", *cb, aio_data); - tprints(", "); - } + PRINT_FIELD_X("", *cb, aio_data); - if (cb->aio_key) { - PRINT_FIELD_U("", *cb, aio_key); - tprints(", "); + if (cb->aio_key) + PRINT_FIELD_U(", ", *cb, aio_key); + + if (cb->AIO_RW_FLAGS_FIELD) { + tprints(", aio_rw_flags="); + printflags(rwf_flags, cb->AIO_RW_FLAGS_FIELD, "RWF_???"); } - tprints("aio_lio_opcode="); + tprints(", aio_lio_opcode="); sub = tprint_lio_opcode(cb->aio_lio_opcode); - if (cb->aio_reqprio) + + if (cb->aio_flags & IOCB_FLAG_IOPRIO) { + tprints(", aio_reqprio="); + print_ioprio(zero_extend_signed_to_ull(cb->aio_reqprio)); + } else if (cb->aio_reqprio) { PRINT_FIELD_D(", ", *cb, aio_reqprio); + } PRINT_FIELD_FD(", ", *cb, aio_fildes, tcp); @@ -135,6 +153,10 @@ print_iocb(struct tcb *tcp, const struct iocb *cb) PRINT_FIELD_D(", ", *cb, aio_offset); print_common_flags(tcp, cb); break; + case SUB_POLL: + PRINT_FIELD_FLAGS(", ", *cb, aio_buf, pollflags, "POLL???"); + print_common_flags(tcp, cb); + break; case SUB_NONE: break; } diff --git a/configure.ac b/configure.ac index 5441295f..624fc7c0 100644 --- a/configure.ac +++ b/configure.ac @@ -590,6 +590,11 @@ fi AC_CHECK_TYPES([struct __aio_sigset],,, [#include ]) +AC_CHECK_MEMBERS(m4_normalize([ + struct iocb.aio_flags, + struct iocb.aio_rw_flags + ]),,, [#include ]) + CPPFLAGS="$saved_CPPFLAGS" AC_CHECK_HEADERS([linux/btrfs.h], [ diff --git a/defs.h b/defs.h index 2b1d7a00..f71be3a2 100644 --- a/defs.h +++ b/defs.h @@ -345,11 +345,13 @@ extern const struct xlat nl_netfilter_msg_types[]; extern const struct xlat nl_route_types[]; extern const struct xlat open_access_modes[]; extern const struct xlat open_mode_flags[]; +extern const struct xlat pollflags[]; extern const struct xlat ptrace_cmds[]; extern const struct xlat resource_flags[]; extern const struct xlat routing_scopes[]; extern const struct xlat routing_table_ids[]; extern const struct xlat routing_types[]; +extern const struct xlat rwf_flags[]; extern const struct xlat seccomp_filter_flags[]; extern const struct xlat seccomp_ret_action[]; extern const struct xlat setns_types[]; diff --git a/tests/aio.c b/tests/aio.c index 13821998..ff82c41e 100644 --- a/tests/aio.c +++ b/tests/aio.c @@ -117,7 +117,7 @@ main(void) /* In order to make record valid */ .aio_nbytes = (size_t) 0x1020304050607080ULL, .aio_offset = 0xdeadda7abadc0dedULL, -# ifdef IOCB_FLAG_RESFD +# ifdef HAVE_STRUCT_IOCB_AIO_FLAGS .aio_flags = 0xfacef157, .aio_resfd = 0xded1ca7e, # endif @@ -298,30 +298,31 @@ main(void) printf("io_submit(%#lx, %ld, [" "{aio_data=%#" PRI__x64 ", aio_key=%u" ", aio_lio_opcode=%hu /* IOCB_CMD_??? */, aio_fildes=%d}" - ", {aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITE, aio_reqprio=%hd" - ", aio_fildes=%d, aio_buf=NULL" + ", {aio_data=0, aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITE" + ", aio_reqprio=IOPRIO_PRIO_VALUE(0x5 /* IOPRIO_CLASS_??? */" + ", 7919), aio_fildes=%d, aio_buf=NULL" ", aio_nbytes=%" PRI__u64 ", aio_offset=%" PRI__d64 -# ifdef IOCB_FLAG_RESFD - ", aio_resfd=%d, aio_flags=%#x" +# ifdef HAVE_STRUCT_IOCB_AIO_FLAGS + ", aio_flags=IOCB_FLAG_RESFD|IOCB_FLAG_IOPRIO|%#x, aio_resfd=%d" # endif - "}, {aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITE" + "}, {aio_data=0, aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITE" ", aio_reqprio=%hd, aio_fildes=%d, aio_buf=%#" PRI__x64 ", aio_nbytes=%" PRI__u64 ", aio_offset=%" PRI__d64 - "}, {aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITE" + "}, {aio_data=0, aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITE" ", aio_reqprio=%hd, aio_fildes=%d" ", aio_buf=\"\\0\\1\\2\\3%.28s\"..." ", aio_nbytes=%" PRI__u64 ", aio_offset=%" PRI__d64 - "}, {aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITEV" + "}, {aio_data=0, aio_key=%u, aio_lio_opcode=IOCB_CMD_PWRITEV" ", aio_reqprio=%hd, aio_fildes=%d, aio_buf=%#" PRI__x64 ", aio_nbytes=%" PRI__u64 ", aio_offset=%" PRI__d64 "}, NULL, %#lx, ... /* %p */]) = ", *ctx, 1057L, cbv2[0].aio_data, cbv2[0].aio_key, cbv2[0].aio_lio_opcode, cbv2[0].aio_fildes, - cbv2[1].aio_key, cbv2[1].aio_reqprio, cbv2[1].aio_fildes, + cbv2[1].aio_key, cbv2[1].aio_fildes, cbv2[1].aio_nbytes, cbv2[1].aio_offset, -# ifdef IOCB_FLAG_RESFD - cbv2[1].aio_resfd, cbv2[1].aio_flags, +# ifdef HAVE_STRUCT_IOCB_AIO_FLAGS + cbv2[1].aio_flags & ~3, cbv2[1].aio_resfd, # endif cbv2[2].aio_key, cbv2[2].aio_reqprio, cbv2[2].aio_fildes, cbv2[2].aio_buf, cbv2[2].aio_nbytes, cbv2[2].aio_offset, diff --git a/xlat/aio_iocb_flags.in b/xlat/aio_iocb_flags.in new file mode 100644 index 00000000..f6a5ab7c --- /dev/null +++ b/xlat/aio_iocb_flags.in @@ -0,0 +1,2 @@ +IOCB_FLAG_RESFD 1 +IOCB_FLAG_IOPRIO 2