From patchwork Tue Nov 15 22:56:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 125881 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 14919B6F95 for ; Wed, 16 Nov 2011 09:56:13 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756829Ab1KOW4L (ORCPT ); Tue, 15 Nov 2011 17:56:11 -0500 Received: from mail-ey0-f202.google.com ([209.85.215.202]:62151 "EHLO mail-ey0-f202.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756800Ab1KOW4K (ORCPT ); Tue, 15 Nov 2011 17:56:10 -0500 Received: by eyg5 with SMTP id 5so200774eyg.1 for ; Tue, 15 Nov 2011 14:56:09 -0800 (PST) Received: by 10.14.18.98 with SMTP id k74mr1725747eek.6.1321397769261; Tue, 15 Nov 2011 14:56:09 -0800 (PST) Received: from hpza10.eem.corp.google.com ([74.125.121.33]) by gmr-mx.google.com with ESMTPS id n13si12113722eef.2.2011.11.15.14.56.09 (version=TLSv1/SSLv3 cipher=AES128-SHA); Tue, 15 Nov 2011 14:56:09 -0800 (PST) Received: from wpaz9.hot.corp.google.com (wpaz9.hot.corp.google.com [172.24.198.73]) by hpza10.eem.corp.google.com (Postfix) with ESMTPS id F34CA20004E; Tue, 15 Nov 2011 14:56:08 -0800 (PST) Received: from localhost.localdomain (akpm.mtv.corp.google.com [172.18.96.75]) by wpaz9.hot.corp.google.com with ESMTP id pAFMu6Xw017147; Tue, 15 Nov 2011 14:56:07 -0800 Message-Id: <201111152256.pAFMu6Xw017147@wpaz9.hot.corp.google.com> Subject: [patch 1/1] ext4: use proper little-endian bitops To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org, akpm@linux-foundation.org, akinobu.mita@gmail.com, adilger.kernel@dilger.ca From: akpm@linux-foundation.org Date: Tue, 15 Nov 2011 14:56:06 -0800 MIME-Version: 1.0 Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Akinobu Mita Subject: ext4: use proper little-endian bitops ext4_{set,clear}_bit() is defined as __test_and_{set,clear}_bit_le() for ext4. Only two ext4_{set,clear}_bit() calls check the return value. The rest of calls ignore the return value and they can be replaced with __{set,clear}_bit_le(). This changes ext4_{set,clear}_bit() from __test_and_{set,clear}_bit_le() to __{set,clear}_bit_le() and introduces ext4_test_and_{set,clear}_bit() for the two places where old bit needs to be returned. This ext4_{set,clear}_bit() change is considered safe, because if someone uses these macros without noticing the change, new ext4_{set,clear}_bit don't have return value and causes compiler errors where the return value is used. This also removes unused ext4_find_first_zero_bit(). Signed-off-by: Akinobu Mita Cc: "Theodore Ts'o" Cc: Andreas Dilger Signed-off-by: Andrew Morton --- fs/ext4/ext4.h | 7 ++++--- fs/ext4/ialloc.c | 4 ++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff -puN fs/ext4/ext4.h~ext4-use-proper-little-endian-bitops fs/ext4/ext4.h --- a/fs/ext4/ext4.h~ext4-use-proper-little-endian-bitops +++ a/fs/ext4/ext4.h @@ -957,12 +957,13 @@ struct ext4_inode_info { #define test_opt2(sb, opt) (EXT4_SB(sb)->s_mount_opt2 & \ EXT4_MOUNT2_##opt) -#define ext4_set_bit __test_and_set_bit_le +#define ext4_test_and_set_bit __test_and_set_bit_le +#define ext4_set_bit __set_bit_le #define ext4_set_bit_atomic ext2_set_bit_atomic -#define ext4_clear_bit __test_and_clear_bit_le +#define ext4_test_and_clear_bit __test_and_clear_bit_le +#define ext4_clear_bit __clear_bit_le #define ext4_clear_bit_atomic ext2_clear_bit_atomic #define ext4_test_bit test_bit_le -#define ext4_find_first_zero_bit find_first_zero_bit_le #define ext4_find_next_zero_bit find_next_zero_bit_le #define ext4_find_next_bit find_next_bit_le diff -puN fs/ext4/ialloc.c~ext4-use-proper-little-endian-bitops fs/ext4/ialloc.c --- a/fs/ext4/ialloc.c~ext4-use-proper-little-endian-bitops +++ a/fs/ext4/ialloc.c @@ -252,7 +252,7 @@ void ext4_free_inode(handle_t *handle, s fatal = ext4_journal_get_write_access(handle, bh2); } ext4_lock_group(sb, block_group); - cleared = ext4_clear_bit(bit, bitmap_bh->b_data); + cleared = ext4_test_and_clear_bit(bit, bitmap_bh->b_data); if (fatal || !cleared) { ext4_unlock_group(sb, block_group); goto out; @@ -618,7 +618,7 @@ static int ext4_claim_inode(struct super */ down_read(&grp->alloc_sem); ext4_lock_group(sb, group); - if (ext4_set_bit(ino, inode_bitmap_bh->b_data)) { + if (ext4_test_and_set_bit(ino, inode_bitmap_bh->b_data)) { /* not a free inode */ retval = 1; goto err_ret;