]>
git.ipfire.org Git - thirdparty/xfsprogs-dev.git/blob - libxfs/logitem.c
2 * Copyright (c) 2000-2001,2005 Silicon Graphics, Inc.
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.
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.
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
19 #include "libxfs_priv.h"
21 #include "xfs_shared.h"
22 #include "xfs_format.h"
23 #include "xfs_log_format.h"
24 #include "xfs_trans_resv.h"
25 #include "xfs_mount.h"
26 #include "xfs_inode_buf.h"
27 #include "xfs_inode_fork.h"
28 #include "xfs_inode.h"
29 #include "xfs_trans.h"
31 kmem_zone_t
*xfs_buf_item_zone
;
32 kmem_zone_t
*xfs_ili_zone
; /* inode log item zone */
35 * Following functions from fs/xfs/xfs_trans_buf.c
39 * Check to see if a buffer matching the given parameters is already
40 * a part of the given transaction.
43 xfs_trans_buf_item_match(
45 struct xfs_buftarg
*btp
,
46 struct xfs_buf_map
*map
,
49 struct xfs_log_item_desc
*lidp
;
50 struct xfs_buf_log_item
*blip
;
54 for (i
= 0; i
< nmaps
; i
++)
57 list_for_each_entry(lidp
, &tp
->t_items
, lid_trans
) {
58 blip
= (struct xfs_buf_log_item
*)lidp
->lid_item
;
59 if (blip
->bli_item
.li_type
== XFS_LI_BUF
&&
60 blip
->bli_buf
->b_target
->dev
== btp
->dev
&&
61 XFS_BUF_ADDR(blip
->bli_buf
) == map
[0].bm_bn
&&
62 blip
->bli_buf
->b_bcount
== BBTOB(len
)) {
63 ASSERT(blip
->bli_buf
->b_map_count
== nmaps
);
71 * The following are from fs/xfs/xfs_buf_item.c
75 * Allocate a new buf log item to go with the given buffer.
76 * Set the buffer's b_log_item field to point to the new
77 * buf log item. If there are other item's attached to the
78 * buffer (see xfs_buf_attach_iodone() below), then put the
79 * buf log item at the front.
87 xfs_buf_log_item_t
*bip
;
90 fprintf(stderr
, "buf_item_init for buffer %p\n", bp
);
94 * Check to see if there is already a buf log item for
95 * this buffer. If there is, it is guaranteed to be
96 * the first. If we do already have one, there is
97 * nothing to do here so return.
99 XFS_BUF_SET_BDSTRAT_FUNC(bp
, xfs_bdstrat_cb
);
100 if (bp
->b_log_item
!= NULL
) {
101 lip
= bp
->b_log_item
;
102 if (lip
->li_type
== XFS_LI_BUF
) {
105 "reused buf item %p for pre-logged buffer %p\n",
112 bip
= (xfs_buf_log_item_t
*)kmem_zone_zalloc(xfs_buf_item_zone
,
115 fprintf(stderr
, "adding buf item %p for not-logged buffer %p\n",
118 bip
->bli_item
.li_type
= XFS_LI_BUF
;
119 bip
->bli_item
.li_mountp
= mp
;
121 bip
->bli_format
.blf_type
= XFS_LI_BUF
;
122 bip
->bli_format
.blf_blkno
= (int64_t)XFS_BUF_ADDR(bp
);
123 bip
->bli_format
.blf_len
= (unsigned short)BTOBB(XFS_BUF_COUNT(bp
));
124 bp
->b_log_item
= bip
;
129 * Mark bytes first through last inclusive as dirty in the buf
134 xfs_buf_log_item_t
*bip
,
139 * Mark the item as having some dirty data for
140 * quick reference in xfs_buf_item_dirty.
142 bip
->bli_flags
|= XFS_BLI_DIRTY
;
146 * Initialize the inode log item for a newly allocated (in-core) inode.
153 xfs_inode_log_item_t
*iip
;
155 ASSERT(ip
->i_itemp
== NULL
);
156 iip
= ip
->i_itemp
= (xfs_inode_log_item_t
*)
157 kmem_zone_zalloc(xfs_ili_zone
, KM_SLEEP
);
159 fprintf(stderr
, "inode_item_init for inode %llu, iip=%p\n",
163 iip
->ili_item
.li_type
= XFS_LI_INODE
;
164 iip
->ili_item
.li_mountp
= mp
;