__atomic_store(ptr, &__n, __ATOMIC_RELAXED); \
} while(0)
+#define erofs_atomic_set_bit(bit, ptr) do { \
+ typeof(*ptr) __n = (1 << bit); \
+ __atomic_or_fetch(ptr, __n, __ATOMIC_ACQ_REL); \
+} while(0)
+
#define erofs_atomic_test_and_set(ptr) \
__atomic_test_and_set(ptr, __ATOMIC_RELAXED)
EROFS_FEATURE_FUNCS(sb_chksum, compat, COMPAT_SB_CHKSUM)
EROFS_FEATURE_FUNCS(xattr_filter, compat, COMPAT_XATTR_FILTER)
-#define EROFS_I_EA_INITED (1 << 0)
-#define EROFS_I_Z_INITED (1 << 1)
+#define EROFS_I_EA_INITED_BIT 0
+#define EROFS_I_Z_INITED_BIT 1
+
+#define EROFS_I_EA_INITED (1 << EROFS_I_EA_INITED_BIT)
+#define EROFS_I_Z_INITED (1 << EROFS_I_Z_INITED_BIT)
struct erofs_diskbuf;
union {
/* (erofsfuse) runtime flags */
- unsigned int flags;
+ erofs_atomic_t flags;
/* (mkfs.erofs) next pointer for directory dumping */
struct erofs_inode *next_dirwrite;
int ret = 0;
/* the most case is that xattrs of this inode are initialized. */
- if (vi->flags & EROFS_I_EA_INITED)
+ if (erofs_atomic_read(&vi->flags) & EROFS_I_EA_INITED)
return ret;
/*
le32_to_cpu(*(__le32 *)(it.kaddr + it.ofs));
it.ofs += sizeof(__le32);
}
-
- vi->flags |= EROFS_I_EA_INITED;
-
+ erofs_atomic_set_bit(EROFS_I_EA_INITED_BIT, &vi->flags);
return ret;
}
struct erofs_sb_info *sbi = vi->sbi;
int err, headnr;
- if (vi->flags & EROFS_I_Z_INITED)
+ if (erofs_atomic_read(&vi->flags) & EROFS_I_Z_INITED)
return 0;
pos = round_up(erofs_iloc(vi) + vi->inode_isize + vi->xattr_isize, 8);
return err;
}
out:
- vi->flags |= EROFS_I_Z_INITED;
+ erofs_atomic_set_bit(EROFS_I_Z_INITED_BIT, &vi->flags);
return 0;
}