Re: [PATCH 1/2] ext4: use little-endian bitops directly

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 2011-05-30, at 9:45 PM, Akinobu Mita wrote:
> 2011/5/31 Andreas Dilger <adilger@xxxxxxxxx>:
>> 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@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux