[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <4B858003-053B-4895-BAD7-71861AAFB00E@dilger.ca>
Date: Mon, 30 May 2011 22:56:48 -0600
From: Andreas Dilger <adilger@...ger.ca>
To: Akinobu Mita <akinobu.mita@...il.com>
Cc: "Ted Ts'o" <tytso@....edu>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-ext4@...r.kernel.org" <linux-ext4@...r.kernel.org>
Subject: Re: [PATCH 1/2] ext4: use little-endian bitops directly
On 2011-05-30, at 9:45 PM, Akinobu Mita wrote:
> 2011/5/31 Andreas Dilger <adilger@...ger.ca>:
>> I would also encourage you to finish off this patch series by pushing up the generic ext2_{set,clear}_bit_atomic() to the few places that are currently using ext2_{set,clear}_bit_atomic() directly (looks like only fs/nilfs2/alloc.h and include/linux/ext3.h) and then removing them from the arch headers.
>
> The difficulty of doing this is that there are two different
> implementations of ext2_{set,clear}_bit_atomic (spin lock version and
> test_and_{set,clear}_bit_le version). If we can switch to one of which
> on all architectures, the change is easy. But I don't have less messy idea
> to keep current behavior on all architectures.
It looks like all of the versions that are #defined in arch/*/asm/bitops.h are really just re-implementations of test_and_{set,clear}_bit_le(), since they ignore the "lock" parameter entirely.
It would be sufficient to replace all of those implementations with:
#define ARCH_NO_EXT2_ATOMIC_SPINLOCK
#include <asm-generic/bitops/ext2-atomic.h>
and then change the ext2-atomic.h to check for this:
#ifdef ARCH_NO_EXT2_ATOMIC_SPINLOCK
#define EXT2_SPIN_LOCK(lock) do {} while(0)
#define EXT2_SPIN_UNLOCK(lock) do {} while(0)
#else
#define EXT2_SPIN_LOCK(lock) spin_lock(lock)
#define EXT2_SPIN_UNLOCK(lock) spin_unlock(lock)
#endif
#define ext2_set_bit_atomic(lock, nr, addr) \
({ \
int ret; \
EXT2_SPIN_LOCK(lock); \
ret = __test_and_set_bit_le(nr, addr); \
EXT2_SPIN_UNLOCK(lock); \
ret; \
})
#define ext2_clear_bit_atomic(lock, nr, addr) \
({ \
int ret; \
EXT2_SPIN_LOCK(lock); \
ret = __test_and_clear_bit_le(nr, addr);\
EXT2_SPIN_UNLOCK(lock); \
ret; \
})
Cheers, Andreas
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Powered by blists - more mailing lists