Linux Device Mapper development
 help / color / mirror / Atom feed
From: "Benjamin Marzinski" <bmarzins@redhat.com>
To: Martin Wilck <mwilck@suse.com>
Cc: device-mapper development <dm-devel@redhat.com>
Subject: Re: [PATCH 2/5] libmultipath: change reservation_key to a uint64_t
Date: Fri, 8 Sep 2017 17:55:03 -0500	[thread overview]
Message-ID: <20170908225503.GG3145@octiron.msp.redhat.com> (raw)
In-Reply-To: <1504904957.4585.26.camel@suse.com>

On Fri, Sep 08, 2017 at 11:09:17PM +0200, Martin Wilck wrote:
> On Fri, 2017-09-08 at 13:45 -0500, Benjamin Marzinski wrote:
> > The reservation key is currently being stored as any array of 8
> > unsigned
> > chars.  This is exactly the same in-memory representation as a big
> > endian 64 bit integer. However, the code for dealing with a big
> > endian
> > 64 bit integer is much simpler, so switch to use that instead.
> > 
> > Signed-off-by: Benjamin Marzinski <bmarzins@redhat.com>
> > ---
> >  libmpathpersist/mpath_persist.c | 23 +++++++----------------
> >  libmultipath/byteorder.h        | 36
> > ++++++++++++++++++++++++++++++++++++
> >  libmultipath/config.c           |  3 ---
> >  libmultipath/config.h           |  6 ++++--
> >  libmultipath/dict.c             | 31 ++++---------------------------
> >  libmultipath/propsel.c          |  6 +++---
> >  libmultipath/structs.h          |  5 ++++-
> >  multipathd/main.c               | 23 +++++------------------
> >  8 files changed, 63 insertions(+), 70 deletions(-)
> >  create mode 100644 libmultipath/byteorder.h
> > 
> >  
> >  	char * prio_name;
> >  	char * prio_args;
> > -	unsigned char * reservation_key;
> > +	uint64_t  reservation_key; /* stored in big-endian format */
> 
> I would prefer if you could encapsulate this into a type that can't be
> implicitly converted to an int, such as
> 
> struct res_key {
> 	uint64_t _v;
> } reservation_key;
> 
> together with macros like
> 
> #define reskey_to_uint64(r) be64_to_cpu((r)->_v)
> #define set_reskey_from_uint64(r, x) do { (r)->_v = (x); } while (0)
> 
> Using be64_to_cpu is all too easily forgotten, which leads to nasty
> bugs.

That's a good idea. I'll resend with a structure instead of a straight
uint64_t.

-Ben

> 
> Apart from that, ack.
> 
> -- 
> Dr. Martin Wilck <mwilck@suse.com>, Tel. +49 (0)911 74053 2107
> SUSE Linux GmbH, GF: Felix Imendörffer, Jane Smithard, Graham Norton
> HRB 21284 (AG Nürnberg)

  reply	other threads:[~2017-09-08 22:55 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-08 18:45 [PATCH 0/5] multipath: alternative reservation_key method Benjamin Marzinski
2017-09-08 18:45 ` [PATCH 1/5] libmultipath: pull functions into util.c Benjamin Marzinski
2017-09-08 20:51   ` Martin Wilck
2017-09-08 18:45 ` [PATCH 2/5] libmultipath: change reservation_key to a uint64_t Benjamin Marzinski
2017-09-08 21:09   ` Martin Wilck
2017-09-08 22:55     ` Benjamin Marzinski [this message]
2017-09-08 18:45 ` [PATCH 3/5] libmpathpersist: fix update_prflag code Benjamin Marzinski
2017-09-08 21:17   ` Martin Wilck
2017-09-08 18:45 ` [PATCH 4/5] multipath: add alternate reservation_key method Benjamin Marzinski
2017-09-08 21:34   ` Martin Wilck
2017-09-08 23:00     ` Benjamin Marzinski
2017-09-13 15:22   ` Xose Vazquez Perez
2017-09-08 18:45 ` [PATCH 5/5] mpathpersist: add support for prkeys file Benjamin Marzinski
2017-09-08 21:35   ` Martin Wilck
  -- strict thread matches above, loose matches on Subject: below --
2017-09-15 22:25 [PATCH v2 0/5] multipath: alternative reservation_key method Benjamin Marzinski
2017-09-15 22:25 ` [PATCH 2/5] libmultipath: change reservation_key to a uint64_t Benjamin Marzinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170908225503.GG3145@octiron.msp.redhat.com \
    --to=bmarzins@redhat.com \
    --cc=dm-devel@redhat.com \
    --cc=mwilck@suse.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox