11da177e4SLinus Torvalds /* 27b718769SNathan Scott * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc. 37b718769SNathan Scott * All Rights Reserved. 41da177e4SLinus Torvalds * 57b718769SNathan Scott * This program is free software; you can redistribute it and/or 67b718769SNathan Scott * modify it under the terms of the GNU General Public License as 71da177e4SLinus Torvalds * published by the Free Software Foundation. 81da177e4SLinus Torvalds * 97b718769SNathan Scott * This program is distributed in the hope that it would be useful, 107b718769SNathan Scott * but WITHOUT ANY WARRANTY; without even the implied warranty of 117b718769SNathan Scott * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 127b718769SNathan Scott * GNU General Public License for more details. 131da177e4SLinus Torvalds * 147b718769SNathan Scott * You should have received a copy of the GNU General Public License 157b718769SNathan Scott * along with this program; if not, write the Free Software Foundation, 167b718769SNathan Scott * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 171da177e4SLinus Torvalds */ 181da177e4SLinus Torvalds #ifndef __XFS_BUF_ITEM_H__ 191da177e4SLinus Torvalds #define __XFS_BUF_ITEM_H__ 201da177e4SLinus Torvalds 21a8272ce0SDavid Chinner extern kmem_zone_t *xfs_buf_item_zone; 22a8272ce0SDavid Chinner 231da177e4SLinus Torvalds /* 241da177e4SLinus Torvalds * This flag indicates that the buffer contains on disk inodes 251da177e4SLinus Torvalds * and requires special recovery handling. 261da177e4SLinus Torvalds */ 27c1155410SDave Chinner #define XFS_BLF_INODE_BUF 0x1 281da177e4SLinus Torvalds /* 291da177e4SLinus Torvalds * This flag indicates that the buffer should not be replayed 301da177e4SLinus Torvalds * during recovery because its blocks are being freed. 311da177e4SLinus Torvalds */ 32c1155410SDave Chinner #define XFS_BLF_CANCEL 0x2 331da177e4SLinus Torvalds /* 341da177e4SLinus Torvalds * This flag indicates that the buffer contains on disk 351da177e4SLinus Torvalds * user or group dquots and may require special recovery handling. 361da177e4SLinus Torvalds */ 37c1155410SDave Chinner #define XFS_BLF_UDQUOT_BUF 0x4 38c1155410SDave Chinner #define XFS_BLF_PDQUOT_BUF 0x8 39c1155410SDave Chinner #define XFS_BLF_GDQUOT_BUF 0x10 401da177e4SLinus Torvalds 41c1155410SDave Chinner #define XFS_BLF_CHUNK 128 42c1155410SDave Chinner #define XFS_BLF_SHIFT 7 431da177e4SLinus Torvalds #define BIT_TO_WORD_SHIFT 5 441da177e4SLinus Torvalds #define NBWORD (NBBY * sizeof(unsigned int)) 451da177e4SLinus Torvalds 461da177e4SLinus Torvalds /* 47*77c1a08fSDave Chinner * This is the structure used to lay out a buf log item in the 48*77c1a08fSDave Chinner * log. The data map describes which 128 byte chunks of the buffer 49*77c1a08fSDave Chinner * have been logged. 50*77c1a08fSDave Chinner */ 51*77c1a08fSDave Chinner #define XFS_BLF_DATAMAP_SIZE ((XFS_MAX_BLOCKSIZE / XFS_BLF_CHUNK) / NBWORD) 52*77c1a08fSDave Chinner 53*77c1a08fSDave Chinner typedef struct xfs_buf_log_format { 54*77c1a08fSDave Chinner unsigned short blf_type; /* buf log item type indicator */ 55*77c1a08fSDave Chinner unsigned short blf_size; /* size of this item */ 56*77c1a08fSDave Chinner ushort blf_flags; /* misc state */ 57*77c1a08fSDave Chinner ushort blf_len; /* number of blocks in this buf */ 58*77c1a08fSDave Chinner __int64_t blf_blkno; /* starting blkno of this buf */ 59*77c1a08fSDave Chinner unsigned int blf_map_size; /* used size of data bitmap in words */ 60*77c1a08fSDave Chinner unsigned int blf_data_map[XFS_BLF_DATAMAP_SIZE]; /* dirty bitmap */ 61*77c1a08fSDave Chinner } xfs_buf_log_format_t; 62*77c1a08fSDave Chinner 63*77c1a08fSDave Chinner /* 641da177e4SLinus Torvalds * buf log item flags 651da177e4SLinus Torvalds */ 661da177e4SLinus Torvalds #define XFS_BLI_HOLD 0x01 671da177e4SLinus Torvalds #define XFS_BLI_DIRTY 0x02 681da177e4SLinus Torvalds #define XFS_BLI_STALE 0x04 691da177e4SLinus Torvalds #define XFS_BLI_LOGGED 0x08 701da177e4SLinus Torvalds #define XFS_BLI_INODE_ALLOC_BUF 0x10 711da177e4SLinus Torvalds #define XFS_BLI_STALE_INODE 0x20 72ccf7c23fSDave Chinner #define XFS_BLI_INODE_BUF 0x40 731da177e4SLinus Torvalds 740b1b213fSChristoph Hellwig #define XFS_BLI_FLAGS \ 750b1b213fSChristoph Hellwig { XFS_BLI_HOLD, "HOLD" }, \ 760b1b213fSChristoph Hellwig { XFS_BLI_DIRTY, "DIRTY" }, \ 770b1b213fSChristoph Hellwig { XFS_BLI_STALE, "STALE" }, \ 780b1b213fSChristoph Hellwig { XFS_BLI_LOGGED, "LOGGED" }, \ 790b1b213fSChristoph Hellwig { XFS_BLI_INODE_ALLOC_BUF, "INODE_ALLOC" }, \ 80ccf7c23fSDave Chinner { XFS_BLI_STALE_INODE, "STALE_INODE" }, \ 81ccf7c23fSDave Chinner { XFS_BLI_INODE_BUF, "INODE_BUF" } 820b1b213fSChristoph Hellwig 831da177e4SLinus Torvalds 841da177e4SLinus Torvalds #ifdef __KERNEL__ 851da177e4SLinus Torvalds 861da177e4SLinus Torvalds struct xfs_buf; 871da177e4SLinus Torvalds struct xfs_mount; 881da177e4SLinus Torvalds struct xfs_buf_log_item; 891da177e4SLinus Torvalds 901da177e4SLinus Torvalds /* 911da177e4SLinus Torvalds * This is the in core log item structure used to track information 921da177e4SLinus Torvalds * needed to log buffers. It tracks how many times the lock has been 931da177e4SLinus Torvalds * locked, and which 128 byte chunks of the buffer are dirty. 941da177e4SLinus Torvalds */ 951da177e4SLinus Torvalds typedef struct xfs_buf_log_item { 961da177e4SLinus Torvalds xfs_log_item_t bli_item; /* common item structure */ 971da177e4SLinus Torvalds struct xfs_buf *bli_buf; /* real buffer pointer */ 981da177e4SLinus Torvalds unsigned int bli_flags; /* misc flags */ 991da177e4SLinus Torvalds unsigned int bli_recur; /* lock recursion count */ 1001da177e4SLinus Torvalds atomic_t bli_refcount; /* cnt of tp refs */ 1011da177e4SLinus Torvalds #ifdef XFS_TRANS_DEBUG 1021da177e4SLinus Torvalds char *bli_orig; /* original buffer copy */ 1031da177e4SLinus Torvalds char *bli_logged; /* bytes logged (bitmap) */ 1041da177e4SLinus Torvalds #endif 105*77c1a08fSDave Chinner struct xfs_buf_log_format bli_format; /* embedded in-log header */ 1061da177e4SLinus Torvalds } xfs_buf_log_item_t; 1071da177e4SLinus Torvalds 1081da177e4SLinus Torvalds void xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *); 1091da177e4SLinus Torvalds void xfs_buf_item_relse(struct xfs_buf *); 1101da177e4SLinus Torvalds void xfs_buf_item_log(xfs_buf_log_item_t *, uint, uint); 1111da177e4SLinus Torvalds uint xfs_buf_item_dirty(xfs_buf_log_item_t *); 1121da177e4SLinus Torvalds void xfs_buf_attach_iodone(struct xfs_buf *, 1131da177e4SLinus Torvalds void(*)(struct xfs_buf *, xfs_log_item_t *), 1141da177e4SLinus Torvalds xfs_log_item_t *); 1151da177e4SLinus Torvalds void xfs_buf_iodone_callbacks(struct xfs_buf *); 116ca30b2a7SChristoph Hellwig void xfs_buf_iodone(struct xfs_buf *, struct xfs_log_item *); 1171da177e4SLinus Torvalds 1181da177e4SLinus Torvalds #ifdef XFS_TRANS_DEBUG 1191da177e4SLinus Torvalds void 1201da177e4SLinus Torvalds xfs_buf_item_flush_log_debug( 1211da177e4SLinus Torvalds struct xfs_buf *bp, 1221da177e4SLinus Torvalds uint first, 1231da177e4SLinus Torvalds uint last); 1241da177e4SLinus Torvalds #else 1251da177e4SLinus Torvalds #define xfs_buf_item_flush_log_debug(bp, first, last) 1261da177e4SLinus Torvalds #endif 1271da177e4SLinus Torvalds 1281da177e4SLinus Torvalds #endif /* __KERNEL__ */ 1291da177e4SLinus Torvalds 1301da177e4SLinus Torvalds #endif /* __XFS_BUF_ITEM_H__ */ 131