#ifndef _FS_NILFS_NILFS_H_
#define _FS_NILFS_NILFS_H_
#include <sys/queue.h>
#include <sys/uio.h>
#include <sys/mutex.h>
#include <sys/bufq.h>
#include <sys/disk.h>
#include <sys/kthread.h>
#include <miscfs/genfs/genfs_node.h>
#include "nilfs_fs.h"
#define NILFS_DEBUG_VOLUMES 0x000001
#define NILFS_DEBUG_VFSCALL 0x000002
#define NILFS_DEBUG_CALL 0x000004
#define NILFS_DEBUG_LOCKING 0x000008
#define NILFS_DEBUG_NODE 0x000010
#define NILFS_DEBUG_LOOKUP 0x000020
#define NILFS_DEBUG_READDIR 0x000040
#define NILFS_DEBUG_TRANSLATE 0x000080
#define NILFS_DEBUG_STRATEGY 0x000100
#define NILFS_DEBUG_READ 0x000200
#define NILFS_DEBUG_WRITE 0x000400
#define NILFS_DEBUG_ATTR 0x001000
#define NILFS_DEBUG_EXTATTR 0x002000
#define NILFS_DEBUG_ALLOC 0x004000
#define NILFS_DEBUG_DIRHASH 0x010000
#define NILFS_DEBUG_NOTIMPL 0x020000
#define NILFS_DEBUG_SHEDULE 0x040000
#define NILFS_DEBUG_SYNC 0x100000
#define NILFS_DEBUG_PARANOIA 0x200000
extern int nilfs_verbose;
#define NILFS_DEBUGGING 0
#ifdef DEBUG
#define DPRINTF(name, arg) { \
if (nilfs_verbose & NILFS_DEBUG_##name) {\
printf arg;\
};\
}
#define DPRINTFIF(name, cond, arg) { \
if (nilfs_verbose & NILFS_DEBUG_##name) { \
if (cond) printf arg;\
};\
}
#else
#define DPRINTF(name, arg) {}
#define DPRINTFIF(name, cond, arg) {}
#endif
#define NILFS_INODE_HASHBITS 10
#define NILFS_INODE_HASHSIZE (1<<NILFS_INODE_HASHBITS)
#define NILFS_INODE_HASHMASK (NILFS_INODE_HASHSIZE - 1)
#define NILFS_DIRCOOKIE_DOT 1
#define VFSTONILFS(mp) ((struct nilfs_mount *)mp->mnt_data)
MALLOC_DECLARE(M_NILFSMNT);
MALLOC_DECLARE(M_NILFSTEMP);
extern struct pool nilfs_node_pool;
struct nilfs_node;
struct nilfs_mount;
#define NILFS_MAXNAMLEN 255
struct nilfs_mdt {
uint32_t entries_per_block;
uint32_t entries_per_group;
uint32_t blocks_per_group;
uint32_t groups_per_desc_block;
uint32_t blocks_per_desc_block;
};
struct nilfs_device {
struct vnode *devvp;
struct mount *vfs_mountp;
int refcnt;
uint64_t devsize;
uint32_t blocksize;
struct nilfs_super_block super, super2;
struct nilfs_node *dat_node;
struct nilfs_node *cp_node;
struct nilfs_node *su_node;
struct nilfs_mdt dat_mdt;
struct nilfs_mdt ifile_mdt;
int mount_state;
uint64_t last_seg_seq;
uint64_t last_seg_num;
uint64_t next_seg_num;
uint64_t last_cno;
struct nilfs_segment_summary last_segsum;
struct nilfs_super_root super_root;
int syncing;
kcondvar_t sync_cv;
uint32_t uncomitted_bl;
STAILQ_HEAD(nilfs_mnts, nilfs_mount) mounts;
SLIST_ENTRY(nilfs_device) next_device;
};
extern SLIST_HEAD(_nilfs_devices, nilfs_device) nilfs_devices;
struct nilfs_mount {
struct mount *vfs_mountp;
struct nilfs_device *nilfsdev;
struct nilfs_args mount_args;
struct nilfs_node *ifile_node;
STAILQ_ENTRY(nilfs_mount) next_mount;
};
struct nilfs_node {
struct genfs_node i_gnode;
struct vnode *vnode;
struct nilfs_mount *ump;
struct nilfs_device *nilfsdev;
ino_t ino;
struct nilfs_inode inode;
struct dirhash *dir_hash;
kmutex_t node_mutex;
kcondvar_t node_lock;
char const *lock_fname;
int lock_lineno;
uint32_t i_flags;
struct lockf *lockf;
LIST_ENTRY(nilfs_node) hashchain;
};
#define IN_ACCESS 0x0001
#define IN_CHANGE 0x0002
#define IN_UPDATE 0x0004
#define IN_MODIFY 0x0008
#define IN_MODIFIED 0x0010
#define IN_ACCESSED 0x0020
#define IN_RENAME 0x0040
#define IN_DELETED 0x0080
#define IN_LOCKED 0x0100
#define IN_SYNCED 0x0200
#define IN_CALLBACK_ULK 0x0400
#define IN_NODE_REBUILD 0x0800
#define IN_FLAGBITS \
"\10\1IN_ACCESS\2IN_CHANGE\3IN_UPDATE\4IN_MODIFY\5IN_MODIFIED" \
"\6IN_ACCESSED\7IN_RENAME\10IN_DELETED\11IN_LOCKED\12IN_SYNCED" \
"\13IN_CALLBACK_ULK\14IN_NODE_REBUILD"
#endif