diff options
author | Kinsey Moore <kinsey.moore@oarcorp.com> | 2023-10-04 12:26:57 -0500 |
---|---|---|
committer | Joel Sherrill <joel@rtems.org> | 2023-10-12 18:56:43 -0500 |
commit | d7aa1ab86fc06799286eb5a648eeb488446c4bbc (patch) | |
tree | b0b1e07f4fe8d5001407852ad7db8ac07a06b960 /cpukit | |
parent | c5476e2b8c14b62a95a9fa35c1e4db0c4ae7bb7c (diff) |
cpukit/jffs2: Implement JFFS2 spinlocks
This provides a non-noop implementation of spinlocks for JFFS2 in terms
of RTEMS mutexes. POSIX spinlocks are not appropriate for the types of
actions that occur during a held JFFS2 spinlock and can cause bad
dispatch level conditions.
Diffstat (limited to 'cpukit')
-rw-r--r-- | cpukit/libfs/src/jffs2/include/linux/spinlock.h | 30 | ||||
-rw-r--r-- | cpukit/libfs/src/jffs2/src/fs-rtems.c | 2 |
2 files changed, 8 insertions, 24 deletions
diff --git a/cpukit/libfs/src/jffs2/include/linux/spinlock.h b/cpukit/libfs/src/jffs2/include/linux/spinlock.h index 22eba0ba55..44f6b7c53e 100644 --- a/cpukit/libfs/src/jffs2/include/linux/spinlock.h +++ b/cpukit/libfs/src/jffs2/include/linux/spinlock.h @@ -1,34 +1,16 @@ #ifndef __LINUX_SPINLOCK_H__ #define __LINUX_SPINLOCK_H__ +#include <rtems/thread.h> -typedef struct { } spinlock_t; -#define SPIN_LOCK_UNLOCKED (spinlock_t) { } -#define DEFINE_SPINLOCK(x) spinlock_t x = SPIN_LOCK_UNLOCKED +typedef struct { rtems_mutex r_m; } spinlock_t; -#define spin_lock_init(lock) \ -CYG_MACRO_START; \ -CYG_UNUSED_PARAM(spinlock_t *, lock); \ -CYG_MACRO_END +#define DEFINE_SPINLOCK(x) spinlock_t x -#define spin_lock(lock) \ -CYG_MACRO_START; \ -CYG_UNUSED_PARAM(spinlock_t *, lock); \ -CYG_MACRO_END +#define spin_lock_init(x) rtems_mutex_init(&(x)->r_m, "JFFS2 Spinlock"); -#define spin_unlock(lock) \ -CYG_MACRO_START; \ -CYG_UNUSED_PARAM(spinlock_t *, lock); \ -CYG_MACRO_END +#define spin_lock(x) rtems_mutex_lock(&(x)->r_m); -#define spin_lock_bh(lock) \ -CYG_MACRO_START; \ -CYG_UNUSED_PARAM(spinlock_t *, lock); \ -CYG_MACRO_END - -#define spin_unlock_bh(lock) \ -CYG_MACRO_START; \ -CYG_UNUSED_PARAM(spinlock_t *, lock); \ -CYG_MACRO_END +#define spin_unlock(x) rtems_mutex_unlock(&(x)->r_m); #endif /* __LINUX_SPINLOCK_H__ */ diff --git a/cpukit/libfs/src/jffs2/src/fs-rtems.c b/cpukit/libfs/src/jffs2/src/fs-rtems.c index e47f2e7fd2..0d97e7a6fb 100644 --- a/cpukit/libfs/src/jffs2/src/fs-rtems.c +++ b/cpukit/libfs/src/jffs2/src/fs-rtems.c @@ -1384,6 +1384,8 @@ int rtems_jffs2_initialize( #ifdef CONFIG_JFFS2_FS_WRITEBUFFER add_delayed_work_to_chain(&c->wbuf_dwork); #endif + spin_lock_init(&c->erase_completion_lock); + spin_lock_init(&c->inocache_lock); c->mtd = NULL; rtems_recursive_mutex_init(&sb->s_mutex, RTEMS_FILESYSTEM_TYPE_JFFS2); } |