ufs_trans.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (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 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _SYS_FS_UFS_TRANS_H
#define _SYS_FS_UFS_TRANS_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* Types of deltas
*/
typedef enum delta_type {
DT_NONE, /* 0 no assigned type */
DT_SB, /* 1 superblock */
DT_CG, /* 2 cylinder group */
DT_SI, /* 3 summary info */
DT_AB, /* 4 allocation block */
DT_ABZERO, /* 5 a zero'ed allocation block */
DT_DIR, /* 6 directory */
DT_INODE, /* 7 inode */
DT_FBI, /* 8 fbiwrite */
DT_QR, /* 9 quota record */
DT_COMMIT, /* 10 commit record */
DT_CANCEL, /* 11 cancel record */
DT_BOT, /* 12 begin transaction */
DT_EOT, /* 13 end transaction */
DT_UD, /* 14 userdata */
DT_SUD, /* 15 userdata found during log scan */
DT_SHAD, /* 16 data for a shadow inode */
DT_MAX /* 17 maximum delta type */
} delta_t;
/*
* transaction operation types
*/
typedef enum top_type {
TOP_READ_SYNC, /* 0 */
TOP_WRITE, /* 1 */
TOP_WRITE_SYNC, /* 2 */
TOP_SETATTR, /* 3 */
TOP_CREATE, /* 4 */
TOP_REMOVE, /* 5 */
TOP_LINK, /* 6 */
TOP_RENAME, /* 7 */
TOP_MKDIR, /* 8 */
TOP_RMDIR, /* 9 */
TOP_SYMLINK, /* 10 */
TOP_FSYNC, /* 11 */
TOP_GETPAGE, /* 12 */
TOP_PUTPAGE, /* 13 */
TOP_SBUPDATE_FLUSH, /* 14 */
TOP_SBUPDATE_UPDATE, /* 15 */
TOP_SBUPDATE_UNMOUNT, /* 16 */
TOP_SYNCIP_CLOSEDQ, /* 17 */
TOP_SYNCIP_FLUSHI, /* 18 */
TOP_SYNCIP_HLOCK, /* 19 */
TOP_SYNCIP_SYNC, /* 20 */
TOP_SYNCIP_FREE, /* 21 */
TOP_SBWRITE_RECLAIM, /* 22 */
TOP_SBWRITE_STABLE, /* 23 */
TOP_IFREE, /* 24 */
TOP_IUPDAT, /* 25 */
TOP_MOUNT, /* 26 */
TOP_COMMIT_ASYNC, /* 27 */
TOP_COMMIT_FLUSH, /* 28 */
TOP_COMMIT_UPDATE, /* 29 */
TOP_COMMIT_UNMOUNT, /* 30 */
TOP_SETSECATTR, /* 31 */
TOP_QUOTA, /* 32 */
TOP_ITRUNC, /* 33 */
TOP_MAX /* 34 */
} top_t;
struct inode;
struct ufsvfs;
/*
* vfs_log == NULL means not logging
*/
/*
* begin a synchronous transaction
*/
{\
if (TRANS_ISTRANS(ufsvfsp)) { \
error = 0; \
} \
}
/*
* begin a asynchronous transaction
*/
{\
if (TRANS_ISTRANS(ufsvfsp))\
}
/*
* try to begin a asynchronous transaction
*/
{\
if (TRANS_ISTRANS(ufsvfsp))\
else\
err = 0; \
}
/*
* Begin a synchronous or asynchronous transaction.
* The lint case is needed because vsize can be a constant.
*/
#ifndef __lint
{\
if (TRANS_ISTRANS(ufsvfsp)) {\
if (ufsvfsp->vfs_syncdir) {\
int error = 0; \
issync = 1; \
} else {\
issync = 0; \
}\
}\
}
#else /* __lint */
{\
if (TRANS_ISTRANS(ufsvfsp)) {\
if (ufsvfsp->vfs_syncdir) {\
int error = 0; \
issync = 1; \
} else {\
issync = 0; \
}\
}\
}
#endif /* __lint */
/*
* try to begin a synchronous or asynchronous transaction
*/
{\
if (TRANS_ISTRANS(ufsvfsp)) {\
if (ufsvfsp->vfs_syncdir) {\
issync = 1; \
} else {\
issync = 0; \
}\
}\
}\
/*
* end a asynchronous transaction
*/
{\
if (TRANS_ISTRANS(ufsvfsp))\
}
/*
* end a synchronous transaction
*/
{\
if (TRANS_ISTRANS(ufsvfsp))\
}
/*
* end a synchronous or asynchronous transaction
*/
{\
if (TRANS_ISTRANS(ufsvfsp))\
if (issync)\
else\
}
/*
* record a delta
*/
if (TRANS_ISTRANS(ufsvfsp)) \
/*
* cancel a delta
*/
if (TRANS_ISTRANS(ufsvfsp)) \
/*
* log a delta
*/
if (TRANS_ISTRANS(ufsvfsp)) \
/*
* check if a range is being canceled (converting from metadata into userdata)
*/
((TRANS_ISTRANS(ufsvfsp)) ? \
/*
* put the log into error state
*/
#define TRANS_SETERROR(ufsvfsp) \
if (TRANS_ISTRANS(ufsvfsp)) \
/*
* check if device has had an error
*/
#define TRANS_ISERROR(ufsvfsp) \
((TRANS_ISTRANS(ufsvfsp)) ? \
/*
* The following macros provide a more readable interface to TRANS_DELTA
*/
/*
* If ever parts of an inode except the timestamps are logged using
* this macro (or any other technique), bootloader logging support must
* be made aware of these changes.
*/
/*
* Check if we need to log cylinder group summary info.
*/
if (TRANS_ISTRANS(ufsvfsp)) \
if (ufsvfsp->vfs_nolog_si) \
else \
#define TRANS_QUOTA(dqp) \
if (TRANS_ISTRANS(ufsvfsp) && \
ufs_trans_dqrele(dqp); \
} else { \
}
else \
/*
* These functions "wrap" functions that are not VOP or VFS
* entry points but must still use the TRANS_BEGIN/TRANS_END
* protocol
*/
#ifdef DEBUG
/*
* The following ops maintain the metadata map.
* These ops are *not* used in the production product.
*/
/*
* Set a flag if meta data checking.
*/
#define TRANS_DOMATAMAP(ufsvfsp) \
ufsvfsp->vfs_domatamap = \
(TRANS_ISTRANS(ufsvfsp) && \
if (ufsvfsp->vfs_domatamap) \
if (ufsvfsp->vfs_domatamap) \
if (ufsvfsp->vfs_domatamap) \
#define TRANS_MATA_MOUNT(ufsvfsp) \
if (ufsvfsp->vfs_domatamap) \
#define TRANS_MATA_UMOUNT(ufsvfsp) \
if (ufsvfsp->vfs_domatamap) \
if (ufsvfsp->vfs_domatamap) \
#else /* !DEBUG */
#define TRANS_DOMATAMAP(ufsvfsp)
#define TRANS_MATA_MOUNT(ufsvfsp)
#define TRANS_MATA_UMOUNT(ufsvfsp)
#endif /* !DEBUG */
/*
* identifies the type of operation passed into TRANS_BEGIN/END
*/
#define TOP_SYNC (0x00000001)
#define TOP_ASYNC (0x00000002)
/*
* estimated values
*/
#define HEADERSIZE (128)
#define ALLOCSIZE (160)
/*
* calculated values
*/
/*
* size calculations
*/
#define TOP_CREATE_SIZE(IP) \
#define TOP_REMOVE_SIZE(IP) \
#define TOP_LINK_SIZE(IP) \
#define TOP_RENAME_SIZE(IP) \
#define TOP_MKDIR_SIZE(IP) \
#define TOP_SYMLINK_SIZE(IP) \
#define TOP_GETPAGE_SIZE(IP) \
#define TOP_SYNCIP_SIZE INODESIZE
#define TOP_READ_SIZE INODESIZE
#define TOP_QUOTA_SIZE (QUOTASIZE)
#define TOP_SBUPDATE_SIZE (SIZESB)
#define TOP_SBWRITE_SIZE (SIZESB)
#define TOP_MOUNT_SIZE (SIZESB)
#define TOP_COMMIT_SIZE (0)
/*
* The minimum log size is 1M. So we will allow 1 fs operation to
* reserve at most 512K of log space.
*/
/*
* ufs trans function prototypes
*/
extern int ufs_trans_hlock();
extern void ufs_trans_onerror();
top_t);
extern void ufs_trans_iupdat(struct inode *, int);
extern void ufs_trans_mata_mount(struct ufsvfs *);
extern void ufs_trans_mata_umount(struct ufsvfs *);
extern void ufs_trans_mata_iget(struct inode *);
extern void ufs_trans_quota(struct dquot *);
extern void ufs_trans_dqrele(struct dquot *);
cred_t *);
cred_t *, int, long);
int *, int *);
extern int ufs_trans_check(dev_t);
/*
* transaction prototypes
*/
int *error);
int tryasync);
#endif /* defined(_KERNEL) && defined(__STDC__) */
#ifdef __cplusplus
}
#endif
#endif /* _SYS_FS_UFS_TRANS_H */