jfs_xtree.h 3.8 KB

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