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