From patchwork Fri Aug 8 00:56:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: dongmao zhang X-Patchwork-Id: 4693161 X-Patchwork-Delegate: snitzer@redhat.com Return-Path: X-Original-To: patchwork-dm-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id B242E9F373 for ; Fri, 8 Aug 2014 01:01:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B52632017A for ; Fri, 8 Aug 2014 01:01:38 +0000 (UTC) Received: from mx5-phx2.redhat.com (mx5-phx2.redhat.com [209.132.183.37]) by mail.kernel.org (Postfix) with ESMTP id B55CD2011B for ; Fri, 8 Aug 2014 01:01:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by mx5-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s780vBau008528; Thu, 7 Aug 2014 20:57:11 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id s780v9XH009542 for ; Thu, 7 Aug 2014 20:57:09 -0400 Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.21]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s780v97N024105 for ; Thu, 7 Aug 2014 20:57:09 -0400 Received: from victor.provo.novell.com (victor.provo.novell.com [137.65.250.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s780v72f012947 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Thu, 7 Aug 2014 20:57:08 -0400 Received: from linux-ifim.site (prv-ext-foundry1int.gns.novell.com [137.65.251.240]) by victor.provo.novell.com with ESMTP (TLS encrypted); Thu, 07 Aug 2014 18:56:53 -0600 From: Dongmao Zhang To: dm-devel@redhat.com Date: Fri, 8 Aug 2014 08:56:05 +0800 Message-Id: <1407459365-697-1-git-send-email-dmzhang@suse.com> X-RedHat-Spam-Score: -4.201 (BAYES_00,RCVD_IN_DNSWL_MED,SPF_PASS) X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Scanned-By: MIMEDefang 2.68 on 10.5.110.21 X-loop: dm-devel@redhat.com Cc: Dongmao Zhang Subject: [dm-devel] [PATCH] convert dm_ulog_request data to little endian X-BeenThere: dm-devel@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk Reply-To: device-mapper development List-Id: device-mapper development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dm-devel-bounces@redhat.com Errors-To: dm-devel-bounces@redhat.com X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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)