From patchwork Wed Jun 1 15:51:47 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Feifei Xu X-Patchwork-Id: 9147729 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5CFEA60761 for ; Wed, 1 Jun 2016 15:53:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4ADAE24B5B for ; Wed, 1 Jun 2016 15:53:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3BED526992; Wed, 1 Jun 2016 15:53:20 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D698024B5B for ; Wed, 1 Jun 2016 15:53:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932182AbcFAPxO (ORCPT ); Wed, 1 Jun 2016 11:53:14 -0400 Received: from e17.ny.us.ibm.com ([129.33.205.207]:57017 "EHLO e17.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932108AbcFAPxL (ORCPT ); Wed, 1 Jun 2016 11:53:11 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Wed, 1 Jun 2016 11:53:10 -0400 Received: from d01dlp02.pok.ibm.com (9.56.250.167) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Wed, 1 Jun 2016 11:53:08 -0400 X-IBM-Helo: d01dlp02.pok.ibm.com X-IBM-MailFrom: xufeifei@linux.vnet.ibm.com X-IBM-RcptTo: jbacik@fb.com; feifeixu.sh@gmail.com; steve.capper@linaro.org; chandan@mykolab.com; dsterba@suse.com; linux-btrfs@vger.kernel.org Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 0D6BF6E808C; Wed, 1 Jun 2016 11:52:21 -0400 (EDT) Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u51FqVq853411940; Wed, 1 Jun 2016 15:52:31 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DFF23AC03A; Wed, 1 Jun 2016 11:52:30 -0400 (EDT) Received: from ip9-114-219-65.stglabs.ibm.com (unknown [9.114.219.66]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id D0C7EAC046; Wed, 1 Jun 2016 11:52:30 -0400 (EDT) From: Feifei Xu To: linux-btrfs@vger.kernel.org Cc: steve.capper@linaro.org, chandan@mykolab.com, jbacik@fb.com, dsterba@suse.com, chandan@linux.vnet.ibm.com, feifeixu.sh@gmail.com, Feifei Xu Subject: [PATCH V2 8/8] Btrfs: self-tests: Fix extent buffer bitmap test fail on BE system Date: Wed, 1 Jun 2016 15:51:47 +0000 Message-Id: <1464796307-67173-9-git-send-email-xufeifei@linux.vnet.ibm.com> X-Mailer: git-send-email 2.4.0 In-Reply-To: <1464796307-67173-1-git-send-email-xufeifei@linux.vnet.ibm.com> References: <1464796307-67173-1-git-send-email-xufeifei@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16060115-0041-0000-0000-0000044A1491 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP In __test_eb_bitmaps(), we write random data to a bitmap. Then copy the bitmap to another bitmap that resides inside an extent buffer. Later we verify the values of corresponding bits in the bitmap and the bitmap inside the extent buffer. However, extent_buffer_test_bit() reads in byte granularity while test_bit() reads in unsigned long granularity. Hence we end up comparing wrong bits on big-endian systems such as ppc64. This commit fixes the issue by reading the bitmap in byte granularity. Reviewed-by: Chandan Rajendra Signed-off-by: Feifei Xu --- fs/btrfs/tests/extent-io-tests.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/tests/extent-io-tests.c b/fs/btrfs/tests/extent-io-tests.c index d7f5bbb..0f7cfab 100644 --- a/fs/btrfs/tests/extent-io-tests.c +++ b/fs/btrfs/tests/extent-io-tests.c @@ -273,6 +273,16 @@ out: return ret; } +/** + * test_bit_in_byte - Determine whether a bit is set in a byte + * @nr: bit number to test + * @addr: Address to start counting from + */ +static inline int test_bit_in_byte(int nr, const u8 *addr) +{ + return 1UL & (addr[nr / BITS_PER_BYTE] >> (nr & (BITS_PER_BYTE - 1))); +} + static int __test_eb_bitmaps(unsigned long *bitmap, struct extent_buffer *eb, unsigned long len) { @@ -338,7 +348,7 @@ static int __test_eb_bitmaps(unsigned long *bitmap, struct extent_buffer *eb, for (i = 0; i < len * BITS_PER_BYTE; i++) { int bit, bit1; - bit = !!test_bit(i, bitmap); + bit = !!test_bit_in_byte(i, (u8 *)bitmap); bit1 = !!extent_buffer_test_bit(eb, 0, i); if (bit1 != bit) { test_msg("Testing bit pattern failed\n");