11da177e4SLinus Torvalds /* 21da177e4SLinus Torvalds * Copyright (c) 2000-2001 Silicon Graphics, Inc. All Rights Reserved. 31da177e4SLinus Torvalds * 41da177e4SLinus Torvalds * This program is free software; you can redistribute it and/or modify it 51da177e4SLinus Torvalds * under the terms of version 2 of the GNU General Public License as 61da177e4SLinus Torvalds * published by the Free Software Foundation. 71da177e4SLinus Torvalds * 81da177e4SLinus Torvalds * This program is distributed in the hope that it would be useful, but 91da177e4SLinus Torvalds * WITHOUT ANY WARRANTY; without even the implied warranty of 101da177e4SLinus Torvalds * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 111da177e4SLinus Torvalds * 121da177e4SLinus Torvalds * Further, this software is distributed without any warranty that it is 131da177e4SLinus Torvalds * free of the rightful claim of any third person regarding infringement 141da177e4SLinus Torvalds * or the like. Any license provided herein, whether implied or 151da177e4SLinus Torvalds * otherwise, applies only to this software file. Patent licenses, if 161da177e4SLinus Torvalds * any, provided herein do not apply to combinations of this program with 171da177e4SLinus Torvalds * other software, or any other product whatsoever. 181da177e4SLinus Torvalds * 191da177e4SLinus Torvalds * You should have received a copy of the GNU General Public License along 201da177e4SLinus Torvalds * with this program; if not, write the Free Software Foundation, Inc., 59 211da177e4SLinus Torvalds * Temple Place - Suite 330, Boston MA 02111-1307, USA. 221da177e4SLinus Torvalds * 231da177e4SLinus Torvalds * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, 241da177e4SLinus Torvalds * Mountain View, CA 94043, or: 251da177e4SLinus Torvalds * 261da177e4SLinus Torvalds * http://www.sgi.com 271da177e4SLinus Torvalds * 281da177e4SLinus Torvalds * For further information regarding this notice, see: 291da177e4SLinus Torvalds * 301da177e4SLinus Torvalds * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ 311da177e4SLinus Torvalds */ 321da177e4SLinus Torvalds #ifndef __XFS_BUF_ITEM_H__ 331da177e4SLinus Torvalds #define __XFS_BUF_ITEM_H__ 341da177e4SLinus Torvalds 351da177e4SLinus Torvalds /* 361da177e4SLinus Torvalds * This is the structure used to lay out a buf log item in the 371da177e4SLinus Torvalds * log. The data map describes which 128 byte chunks of the buffer 381da177e4SLinus Torvalds * have been logged. This structure works only on buffers that 391da177e4SLinus Torvalds * reside up to the first TB in the filesystem. These buffers are 401da177e4SLinus Torvalds * generated only by pre-6.2 systems and are known as XFS_LI_6_1_BUF. 411da177e4SLinus Torvalds */ 421da177e4SLinus Torvalds typedef struct xfs_buf_log_format_v1 { 431da177e4SLinus Torvalds unsigned short blf_type; /* buf log item type indicator */ 441da177e4SLinus Torvalds unsigned short blf_size; /* size of this item */ 451da177e4SLinus Torvalds __int32_t blf_blkno; /* starting blkno of this buf */ 461da177e4SLinus Torvalds ushort blf_flags; /* misc state */ 471da177e4SLinus Torvalds ushort blf_len; /* number of blocks in this buf */ 481da177e4SLinus Torvalds unsigned int blf_map_size; /* size of data bitmap in words */ 491da177e4SLinus Torvalds unsigned int blf_data_map[1];/* variable size bitmap of */ 501da177e4SLinus Torvalds /* regions of buffer in this item */ 511da177e4SLinus Torvalds } xfs_buf_log_format_v1_t; 521da177e4SLinus Torvalds 531da177e4SLinus Torvalds /* 541da177e4SLinus Torvalds * This is a form of the above structure with a 64 bit blkno field. 551da177e4SLinus Torvalds * For 6.2 and beyond, this is XFS_LI_BUF. We use this to log everything. 561da177e4SLinus Torvalds */ 571da177e4SLinus Torvalds typedef struct xfs_buf_log_format_t { 581da177e4SLinus Torvalds unsigned short blf_type; /* buf log item type indicator */ 591da177e4SLinus Torvalds unsigned short blf_size; /* size of this item */ 601da177e4SLinus Torvalds ushort blf_flags; /* misc state */ 611da177e4SLinus Torvalds ushort blf_len; /* number of blocks in this buf */ 621da177e4SLinus Torvalds __int64_t blf_blkno; /* starting blkno of this buf */ 631da177e4SLinus Torvalds unsigned int blf_map_size; /* size of data bitmap in words */ 641da177e4SLinus Torvalds unsigned int blf_data_map[1];/* variable size bitmap of */ 651da177e4SLinus Torvalds /* regions of buffer in this item */ 661da177e4SLinus Torvalds } xfs_buf_log_format_t; 671da177e4SLinus Torvalds 681da177e4SLinus Torvalds /* 691da177e4SLinus Torvalds * This flag indicates that the buffer contains on disk inodes 701da177e4SLinus Torvalds * and requires special recovery handling. 711da177e4SLinus Torvalds */ 721da177e4SLinus Torvalds #define XFS_BLI_INODE_BUF 0x1 731da177e4SLinus Torvalds /* 741da177e4SLinus Torvalds * This flag indicates that the buffer should not be replayed 751da177e4SLinus Torvalds * during recovery because its blocks are being freed. 761da177e4SLinus Torvalds */ 771da177e4SLinus Torvalds #define XFS_BLI_CANCEL 0x2 781da177e4SLinus Torvalds /* 791da177e4SLinus Torvalds * This flag indicates that the buffer contains on disk 801da177e4SLinus Torvalds * user or group dquots and may require special recovery handling. 811da177e4SLinus Torvalds */ 821da177e4SLinus Torvalds #define XFS_BLI_UDQUOT_BUF 0x4 83*c8ad20ffSNathan Scott #define XFS_BLI_PDQUOT_BUF 0x8 841da177e4SLinus Torvalds #define XFS_BLI_GDQUOT_BUF 0x10 851da177e4SLinus Torvalds 861da177e4SLinus Torvalds #define XFS_BLI_CHUNK 128 871da177e4SLinus Torvalds #define XFS_BLI_SHIFT 7 881da177e4SLinus Torvalds #define BIT_TO_WORD_SHIFT 5 891da177e4SLinus Torvalds #define NBWORD (NBBY * sizeof(unsigned int)) 901da177e4SLinus Torvalds 911da177e4SLinus Torvalds /* 921da177e4SLinus Torvalds * buf log item flags 931da177e4SLinus Torvalds */ 941da177e4SLinus Torvalds #define XFS_BLI_HOLD 0x01 951da177e4SLinus Torvalds #define XFS_BLI_DIRTY 0x02 961da177e4SLinus Torvalds #define XFS_BLI_STALE 0x04 971da177e4SLinus Torvalds #define XFS_BLI_LOGGED 0x08 981da177e4SLinus Torvalds #define XFS_BLI_INODE_ALLOC_BUF 0x10 991da177e4SLinus Torvalds #define XFS_BLI_STALE_INODE 0x20 1001da177e4SLinus Torvalds 1011da177e4SLinus Torvalds 1021da177e4SLinus Torvalds #ifdef __KERNEL__ 1031da177e4SLinus Torvalds 1041da177e4SLinus Torvalds struct xfs_buf; 1051da177e4SLinus Torvalds struct ktrace; 1061da177e4SLinus Torvalds struct xfs_mount; 1071da177e4SLinus Torvalds struct xfs_buf_log_item; 1081da177e4SLinus Torvalds 1091da177e4SLinus Torvalds #if defined(XFS_BLI_TRACE) 1101da177e4SLinus Torvalds #define XFS_BLI_TRACE_SIZE 32 1111da177e4SLinus Torvalds 1121da177e4SLinus Torvalds void xfs_buf_item_trace(char *, struct xfs_buf_log_item *); 1131da177e4SLinus Torvalds #else 1141da177e4SLinus Torvalds #define xfs_buf_item_trace(id, bip) 1151da177e4SLinus Torvalds #endif 1161da177e4SLinus Torvalds 1171da177e4SLinus Torvalds /* 1181da177e4SLinus Torvalds * This is the in core log item structure used to track information 1191da177e4SLinus Torvalds * needed to log buffers. It tracks how many times the lock has been 1201da177e4SLinus Torvalds * locked, and which 128 byte chunks of the buffer are dirty. 1211da177e4SLinus Torvalds */ 1221da177e4SLinus Torvalds typedef struct xfs_buf_log_item { 1231da177e4SLinus Torvalds xfs_log_item_t bli_item; /* common item structure */ 1241da177e4SLinus Torvalds struct xfs_buf *bli_buf; /* real buffer pointer */ 1251da177e4SLinus Torvalds unsigned int bli_flags; /* misc flags */ 1261da177e4SLinus Torvalds unsigned int bli_recur; /* lock recursion count */ 1271da177e4SLinus Torvalds atomic_t bli_refcount; /* cnt of tp refs */ 1281da177e4SLinus Torvalds #ifdef XFS_BLI_TRACE 1291da177e4SLinus Torvalds struct ktrace *bli_trace; /* event trace buf */ 1301da177e4SLinus Torvalds #endif 1311da177e4SLinus Torvalds #ifdef XFS_TRANS_DEBUG 1321da177e4SLinus Torvalds char *bli_orig; /* original buffer copy */ 1331da177e4SLinus Torvalds char *bli_logged; /* bytes logged (bitmap) */ 1341da177e4SLinus Torvalds #endif 1351da177e4SLinus Torvalds xfs_buf_log_format_t bli_format; /* in-log header */ 1361da177e4SLinus Torvalds } xfs_buf_log_item_t; 1371da177e4SLinus Torvalds 1381da177e4SLinus Torvalds /* 1391da177e4SLinus Torvalds * This structure is used during recovery to record the buf log 1401da177e4SLinus Torvalds * items which have been canceled and should not be replayed. 1411da177e4SLinus Torvalds */ 1421da177e4SLinus Torvalds typedef struct xfs_buf_cancel { 1431da177e4SLinus Torvalds xfs_daddr_t bc_blkno; 1441da177e4SLinus Torvalds uint bc_len; 1451da177e4SLinus Torvalds int bc_refcount; 1461da177e4SLinus Torvalds struct xfs_buf_cancel *bc_next; 1471da177e4SLinus Torvalds } xfs_buf_cancel_t; 1481da177e4SLinus Torvalds 1491da177e4SLinus Torvalds void xfs_buf_item_init(struct xfs_buf *, struct xfs_mount *); 1501da177e4SLinus Torvalds void xfs_buf_item_relse(struct xfs_buf *); 1511da177e4SLinus Torvalds void xfs_buf_item_log(xfs_buf_log_item_t *, uint, uint); 1521da177e4SLinus Torvalds uint xfs_buf_item_dirty(xfs_buf_log_item_t *); 1531da177e4SLinus Torvalds void xfs_buf_attach_iodone(struct xfs_buf *, 1541da177e4SLinus Torvalds void(*)(struct xfs_buf *, xfs_log_item_t *), 1551da177e4SLinus Torvalds xfs_log_item_t *); 1561da177e4SLinus Torvalds void xfs_buf_iodone_callbacks(struct xfs_buf *); 1571da177e4SLinus Torvalds void xfs_buf_iodone(struct xfs_buf *, xfs_buf_log_item_t *); 1581da177e4SLinus Torvalds 1591da177e4SLinus Torvalds #ifdef XFS_TRANS_DEBUG 1601da177e4SLinus Torvalds void 1611da177e4SLinus Torvalds xfs_buf_item_flush_log_debug( 1621da177e4SLinus Torvalds struct xfs_buf *bp, 1631da177e4SLinus Torvalds uint first, 1641da177e4SLinus Torvalds uint last); 1651da177e4SLinus Torvalds #else 1661da177e4SLinus Torvalds #define xfs_buf_item_flush_log_debug(bp, first, last) 1671da177e4SLinus Torvalds #endif 1681da177e4SLinus Torvalds 1691da177e4SLinus Torvalds #endif /* __KERNEL__ */ 1701da177e4SLinus Torvalds 1711da177e4SLinus Torvalds #endif /* __XFS_BUF_ITEM_H__ */ 172