From: Mike Snitzer <snitzer@redhat.com>
To: Dongmao Zhang <dmzhang@suse.com>
Cc: dm-devel@redhat.com, Mikulas Patocka <mpatocka@redhat.com>,
"Alasdair G. Kergon" <agk@redhat.com>
Subject: Re: convert dm_ulog_request data to little endian
Date: Sun, 10 Aug 2014 23:15:56 -0400 [thread overview]
Message-ID: <20140811031556.GA27789@redhat.com> (raw)
In-Reply-To: <1407459365-697-1-git-send-email-dmzhang@suse.com>
On Thu, Aug 07 2014 at 8:56pm -0400,
Dongmao Zhang <dmzhang@suse.com> wrote:
> the dm_ulog_request might be little endian or big endian depending on
> the architecture. This is not right. This patch is to convert
> dm_ulog_request to little endian.
>
> I met a bug when running cmirrord on s390 linux
>
> Signed-off-by: Dongmao Zhang <dmzhang@suse.com>
> ---
> drivers/md/dm-log-userspace-transfer.c | 31 ++++++++++++++++++++++++++++++-
> 1 file changed, 30 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/md/dm-log-userspace-transfer.c b/drivers/md/dm-log-userspace-transfer.c
> index b428c0a..cddef2f 100644
> --- a/drivers/md/dm-log-userspace-transfer.c
> +++ b/drivers/md/dm-log-userspace-transfer.c
> @@ -53,6 +53,29 @@ struct receiving_pkg {
> static DEFINE_SPINLOCK(receiving_list_lock);
> static struct list_head receiving_list;
>
> +static void cpu_to_network(struct dm_ulog_request *tfr)
> +{
> + if (tfr == NULL)
> + return;
> + tfr->luid = cpu_to_le64(tfr->luid);
> + tfr->version = cpu_to_le32(tfr->version);
> + tfr->seq = cpu_to_le32(tfr->seq);
> + tfr->request_type = cpu_to_le32(tfr->request_type);
> + tfr->data_size = cpu_to_le32(tfr->data_size);
> +}
> +
> +static void network_to_cpu(struct dm_ulog_request *tfr)
> +{
> + if (tfr == NULL)
> + return;
> + tfr->luid = le64_to_cpu(tfr->luid);
> + tfr->version = le32_to_cpu(tfr->version);
> + tfr->seq = le32_to_cpu(tfr->seq);
> + tfr->request_type = le32_to_cpu(tfr->request_type);
> + tfr->data_size = le32_to_cpu(tfr->data_size);
> + tfr->error = le32_to_cpu(tfr->error);
> +}
> +
> static int dm_ulog_sendto_server(struct dm_ulog_request *tfr)
> {
> int r;
> @@ -66,6 +89,7 @@ static int dm_ulog_sendto_server(struct dm_ulog_request *tfr)
> msg->seq = tfr->seq;
> msg->len = sizeof(struct dm_ulog_request) + tfr->data_size;
>
> + cpu_to_network(tfr);
> r = cn_netlink_send(msg, 0, 0, gfp_any());
>
> return r;
> @@ -81,8 +105,11 @@ static int dm_ulog_sendto_server(struct dm_ulog_request *tfr)
> */
> static int fill_pkg(struct cn_msg *msg, struct dm_ulog_request *tfr)
> {
> - uint32_t rtn_seq = (msg) ? msg->seq : (tfr) ? tfr->seq : 0;
> struct receiving_pkg *pkg;
> + uint32_t rtn_seq;
> +
> + network_to_cpu(tfr);
> + rtn_seq = (msg) ? msg->seq : (tfr) ? tfr->seq : 0;
>
> /*
> * The 'receiving_pkg' entries in this list are statically
> @@ -148,6 +175,8 @@ static void cn_ulog_callback(struct cn_msg *msg, struct netlink_skb_parms *nsp)
> spin_unlock(&receiving_list_lock);
> }
>
> +
> +
> /**
> * dm_consult_userspace
> * @uuid: log's universal unique identifier (must be DM_UUID_LEN in size)
Other than this last hunk (extra whitespace) this patch looks fine to me.
Jon/Mikulas/Alasdair: could you review this too? If you guys agree I'll
get it staged for 3.17 (and mark it for stable).
Thanks,
Mike
next prev parent reply other threads:[~2014-08-11 3:15 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 [this message]
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
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=20140811031556.GA27789@redhat.com \
--to=snitzer@redhat.com \
--cc=agk@redhat.com \
--cc=dm-devel@redhat.com \
--cc=dmzhang@suse.com \
--cc=mpatocka@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox