1153323Srodrigc/* 2159451Srodrigc * Copyright (c) 2000,2005 Silicon Graphics, Inc. 3159451Srodrigc * All Rights Reserved. 4153323Srodrigc * 5159451Srodrigc * This program is free software; you can redistribute it and/or 6159451Srodrigc * modify it under the terms of the GNU General Public License as 7153323Srodrigc * published by the Free Software Foundation. 8153323Srodrigc * 9159451Srodrigc * This program is distributed in the hope that it would be useful, 10159451Srodrigc * but WITHOUT ANY WARRANTY; without even the implied warranty of 11159451Srodrigc * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12159451Srodrigc * GNU General Public License for more details. 13153323Srodrigc * 14159451Srodrigc * You should have received a copy of the GNU General Public License 15159451Srodrigc * along with this program; if not, write the Free Software Foundation, 16159451Srodrigc * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 17153323Srodrigc */ 18153323Srodrigc#ifndef __XFS_EXTFREE_ITEM_H__ 19153323Srodrigc#define __XFS_EXTFREE_ITEM_H__ 20153323Srodrigc 21153323Srodrigcstruct xfs_mount; 22153323Srodrigcstruct kmem_zone; 23153323Srodrigc 24153323Srodrigctypedef struct xfs_extent { 25153323Srodrigc xfs_dfsbno_t ext_start; 26153323Srodrigc xfs_extlen_t ext_len; 27153323Srodrigc} xfs_extent_t; 28153323Srodrigc 29153323Srodrigc/* 30153323Srodrigc * This is the structure used to lay out an efi log item in the 31153323Srodrigc * log. The efi_extents field is a variable size array whose 32153323Srodrigc * size is given by efi_nextents. 33153323Srodrigc */ 34153323Srodrigctypedef struct xfs_efi_log_format { 35153323Srodrigc unsigned short efi_type; /* efi log item type */ 36153323Srodrigc unsigned short efi_size; /* size of this item */ 37153323Srodrigc uint efi_nextents; /* # extents to free */ 38153323Srodrigc __uint64_t efi_id; /* efi identifier */ 39153323Srodrigc xfs_extent_t efi_extents[1]; /* array of extents to free */ 40153323Srodrigc} xfs_efi_log_format_t; 41153323Srodrigc 42153323Srodrigc/* 43153323Srodrigc * This is the structure used to lay out an efd log item in the 44153323Srodrigc * log. The efd_extents array is a variable size array whose 45153323Srodrigc * size is given by efd_nextents; 46153323Srodrigc */ 47153323Srodrigctypedef struct xfs_efd_log_format { 48153323Srodrigc unsigned short efd_type; /* efd log item type */ 49153323Srodrigc unsigned short efd_size; /* size of this item */ 50153323Srodrigc uint efd_nextents; /* # of extents freed */ 51153323Srodrigc __uint64_t efd_efi_id; /* id of corresponding efi */ 52153323Srodrigc xfs_extent_t efd_extents[1]; /* array of extents freed */ 53153323Srodrigc} xfs_efd_log_format_t; 54153323Srodrigc 55153323Srodrigc 56153323Srodrigc#ifdef __KERNEL__ 57153323Srodrigc 58153323Srodrigc/* 59153323Srodrigc * Max number of extents in fast allocation path. 60153323Srodrigc */ 61153323Srodrigc#define XFS_EFI_MAX_FAST_EXTENTS 16 62153323Srodrigc 63153323Srodrigc/* 64153323Srodrigc * Define EFI flags. 65153323Srodrigc */ 66153323Srodrigc#define XFS_EFI_RECOVERED 0x1 67153323Srodrigc#define XFS_EFI_COMMITTED 0x2 68153323Srodrigc#define XFS_EFI_CANCELED 0x4 69153323Srodrigc 70153323Srodrigc/* 71153323Srodrigc * This is the "extent free intention" log item. It is used 72153323Srodrigc * to log the fact that some extents need to be free. It is 73153323Srodrigc * used in conjunction with the "extent free done" log item 74153323Srodrigc * described below. 75153323Srodrigc */ 76153323Srodrigctypedef struct xfs_efi_log_item { 77153323Srodrigc xfs_log_item_t efi_item; 78153323Srodrigc uint efi_flags; /* misc flags */ 79153323Srodrigc uint efi_next_extent; 80153323Srodrigc xfs_efi_log_format_t efi_format; 81153323Srodrigc} xfs_efi_log_item_t; 82153323Srodrigc 83153323Srodrigc/* 84153323Srodrigc * This is the "extent free done" log item. It is used to log 85153323Srodrigc * the fact that some extents earlier mentioned in an efi item 86153323Srodrigc * have been freed. 87153323Srodrigc */ 88153323Srodrigctypedef struct xfs_efd_log_item { 89153323Srodrigc xfs_log_item_t efd_item; 90153323Srodrigc xfs_efi_log_item_t *efd_efip; 91153323Srodrigc uint efd_next_extent; 92153323Srodrigc xfs_efd_log_format_t efd_format; 93153323Srodrigc} xfs_efd_log_item_t; 94153323Srodrigc 95153323Srodrigc/* 96153323Srodrigc * Max number of extents in fast allocation path. 97153323Srodrigc */ 98153323Srodrigc#define XFS_EFD_MAX_FAST_EXTENTS 16 99153323Srodrigc 100153323Srodrigcextern struct kmem_zone *xfs_efi_zone; 101153323Srodrigcextern struct kmem_zone *xfs_efd_zone; 102153323Srodrigc 103153323Srodrigcxfs_efi_log_item_t *xfs_efi_init(struct xfs_mount *, uint); 104153323Srodrigcxfs_efd_log_item_t *xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *, 105153323Srodrigc uint); 106153323Srodrigc 107159451Srodrigcvoid xfs_efi_item_free(xfs_efi_log_item_t *); 108159451Srodrigc 109153323Srodrigc#endif /* __KERNEL__ */ 110153323Srodrigc 111153323Srodrigc#endif /* __XFS_EXTFREE_ITEM_H__ */ 112