162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-or-later */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) International Business Machines Corp., 2000-2004 462306a36Sopenharmony_ci * Portions Copyright (C) Christoph Hellwig, 2001-2002 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci#ifndef _H_JFS_LOGMGR 762306a36Sopenharmony_ci#define _H_JFS_LOGMGR 862306a36Sopenharmony_ci 962306a36Sopenharmony_ci#include <linux/uuid.h> 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci#include "jfs_filsys.h" 1262306a36Sopenharmony_ci#include "jfs_lock.h" 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci/* 1562306a36Sopenharmony_ci * log manager configuration parameters 1662306a36Sopenharmony_ci */ 1762306a36Sopenharmony_ci 1862306a36Sopenharmony_ci/* log page size */ 1962306a36Sopenharmony_ci#define LOGPSIZE 4096 2062306a36Sopenharmony_ci#define L2LOGPSIZE 12 2162306a36Sopenharmony_ci 2262306a36Sopenharmony_ci#define LOGPAGES 16 /* Log pages per mounted file system */ 2362306a36Sopenharmony_ci 2462306a36Sopenharmony_ci/* 2562306a36Sopenharmony_ci * log logical volume 2662306a36Sopenharmony_ci * 2762306a36Sopenharmony_ci * a log is used to make the commit operation on journalled 2862306a36Sopenharmony_ci * files within the same logical volume group atomic. 2962306a36Sopenharmony_ci * a log is implemented with a logical volume. 3062306a36Sopenharmony_ci * there is one log per logical volume group. 3162306a36Sopenharmony_ci * 3262306a36Sopenharmony_ci * block 0 of the log logical volume is not used (ipl etc). 3362306a36Sopenharmony_ci * block 1 contains a log "superblock" and is used by logFormat(), 3462306a36Sopenharmony_ci * lmLogInit(), lmLogShutdown(), and logRedo() to record status 3562306a36Sopenharmony_ci * of the log but is not otherwise used during normal processing. 3662306a36Sopenharmony_ci * blocks 2 - (N-1) are used to contain log records. 3762306a36Sopenharmony_ci * 3862306a36Sopenharmony_ci * when a volume group is varied-on-line, logRedo() must have 3962306a36Sopenharmony_ci * been executed before the file systems (logical volumes) in 4062306a36Sopenharmony_ci * the volume group can be mounted. 4162306a36Sopenharmony_ci */ 4262306a36Sopenharmony_ci/* 4362306a36Sopenharmony_ci * log superblock (block 1 of logical volume) 4462306a36Sopenharmony_ci */ 4562306a36Sopenharmony_ci#define LOGSUPER_B 1 4662306a36Sopenharmony_ci#define LOGSTART_B 2 4762306a36Sopenharmony_ci 4862306a36Sopenharmony_ci#define LOGMAGIC 0x87654321 4962306a36Sopenharmony_ci#define LOGVERSION 1 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ci#define MAX_ACTIVE 128 /* Max active file systems sharing log */ 5262306a36Sopenharmony_ci 5362306a36Sopenharmony_cistruct logsuper { 5462306a36Sopenharmony_ci __le32 magic; /* 4: log lv identifier */ 5562306a36Sopenharmony_ci __le32 version; /* 4: version number */ 5662306a36Sopenharmony_ci __le32 serial; /* 4: log open/mount counter */ 5762306a36Sopenharmony_ci __le32 size; /* 4: size in number of LOGPSIZE blocks */ 5862306a36Sopenharmony_ci __le32 bsize; /* 4: logical block size in byte */ 5962306a36Sopenharmony_ci __le32 l2bsize; /* 4: log2 of bsize */ 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci __le32 flag; /* 4: option */ 6262306a36Sopenharmony_ci __le32 state; /* 4: state - see below */ 6362306a36Sopenharmony_ci 6462306a36Sopenharmony_ci __le32 end; /* 4: addr of last log record set by logredo */ 6562306a36Sopenharmony_ci uuid_t uuid; /* 16: 128-bit journal uuid */ 6662306a36Sopenharmony_ci char label[16]; /* 16: journal label */ 6762306a36Sopenharmony_ci struct { 6862306a36Sopenharmony_ci uuid_t uuid; 6962306a36Sopenharmony_ci } active[MAX_ACTIVE]; /* 2048: active file systems list */ 7062306a36Sopenharmony_ci}; 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/* log flag: commit option (see jfs_filsys.h) */ 7362306a36Sopenharmony_ci 7462306a36Sopenharmony_ci/* log state */ 7562306a36Sopenharmony_ci#define LOGMOUNT 0 /* log mounted by lmLogInit() */ 7662306a36Sopenharmony_ci#define LOGREDONE 1 /* log shutdown by lmLogShutdown(). 7762306a36Sopenharmony_ci * log redo completed by logredo(). 7862306a36Sopenharmony_ci */ 7962306a36Sopenharmony_ci#define LOGWRAP 2 /* log wrapped */ 8062306a36Sopenharmony_ci#define LOGREADERR 3 /* log read error detected in logredo() */ 8162306a36Sopenharmony_ci 8262306a36Sopenharmony_ci 8362306a36Sopenharmony_ci/* 8462306a36Sopenharmony_ci * log logical page 8562306a36Sopenharmony_ci * 8662306a36Sopenharmony_ci * (this comment should be rewritten !) 8762306a36Sopenharmony_ci * the header and trailer structures (h,t) will normally have 8862306a36Sopenharmony_ci * the same page and eor value. 8962306a36Sopenharmony_ci * An exception to this occurs when a complete page write is not 9062306a36Sopenharmony_ci * accomplished on a power failure. Since the hardware may "split write" 9162306a36Sopenharmony_ci * sectors in the page, any out of order sequence may occur during powerfail 9262306a36Sopenharmony_ci * and needs to be recognized during log replay. The xor value is 9362306a36Sopenharmony_ci * an "exclusive or" of all log words in the page up to eor. This 9462306a36Sopenharmony_ci * 32 bit eor is stored with the top 16 bits in the header and the 9562306a36Sopenharmony_ci * bottom 16 bits in the trailer. logredo can easily recognize pages 9662306a36Sopenharmony_ci * that were not completed by reconstructing this eor and checking 9762306a36Sopenharmony_ci * the log page. 9862306a36Sopenharmony_ci * 9962306a36Sopenharmony_ci * Previous versions of the operating system did not allow split 10062306a36Sopenharmony_ci * writes and detected partially written records in logredo by 10162306a36Sopenharmony_ci * ordering the updates to the header, trailer, and the move of data 10262306a36Sopenharmony_ci * into the logdata area. The order: (1) data is moved (2) header 10362306a36Sopenharmony_ci * is updated (3) trailer is updated. In logredo, when the header 10462306a36Sopenharmony_ci * differed from the trailer, the header and trailer were reconciled 10562306a36Sopenharmony_ci * as follows: if h.page != t.page they were set to the smaller of 10662306a36Sopenharmony_ci * the two and h.eor and t.eor set to 8 (i.e. empty page). if (only) 10762306a36Sopenharmony_ci * h.eor != t.eor they were set to the smaller of their two values. 10862306a36Sopenharmony_ci */ 10962306a36Sopenharmony_cistruct logpage { 11062306a36Sopenharmony_ci struct { /* header */ 11162306a36Sopenharmony_ci __le32 page; /* 4: log sequence page number */ 11262306a36Sopenharmony_ci __le16 rsrvd; /* 2: */ 11362306a36Sopenharmony_ci __le16 eor; /* 2: end-of-log offset of lasrt record write */ 11462306a36Sopenharmony_ci } h; 11562306a36Sopenharmony_ci 11662306a36Sopenharmony_ci __le32 data[LOGPSIZE / 4 - 4]; /* log record area */ 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_ci struct { /* trailer */ 11962306a36Sopenharmony_ci __le32 page; /* 4: normally the same as h.page */ 12062306a36Sopenharmony_ci __le16 rsrvd; /* 2: */ 12162306a36Sopenharmony_ci __le16 eor; /* 2: normally the same as h.eor */ 12262306a36Sopenharmony_ci } t; 12362306a36Sopenharmony_ci}; 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ci#define LOGPHDRSIZE 8 /* log page header size */ 12662306a36Sopenharmony_ci#define LOGPTLRSIZE 8 /* log page trailer size */ 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_ci 12962306a36Sopenharmony_ci/* 13062306a36Sopenharmony_ci * log record 13162306a36Sopenharmony_ci * 13262306a36Sopenharmony_ci * (this comment should be rewritten !) 13362306a36Sopenharmony_ci * jfs uses only "after" log records (only a single writer is allowed 13462306a36Sopenharmony_ci * in a page, pages are written to temporary paging space if 13562306a36Sopenharmony_ci * they must be written to disk before commit, and i/o is 13662306a36Sopenharmony_ci * scheduled for modified pages to their home location after 13762306a36Sopenharmony_ci * the log records containing the after values and the commit 13862306a36Sopenharmony_ci * record is written to the log on disk, undo discards the copy 13962306a36Sopenharmony_ci * in main-memory.) 14062306a36Sopenharmony_ci * 14162306a36Sopenharmony_ci * a log record consists of a data area of variable length followed by 14262306a36Sopenharmony_ci * a descriptor of fixed size LOGRDSIZE bytes. 14362306a36Sopenharmony_ci * the data area is rounded up to an integral number of 4-bytes and 14462306a36Sopenharmony_ci * must be no longer than LOGPSIZE. 14562306a36Sopenharmony_ci * the descriptor is of size of multiple of 4-bytes and aligned on a 14662306a36Sopenharmony_ci * 4-byte boundary. 14762306a36Sopenharmony_ci * records are packed one after the other in the data area of log pages. 14862306a36Sopenharmony_ci * (sometimes a DUMMY record is inserted so that at least one record ends 14962306a36Sopenharmony_ci * on every page or the longest record is placed on at most two pages). 15062306a36Sopenharmony_ci * the field eor in page header/trailer points to the byte following 15162306a36Sopenharmony_ci * the last record on a page. 15262306a36Sopenharmony_ci */ 15362306a36Sopenharmony_ci 15462306a36Sopenharmony_ci/* log record types */ 15562306a36Sopenharmony_ci#define LOG_COMMIT 0x8000 15662306a36Sopenharmony_ci#define LOG_SYNCPT 0x4000 15762306a36Sopenharmony_ci#define LOG_MOUNT 0x2000 15862306a36Sopenharmony_ci#define LOG_REDOPAGE 0x0800 15962306a36Sopenharmony_ci#define LOG_NOREDOPAGE 0x0080 16062306a36Sopenharmony_ci#define LOG_NOREDOINOEXT 0x0040 16162306a36Sopenharmony_ci#define LOG_UPDATEMAP 0x0008 16262306a36Sopenharmony_ci#define LOG_NOREDOFILE 0x0001 16362306a36Sopenharmony_ci 16462306a36Sopenharmony_ci/* REDOPAGE/NOREDOPAGE log record data type */ 16562306a36Sopenharmony_ci#define LOG_INODE 0x0001 16662306a36Sopenharmony_ci#define LOG_XTREE 0x0002 16762306a36Sopenharmony_ci#define LOG_DTREE 0x0004 16862306a36Sopenharmony_ci#define LOG_BTROOT 0x0010 16962306a36Sopenharmony_ci#define LOG_EA 0x0020 17062306a36Sopenharmony_ci#define LOG_ACL 0x0040 17162306a36Sopenharmony_ci#define LOG_DATA 0x0080 17262306a36Sopenharmony_ci#define LOG_NEW 0x0100 17362306a36Sopenharmony_ci#define LOG_EXTEND 0x0200 17462306a36Sopenharmony_ci#define LOG_RELOCATE 0x0400 17562306a36Sopenharmony_ci#define LOG_DIR_XTREE 0x0800 /* Xtree is in directory inode */ 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ci/* UPDATEMAP log record descriptor type */ 17862306a36Sopenharmony_ci#define LOG_ALLOCXADLIST 0x0080 17962306a36Sopenharmony_ci#define LOG_ALLOCPXDLIST 0x0040 18062306a36Sopenharmony_ci#define LOG_ALLOCXAD 0x0020 18162306a36Sopenharmony_ci#define LOG_ALLOCPXD 0x0010 18262306a36Sopenharmony_ci#define LOG_FREEXADLIST 0x0008 18362306a36Sopenharmony_ci#define LOG_FREEPXDLIST 0x0004 18462306a36Sopenharmony_ci#define LOG_FREEXAD 0x0002 18562306a36Sopenharmony_ci#define LOG_FREEPXD 0x0001 18662306a36Sopenharmony_ci 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_cistruct lrd { 18962306a36Sopenharmony_ci /* 19062306a36Sopenharmony_ci * type independent area 19162306a36Sopenharmony_ci */ 19262306a36Sopenharmony_ci __le32 logtid; /* 4: log transaction identifier */ 19362306a36Sopenharmony_ci __le32 backchain; /* 4: ptr to prev record of same transaction */ 19462306a36Sopenharmony_ci __le16 type; /* 2: record type */ 19562306a36Sopenharmony_ci __le16 length; /* 2: length of data in record (in byte) */ 19662306a36Sopenharmony_ci __le32 aggregate; /* 4: file system lv/aggregate */ 19762306a36Sopenharmony_ci /* (16) */ 19862306a36Sopenharmony_ci 19962306a36Sopenharmony_ci /* 20062306a36Sopenharmony_ci * type dependent area (20) 20162306a36Sopenharmony_ci */ 20262306a36Sopenharmony_ci union { 20362306a36Sopenharmony_ci 20462306a36Sopenharmony_ci /* 20562306a36Sopenharmony_ci * COMMIT: commit 20662306a36Sopenharmony_ci * 20762306a36Sopenharmony_ci * transaction commit: no type-dependent information; 20862306a36Sopenharmony_ci */ 20962306a36Sopenharmony_ci 21062306a36Sopenharmony_ci /* 21162306a36Sopenharmony_ci * REDOPAGE: after-image 21262306a36Sopenharmony_ci * 21362306a36Sopenharmony_ci * apply after-image; 21462306a36Sopenharmony_ci * 21562306a36Sopenharmony_ci * N.B. REDOPAGE, NOREDOPAGE, and UPDATEMAP must be same format; 21662306a36Sopenharmony_ci */ 21762306a36Sopenharmony_ci struct { 21862306a36Sopenharmony_ci __le32 fileset; /* 4: fileset number */ 21962306a36Sopenharmony_ci __le32 inode; /* 4: inode number */ 22062306a36Sopenharmony_ci __le16 type; /* 2: REDOPAGE record type */ 22162306a36Sopenharmony_ci __le16 l2linesize; /* 2: log2 of line size */ 22262306a36Sopenharmony_ci pxd_t pxd; /* 8: on-disk page pxd */ 22362306a36Sopenharmony_ci } redopage; /* (20) */ 22462306a36Sopenharmony_ci 22562306a36Sopenharmony_ci /* 22662306a36Sopenharmony_ci * NOREDOPAGE: the page is freed 22762306a36Sopenharmony_ci * 22862306a36Sopenharmony_ci * do not apply after-image records which precede this record 22962306a36Sopenharmony_ci * in the log with the same page block number to this page. 23062306a36Sopenharmony_ci * 23162306a36Sopenharmony_ci * N.B. REDOPAGE, NOREDOPAGE, and UPDATEMAP must be same format; 23262306a36Sopenharmony_ci */ 23362306a36Sopenharmony_ci struct { 23462306a36Sopenharmony_ci __le32 fileset; /* 4: fileset number */ 23562306a36Sopenharmony_ci __le32 inode; /* 4: inode number */ 23662306a36Sopenharmony_ci __le16 type; /* 2: NOREDOPAGE record type */ 23762306a36Sopenharmony_ci __le16 rsrvd; /* 2: reserved */ 23862306a36Sopenharmony_ci pxd_t pxd; /* 8: on-disk page pxd */ 23962306a36Sopenharmony_ci } noredopage; /* (20) */ 24062306a36Sopenharmony_ci 24162306a36Sopenharmony_ci /* 24262306a36Sopenharmony_ci * UPDATEMAP: update block allocation map 24362306a36Sopenharmony_ci * 24462306a36Sopenharmony_ci * either in-line PXD, 24562306a36Sopenharmony_ci * or out-of-line XADLIST; 24662306a36Sopenharmony_ci * 24762306a36Sopenharmony_ci * N.B. REDOPAGE, NOREDOPAGE, and UPDATEMAP must be same format; 24862306a36Sopenharmony_ci */ 24962306a36Sopenharmony_ci struct { 25062306a36Sopenharmony_ci __le32 fileset; /* 4: fileset number */ 25162306a36Sopenharmony_ci __le32 inode; /* 4: inode number */ 25262306a36Sopenharmony_ci __le16 type; /* 2: UPDATEMAP record type */ 25362306a36Sopenharmony_ci __le16 nxd; /* 2: number of extents */ 25462306a36Sopenharmony_ci pxd_t pxd; /* 8: pxd */ 25562306a36Sopenharmony_ci } updatemap; /* (20) */ 25662306a36Sopenharmony_ci 25762306a36Sopenharmony_ci /* 25862306a36Sopenharmony_ci * NOREDOINOEXT: the inode extent is freed 25962306a36Sopenharmony_ci * 26062306a36Sopenharmony_ci * do not apply after-image records which precede this 26162306a36Sopenharmony_ci * record in the log with the any of the 4 page block 26262306a36Sopenharmony_ci * numbers in this inode extent. 26362306a36Sopenharmony_ci * 26462306a36Sopenharmony_ci * NOTE: The fileset and pxd fields MUST remain in 26562306a36Sopenharmony_ci * the same fields in the REDOPAGE record format. 26662306a36Sopenharmony_ci * 26762306a36Sopenharmony_ci */ 26862306a36Sopenharmony_ci struct { 26962306a36Sopenharmony_ci __le32 fileset; /* 4: fileset number */ 27062306a36Sopenharmony_ci __le32 iagnum; /* 4: IAG number */ 27162306a36Sopenharmony_ci __le32 inoext_idx; /* 4: inode extent index */ 27262306a36Sopenharmony_ci pxd_t pxd; /* 8: on-disk page pxd */ 27362306a36Sopenharmony_ci } noredoinoext; /* (20) */ 27462306a36Sopenharmony_ci 27562306a36Sopenharmony_ci /* 27662306a36Sopenharmony_ci * SYNCPT: log sync point 27762306a36Sopenharmony_ci * 27862306a36Sopenharmony_ci * replay log up to syncpt address specified; 27962306a36Sopenharmony_ci */ 28062306a36Sopenharmony_ci struct { 28162306a36Sopenharmony_ci __le32 sync; /* 4: syncpt address (0 = here) */ 28262306a36Sopenharmony_ci } syncpt; 28362306a36Sopenharmony_ci 28462306a36Sopenharmony_ci /* 28562306a36Sopenharmony_ci * MOUNT: file system mount 28662306a36Sopenharmony_ci * 28762306a36Sopenharmony_ci * file system mount: no type-dependent information; 28862306a36Sopenharmony_ci */ 28962306a36Sopenharmony_ci 29062306a36Sopenharmony_ci /* 29162306a36Sopenharmony_ci * ? FREEXTENT: free specified extent(s) 29262306a36Sopenharmony_ci * 29362306a36Sopenharmony_ci * free specified extent(s) from block allocation map 29462306a36Sopenharmony_ci * N.B.: nextents should be length of data/sizeof(xad_t) 29562306a36Sopenharmony_ci */ 29662306a36Sopenharmony_ci struct { 29762306a36Sopenharmony_ci __le32 type; /* 4: FREEXTENT record type */ 29862306a36Sopenharmony_ci __le32 nextent; /* 4: number of extents */ 29962306a36Sopenharmony_ci 30062306a36Sopenharmony_ci /* data: PXD or XAD list */ 30162306a36Sopenharmony_ci } freextent; 30262306a36Sopenharmony_ci 30362306a36Sopenharmony_ci /* 30462306a36Sopenharmony_ci * ? NOREDOFILE: this file is freed 30562306a36Sopenharmony_ci * 30662306a36Sopenharmony_ci * do not apply records which precede this record in the log 30762306a36Sopenharmony_ci * with the same inode number. 30862306a36Sopenharmony_ci * 30962306a36Sopenharmony_ci * NOREDOFILE must be the first to be written at commit 31062306a36Sopenharmony_ci * (last to be read in logredo()) - it prevents 31162306a36Sopenharmony_ci * replay of preceding updates of all preceding generations 31262306a36Sopenharmony_ci * of the inumber esp. the on-disk inode itself. 31362306a36Sopenharmony_ci */ 31462306a36Sopenharmony_ci struct { 31562306a36Sopenharmony_ci __le32 fileset; /* 4: fileset number */ 31662306a36Sopenharmony_ci __le32 inode; /* 4: inode number */ 31762306a36Sopenharmony_ci } noredofile; 31862306a36Sopenharmony_ci 31962306a36Sopenharmony_ci /* 32062306a36Sopenharmony_ci * ? NEWPAGE: 32162306a36Sopenharmony_ci * 32262306a36Sopenharmony_ci * metadata type dependent 32362306a36Sopenharmony_ci */ 32462306a36Sopenharmony_ci struct { 32562306a36Sopenharmony_ci __le32 fileset; /* 4: fileset number */ 32662306a36Sopenharmony_ci __le32 inode; /* 4: inode number */ 32762306a36Sopenharmony_ci __le32 type; /* 4: NEWPAGE record type */ 32862306a36Sopenharmony_ci pxd_t pxd; /* 8: on-disk page pxd */ 32962306a36Sopenharmony_ci } newpage; 33062306a36Sopenharmony_ci 33162306a36Sopenharmony_ci /* 33262306a36Sopenharmony_ci * ? DUMMY: filler 33362306a36Sopenharmony_ci * 33462306a36Sopenharmony_ci * no type-dependent information 33562306a36Sopenharmony_ci */ 33662306a36Sopenharmony_ci } log; 33762306a36Sopenharmony_ci}; /* (36) */ 33862306a36Sopenharmony_ci 33962306a36Sopenharmony_ci#define LOGRDSIZE (sizeof(struct lrd)) 34062306a36Sopenharmony_ci 34162306a36Sopenharmony_ci/* 34262306a36Sopenharmony_ci * line vector descriptor 34362306a36Sopenharmony_ci */ 34462306a36Sopenharmony_cistruct lvd { 34562306a36Sopenharmony_ci __le16 offset; 34662306a36Sopenharmony_ci __le16 length; 34762306a36Sopenharmony_ci}; 34862306a36Sopenharmony_ci 34962306a36Sopenharmony_ci 35062306a36Sopenharmony_ci/* 35162306a36Sopenharmony_ci * log logical volume 35262306a36Sopenharmony_ci */ 35362306a36Sopenharmony_cistruct jfs_log { 35462306a36Sopenharmony_ci 35562306a36Sopenharmony_ci struct list_head sb_list;/* This is used to sync metadata 35662306a36Sopenharmony_ci * before writing syncpt. 35762306a36Sopenharmony_ci */ 35862306a36Sopenharmony_ci struct list_head journal_list; /* Global list */ 35962306a36Sopenharmony_ci struct block_device *bdev; /* 4: log lv pointer */ 36062306a36Sopenharmony_ci int serial; /* 4: log mount serial number */ 36162306a36Sopenharmony_ci 36262306a36Sopenharmony_ci s64 base; /* @8: log extent address (inline log ) */ 36362306a36Sopenharmony_ci int size; /* 4: log size in log page (in page) */ 36462306a36Sopenharmony_ci int l2bsize; /* 4: log2 of bsize */ 36562306a36Sopenharmony_ci 36662306a36Sopenharmony_ci unsigned long flag; /* 4: flag */ 36762306a36Sopenharmony_ci 36862306a36Sopenharmony_ci struct lbuf *lbuf_free; /* 4: free lbufs */ 36962306a36Sopenharmony_ci wait_queue_head_t free_wait; /* 4: */ 37062306a36Sopenharmony_ci 37162306a36Sopenharmony_ci /* log write */ 37262306a36Sopenharmony_ci int logtid; /* 4: log tid */ 37362306a36Sopenharmony_ci int page; /* 4: page number of eol page */ 37462306a36Sopenharmony_ci int eor; /* 4: eor of last record in eol page */ 37562306a36Sopenharmony_ci struct lbuf *bp; /* 4: current log page buffer */ 37662306a36Sopenharmony_ci 37762306a36Sopenharmony_ci struct mutex loglock; /* 4: log write serialization lock */ 37862306a36Sopenharmony_ci 37962306a36Sopenharmony_ci /* syncpt */ 38062306a36Sopenharmony_ci int nextsync; /* 4: bytes to write before next syncpt */ 38162306a36Sopenharmony_ci int active; /* 4: */ 38262306a36Sopenharmony_ci wait_queue_head_t syncwait; /* 4: */ 38362306a36Sopenharmony_ci 38462306a36Sopenharmony_ci /* commit */ 38562306a36Sopenharmony_ci uint cflag; /* 4: */ 38662306a36Sopenharmony_ci struct list_head cqueue; /* FIFO commit queue */ 38762306a36Sopenharmony_ci struct tblock *flush_tblk; /* tblk we're waiting on for flush */ 38862306a36Sopenharmony_ci int gcrtc; /* 4: GC_READY transaction count */ 38962306a36Sopenharmony_ci struct tblock *gclrt; /* 4: latest GC_READY transaction */ 39062306a36Sopenharmony_ci spinlock_t gclock; /* 4: group commit lock */ 39162306a36Sopenharmony_ci int logsize; /* 4: log data area size in byte */ 39262306a36Sopenharmony_ci int lsn; /* 4: end-of-log */ 39362306a36Sopenharmony_ci int clsn; /* 4: clsn */ 39462306a36Sopenharmony_ci int syncpt; /* 4: addr of last syncpt record */ 39562306a36Sopenharmony_ci int sync; /* 4: addr from last logsync() */ 39662306a36Sopenharmony_ci struct list_head synclist; /* 8: logsynclist anchor */ 39762306a36Sopenharmony_ci spinlock_t synclock; /* 4: synclist lock */ 39862306a36Sopenharmony_ci struct lbuf *wqueue; /* 4: log pageout queue */ 39962306a36Sopenharmony_ci int count; /* 4: count */ 40062306a36Sopenharmony_ci uuid_t uuid; /* 16: 128-bit uuid of log device */ 40162306a36Sopenharmony_ci 40262306a36Sopenharmony_ci int no_integrity; /* 3: flag to disable journaling to disk */ 40362306a36Sopenharmony_ci}; 40462306a36Sopenharmony_ci 40562306a36Sopenharmony_ci/* 40662306a36Sopenharmony_ci * Log flag 40762306a36Sopenharmony_ci */ 40862306a36Sopenharmony_ci#define log_INLINELOG 1 40962306a36Sopenharmony_ci#define log_SYNCBARRIER 2 41062306a36Sopenharmony_ci#define log_QUIESCE 3 41162306a36Sopenharmony_ci#define log_FLUSH 4 41262306a36Sopenharmony_ci 41362306a36Sopenharmony_ci/* 41462306a36Sopenharmony_ci * group commit flag 41562306a36Sopenharmony_ci */ 41662306a36Sopenharmony_ci/* jfs_log */ 41762306a36Sopenharmony_ci#define logGC_PAGEOUT 0x00000001 41862306a36Sopenharmony_ci 41962306a36Sopenharmony_ci/* tblock/lbuf */ 42062306a36Sopenharmony_ci#define tblkGC_QUEUE 0x0001 42162306a36Sopenharmony_ci#define tblkGC_READY 0x0002 42262306a36Sopenharmony_ci#define tblkGC_COMMIT 0x0004 42362306a36Sopenharmony_ci#define tblkGC_COMMITTED 0x0008 42462306a36Sopenharmony_ci#define tblkGC_EOP 0x0010 42562306a36Sopenharmony_ci#define tblkGC_FREE 0x0020 42662306a36Sopenharmony_ci#define tblkGC_LEADER 0x0040 42762306a36Sopenharmony_ci#define tblkGC_ERROR 0x0080 42862306a36Sopenharmony_ci#define tblkGC_LAZY 0x0100 // D230860 42962306a36Sopenharmony_ci#define tblkGC_UNLOCKED 0x0200 // D230860 43062306a36Sopenharmony_ci 43162306a36Sopenharmony_ci/* 43262306a36Sopenharmony_ci * log cache buffer header 43362306a36Sopenharmony_ci */ 43462306a36Sopenharmony_cistruct lbuf { 43562306a36Sopenharmony_ci struct jfs_log *l_log; /* 4: log associated with buffer */ 43662306a36Sopenharmony_ci 43762306a36Sopenharmony_ci /* 43862306a36Sopenharmony_ci * data buffer base area 43962306a36Sopenharmony_ci */ 44062306a36Sopenharmony_ci uint l_flag; /* 4: pageout control flags */ 44162306a36Sopenharmony_ci 44262306a36Sopenharmony_ci struct lbuf *l_wqnext; /* 4: write queue link */ 44362306a36Sopenharmony_ci struct lbuf *l_freelist; /* 4: freelistlink */ 44462306a36Sopenharmony_ci 44562306a36Sopenharmony_ci int l_pn; /* 4: log page number */ 44662306a36Sopenharmony_ci int l_eor; /* 4: log record eor */ 44762306a36Sopenharmony_ci int l_ceor; /* 4: committed log record eor */ 44862306a36Sopenharmony_ci 44962306a36Sopenharmony_ci s64 l_blkno; /* 8: log page block number */ 45062306a36Sopenharmony_ci caddr_t l_ldata; /* 4: data page */ 45162306a36Sopenharmony_ci struct page *l_page; /* The page itself */ 45262306a36Sopenharmony_ci uint l_offset; /* Offset of l_ldata within the page */ 45362306a36Sopenharmony_ci 45462306a36Sopenharmony_ci wait_queue_head_t l_ioevent; /* 4: i/o done event */ 45562306a36Sopenharmony_ci}; 45662306a36Sopenharmony_ci 45762306a36Sopenharmony_ci/* Reuse l_freelist for redrive list */ 45862306a36Sopenharmony_ci#define l_redrive_next l_freelist 45962306a36Sopenharmony_ci 46062306a36Sopenharmony_ci/* 46162306a36Sopenharmony_ci * logsynclist block 46262306a36Sopenharmony_ci * 46362306a36Sopenharmony_ci * common logsyncblk prefix for jbuf_t and tblock 46462306a36Sopenharmony_ci */ 46562306a36Sopenharmony_cistruct logsyncblk { 46662306a36Sopenharmony_ci u16 xflag; /* flags */ 46762306a36Sopenharmony_ci u16 flag; /* only meaninful in tblock */ 46862306a36Sopenharmony_ci lid_t lid; /* lock id */ 46962306a36Sopenharmony_ci s32 lsn; /* log sequence number */ 47062306a36Sopenharmony_ci struct list_head synclist; /* log sync list link */ 47162306a36Sopenharmony_ci}; 47262306a36Sopenharmony_ci 47362306a36Sopenharmony_ci/* 47462306a36Sopenharmony_ci * logsynclist serialization (per log) 47562306a36Sopenharmony_ci */ 47662306a36Sopenharmony_ci 47762306a36Sopenharmony_ci#define LOGSYNC_LOCK_INIT(log) spin_lock_init(&(log)->synclock) 47862306a36Sopenharmony_ci#define LOGSYNC_LOCK(log, flags) spin_lock_irqsave(&(log)->synclock, flags) 47962306a36Sopenharmony_ci#define LOGSYNC_UNLOCK(log, flags) \ 48062306a36Sopenharmony_ci spin_unlock_irqrestore(&(log)->synclock, flags) 48162306a36Sopenharmony_ci 48262306a36Sopenharmony_ci/* compute the difference in bytes of lsn from sync point */ 48362306a36Sopenharmony_ci#define logdiff(diff, lsn, log)\ 48462306a36Sopenharmony_ci{\ 48562306a36Sopenharmony_ci diff = (lsn) - (log)->syncpt;\ 48662306a36Sopenharmony_ci if (diff < 0)\ 48762306a36Sopenharmony_ci diff += (log)->logsize;\ 48862306a36Sopenharmony_ci} 48962306a36Sopenharmony_ci 49062306a36Sopenharmony_ciextern int lmLogOpen(struct super_block *sb); 49162306a36Sopenharmony_ciextern int lmLogClose(struct super_block *sb); 49262306a36Sopenharmony_ciextern int lmLogShutdown(struct jfs_log * log); 49362306a36Sopenharmony_ciextern int lmLogInit(struct jfs_log * log); 49462306a36Sopenharmony_ciextern int lmLogFormat(struct jfs_log *log, s64 logAddress, int logSize); 49562306a36Sopenharmony_ciextern int lmGroupCommit(struct jfs_log *, struct tblock *); 49662306a36Sopenharmony_ciextern int jfsIOWait(void *); 49762306a36Sopenharmony_ciextern void jfs_flush_journal(struct jfs_log * log, int wait); 49862306a36Sopenharmony_ciextern void jfs_syncpt(struct jfs_log *log, int hard_sync); 49962306a36Sopenharmony_ci 50062306a36Sopenharmony_ci#endif /* _H_JFS_LOGMGR */ 501