lkml.org 
[lkml]   [2011]   [May]   [31]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH 1/2] ext4: use little-endian bitops directly
From
Date
On 2011-05-30, at 9:45 PM, Akinobu Mita wrote:
> 2011/5/31 Andreas Dilger <adilger@dilger.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







\
 
 \ /
  Last update: 2011-05-31 06:59    [W:0.588 / U:0.032 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site