All of lore.kernel.org
 help / color / mirror / Atom feed
From: zhangdongmao <dmzhang@suse.com>
To: Brassow Jonathan <jbrassow@redhat.com>
Cc: device-mapper development <dm-devel@redhat.com>
Subject: Re: [PATCH] convert dm_ulog_request data to little endian
Date: Thu, 21 Aug 2014 13:07:11 +0800	[thread overview]
Message-ID: <53F57E7F.2090705@suse.com> (raw)
In-Reply-To: <9FC3B4B3-9310-41FF-8E89-709A8790549E@redhat.com>


> v5_endian_from_network() only gets called if it is needed.  I suspect there is a bug here, 'clog_request_to_network' should detect if big endian is being used and switch it to little endian.  In-coming communication must always be little endian.  I'm not sure which end the problem is on (I think the send side).  You could add some prints to detect the issue.
>
> lvm2/daemons/cmirrord/cluster.c:cluster_send() sets two version numbers - one is forced to be little endian via xlate64().  'clog_request_to_network()' is then called and compares the two version numbers.  If they are different, the machine is big endian and the contents must be converted.  If this is not happening, it is bad.  Then, *from_network() performs a similar action and test and then must xlate back to big endian.  If this is not happening, it is bad.  So, for big endian machines, ensure that v5_endian_*_network() is being called.  (For little endian, it should not be.)
>
>   brassow
hi,  brassow ,

       There might be a bug in v5_endian_to_network when sending packet.
       If the machine were big-endian,  v5_endian_to_network will 
convert request_type to little endian.
But in v5_data_endian_switch, it will check request_type again, and this 
check will failed because request_type is already converted
to little endian. So my solution to this is to delay xlate32 of 
u_rq->request_type.

      On the other hand, when receiving package in 
clog_request_from_network. I think the vp[0] will always be little endian.
we could use xlate64(vp[0]) == vp[0] to decide if the local node is 
little endian or not. if local node is little endian, we do nothing,
if the local node is big endian, we have to call v5_endian_from_network 
to convert little endian to big endian.

      But for now, I have not had a chance to test this patch on s390


here's the patch:

diff --git a/daemons/cmirrord/compat.c b/daemons/cmirrord/compat.c
index 3f7a9b5..c9cb803 100644
--- a/daemons/cmirrord/compat.c
+++ b/daemons/cmirrord/compat.c
@@ -126,13 +126,14 @@ static int v5_endian_to_network(struct 
clog_request *rq)

         u_rq->error = xlate32(u_rq->error);
         u_rq->seq = xlate32(u_rq->seq);
-       u_rq->request_type = xlate32(u_rq->request_type);
         u_rq->data_size = xlate64(u_rq->data_size);

         rq->originator = xlate32(rq->originator);

         v5_data_endian_switch(rq, 1);

+       rq->u_rq.request_type = xlate32(rq->u_rq.request_type);
+
         return size;
  }

@@ -187,7 +188,7 @@ int clog_request_from_network(void *data, size_t 
data_len)

         switch (version) {
         case 5: /* Upstream */
-               if (version == unconverted_version)
+               if (version == vp[0])
                         return 0;
                 break;
         case 4: /* RHEL 5.[45] */



Dongmao Zhang

      reply	other threads:[~2014-08-21  5:07 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-08-08  0:56 [PATCH] convert dm_ulog_request data to little endian Dongmao Zhang
2014-08-11  3:15 ` Mike Snitzer
2014-08-11 14:03   ` Mikulas Patocka
2014-08-21  6:00   ` Brassow Jonathan
2014-08-21 11:08     ` zhangdongmao
2014-08-20  0:58 ` [PATCH] " Brassow Jonathan
2014-08-20  3:19   ` zhangdongmao
2014-08-20  4:20     ` Brassow Jonathan
2014-08-21  5:07       ` zhangdongmao [this message]

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=53F57E7F.2090705@suse.com \
    --to=dmzhang@suse.com \
    --cc=dm-devel@redhat.com \
    --cc=jbrassow@redhat.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.