jfs_xtree.h 4.2 KB

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