2 * Copyright (c) 2000 Silicon Graphics, Inc. All Rights Reserved.
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of version 2 of the GNU General Public License as
6 * published by the Free Software Foundation.
8 * This program is distributed in the hope that it would be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 * Further, this software is distributed without any warranty that it is
13 * free of the rightful claim of any third person regarding infringement
14 * or the like. Any license provided herein, whether implied or
15 * otherwise, applies only to this software file. Patent licenses, if
16 * any, provided herein do not apply to combinations of this program with
17 * other software, or any other product whatsoever.
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write the Free Software Foundation, Inc., 59
21 * Temple Place - Suite 330, Boston MA 02111-1307, USA.
23 * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
24 * Mountain View, CA 94043, or:
28 * For further information regarding this notice, see:
30 * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
34 #include "xfs_macros.h"
35 #include "xfs_types.h"
38 #include "xfs_trans.h"
41 #include "xfs_dmapi.h"
42 #include "xfs_mount.h"
43 #include "xfs_trans_priv.h"
44 #include "xfs_extfree_item.h"
47 * This routine is called to allocate an "extent free intention"
48 * log item that will hold nextents worth of extents. The
49 * caller must use all nextents extents, because we are not
50 * flexible about this at all.
53 xfs_trans_get_efi(xfs_trans_t
*tp
,
56 xfs_efi_log_item_t
*efip
;
61 efip
= xfs_efi_init(tp
->t_mountp
, nextents
);
65 * Get a log_item_desc to point at the new item.
67 (void) xfs_trans_add_item(tp
, (xfs_log_item_t
*)efip
);
73 * This routine is called to indicate that the described
74 * extent is to be logged as needing to be freed. It should
75 * be called once for each extent to be freed.
78 xfs_trans_log_efi_extent(xfs_trans_t
*tp
,
79 xfs_efi_log_item_t
*efip
,
80 xfs_fsblock_t start_block
,
83 xfs_log_item_desc_t
*lidp
;
87 lidp
= xfs_trans_find_item(tp
, (xfs_log_item_t
*)efip
);
90 tp
->t_flags
|= XFS_TRANS_DIRTY
;
91 lidp
->lid_flags
|= XFS_LID_DIRTY
;
93 next_extent
= efip
->efi_next_extent
;
94 ASSERT(next_extent
< efip
->efi_format
.efi_nextents
);
95 extp
= &(efip
->efi_format
.efi_extents
[next_extent
]);
96 extp
->ext_start
= start_block
;
97 extp
->ext_len
= ext_len
;
98 efip
->efi_next_extent
++;
103 * This routine is called to allocate an "extent free done"
104 * log item that will hold nextents worth of extents. The
105 * caller must use all nextents extents, because we are not
106 * flexible about this at all.
109 xfs_trans_get_efd(xfs_trans_t
*tp
,
110 xfs_efi_log_item_t
*efip
,
113 xfs_efd_log_item_t
*efdp
;
116 ASSERT(nextents
> 0);
118 efdp
= xfs_efd_init(tp
->t_mountp
, efip
, nextents
);
119 ASSERT(efdp
!= NULL
);
122 * Get a log_item_desc to point at the new item.
124 (void) xfs_trans_add_item(tp
, (xfs_log_item_t
*)efdp
);
130 * This routine is called to indicate that the described
131 * extent is to be logged as having been freed. It should
132 * be called once for each extent freed.
135 xfs_trans_log_efd_extent(xfs_trans_t
*tp
,
136 xfs_efd_log_item_t
*efdp
,
137 xfs_fsblock_t start_block
,
138 xfs_extlen_t ext_len
)
140 xfs_log_item_desc_t
*lidp
;
144 lidp
= xfs_trans_find_item(tp
, (xfs_log_item_t
*)efdp
);
145 ASSERT(lidp
!= NULL
);
147 tp
->t_flags
|= XFS_TRANS_DIRTY
;
148 lidp
->lid_flags
|= XFS_LID_DIRTY
;
150 next_extent
= efdp
->efd_next_extent
;
151 ASSERT(next_extent
< efdp
->efd_format
.efd_nextents
);
152 extp
= &(efdp
->efd_format
.efd_extents
[next_extent
]);
153 extp
->ext_start
= start_block
;
154 extp
->ext_len
= ext_len
;
155 efdp
->efd_next_extent
++;