ufs_log.h revision e7da395a007eee67416a7380ecc1fb2141ef39d1
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_FS_UFS_LOG_H
#define _SYS_FS_UFS_LOG_H
#ifdef __cplusplus
extern "C" {
#endif
typedef struct lufs_save {
int sv_error;
} lufs_save_t;
typedef struct lufs_buf {
void *lb_ptr;
} lufs_buf_t;
/*
* Log space is stored as extents
*/
#define LUFS_EXTENTS (UINT32_C(0))
#define LS_SECTORS 2
typedef struct extent {
/* in disk blocks for non-MTB ufs */
/* in frags for MTB ufs */
} extent_t;
typedef struct ic_extent {
/* (always in disk blocks) */
} ic_extent_t;
typedef struct extent_block {
/* structure on disk. */
typedef struct ic_extent_block {
/*
* Don't size the incore buffers too small or too large
*/
/*
* LDL_DIVISOR (ldl_divisor) is the number to calculate the log size
* from the file system size according to the calculation in lufs_enable()
*/
/*
* This gives the maximum size of log for which the 1MB per 1GB rule
* applies. The size of the log will only be greater than this based
* on the cylinder group space requirements.
*/
/*
*/
/*
* Log space requirement per cylinder group. This needs to accommodate a
* cg delta (inc. header) and have a factor to cover other deltas involved
* in a single transaction which could touch all cyl groups in a file system.
*/
#define LDL_CGSIZEREQ(fs) \
typedef struct cirbuf {
} cirbuf_t;
#define LUFS_VERSION_LATEST LUFS_VERSION
/*
* The old Disksuite unit structure has been split into two parts -- the
* incore part which is created at run time and the ondisk structure. To
* minimize code changes, the incore structure retains the old name,
* ml_unit_t and the ondisk structure is called ml_odunit_t. The ondisk
* structure is stored at the beginning of the log.
*
* This structure must fit into a sector (512b)
*
*/
typedef struct ml_odunit {
/*
* Important constants
*/
/*
* The disk space is split into state and circular log
*/
/*
* Head and tail of log
*/
/*
* Used for error recovery
*/
/*
* Debug bits
*/
/*
* Misc
*/
} ml_odunit_t;
typedef struct ml_unit {
int un_flags; /* Incore state */
/*
* Used for managing transactions
*/
/*
* Used during logscan
*/
/*
*/
/*
* Ondisk state
*/
/*
* locks
*/
} ml_unit_t;
/*
* Macros to allow access to the ondisk elements via the ml_unit_t incore
* structure.
*/
/*
* un_flags
*/
typedef struct sect_trailer {
/*
* map block
*/
#define MAPBLOCKSIZE (8192)
#define MAPBLOCKSHIFT (13)
#define MAPBLOCKMASK (~MAPBLOCKOFF)
/*
* cached roll buffer
*/
typedef struct crb {
} crb_t;
/*
* delta header
*/
struct delta {
/* delta */
};
/*
* common map entry
*/
typedef struct mapentry mapentry_t;
struct mapentry {
/*
* doubly linked list of all mapentries in map -- MUST BE FIRST
*/
int (*me_func)();
};
/*
* me_flags
*/
/*
* MAP TYPES
*/
enum maptypes {
};
/*
* MAP
*/
#define DELTAMAP_NHASH (512)
#define LOGMAP_NHASH (2048)
typedef struct mt_map {
/*
* anchor doubly linked list this map's entries -- MUST BE FIRST
*/
int mtm_flags; /* generic flags */
int mtm_ref; /* PTE like ref bit */
long mtm_nme; /* # of mapentries */
long mtm_nmet; /* # of mapentries this transaction */
long mtm_cfrags; /* Canceled frags */
long mtm_cfragmax; /* Maximum canceled frags */
/*
* used after logscan to set the log's tail
*/
/*
* debug field for Scan test
*/
/*
* moby trans stuff
*/
long mtm_wantin;
long mtm_active;
long mtm_activesync;
/*
* mutex that protects all the fields in mt_map except
* mtm_mapnext and mtm_refcnt
*/
/*
* logmap only condition variables
*/
/*
* rw lock for the agenext mapentry field
*/
/*
* DEBUG: runtestscan
*/
/*
* logmap only taskq sync count variable, protected by mtm_lock.
* keeps track of the number of pending top_issue_sync
* dispatches.
*/
int mtm_taskq_sync_count;
/*
* logmap only condition variable, to synchronize with lufs_unsnarf.
*/
} mt_map_t;
/*
* mtm_flags
*/
/*
* Generic range checking macros
*/
/*
* TRANSACTION OPS STATS
*/
typedef struct topstats {
} topstats_t;
/*
* fio_lufs_stats_t is used by _FIO_GET_TOP_STATS ioctl for getting topstats
*/
typedef struct fio_lufs_stats {
/*
* roll buf structure; one per roll buffer
*/
typedef uint16_t rbsecmap_t;
typedef struct rollbuf {
} rollbuf_t;
/*
* un_debug
* MT_TRANSACT - keep per thread accounting of tranactions
* MT_MATAMAP - double check deltas and ops against matamap
* MT_WRITE_CHECK - check master+deltas against metadata write
* MT_LOG_WRITE_CHECK - read after write for log writes
* MT_TRACE - trace transactions (used with MT_TRANSACT)
* MT_SIZE - fail on size errors (used with MT_TRANSACT)
* MT_NOASYNC - force every op to be sync
* MT_FORCEROLL - forcibly roll the log after every commit
* MT_SCAN - running runtestscan; special case as needed
*/
#define MT_NONE (0x00000000)
#define MT_TRANSACT (0x00000001)
#define MT_MATAMAP (0x00000002)
#define MT_WRITE_CHECK (0x00000004)
#define MT_LOG_WRITE_CHECK (0x00000008)
#define MT_CHECK_MAP (0x00000010)
#define MT_TRACE (0x00000020)
#define MT_SIZE (0x00000040)
#define MT_NOASYNC (0x00000080)
#define MT_FORCEROLL (0x00000100)
#define MT_SCAN (0x00000200)
struct logstats {
};
#ifdef _KERNEL
typedef struct threadtrans {
#ifdef DEBUG
#endif /* DEBUG */
/*
* Log layer protos -- lufs_log.c
*/
extern void ldl_round_commit(ml_unit_t *);
extern void ldl_push_commit(ml_unit_t *);
extern int ldl_need_commit(ml_unit_t *);
mapentry_t *);
extern void ldl_logscan_begin(ml_unit_t *);
extern void ldl_logscan_end(ml_unit_t *);
extern int ldl_need_roll(ml_unit_t *);
extern void ldl_seterror(ml_unit_t *, char *);
extern void ldl_savestate(ml_unit_t *);
extern void free_cirbuf(cirbuf_t *);
/*
* trans driver layer -- lufs.c
*/
extern void lufs_init(void);
/*
* transaction op layer -- lufs_top.c
*/
extern void _init_top(void);
/*
* map layer -- lufs_map.c
*/
extern void map_free_entries(mt_map_t *);
extern int deltamap_need_commit(mt_map_t *);
extern void deltamap_push(ml_unit_t *);
extern void logmap_cancel_remove(mt_map_t *);
extern int logmap_need_commit(mt_map_t *);
extern int logmap_need_roll_async(mt_map_t *);
extern int logmap_need_roll_sync(mt_map_t *);
extern void logmap_start_roll(ml_unit_t *);
extern void logmap_kill_roll(ml_unit_t *);
extern void logmap_forceroll(mt_map_t *);
extern void logmap_forceroll_nowait(mt_map_t *);
mapentry_t **);
mapentry_t *);
extern void logmap_logscan(ml_unit_t *);
extern void _init_map(void);
/*
* scan and roll threads -- lufs_thread.c
*/
extern void trans_roll(ml_unit_t *);
/*
* DEBUG
*/
#ifdef DEBUG
extern int map_put_debug(mt_map_t *);
extern int ldl_sethead_debug(ml_unit_t *);
extern int map_check_linkage(mt_map_t *);
mapentry_t *);
extern int top_roll_debug(ml_unit_t *);
extern int top_init_debug(void);
extern int lufs_initialize_debug(ml_odunit_t *);
#endif /* DEBUG */
extern int ufs_crb_enable;
extern uint32_t ufs_ncg_log;
extern uint_t lufs_debug;
#endif /* _KERNEL */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_FS_UFS_LOG_H */