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_types.h"
37 #include "xfs_trans.h"
40 #include "xfs_dmapi.h"
41 #include "xfs_mount.h"
42 #include "xfs_trans_priv.h"
43 #include "xfs_extfree_item.h"
46 * This routine is called to allocate an "extent free intention"
47 * log item that will hold nextents worth of extents. The
48 * caller must use all nextents extents, because we are not
49 * flexible about this at all.
52 xfs_trans_get_efi(xfs_trans_t *tp,
55 xfs_efi_log_item_t *efip;
60 efip = xfs_efi_init(tp->t_mountp, nextents);
64 * Get a log_item_desc to point at the new item.
66 (void) xfs_trans_add_item(tp, (xfs_log_item_t*)efip);
72 * This routine is called to indicate that the described
73 * extent is to be logged as needing to be freed. It should
74 * be called once for each extent to be freed.
77 xfs_trans_log_efi_extent(xfs_trans_t *tp,
78 xfs_efi_log_item_t *efip,
79 xfs_fsblock_t start_block,
82 xfs_log_item_desc_t *lidp;
86 lidp = xfs_trans_find_item(tp, (xfs_log_item_t*)efip);
89 tp->t_flags |= XFS_TRANS_DIRTY;
90 lidp->lid_flags |= XFS_LID_DIRTY;
92 next_extent = efip->efi_next_extent;
93 ASSERT(next_extent < efip->efi_format.efi_nextents);
94 extp = &(efip->efi_format.efi_extents[next_extent]);
95 extp->ext_start = start_block;
96 extp->ext_len = ext_len;
97 efip->efi_next_extent++;
102 * This routine is called to allocate an "extent free done"
103 * log item that will hold nextents worth of extents. The
104 * caller must use all nextents extents, because we are not
105 * flexible about this at all.
108 xfs_trans_get_efd(xfs_trans_t *tp,
109 xfs_efi_log_item_t *efip,
112 xfs_efd_log_item_t *efdp;
115 ASSERT(nextents > 0);
117 efdp = xfs_efd_init(tp->t_mountp, efip, nextents);
118 ASSERT(efdp != NULL);
121 * Get a log_item_desc to point at the new item.
123 (void) xfs_trans_add_item(tp, (xfs_log_item_t*)efdp);
129 * This routine is called to indicate that the described
130 * extent is to be logged as having been freed. It should
131 * be called once for each extent freed.
134 xfs_trans_log_efd_extent(xfs_trans_t *tp,
135 xfs_efd_log_item_t *efdp,
136 xfs_fsblock_t start_block,
137 xfs_extlen_t ext_len)
139 xfs_log_item_desc_t *lidp;
143 lidp = xfs_trans_find_item(tp, (xfs_log_item_t*)efdp);
144 ASSERT(lidp != NULL);
146 tp->t_flags |= XFS_TRANS_DIRTY;
147 lidp->lid_flags |= XFS_LID_DIRTY;
149 next_extent = efdp->efd_next_extent;
150 ASSERT(next_extent < efdp->efd_format.efd_nextents);
151 extp = &(efdp->efd_format.efd_extents[next_extent]);
152 extp->ext_start = start_block;
153 extp->ext_len = ext_len;
154 efdp->efd_next_extent++;