Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 | * Copyright (c) 2000,2005 Silicon Graphics, Inc. |
| 3 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License as |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. |
| 8 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 9 | * This program is distributed in the hope that it would be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write the Free Software Foundation, |
| 16 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
| 18 | #ifndef __XFS_EXTFREE_ITEM_H__ |
| 19 | #define __XFS_EXTFREE_ITEM_H__ |
| 20 | |
| 21 | struct xfs_mount; |
| 22 | struct kmem_zone; |
| 23 | |
| 24 | typedef struct xfs_extent { |
| 25 | xfs_dfsbno_t ext_start; |
| 26 | xfs_extlen_t ext_len; |
| 27 | } xfs_extent_t; |
| 28 | |
| 29 | /* |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 30 | * Since an xfs_extent_t has types (start:64, len: 32) |
| 31 | * there are different alignments on 32 bit and 64 bit kernels. |
| 32 | * So we provide the different variants for use by a |
| 33 | * conversion routine. |
| 34 | */ |
| 35 | |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 36 | #ifndef HAVE_FORMAT32 |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 37 | typedef struct xfs_extent_32 { |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 38 | __uint64_t ext_start; |
| 39 | __uint32_t ext_len; |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 40 | } __attribute__((packed)) xfs_extent_32_t; |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 41 | #endif |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 42 | |
| 43 | typedef struct xfs_extent_64 { |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 44 | __uint64_t ext_start; |
| 45 | __uint32_t ext_len; |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 46 | __uint32_t ext_pad; |
| 47 | } xfs_extent_64_t; |
| 48 | |
| 49 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | * This is the structure used to lay out an efi log item in the |
| 51 | * log. The efi_extents field is a variable size array whose |
| 52 | * size is given by efi_nextents. |
| 53 | */ |
| 54 | typedef struct xfs_efi_log_format { |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 55 | __uint16_t efi_type; /* efi log item type */ |
| 56 | __uint16_t efi_size; /* size of this item */ |
| 57 | __uint32_t efi_nextents; /* # extents to free */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | __uint64_t efi_id; /* efi identifier */ |
| 59 | xfs_extent_t efi_extents[1]; /* array of extents to free */ |
| 60 | } xfs_efi_log_format_t; |
| 61 | |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 62 | #ifndef HAVE_FORMAT32 |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 63 | typedef struct xfs_efi_log_format_32 { |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 64 | __uint16_t efi_type; /* efi log item type */ |
| 65 | __uint16_t efi_size; /* size of this item */ |
| 66 | __uint32_t efi_nextents; /* # extents to free */ |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 67 | __uint64_t efi_id; /* efi identifier */ |
| 68 | xfs_extent_32_t efi_extents[1]; /* array of extents to free */ |
| 69 | } __attribute__((packed)) xfs_efi_log_format_32_t; |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 70 | #endif |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 71 | |
| 72 | typedef struct xfs_efi_log_format_64 { |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 73 | __uint16_t efi_type; /* efi log item type */ |
| 74 | __uint16_t efi_size; /* size of this item */ |
| 75 | __uint32_t efi_nextents; /* # extents to free */ |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 76 | __uint64_t efi_id; /* efi identifier */ |
| 77 | xfs_extent_64_t efi_extents[1]; /* array of extents to free */ |
| 78 | } xfs_efi_log_format_64_t; |
| 79 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 80 | /* |
| 81 | * This is the structure used to lay out an efd log item in the |
| 82 | * log. The efd_extents array is a variable size array whose |
| 83 | * size is given by efd_nextents; |
| 84 | */ |
| 85 | typedef struct xfs_efd_log_format { |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 86 | __uint16_t efd_type; /* efd log item type */ |
| 87 | __uint16_t efd_size; /* size of this item */ |
| 88 | __uint32_t efd_nextents; /* # of extents freed */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | __uint64_t efd_efi_id; /* id of corresponding efi */ |
| 90 | xfs_extent_t efd_extents[1]; /* array of extents freed */ |
| 91 | } xfs_efd_log_format_t; |
| 92 | |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 93 | #ifndef HAVE_FORMAT32 |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 94 | typedef struct xfs_efd_log_format_32 { |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 95 | __uint16_t efd_type; /* efd log item type */ |
| 96 | __uint16_t efd_size; /* size of this item */ |
| 97 | __uint32_t efd_nextents; /* # of extents freed */ |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 98 | __uint64_t efd_efi_id; /* id of corresponding efi */ |
| 99 | xfs_extent_32_t efd_extents[1]; /* array of extents freed */ |
| 100 | } __attribute__((packed)) xfs_efd_log_format_32_t; |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 101 | #endif |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 102 | |
| 103 | typedef struct xfs_efd_log_format_64 { |
Tim Shimmin | 128dabc | 2006-09-28 10:55:43 +1000 | [diff] [blame] | 104 | __uint16_t efd_type; /* efd log item type */ |
| 105 | __uint16_t efd_size; /* size of this item */ |
| 106 | __uint32_t efd_nextents; /* # of extents freed */ |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 107 | __uint64_t efd_efi_id; /* id of corresponding efi */ |
| 108 | xfs_extent_64_t efd_extents[1]; /* array of extents freed */ |
| 109 | } xfs_efd_log_format_64_t; |
| 110 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | |
| 112 | #ifdef __KERNEL__ |
| 113 | |
| 114 | /* |
| 115 | * Max number of extents in fast allocation path. |
| 116 | */ |
| 117 | #define XFS_EFI_MAX_FAST_EXTENTS 16 |
| 118 | |
| 119 | /* |
| 120 | * Define EFI flags. |
| 121 | */ |
| 122 | #define XFS_EFI_RECOVERED 0x1 |
| 123 | #define XFS_EFI_COMMITTED 0x2 |
| 124 | #define XFS_EFI_CANCELED 0x4 |
| 125 | |
| 126 | /* |
| 127 | * This is the "extent free intention" log item. It is used |
| 128 | * to log the fact that some extents need to be free. It is |
| 129 | * used in conjunction with the "extent free done" log item |
| 130 | * described below. |
| 131 | */ |
| 132 | typedef struct xfs_efi_log_item { |
| 133 | xfs_log_item_t efi_item; |
| 134 | uint efi_flags; /* misc flags */ |
| 135 | uint efi_next_extent; |
| 136 | xfs_efi_log_format_t efi_format; |
| 137 | } xfs_efi_log_item_t; |
| 138 | |
| 139 | /* |
| 140 | * This is the "extent free done" log item. It is used to log |
| 141 | * the fact that some extents earlier mentioned in an efi item |
| 142 | * have been freed. |
| 143 | */ |
| 144 | typedef struct xfs_efd_log_item { |
| 145 | xfs_log_item_t efd_item; |
| 146 | xfs_efi_log_item_t *efd_efip; |
| 147 | uint efd_next_extent; |
| 148 | xfs_efd_log_format_t efd_format; |
| 149 | } xfs_efd_log_item_t; |
| 150 | |
| 151 | /* |
| 152 | * Max number of extents in fast allocation path. |
| 153 | */ |
| 154 | #define XFS_EFD_MAX_FAST_EXTENTS 16 |
| 155 | |
| 156 | extern struct kmem_zone *xfs_efi_zone; |
| 157 | extern struct kmem_zone *xfs_efd_zone; |
| 158 | |
| 159 | xfs_efi_log_item_t *xfs_efi_init(struct xfs_mount *, uint); |
| 160 | xfs_efd_log_item_t *xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *, |
| 161 | uint); |
Tim Shimmin | 6d192a9 | 2006-06-09 14:55:38 +1000 | [diff] [blame] | 162 | int xfs_efi_copy_format(xfs_log_iovec_t *buf, |
| 163 | xfs_efi_log_format_t *dst_efi_fmt); |
Christoph Hellwig | 7d795ca | 2005-06-21 15:41:19 +1000 | [diff] [blame] | 164 | void xfs_efi_item_free(xfs_efi_log_item_t *); |
| 165 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | #endif /* __KERNEL__ */ |
| 167 | |
| 168 | #endif /* __XFS_EXTFREE_ITEM_H__ */ |