Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Dave Kleikamp | 63f83c9 | 2006-10-02 09:55:27 -0500 | [diff] [blame] | 2 | * Copyright (C) International Business Machines Corp., 2000-2002 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
Dave Kleikamp | 63f83c9 | 2006-10-02 09:55:27 -0500 | [diff] [blame] | 6 | * the Free Software Foundation; either version 2 of the License, or |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * (at your option) any later version. |
Dave Kleikamp | 63f83c9 | 2006-10-02 09:55:27 -0500 | [diff] [blame] | 8 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See |
| 12 | * the GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
Dave Kleikamp | 63f83c9 | 2006-10-02 09:55:27 -0500 | [diff] [blame] | 15 | * along with this program; if not, write to the Free Software |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | */ |
| 18 | #ifndef _H_JFS_XTREE |
| 19 | #define _H_JFS_XTREE |
| 20 | |
| 21 | /* |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 22 | * jfs_xtree.h: extent allocation descriptor B+-tree manager |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | */ |
| 24 | |
| 25 | #include "jfs_btree.h" |
| 26 | |
| 27 | |
| 28 | /* |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 29 | * extent allocation descriptor (xad) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | */ |
| 31 | typedef struct xad { |
Al Viro | e1f1fe7 | 2014-12-19 06:51:26 +0000 | [diff] [blame] | 32 | __u8 flag; /* 1: flag */ |
| 33 | __u8 rsvrd[2]; /* 2: reserved */ |
| 34 | __u8 off1; /* 1: offset in unit of fsblksize */ |
| 35 | __le32 off2; /* 4: offset in unit of fsblksize */ |
| 36 | pxd_t loc; /* 8: length and address in unit of fsblksize */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 37 | } xad_t; /* (16) */ |
| 38 | |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 39 | #define MAXXLEN ((1 << 24) - 1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 40 | |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 41 | #define XTSLOTSIZE 16 |
| 42 | #define L2XTSLOTSIZE 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | |
| 44 | /* xad_t field construction */ |
| 45 | #define XADoffset(xad, offset64)\ |
| 46 | {\ |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 47 | (xad)->off1 = ((u64)offset64) >> 32;\ |
| 48 | (xad)->off2 = __cpu_to_le32((offset64) & 0xffffffff);\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | } |
Al Viro | e1f1fe7 | 2014-12-19 06:51:26 +0000 | [diff] [blame] | 50 | #define XADaddress(xad, address64) PXDaddress(&(xad)->loc, address64) |
| 51 | #define XADlength(xad, length32) PXDlength(&(xad)->loc, length32) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | |
| 53 | /* xad_t field extraction */ |
| 54 | #define offsetXAD(xad)\ |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 55 | ( ((s64)((xad)->off1)) << 32 | __le32_to_cpu((xad)->off2)) |
Al Viro | e1f1fe7 | 2014-12-19 06:51:26 +0000 | [diff] [blame] | 56 | #define addressXAD(xad) addressPXD(&(xad)->loc) |
| 57 | #define lengthXAD(xad) lengthPXD(&(xad)->loc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
| 59 | /* xad list */ |
| 60 | struct xadlist { |
| 61 | s16 maxnxad; |
| 62 | s16 nxad; |
| 63 | xad_t *xad; |
| 64 | }; |
| 65 | |
| 66 | /* xad_t flags */ |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 67 | #define XAD_NEW 0x01 /* new */ |
| 68 | #define XAD_EXTENDED 0x02 /* extended */ |
| 69 | #define XAD_COMPRESSED 0x04 /* compressed with recorded length */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | #define XAD_NOTRECORDED 0x08 /* allocated but not recorded */ |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 71 | #define XAD_COW 0x10 /* copy-on-write */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | |
| 73 | |
| 74 | /* possible values for maxentry */ |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 75 | #define XTROOTINITSLOT_DIR 6 |
| 76 | #define XTROOTINITSLOT 10 |
| 77 | #define XTROOTMAXSLOT 18 |
| 78 | #define XTPAGEMAXSLOT 256 |
| 79 | #define XTENTRYSTART 2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | |
| 81 | /* |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 82 | * xtree page: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | */ |
| 84 | typedef union { |
| 85 | struct xtheader { |
| 86 | __le64 next; /* 8: */ |
| 87 | __le64 prev; /* 8: */ |
| 88 | |
| 89 | u8 flag; /* 1: */ |
| 90 | u8 rsrvd1; /* 1: */ |
| 91 | __le16 nextindex; /* 2: next index = number of entries */ |
| 92 | __le16 maxentry; /* 2: max number of entries */ |
| 93 | __le16 rsrvd2; /* 2: */ |
| 94 | |
| 95 | pxd_t self; /* 8: self */ |
| 96 | } header; /* (32) */ |
| 97 | |
| 98 | xad_t xad[XTROOTMAXSLOT]; /* 16 * maxentry: xad array */ |
| 99 | } xtpage_t; |
| 100 | |
| 101 | /* |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 102 | * external declaration |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 103 | */ |
| 104 | extern int xtLookup(struct inode *ip, s64 lstart, s64 llen, |
| 105 | int *pflag, s64 * paddr, int *plen, int flag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | extern void xtInitRoot(tid_t tid, struct inode *ip); |
| 107 | extern int xtInsert(tid_t tid, struct inode *ip, |
| 108 | int xflag, s64 xoff, int xlen, s64 * xaddrp, int flag); |
| 109 | extern int xtExtend(tid_t tid, struct inode *ip, s64 xoff, int xlen, |
| 110 | int flag); |
| 111 | #ifdef _NOTYET |
| 112 | extern int xtTailgate(tid_t tid, struct inode *ip, |
| 113 | s64 xoff, int xlen, s64 xaddr, int flag); |
| 114 | #endif |
| 115 | extern int xtUpdate(tid_t tid, struct inode *ip, struct xad *nxad); |
| 116 | extern int xtDelete(tid_t tid, struct inode *ip, s64 xoff, int xlen, |
| 117 | int flag); |
| 118 | extern s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int type); |
| 119 | extern s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size); |
| 120 | extern int xtRelocate(tid_t tid, struct inode *ip, |
| 121 | xad_t * oxad, s64 nxaddr, int xtype); |
| 122 | extern int xtAppend(tid_t tid, |
| 123 | struct inode *ip, int xflag, s64 xoff, int maxblocks, |
| 124 | int *xlenp, s64 * xaddrp, int flag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 125 | #endif /* !_H_JFS_XTREE */ |