blob: 5bf681708fec915348cf0324b9392c81fa7f0287 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7b718762005-11-02 14:58:39 +11002 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * 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 Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * 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 Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * 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 Torvalds1da177e2005-04-16 15:20:36 -070017 */
18#ifndef __XFS_EXTFREE_ITEM_H__
19#define __XFS_EXTFREE_ITEM_H__
20
21struct xfs_mount;
22struct kmem_zone;
23
24typedef struct xfs_extent {
25 xfs_dfsbno_t ext_start;
26 xfs_extlen_t ext_len;
27} xfs_extent_t;
28
29/*
30 * This is the structure used to lay out an efi log item in the
31 * log. The efi_extents field is a variable size array whose
32 * size is given by efi_nextents.
33 */
34typedef struct xfs_efi_log_format {
35 unsigned short efi_type; /* efi log item type */
36 unsigned short efi_size; /* size of this item */
37 uint efi_nextents; /* # extents to free */
38 __uint64_t efi_id; /* efi identifier */
39 xfs_extent_t efi_extents[1]; /* array of extents to free */
40} xfs_efi_log_format_t;
41
42/*
43 * This is the structure used to lay out an efd log item in the
44 * log. The efd_extents array is a variable size array whose
45 * size is given by efd_nextents;
46 */
47typedef struct xfs_efd_log_format {
48 unsigned short efd_type; /* efd log item type */
49 unsigned short efd_size; /* size of this item */
50 uint efd_nextents; /* # of extents freed */
51 __uint64_t efd_efi_id; /* id of corresponding efi */
52 xfs_extent_t efd_extents[1]; /* array of extents freed */
53} xfs_efd_log_format_t;
54
55
56#ifdef __KERNEL__
57
58/*
59 * Max number of extents in fast allocation path.
60 */
61#define XFS_EFI_MAX_FAST_EXTENTS 16
62
63/*
64 * Define EFI flags.
65 */
66#define XFS_EFI_RECOVERED 0x1
67#define XFS_EFI_COMMITTED 0x2
68#define XFS_EFI_CANCELED 0x4
69
70/*
71 * This is the "extent free intention" log item. It is used
72 * to log the fact that some extents need to be free. It is
73 * used in conjunction with the "extent free done" log item
74 * described below.
75 */
76typedef struct xfs_efi_log_item {
77 xfs_log_item_t efi_item;
78 uint efi_flags; /* misc flags */
79 uint efi_next_extent;
80 xfs_efi_log_format_t efi_format;
81} xfs_efi_log_item_t;
82
83/*
84 * This is the "extent free done" log item. It is used to log
85 * the fact that some extents earlier mentioned in an efi item
86 * have been freed.
87 */
88typedef struct xfs_efd_log_item {
89 xfs_log_item_t efd_item;
90 xfs_efi_log_item_t *efd_efip;
91 uint efd_next_extent;
92 xfs_efd_log_format_t efd_format;
93} xfs_efd_log_item_t;
94
95/*
96 * Max number of extents in fast allocation path.
97 */
98#define XFS_EFD_MAX_FAST_EXTENTS 16
99
100extern struct kmem_zone *xfs_efi_zone;
101extern struct kmem_zone *xfs_efd_zone;
102
103xfs_efi_log_item_t *xfs_efi_init(struct xfs_mount *, uint);
104xfs_efd_log_item_t *xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *,
105 uint);
106
Christoph Hellwig7d795ca2005-06-21 15:41:19 +1000107void xfs_efi_item_free(xfs_efi_log_item_t *);
108
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109#endif /* __KERNEL__ */
110
111#endif /* __XFS_EXTFREE_ITEM_H__ */