Skip to content

Commit 2db0a3f

Browse files
bmarzinsmwilck
authored andcommitted
mpathpersist: Fix REPORT CAPABILITIES output
mpathpersist was incorrectly parsing the REPORT CAPABILITES service action output. In reality, the type mask is two bytes where the type information is stored in bits 7, 6, 5, 3, & 1 (0xea) of the first byte and bit 0 (0x01) of the second byte. libmpathpersist was treating these two bytes as a big endian 16 bit number, but mpathpersist was looking for bits in that number as if it was little endian number. Ideally, libmpathpersist would treat prin_capdescr.pr_type_mask as two bytes, like it does for the flags. But we already expose this as a 16 bit number, where we treated the input bytes as a big endian number. There's no great reason to mess with the libmpathpersist API, when we can just make mpathpersist treat this data like libmpathpersist provides it. So, fix mpathpersist to print the data out correctly. Additionally, instead of printing a 1 or a 0 to indicate if a type was supported or not, it was printing the value of the type flag. Also, Persist Through Power Loss Capable (PTPL_C) was being reported if any bit in flags[0] was set. Fix these as well. Reformat all of the capability printing lines, since it is less confusing than only reformatting some of them. Fixes: ae4e8a6 ("mpathpersist: Add new utility for managing persistent reservation on dm multipath device") Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
1 parent 0fbc08a commit 2db0a3f

2 files changed

Lines changed: 33 additions & 14 deletions

File tree

libmpathpersist/mpath_persist.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ struct prin_capdescr
113113
{
114114
uint16_t length;
115115
uint8_t flags[2];
116-
uint16_t pr_type_mask;
116+
uint16_t pr_type_mask; /* The two bytes of the type mask are treated
117+
as a single big-endian number. So the valid
118+
type bits are 0xea01 */
117119
uint16_t _reserved;
118120
};
119121

mpathpersist/main.c

Lines changed: 30 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -748,25 +748,42 @@ void mpath_print_buf_readcap( struct prin_resp *pr_buff)
748748

749749
printf("Report capabilities response:\n");
750750

751-
printf(" Compatible Reservation Handling(CRH): %d\n", !!(pr_buff->prin_descriptor.prin_readcap.flags[0] & 0x10));
752-
printf(" Specify Initiator Ports Capable(SIP_C): %d\n",!!(pr_buff->prin_descriptor.prin_readcap.flags[0] & 0x8));
753-
printf(" All Target Ports Capable(ATP_C): %d\n",!!(pr_buff->prin_descriptor.prin_readcap.flags[0] & 0x4 ));
754-
printf(" Persist Through Power Loss Capable(PTPL_C): %d\n",!!(pr_buff->prin_descriptor.prin_readcap.flags[0]));
755-
printf(" Type Mask Valid(TMV): %d\n", !!(pr_buff->prin_descriptor.prin_readcap.flags[1] & 0x80));
756-
printf(" Allow Commands: %d\n", !!(( pr_buff->prin_descriptor.prin_readcap.flags[1] >> 4) & 0x7));
751+
printf(" Compatible Reservation Handling(CRH): %d\n",
752+
!!(pr_buff->prin_descriptor.prin_readcap.flags[0] & 0x10));
753+
printf(" Specify Initiator Ports Capable(SIP_C): %d\n",
754+
!!(pr_buff->prin_descriptor.prin_readcap.flags[0] & 0x8));
755+
printf(" All Target Ports Capable(ATP_C): %d\n",
756+
!!(pr_buff->prin_descriptor.prin_readcap.flags[0] & 0x4));
757+
printf(" Persist Through Power Loss Capable(PTPL_C): %d\n",
758+
!!(pr_buff->prin_descriptor.prin_readcap.flags[0] & 0x1));
759+
printf(" Type Mask Valid(TMV): %d\n",
760+
!!(pr_buff->prin_descriptor.prin_readcap.flags[1] & 0x80));
761+
printf(" Allow Commands: %d\n",
762+
!!((pr_buff->prin_descriptor.prin_readcap.flags[1] >> 4) & 0x7));
757763
printf(" Persist Through Power Loss Active(PTPL_A): %d\n",
758-
!!(pr_buff->prin_descriptor.prin_readcap.flags[1] & 0x1));
764+
!!(pr_buff->prin_descriptor.prin_readcap.flags[1] & 0x1));
759765

760766
if(pr_buff->prin_descriptor.prin_readcap.flags[1] & 0x80)
761767
{
762768
printf(" Support indicated in Type mask:\n");
763769

764-
printf(" %s: %d\n", pr_type_strs[7], pr_buff->prin_descriptor.prin_readcap.pr_type_mask & 0x80);
765-
printf(" %s: %d\n", pr_type_strs[6], pr_buff->prin_descriptor.prin_readcap.pr_type_mask & 0x40);
766-
printf(" %s: %d\n", pr_type_strs[5], pr_buff->prin_descriptor.prin_readcap.pr_type_mask & 0x20);
767-
printf(" %s: %d\n", pr_type_strs[3], pr_buff->prin_descriptor.prin_readcap.pr_type_mask & 0x8);
768-
printf(" %s: %d\n", pr_type_strs[1], pr_buff->prin_descriptor.prin_readcap.pr_type_mask & 0x2);
769-
printf(" %s: %d\n", pr_type_strs[8], pr_buff->prin_descriptor.prin_readcap.pr_type_mask & 0x100);
770+
printf(" %s: %d\n", pr_type_strs[7],
771+
!!(pr_buff->prin_descriptor.prin_readcap.pr_type_mask &
772+
0x8000));
773+
printf(" %s: %d\n", pr_type_strs[6],
774+
!!(pr_buff->prin_descriptor.prin_readcap.pr_type_mask &
775+
0x4000));
776+
printf(" %s: %d\n", pr_type_strs[5],
777+
!!(pr_buff->prin_descriptor.prin_readcap.pr_type_mask &
778+
0x2000));
779+
printf(" %s: %d\n", pr_type_strs[3],
780+
!!(pr_buff->prin_descriptor.prin_readcap.pr_type_mask &
781+
0x800));
782+
printf(" %s: %d\n", pr_type_strs[1],
783+
!!(pr_buff->prin_descriptor.prin_readcap.pr_type_mask &
784+
0x200));
785+
printf(" %s: %d\n", pr_type_strs[8],
786+
!!(pr_buff->prin_descriptor.prin_readcap.pr_type_mask & 0x1));
770787
}
771788
}
772789

0 commit comments

Comments
 (0)