Thomas Gleixner | 1a59d1b8 | 2019-05-27 08:55:05 +0200 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-or-later */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Dave Kleikamp | 63f83c9 | 2006-10-02 09:55:27 -0500 | [diff] [blame] | 3 | * Copyright (C) International Business Machines Corp., 2000-2002 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | */ |
| 5 | #ifndef _H_JFS_XTREE |
| 6 | #define _H_JFS_XTREE |
| 7 | |
| 8 | /* |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 9 | * jfs_xtree.h: extent allocation descriptor B+-tree manager |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include "jfs_btree.h" |
| 13 | |
| 14 | |
| 15 | /* |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 16 | * extent allocation descriptor (xad) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
| 18 | typedef struct xad { |
Al Viro | e1f1fe7 | 2014-12-19 06:51:26 +0000 | [diff] [blame] | 19 | __u8 flag; /* 1: flag */ |
| 20 | __u8 rsvrd[2]; /* 2: reserved */ |
| 21 | __u8 off1; /* 1: offset in unit of fsblksize */ |
| 22 | __le32 off2; /* 4: offset in unit of fsblksize */ |
| 23 | pxd_t loc; /* 8: length and address in unit of fsblksize */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | } xad_t; /* (16) */ |
| 25 | |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 26 | #define MAXXLEN ((1 << 24) - 1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 28 | #define XTSLOTSIZE 16 |
| 29 | #define L2XTSLOTSIZE 4 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | |
| 31 | /* xad_t field construction */ |
| 32 | #define XADoffset(xad, offset64)\ |
| 33 | {\ |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 34 | (xad)->off1 = ((u64)offset64) >> 32;\ |
| 35 | (xad)->off2 = __cpu_to_le32((offset64) & 0xffffffff);\ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | } |
Al Viro | e1f1fe7 | 2014-12-19 06:51:26 +0000 | [diff] [blame] | 37 | #define XADaddress(xad, address64) PXDaddress(&(xad)->loc, address64) |
| 38 | #define XADlength(xad, length32) PXDlength(&(xad)->loc, length32) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 39 | |
| 40 | /* xad_t field extraction */ |
| 41 | #define offsetXAD(xad)\ |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 42 | ( ((s64)((xad)->off1)) << 32 | __le32_to_cpu((xad)->off2)) |
Al Viro | e1f1fe7 | 2014-12-19 06:51:26 +0000 | [diff] [blame] | 43 | #define addressXAD(xad) addressPXD(&(xad)->loc) |
| 44 | #define lengthXAD(xad) lengthPXD(&(xad)->loc) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | |
| 46 | /* xad list */ |
| 47 | struct xadlist { |
| 48 | s16 maxnxad; |
| 49 | s16 nxad; |
| 50 | xad_t *xad; |
| 51 | }; |
| 52 | |
| 53 | /* xad_t flags */ |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 54 | #define XAD_NEW 0x01 /* new */ |
| 55 | #define XAD_EXTENDED 0x02 /* extended */ |
| 56 | #define XAD_COMPRESSED 0x04 /* compressed with recorded length */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | #define XAD_NOTRECORDED 0x08 /* allocated but not recorded */ |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 58 | #define XAD_COW 0x10 /* copy-on-write */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | |
| 60 | |
| 61 | /* possible values for maxentry */ |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 62 | #define XTROOTINITSLOT_DIR 6 |
| 63 | #define XTROOTINITSLOT 10 |
| 64 | #define XTROOTMAXSLOT 18 |
| 65 | #define XTPAGEMAXSLOT 256 |
| 66 | #define XTENTRYSTART 2 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
| 68 | /* |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 69 | * xtree page: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | */ |
| 71 | typedef union { |
| 72 | struct xtheader { |
| 73 | __le64 next; /* 8: */ |
| 74 | __le64 prev; /* 8: */ |
| 75 | |
| 76 | u8 flag; /* 1: */ |
| 77 | u8 rsrvd1; /* 1: */ |
| 78 | __le16 nextindex; /* 2: next index = number of entries */ |
| 79 | __le16 maxentry; /* 2: max number of entries */ |
| 80 | __le16 rsrvd2; /* 2: */ |
| 81 | |
| 82 | pxd_t self; /* 8: self */ |
| 83 | } header; /* (32) */ |
| 84 | |
| 85 | xad_t xad[XTROOTMAXSLOT]; /* 16 * maxentry: xad array */ |
| 86 | } xtpage_t; |
| 87 | |
| 88 | /* |
Dave Kleikamp | f720e3b | 2007-06-06 15:28:35 -0500 | [diff] [blame] | 89 | * external declaration |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | */ |
| 91 | extern int xtLookup(struct inode *ip, s64 lstart, s64 llen, |
| 92 | int *pflag, s64 * paddr, int *plen, int flag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | extern void xtInitRoot(tid_t tid, struct inode *ip); |
| 94 | extern int xtInsert(tid_t tid, struct inode *ip, |
| 95 | int xflag, s64 xoff, int xlen, s64 * xaddrp, int flag); |
| 96 | extern int xtExtend(tid_t tid, struct inode *ip, s64 xoff, int xlen, |
| 97 | int flag); |
| 98 | #ifdef _NOTYET |
| 99 | extern int xtTailgate(tid_t tid, struct inode *ip, |
| 100 | s64 xoff, int xlen, s64 xaddr, int flag); |
| 101 | #endif |
| 102 | extern int xtUpdate(tid_t tid, struct inode *ip, struct xad *nxad); |
| 103 | extern int xtDelete(tid_t tid, struct inode *ip, s64 xoff, int xlen, |
| 104 | int flag); |
| 105 | extern s64 xtTruncate(tid_t tid, struct inode *ip, s64 newsize, int type); |
| 106 | extern s64 xtTruncate_pmap(tid_t tid, struct inode *ip, s64 committed_size); |
| 107 | extern int xtRelocate(tid_t tid, struct inode *ip, |
| 108 | xad_t * oxad, s64 nxaddr, int xtype); |
| 109 | extern int xtAppend(tid_t tid, |
| 110 | struct inode *ip, int xflag, s64 xoff, int maxblocks, |
| 111 | int *xlenp, s64 * xaddrp, int flag); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 112 | #endif /* !_H_JFS_XTREE */ |