[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <BANLkTimnB5okiG_M9zhUG6F22PHPoAsZLw@mail.gmail.com>
Date: Tue, 31 May 2011 18:43:44 +0900
From: Akinobu Mita <akinobu.mita@...il.com>
To: Andreas Dilger <adilger@...ger.ca>
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
2011/5/31 Andreas Dilger <adilger@...ger.ca>:
> 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; \
> })
This is not equivalent change if ARCH_NO_EXT2_ATOMIC_SPINLOCK is defined
because ext2_set_bit_atomic for the majority of architectures is
#define ext2_set_bit_atomic(lock, nr, addr) \
test_and_set_bit_le((nr), (unsigned long*)addr)
So ext2-atomic.h could be:
#ifdef ARCH_NO_EXT2_ATOMIC_SPINLOCK
#define ext2_set_bit_atomic(l, nr, addr) test_and_set_bit_le(nr, addr)
#define ext2_clear_bit_atomic(l, nr, addr) test_and_clear_bit_le(nr, addr)
#else
#define ext2_set_bit_atomic(lock, nr, addr) \
({ \
int ret; \
spin_lock(lock); \
ret = __test_and_set_bit_le(nr, addr); \
spin_unlock(lock); \
ret; \
})
#define ext2_clear_bit_atomic(lock, nr, addr) \
({ \
int ret; \
spin_lock(lock); \
ret = __test_and_clear_bit_le(nr, addr); \
spin_unlock(lock); \
ret; \
})
#endif
--
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