Linux Audio

Check our new training course

Loading...
v6.2
 1// SPDX-License-Identifier: GPL-2.0
 2/*
 3 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
 4 * All Rights Reserved.
 
 
 
 
 
 
 
 
 
 
 
 
 
 5 */
 6#ifndef	__XFS_EXTFREE_ITEM_H__
 7#define	__XFS_EXTFREE_ITEM_H__
 8
 9/* kernel only EFI/EFD definitions */
10
11struct xfs_mount;
12struct kmem_cache;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
14/*
15 * Max number of extents in fast allocation path.
16 */
17#define	XFS_EFI_MAX_FAST_EXTENTS	16
18
19/*
20 * This is the "extent free intention" log item.  It is used to log the fact
21 * that some extents need to be free.  It is used in conjunction with the
22 * "extent free done" log item described below.
23 *
24 * The EFI is reference counted so that it is not freed prior to both the EFI
25 * and EFD being committed and unpinned. This ensures the EFI is inserted into
26 * the AIL even in the event of out of order EFI/EFD processing. In other words,
27 * an EFI is born with two references:
28 *
29 * 	1.) an EFI held reference to track EFI AIL insertion
30 * 	2.) an EFD held reference to track EFD commit
31 *
32 * On allocation, both references are the responsibility of the caller. Once the
33 * EFI is added to and dirtied in a transaction, ownership of reference one
34 * transfers to the transaction. The reference is dropped once the EFI is
35 * inserted to the AIL or in the event of failure along the way (e.g., commit
36 * failure, log I/O error, etc.). Note that the caller remains responsible for
37 * the EFD reference under all circumstances to this point. The caller has no
38 * means to detect failure once the transaction is committed, however.
39 * Therefore, an EFD is required after this point, even in the event of
40 * unrelated failure.
41 *
42 * Once an EFD is allocated and dirtied in a transaction, reference two
43 * transfers to the transaction. The EFD reference is dropped once it reaches
44 * the unpin handler. Similar to the EFI, the reference also drops in the event
45 * of commit failure or log I/O errors. Note that the EFD is not inserted in the
46 * AIL, so at this point both the EFI and EFD are freed.
47 */
48struct xfs_efi_log_item {
49	struct xfs_log_item	efi_item;
50	atomic_t		efi_refcount;
51	atomic_t		efi_next_extent;
 
52	xfs_efi_log_format_t	efi_format;
53};
54
55static inline size_t
56xfs_efi_log_item_sizeof(
57	unsigned int		nr)
58{
59	return offsetof(struct xfs_efi_log_item, efi_format) +
60			xfs_efi_log_format_sizeof(nr);
61}
62
63/*
64 * This is the "extent free done" log item.  It is used to log
65 * the fact that some extents earlier mentioned in an efi item
66 * have been freed.
67 */
68struct xfs_efd_log_item {
69	struct xfs_log_item	efd_item;
70	struct xfs_efi_log_item *efd_efip;
71	uint			efd_next_extent;
72	xfs_efd_log_format_t	efd_format;
73};
74
75static inline size_t
76xfs_efd_log_item_sizeof(
77	unsigned int		nr)
78{
79	return offsetof(struct xfs_efd_log_item, efd_format) +
80			xfs_efd_log_format_sizeof(nr);
81}
82
83/*
84 * Max number of extents in fast allocation path.
85 */
86#define	XFS_EFD_MAX_FAST_EXTENTS	16
87
88extern struct kmem_cache	*xfs_efi_cache;
89extern struct kmem_cache	*xfs_efd_cache;
 
 
 
 
 
 
 
 
 
90
91#endif	/* __XFS_EXTFREE_ITEM_H__ */
v3.1
 
  1/*
  2 * Copyright (c) 2000,2005 Silicon Graphics, Inc.
  3 * All Rights Reserved.
  4 *
  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
  7 * published by the Free Software Foundation.
  8 *
  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.
 13 *
 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
 17 */
 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 * 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
 36typedef struct xfs_extent_32 {
 37	__uint64_t	ext_start;
 38	__uint32_t	ext_len;
 39} __attribute__((packed)) xfs_extent_32_t;
 40
 41typedef struct xfs_extent_64 {
 42	__uint64_t	ext_start;
 43	__uint32_t	ext_len;
 44	__uint32_t	ext_pad;
 45} xfs_extent_64_t;
 46
 47/*
 48 * This is the structure used to lay out an efi log item in the
 49 * log.  The efi_extents field is a variable size array whose
 50 * size is given by efi_nextents.
 51 */
 52typedef struct xfs_efi_log_format {
 53	__uint16_t		efi_type;	/* efi log item type */
 54	__uint16_t		efi_size;	/* size of this item */
 55	__uint32_t		efi_nextents;	/* # extents to free */
 56	__uint64_t		efi_id;		/* efi identifier */
 57	xfs_extent_t		efi_extents[1];	/* array of extents to free */
 58} xfs_efi_log_format_t;
 59
 60typedef struct xfs_efi_log_format_32 {
 61	__uint16_t		efi_type;	/* efi log item type */
 62	__uint16_t		efi_size;	/* size of this item */
 63	__uint32_t		efi_nextents;	/* # extents to free */
 64	__uint64_t		efi_id;		/* efi identifier */
 65	xfs_extent_32_t		efi_extents[1];	/* array of extents to free */
 66} __attribute__((packed)) xfs_efi_log_format_32_t;
 67
 68typedef struct xfs_efi_log_format_64 {
 69	__uint16_t		efi_type;	/* efi log item type */
 70	__uint16_t		efi_size;	/* size of this item */
 71	__uint32_t		efi_nextents;	/* # extents to free */
 72	__uint64_t		efi_id;		/* efi identifier */
 73	xfs_extent_64_t		efi_extents[1];	/* array of extents to free */
 74} xfs_efi_log_format_64_t;
 75
 76/*
 77 * This is the structure used to lay out an efd log item in the
 78 * log.  The efd_extents array is a variable size array whose
 79 * size is given by efd_nextents;
 80 */
 81typedef struct xfs_efd_log_format {
 82	__uint16_t		efd_type;	/* efd log item type */
 83	__uint16_t		efd_size;	/* size of this item */
 84	__uint32_t		efd_nextents;	/* # of extents freed */
 85	__uint64_t		efd_efi_id;	/* id of corresponding efi */
 86	xfs_extent_t		efd_extents[1];	/* array of extents freed */
 87} xfs_efd_log_format_t;
 88
 89typedef struct xfs_efd_log_format_32 {
 90	__uint16_t		efd_type;	/* efd log item type */
 91	__uint16_t		efd_size;	/* size of this item */
 92	__uint32_t		efd_nextents;	/* # of extents freed */
 93	__uint64_t		efd_efi_id;	/* id of corresponding efi */
 94	xfs_extent_32_t		efd_extents[1];	/* array of extents freed */
 95} __attribute__((packed)) xfs_efd_log_format_32_t;
 96
 97typedef struct xfs_efd_log_format_64 {
 98	__uint16_t		efd_type;	/* efd log item type */
 99	__uint16_t		efd_size;	/* size of this item */
100	__uint32_t		efd_nextents;	/* # of extents freed */
101	__uint64_t		efd_efi_id;	/* id of corresponding efi */
102	xfs_extent_64_t		efd_extents[1];	/* array of extents freed */
103} xfs_efd_log_format_64_t;
104
105
106#ifdef __KERNEL__
107
108/*
109 * Max number of extents in fast allocation path.
110 */
111#define	XFS_EFI_MAX_FAST_EXTENTS	16
112
113/*
114 * Define EFI flag bits. Manipulated by set/clear/test_bit operators.
115 */
116#define	XFS_EFI_RECOVERED	1
117#define	XFS_EFI_COMMITTED	2
118
119/*
120 * This is the "extent free intention" log item.  It is used
121 * to log the fact that some extents need to be free.  It is
122 * used in conjunction with the "extent free done" log item
123 * described below.
124 */
125typedef struct xfs_efi_log_item {
126	xfs_log_item_t		efi_item;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127	atomic_t		efi_next_extent;
128	unsigned long		efi_flags;	/* misc flags */
129	xfs_efi_log_format_t	efi_format;
130} xfs_efi_log_item_t;
 
 
 
 
 
 
 
 
131
132/*
133 * This is the "extent free done" log item.  It is used to log
134 * the fact that some extents earlier mentioned in an efi item
135 * have been freed.
136 */
137typedef struct xfs_efd_log_item {
138	xfs_log_item_t		efd_item;
139	xfs_efi_log_item_t	*efd_efip;
140	uint			efd_next_extent;
141	xfs_efd_log_format_t	efd_format;
142} xfs_efd_log_item_t;
 
 
 
 
 
 
 
 
143
144/*
145 * Max number of extents in fast allocation path.
146 */
147#define	XFS_EFD_MAX_FAST_EXTENTS	16
148
149extern struct kmem_zone	*xfs_efi_zone;
150extern struct kmem_zone	*xfs_efd_zone;
151
152xfs_efi_log_item_t	*xfs_efi_init(struct xfs_mount *, uint);
153xfs_efd_log_item_t	*xfs_efd_init(struct xfs_mount *, xfs_efi_log_item_t *,
154				      uint);
155int			xfs_efi_copy_format(xfs_log_iovec_t *buf,
156					    xfs_efi_log_format_t *dst_efi_fmt);
157void			xfs_efi_item_free(xfs_efi_log_item_t *);
158
159#endif	/* __KERNEL__ */
160
161#endif	/* __XFS_EXTFREE_ITEM_H__ */