summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libdde_linux26/include/linux/spinlock.h19
-rw-r--r--libdde_linux26/lib/src/arch/l4/cli_sti.c85
-rw-r--r--libdde_linux26/lib/src/arch/l4/softirq.c3
-rw-r--r--ufs/Makefile2
-rw-r--r--ufs/ufs.h34
-rw-r--r--ufs/xinl.c2
6 files changed, 42 insertions, 103 deletions
diff --git a/libdde_linux26/include/linux/spinlock.h b/libdde_linux26/include/linux/spinlock.h
index 6830752b..ab862f99 100644
--- a/libdde_linux26/include/linux/spinlock.h
+++ b/libdde_linux26/include/linux/spinlock.h
@@ -372,10 +372,6 @@ extern int _atomic_dec_and_lock(atomic_t *atomic, spinlock_t *lock);
#else /* DDE_LINUX */
-unsigned long fake_local_irq_disable_flags(void);
-void fake_local_irq_enable(void);
-void fake_local_irq_restore(unsigned long flags);
-
#define spin_lock_init(l) \
do { \
ddekit_lock_init(&(l)->ddekit_lock); \
@@ -398,7 +394,7 @@ void fake_local_irq_restore(unsigned long flags);
#define read_lock(lock) spin_lock(lock)
#define write_lock(lock) spin_lock(lock)
-#define spin_lock_irq(lock) fake_local_irq_disable_flags(); spin_lock(lock)
+#define spin_lock_irq(lock) local_irq_disable(); spin_lock(lock)
#define spin_lock_bh(lock) spin_lock(lock)
#define read_lock_irq(lock) spin_lock_irq(lock)
#define read_lock_bh(lock) spin_lock_bh(lock)
@@ -415,7 +411,7 @@ void fake_local_irq_restore(unsigned long flags);
#define read_unlock(lock) spin_unlock(lock)
#define write_unlock(lock) spin_unlock(lock)
-#define spin_unlock_irq(lock) spin_unlock(lock); fake_local_irq_enable()
+#define spin_unlock_irq(lock) spin_unlock(lock); local_irq_enable()
#define spin_unlock_bh(lock) spin_unlock(lock)
#define read_unlock_irq(lock) spin_unlock_irq(lock)
#define read_unlock_bh(lock) spin_unlock_bh(lock)
@@ -424,7 +420,7 @@ void fake_local_irq_restore(unsigned long flags);
#define spin_lock_irqsave(lock, flags) \
do { \
- flags = fake_local_irq_disable_flags(); \
+ local_irq_save(flags); \
spin_lock(lock);\
} while (0);
@@ -434,7 +430,7 @@ void fake_local_irq_restore(unsigned long flags);
#define spin_unlock_irqrestore(lock, flags) \
do { \
spin_unlock(lock); \
- fake_local_irq_restore (flags); \
+ local_irq_restore(flags); \
} while (0);
#define read_unlock_irqrestore(lock, flags) spin_unlock_irqrestore(lock, flags)
@@ -450,7 +446,12 @@ static int __lockfunc spin_trylock(spinlock_t *lock)
#define _raw_spin_unlock(l) spin_unlock(l)
#define _raw_spin_trylock(l) spin_trylock(l)
-#define spin_trylock_irqsave(lock, flags) spin_trylock(lock)
+#define spin_trylock_irqsave(lock, flags) \
+({ \
+ local_irq_save(flags); \
+ spin_trylock(lock) ? \
+ 1 : ({ local_irq_restore(flags); 0; }); \
+})
#define read_trylock(l) spin_trylock(l)
#define write_trylock(l) read_trylock(l)
diff --git a/libdde_linux26/lib/src/arch/l4/cli_sti.c b/libdde_linux26/lib/src/arch/l4/cli_sti.c
index e55e6401..81864ebb 100644
--- a/libdde_linux26/lib/src/arch/l4/cli_sti.c
+++ b/libdde_linux26/lib/src/arch/l4/cli_sti.c
@@ -3,10 +3,7 @@
#include <linux/kernel.h>
/* IRQ lock reference counter */
-static atomic_t _refcnt = ATOMIC_INIT(0);
-/* Refcnt value at which unlocking the cli_lock (it's not always 0) */
-static int unlock_refcnt;
-static ddekit_lock_t cli_lock;
+static __thread atomic_t _refcnt = ATOMIC_INIT(0);
/* Check whether IRQs are currently disabled.
*
@@ -18,109 +15,31 @@ int raw_irqs_disabled_flags(unsigned long flags)
return ((int)flags > 0);
}
-/* If it does lock operation successfully, return > 0. Otherwise, 0. */
-static int nested_lock(ddekit_lock_t lock)
-{
- int do_lock = 0;
-
- if (ddekit_lock_try_lock(&lock)) { /* if we cannot lock */
- /* check who hold the lock. */
- if (_ddekit_lock_owner(&lock) != (int) ddekit_thread_myself()) {
- /* Someone else holds the lock,
- * or by the time I try to lock again,
- * the person has release the lock. */
- ddekit_lock_lock(&lock);
- do_lock = 1;
- }
- /* If I hold the lock myself, I don't need to worry
- * the lock will be released somewhere before I do it. */
- }
- else
- do_lock = 2;
-
- return do_lock;
-}
-
-unsigned long fake_local_irq_disable_flags(void)
-{
- return atomic_add_return (1, &_refcnt) - 1;
-}
-
-void fake_local_irq_enable(void)
-{
- atomic_set(&_refcnt, 0);
-}
-
-void fake_local_irq_restore(unsigned long flags)
-{
- atomic_set(&_refcnt, flags);
-}
-
/* Store the current flags state.
*
* This is done by returning the current refcnt.
*/
unsigned long __raw_local_save_flags(void)
{
- unsigned long flags;
- int do_lock = 0;
-
- if (cli_lock == NULL)
- ddekit_lock_init_unlocked(&cli_lock);
- /* It's important to do lock here.
- * Otherwise, a thread might not get correct flags. */
- do_lock = nested_lock(cli_lock);
- flags = (unsigned long)atomic_read(&_refcnt);
- if (do_lock)
- ddekit_lock_unlock(&cli_lock);
- return flags;
+ return (unsigned long)atomic_read(&_refcnt);
}
/* Restore IRQ state. */
void raw_local_irq_restore(unsigned long flags)
{
- Assert(cli_lock != NULL);
atomic_set(&_refcnt, flags);
- if (flags == unlock_refcnt) {
- ddekit_lock_unlock(&cli_lock);
- unlock_refcnt = 0;
- }
}
/* Disable IRQs by grabbing the IRQ lock. */
void raw_local_irq_disable(void)
{
- struct ddekit_thread *helder;
- int is_print = 0;
-
- if (cli_lock == NULL)
- ddekit_lock_init_unlocked(&cli_lock);
-
- if (nested_lock(cli_lock)) {
- /* Tell the corresponding restorer to release cli_lock,
- * but do not update the value if there has been a re-enable in
- * between, that would store a bogus value.
- * XXX: scenario that will still break:
- * save
- * disable
- * enable
- * save
- * disable
- * restore
- * restore
- */
- if (unlock_refcnt < atomic_read(&_refcnt))
- unlock_refcnt = atomic_read(&_refcnt);
- }
atomic_inc(&_refcnt);
}
/* Unlock the IRQ lock until refcnt is 0. */
void raw_local_irq_enable(void)
{
- Assert(cli_lock != NULL);
atomic_set(&_refcnt, 0);
- ddekit_lock_unlock(&cli_lock);
}
diff --git a/libdde_linux26/lib/src/arch/l4/softirq.c b/libdde_linux26/lib/src/arch/l4/softirq.c
index 67e8f5aa..21b36d17 100644
--- a/libdde_linux26/lib/src/arch/l4/softirq.c
+++ b/libdde_linux26/lib/src/arch/l4/softirq.c
@@ -172,6 +172,7 @@ static void tasklet_hi_action(struct softirq_action *a)
}
}
+
#define MAX_SOFTIRQ_RETRIES 10
/** Run softirq handlers
@@ -185,7 +186,6 @@ void __do_softirq(void)
/* reset softirq count */
set_softirq_pending(0);
- local_irq_enable();
/* While we have a softirq pending... */
while (pending) {
@@ -197,7 +197,6 @@ void __do_softirq(void)
/* remove pending flag for last softirq */
pending >>= 1;
}
- local_irq_disable();
/* Somebody might have scheduled another softirq in between
* (e.g., an IRQ thread or another tasklet). */
diff --git a/ufs/Makefile b/ufs/Makefile
index 02cf38ba..cf5c40d7 100644
--- a/ufs/Makefile
+++ b/ufs/Makefile
@@ -21,7 +21,7 @@ makemode := server
target = ufs
SRCS = alloc.c consts.c dir.c hyper.c inode.c main.c pager.c \
- sizes.c subr.c tables.c bmap.c pokeloc.c
+ sizes.c subr.c tables.c bmap.c pokeloc.c xinl.c
LCLHDRS = ufs.h fs.h dinode.h dir.h
OBJS = $(SRCS:.c=.o)
diff --git a/ufs/ufs.h b/ufs/ufs.h
index 5d823ebc..f59784d5 100644
--- a/ufs/ufs.h
+++ b/ufs/ufs.h
@@ -25,9 +25,16 @@
#include <hurd/diskfs.h>
#include <sys/mman.h>
#include <assert.h>
+#include <features.h>
#include "fs.h"
#include "dinode.h"
+#ifdef UFS_DEFINE_EI
+#define UFS_EI
+#else
+#define UFS_EI __extern_inline
+#endif
+
/* Define this if memory objects should not be cached by the kernel.
Normally, don't define it, but defining it causes a much greater rate
of paging requests, which may be helpful in catching bugs. */
@@ -150,8 +157,18 @@ unsigned log2_dev_blocks_per_dev_bsize;
/* Functions for looking inside disk_image */
+extern struct dinode * dino (ino_t inum);
+extern daddr_t * indir_block (daddr_t bno);
+extern struct cg * cg_locate (int ncg);
+extern void sync_disk_blocks (daddr_t blkno, size_t nbytes, int wait);
+extern void sync_dinode (int inum, int wait);
+extern short swab_short (short arg);
+extern long swab_long (long arg);
+extern long long swab_long_long (long long arg);
+
+#if defined(__USE_EXTERN_INLINES) || defined(UFS_DEFINE_EI)
/* Convert an inode number to the dinode on disk. */
-extern inline struct dinode *
+UFS_EI struct dinode *
dino (ino_t inum)
{
return (struct dinode *)
@@ -161,28 +178,28 @@ dino (ino_t inum)
}
/* Convert a indirect block number to a daddr_t table. */
-extern inline daddr_t *
+UFS_EI daddr_t *
indir_block (daddr_t bno)
{
return (daddr_t *) (disk_image + fsaddr (sblock, bno));
}
/* Convert a cg number to the cylinder group. */
-extern inline struct cg *
+UFS_EI struct cg *
cg_locate (int ncg)
{
return (struct cg *) (disk_image + fsaddr (sblock, cgtod (sblock, ncg)));
}
/* Sync part of the disk */
-extern inline void
+UFS_EI void
sync_disk_blocks (daddr_t blkno, size_t nbytes, int wait)
{
pager_sync_some (diskfs_disk_pager, fsaddr (sblock, blkno), nbytes, wait);
}
/* Sync an disk inode */
-extern inline void
+UFS_EI void
sync_dinode (int inum, int wait)
{
sync_disk_blocks (ino_to_fsba (sblock, inum), sblock->fs_fsize, wait);
@@ -190,26 +207,27 @@ sync_dinode (int inum, int wait)
/* Functions for byte swapping */
-extern inline short
+UFS_EI short
swab_short (short arg)
{
return (((arg & 0xff) << 8)
| ((arg & 0xff00) >> 8));
}
-extern inline long
+UFS_EI long
swab_long (long arg)
{
return (((long) swab_short (arg & 0xffff) << 16)
| swab_short ((arg & 0xffff0000) >> 16));
}
-extern inline long long
+UFS_EI long long
swab_long_long (long long arg)
{
return (((long long) swab_long (arg & 0xffffffff) << 32)
| swab_long ((arg & 0xffffffff00000000LL) >> 32));
}
+#endif /* Use extern inlines. */
/* Return ENTRY, after byteswapping it if necessary */
#define read_disk_entry(entry) \
diff --git a/ufs/xinl.c b/ufs/xinl.c
new file mode 100644
index 00000000..7994a1f7
--- /dev/null
+++ b/ufs/xinl.c
@@ -0,0 +1,2 @@
+#define UFS_DEFINE_EI
+#include "ufs.h"