ifnot(ino->c_refs)
panic("inode freed.");
- /* If the inode has no links and no refs, it must have
- its blocks freed. */
+ ifnot(--ino->c_refs) {
+ /* If the inode has no links and no refs, it must have
+ its blocks freed. */
- ifnot(--ino->c_refs || ino->c_node.i_nlink) {
-/*
- SN (mcy)
-*/
-
- m = swizzle16(ino->c_node.i_mode);
- if (((m & F_MASK) == F_REG) ||
- ((m & F_MASK) == F_DIR) || ((m & F_MASK) == F_PIPE)) {
- udata.u_offset = 0;
- f_trunc(ino);
- }
- }
- /* If the inode was modified, we must write it to disk. */
- if (!(ino->c_refs) && ino->c_dirty) {
ifnot(ino->c_node.i_nlink) {
+ m = swizzle16(ino->c_node.i_mode);
+ if (((m & F_MASK) == F_REG) ||
+ ((m & F_MASK) == F_DIR) ||
+ ((m & F_MASK) == F_PIPE)) {
+ udata.u_offset = 0;
+ f_trunc(ino);
+ }
ino->c_node.i_mode = 0;
i_free(ino->c_dev, ino->c_num);
}
- wr_inode(ino);
+
+ /* If the inode was modified, we must write it to disk. */
+ if (ino->c_dirty)
+ wr_inode(ino);
}
}
int32_t blocks;
int j;
+ /*
+ * Note: the previous i_deref() logic relied on f_trunc() always
+ * dirtying the file, and this is no longer the case, must fix it
+ */
if (udata.u_offset >= ino->c_node.i_size)
return;
./pp.sh moveable_core_inode_swap
rm moveable_core_inode_swap/swap.[ch]
cp rassert.h fuzix_fs.[ch] util.[ch] moveable_core_inode_swap
+
+# must leave in a fit state for compiling the pool test
+sed -e 's/^\/\/#define CLASSIC_POOL 1/#define CLASSIC_POOL 1/' -i pool.h
#include <stdbool.h>
-//#define CLASSIC_POOL 1
+#define CLASSIC_POOL 1
#define MOVEABLE_POOL 1
struct pool_item {
(process->swap_inode = i_open(0, 0)) == NULL
)
return false;
+ //printf("open inode %d\n", process->swap_inode->c_num);
// initialize swap inode
process->swap_inode->c_node.i_uid = udata.u_euid;
#else
if (!core_table_alloc(&process->core_item, blocks)) {
#ifdef INODE_SWAP
+ //printf("deref inode %d\n", process->swap_inode->c_num);
i_deref(process->swap_inode);
#elif defined(PREALLOCATE_SWAP) && !defined(MOVEABLE_SWAP)
swap_table_free(&process->swap_item);
#ifdef PREALLOCATE_SWAP
swap_table_free(&process->swap_item);
#elif defined(INODE_SWAP)
+ //printf("deref inode %d\n", process->swap_inode->c_num);
i_deref(process->swap_inode);
#endif
#endif
);
#ifdef INODE_SWAP
+ //printf("deref inode %d\n", processes[i].swap_inode->c_num);
i_deref(processes[i].swap_inode);
#elif defined(INDIRECT_SWAP)
swap_block_free(swap_table_mem + swap_base, swap_blocks);