aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2013-12-12 19:00:43 -0500
committerDave Chinner <david@fromorbit.com>2013-12-12 19:00:43 -0500
commit1234351cba958cd5d4338172ccfc869a687cd736 (patch)
tree4ac537e061808787a266a4d1fcfb0e09d185af2e
parent3de559fbd04d67473b9be2bd183823c40c4b7557 (diff)
xfs: introduce xlog_copy_iovec
Add a helper to abstract out filling the log iovecs in the log item format handlers. This will allow us to change the way we do the log item formatting more easily. The copy in the name is a bit confusing for now as it just assigns a pointer and lets the CIL code perform the copy, but that will change soon. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r--fs/xfs/xfs_buf_item.c30
-rw-r--r--fs/xfs/xfs_dquot_item.c25
-rw-r--r--fs/xfs/xfs_extfree_item.c19
-rw-r--r--fs/xfs/xfs_icreate_item.c9
-rw-r--r--fs/xfs/xfs_inode_item.c115
-rw-r--r--fs/xfs/xfs_log.h13
6 files changed, 103 insertions, 108 deletions
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index a30c1fb1bec6..d49419d4bb46 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -182,20 +182,18 @@ xfs_buf_item_size(
182 trace_xfs_buf_item_size(bip); 182 trace_xfs_buf_item_size(bip);
183} 183}
184 184
185static inline struct xfs_log_iovec * 185static inline void
186xfs_buf_item_copy_iovec( 186xfs_buf_item_copy_iovec(
187 struct xfs_log_iovec *vecp, 187 struct xfs_log_iovec **vecp,
188 struct xfs_buf *bp, 188 struct xfs_buf *bp,
189 uint offset, 189 uint offset,
190 int first_bit, 190 int first_bit,
191 uint nbits) 191 uint nbits)
192{ 192{
193 offset += first_bit * XFS_BLF_CHUNK; 193 offset += first_bit * XFS_BLF_CHUNK;
194 194 xlog_copy_iovec(vecp, XLOG_REG_TYPE_BCHUNK,
195 vecp->i_type = XLOG_REG_TYPE_BCHUNK; 195 xfs_buf_offset(bp, offset),
196 vecp->i_addr = xfs_buf_offset(bp, offset); 196 nbits * XFS_BLF_CHUNK);
197 vecp->i_len = nbits * XFS_BLF_CHUNK;
198 return vecp + 1;
199} 197}
200 198
201static inline bool 199static inline bool
@@ -210,10 +208,10 @@ xfs_buf_item_straddle(
210 XFS_BLF_CHUNK); 208 XFS_BLF_CHUNK);
211} 209}
212 210
213static struct xfs_log_iovec * 211static void
214xfs_buf_item_format_segment( 212xfs_buf_item_format_segment(
215 struct xfs_buf_log_item *bip, 213 struct xfs_buf_log_item *bip,
216 struct xfs_log_iovec *vecp, 214 struct xfs_log_iovec **vecp,
217 uint offset, 215 uint offset,
218 struct xfs_buf_log_format *blfp) 216 struct xfs_buf_log_format *blfp)
219{ 217{
@@ -245,10 +243,7 @@ xfs_buf_item_format_segment(
245 goto out; 243 goto out;
246 } 244 }
247 245
248 vecp->i_addr = blfp; 246 xlog_copy_iovec(vecp, XLOG_REG_TYPE_BFORMAT, blfp, base_size);
249 vecp->i_len = base_size;
250 vecp->i_type = XLOG_REG_TYPE_BFORMAT;
251 vecp++;
252 nvecs = 1; 247 nvecs = 1;
253 248
254 if (bip->bli_flags & XFS_BLI_STALE) { 249 if (bip->bli_flags & XFS_BLI_STALE) {
@@ -291,8 +286,8 @@ xfs_buf_item_format_segment(
291 break; 286 break;
292 } else if (next_bit != last_bit + 1 || 287 } else if (next_bit != last_bit + 1 ||
293 xfs_buf_item_straddle(bp, offset, next_bit, last_bit)) { 288 xfs_buf_item_straddle(bp, offset, next_bit, last_bit)) {
294 vecp = xfs_buf_item_copy_iovec(vecp, bp, offset, 289 xfs_buf_item_copy_iovec(vecp, bp, offset,
295 first_bit, nbits); 290 first_bit, nbits);
296 nvecs++; 291 nvecs++;
297 first_bit = next_bit; 292 first_bit = next_bit;
298 last_bit = next_bit; 293 last_bit = next_bit;
@@ -304,7 +299,6 @@ xfs_buf_item_format_segment(
304 } 299 }
305out: 300out:
306 blfp->blf_size = nvecs; 301 blfp->blf_size = nvecs;
307 return vecp;
308} 302}
309 303
310/* 304/*
@@ -360,8 +354,8 @@ xfs_buf_item_format(
360 } 354 }
361 355
362 for (i = 0; i < bip->bli_format_count; i++) { 356 for (i = 0; i < bip->bli_format_count; i++) {
363 vecp = xfs_buf_item_format_segment(bip, vecp, offset, 357 xfs_buf_item_format_segment(bip, &vecp, offset,
364 &bip->bli_formats[i]); 358 &bip->bli_formats[i]);
365 offset += bp->b_maps[i].bm_len; 359 offset += bp->b_maps[i].bm_len;
366 } 360 }
367 361
diff --git a/fs/xfs/xfs_dquot_item.c b/fs/xfs/xfs_dquot_item.c
index 92e5f62eefc6..ca354a821838 100644
--- a/fs/xfs/xfs_dquot_item.c
+++ b/fs/xfs/xfs_dquot_item.c
@@ -57,20 +57,18 @@ xfs_qm_dquot_logitem_size(
57STATIC void 57STATIC void
58xfs_qm_dquot_logitem_format( 58xfs_qm_dquot_logitem_format(
59 struct xfs_log_item *lip, 59 struct xfs_log_item *lip,
60 struct xfs_log_iovec *logvec) 60 struct xfs_log_iovec *vecp)
61{ 61{
62 struct xfs_dq_logitem *qlip = DQUOT_ITEM(lip); 62 struct xfs_dq_logitem *qlip = DQUOT_ITEM(lip);
63 63
64 logvec->i_addr = &qlip->qli_format; 64 xlog_copy_iovec(&vecp, XLOG_REG_TYPE_QFORMAT,
65 logvec->i_len = sizeof(xfs_dq_logformat_t); 65 &qlip->qli_format,
66 logvec->i_type = XLOG_REG_TYPE_QFORMAT; 66 sizeof(struct xfs_dq_logformat));
67 logvec++; 67 xlog_copy_iovec(&vecp, XLOG_REG_TYPE_DQUOT,
68 logvec->i_addr = &qlip->qli_dquot->q_core; 68 &qlip->qli_dquot->q_core,
69 logvec->i_len = sizeof(xfs_disk_dquot_t); 69 sizeof(struct xfs_disk_dquot));
70 logvec->i_type = XLOG_REG_TYPE_DQUOT;
71 70
72 qlip->qli_format.qlf_size = 2; 71 qlip->qli_format.qlf_size = 2;
73
74} 72}
75 73
76/* 74/*
@@ -304,15 +302,16 @@ xfs_qm_qoff_logitem_size(
304STATIC void 302STATIC void
305xfs_qm_qoff_logitem_format( 303xfs_qm_qoff_logitem_format(
306 struct xfs_log_item *lip, 304 struct xfs_log_item *lip,
307 struct xfs_log_iovec *log_vector) 305 struct xfs_log_iovec *vecp)
308{ 306{
309 struct xfs_qoff_logitem *qflip = QOFF_ITEM(lip); 307 struct xfs_qoff_logitem *qflip = QOFF_ITEM(lip);
310 308
311 ASSERT(qflip->qql_format.qf_type == XFS_LI_QUOTAOFF); 309 ASSERT(qflip->qql_format.qf_type == XFS_LI_QUOTAOFF);
312 310
313 log_vector->i_addr = &qflip->qql_format; 311 xlog_copy_iovec(&vecp, XLOG_REG_TYPE_QUOTAOFF,
314 log_vector->i_len = sizeof(xfs_qoff_logitem_t); 312 &qflip->qql_format,
315 log_vector->i_type = XLOG_REG_TYPE_QUOTAOFF; 313 sizeof(struct xfs_qoff_logitem));
314
316 qflip->qql_format.qf_size = 1; 315 qflip->qql_format.qf_size = 1;
317} 316}
318 317
diff --git a/fs/xfs/xfs_extfree_item.c b/fs/xfs/xfs_extfree_item.c
index 3680d04f973f..08823ecbcd82 100644
--- a/fs/xfs/xfs_extfree_item.c
+++ b/fs/xfs/xfs_extfree_item.c
@@ -26,6 +26,7 @@
26#include "xfs_trans_priv.h" 26#include "xfs_trans_priv.h"
27#include "xfs_buf_item.h" 27#include "xfs_buf_item.h"
28#include "xfs_extfree_item.h" 28#include "xfs_extfree_item.h"
29#include "xfs_log.h"
29 30
30 31
31kmem_zone_t *xfs_efi_zone; 32kmem_zone_t *xfs_efi_zone;
@@ -101,7 +102,7 @@ xfs_efi_item_size(
101STATIC void 102STATIC void
102xfs_efi_item_format( 103xfs_efi_item_format(
103 struct xfs_log_item *lip, 104 struct xfs_log_item *lip,
104 struct xfs_log_iovec *log_vector) 105 struct xfs_log_iovec *vecp)
105{ 106{
106 struct xfs_efi_log_item *efip = EFI_ITEM(lip); 107 struct xfs_efi_log_item *efip = EFI_ITEM(lip);
107 108
@@ -111,10 +112,9 @@ xfs_efi_item_format(
111 efip->efi_format.efi_type = XFS_LI_EFI; 112 efip->efi_format.efi_type = XFS_LI_EFI;
112 efip->efi_format.efi_size = 1; 113 efip->efi_format.efi_size = 1;
113 114
114 log_vector->i_addr = &efip->efi_format; 115 xlog_copy_iovec(&vecp, XLOG_REG_TYPE_EFI_FORMAT,
115 log_vector->i_len = xfs_efi_item_sizeof(efip); 116 &efip->efi_format,
116 log_vector->i_type = XLOG_REG_TYPE_EFI_FORMAT; 117 xfs_efi_item_sizeof(efip));
117 ASSERT(log_vector->i_len >= sizeof(xfs_efi_log_format_t));
118} 118}
119 119
120 120
@@ -368,7 +368,7 @@ xfs_efd_item_size(
368STATIC void 368STATIC void
369xfs_efd_item_format( 369xfs_efd_item_format(
370 struct xfs_log_item *lip, 370 struct xfs_log_item *lip,
371 struct xfs_log_iovec *log_vector) 371 struct xfs_log_iovec *vecp)
372{ 372{
373 struct xfs_efd_log_item *efdp = EFD_ITEM(lip); 373 struct xfs_efd_log_item *efdp = EFD_ITEM(lip);
374 374
@@ -377,10 +377,9 @@ xfs_efd_item_format(
377 efdp->efd_format.efd_type = XFS_LI_EFD; 377 efdp->efd_format.efd_type = XFS_LI_EFD;
378 efdp->efd_format.efd_size = 1; 378 efdp->efd_format.efd_size = 1;
379 379
380 log_vector->i_addr = &efdp->efd_format; 380 xlog_copy_iovec(&vecp, XLOG_REG_TYPE_EFD_FORMAT,
381 log_vector->i_len = xfs_efd_item_sizeof(efdp); 381 &efdp->efd_format,
382 log_vector->i_type = XLOG_REG_TYPE_EFD_FORMAT; 382 xfs_efd_item_sizeof(efdp));
383 ASSERT(log_vector->i_len >= sizeof(xfs_efd_log_format_t));
384} 383}
385 384
386/* 385/*
diff --git a/fs/xfs/xfs_icreate_item.c b/fs/xfs/xfs_icreate_item.c
index d2eaccfa73f4..5751fa8580ee 100644
--- a/fs/xfs/xfs_icreate_item.c
+++ b/fs/xfs/xfs_icreate_item.c
@@ -28,6 +28,7 @@
28#include "xfs_trans_priv.h" 28#include "xfs_trans_priv.h"
29#include "xfs_error.h" 29#include "xfs_error.h"
30#include "xfs_icreate_item.h" 30#include "xfs_icreate_item.h"
31#include "xfs_log.h"
31 32
32kmem_zone_t *xfs_icreate_zone; /* inode create item zone */ 33kmem_zone_t *xfs_icreate_zone; /* inode create item zone */
33 34
@@ -58,13 +59,13 @@ xfs_icreate_item_size(
58STATIC void 59STATIC void
59xfs_icreate_item_format( 60xfs_icreate_item_format(
60 struct xfs_log_item *lip, 61 struct xfs_log_item *lip,
61 struct xfs_log_iovec *log_vector) 62 struct xfs_log_iovec *vecp)
62{ 63{
63 struct xfs_icreate_item *icp = ICR_ITEM(lip); 64 struct xfs_icreate_item *icp = ICR_ITEM(lip);
64 65
65 log_vector->i_addr = (xfs_caddr_t)&icp->ic_format; 66 xlog_copy_iovec(&vecp, XLOG_REG_TYPE_ICREATE,
66 log_vector->i_len = sizeof(struct xfs_icreate_log); 67 &icp->ic_format,
67 log_vector->i_type = XLOG_REG_TYPE_ICREATE; 68 sizeof(struct xfs_icreate_log));
68} 69}
69 70
70 71
diff --git a/fs/xfs/xfs_inode_item.c b/fs/xfs/xfs_inode_item.c
index 2ad12dcf8311..c75e14beff06 100644
--- a/fs/xfs/xfs_inode_item.c
+++ b/fs/xfs/xfs_inode_item.c
@@ -30,6 +30,7 @@
30#include "xfs_trace.h" 30#include "xfs_trace.h"
31#include "xfs_trans_priv.h" 31#include "xfs_trans_priv.h"
32#include "xfs_dinode.h" 32#include "xfs_dinode.h"
33#include "xfs_log.h"
33 34
34 35
35kmem_zone_t *xfs_ili_zone; /* inode log item zone */ 36kmem_zone_t *xfs_ili_zone; /* inode log item zone */
@@ -159,14 +160,15 @@ xfs_inode_item_size(
159 * here, so always use the physical fork size to determine the size of the 160 * here, so always use the physical fork size to determine the size of the
160 * buffer we need to allocate. 161 * buffer we need to allocate.
161 */ 162 */
162STATIC void 163STATIC int
163xfs_inode_item_format_extents( 164xfs_inode_item_format_extents(
164 struct xfs_inode *ip, 165 struct xfs_inode *ip,
165 struct xfs_log_iovec *vecp, 166 struct xfs_log_iovec **vecp,
166 int whichfork, 167 int whichfork,
167 int type) 168 int type)
168{ 169{
169 xfs_bmbt_rec_t *ext_buffer; 170 xfs_bmbt_rec_t *ext_buffer;
171 int len;
170 172
171 ext_buffer = kmem_alloc(XFS_IFORK_SIZE(ip, whichfork), KM_SLEEP); 173 ext_buffer = kmem_alloc(XFS_IFORK_SIZE(ip, whichfork), KM_SLEEP);
172 if (whichfork == XFS_DATA_FORK) 174 if (whichfork == XFS_DATA_FORK)
@@ -174,9 +176,9 @@ xfs_inode_item_format_extents(
174 else 176 else
175 ip->i_itemp->ili_aextents_buf = ext_buffer; 177 ip->i_itemp->ili_aextents_buf = ext_buffer;
176 178
177 vecp->i_addr = ext_buffer; 179 len = xfs_iextents_copy(ip, ext_buffer, whichfork);
178 vecp->i_len = xfs_iextents_copy(ip, ext_buffer, whichfork); 180 xlog_copy_iovec(vecp, type, ext_buffer, len);
179 vecp->i_type = type; 181 return len;
180} 182}
181 183
182/* 184/*
@@ -207,10 +209,10 @@ xfs_inode_item_format_v1_inode(
207 } 209 }
208} 210}
209 211
210STATIC struct xfs_log_iovec * 212STATIC void
211xfs_inode_item_format_data_fork( 213xfs_inode_item_format_data_fork(
212 struct xfs_inode_log_item *iip, 214 struct xfs_inode_log_item *iip,
213 struct xfs_log_iovec *vecp, 215 struct xfs_log_iovec **vecp,
214 int *nvecs) 216 int *nvecs)
215{ 217{
216 struct xfs_inode *ip = iip->ili_inode; 218 struct xfs_inode *ip = iip->ili_inode;
@@ -237,18 +239,18 @@ xfs_inode_item_format_data_fork(
237 * extents, so just point to the 239 * extents, so just point to the
238 * real extents array. 240 * real extents array.
239 */ 241 */
240 vecp->i_addr = ip->i_df.if_u1.if_extents; 242 xlog_copy_iovec(vecp, XLOG_REG_TYPE_IEXT,
241 vecp->i_len = ip->i_df.if_bytes; 243 ip->i_df.if_u1.if_extents,
242 vecp->i_type = XLOG_REG_TYPE_IEXT; 244 ip->i_df.if_bytes);
245 iip->ili_format.ilf_dsize = ip->i_df.if_bytes;
243 } else 246 } else
244#endif 247#endif
245 { 248 {
246 xfs_inode_item_format_extents(ip, vecp, 249 iip->ili_format.ilf_dsize =
247 XFS_DATA_FORK, XLOG_REG_TYPE_IEXT); 250 xfs_inode_item_format_extents(ip, vecp,
251 XFS_DATA_FORK, XLOG_REG_TYPE_IEXT);
252 ASSERT(iip->ili_format.ilf_dsize <= ip->i_df.if_bytes);
248 } 253 }
249 ASSERT(vecp->i_len <= ip->i_df.if_bytes);
250 iip->ili_format.ilf_dsize = vecp->i_len;
251 vecp++;
252 (*nvecs)++; 254 (*nvecs)++;
253 } else { 255 } else {
254 iip->ili_fields &= ~XFS_ILOG_DEXT; 256 iip->ili_fields &= ~XFS_ILOG_DEXT;
@@ -262,10 +264,9 @@ xfs_inode_item_format_data_fork(
262 if ((iip->ili_fields & XFS_ILOG_DBROOT) && 264 if ((iip->ili_fields & XFS_ILOG_DBROOT) &&
263 ip->i_df.if_broot_bytes > 0) { 265 ip->i_df.if_broot_bytes > 0) {
264 ASSERT(ip->i_df.if_broot != NULL); 266 ASSERT(ip->i_df.if_broot != NULL);
265 vecp->i_addr = ip->i_df.if_broot; 267 xlog_copy_iovec(vecp, XLOG_REG_TYPE_IBROOT,
266 vecp->i_len = ip->i_df.if_broot_bytes; 268 ip->i_df.if_broot,
267 vecp->i_type = XLOG_REG_TYPE_IBROOT; 269 ip->i_df.if_broot_bytes);
268 vecp++;
269 (*nvecs)++; 270 (*nvecs)++;
270 iip->ili_format.ilf_dsize = ip->i_df.if_broot_bytes; 271 iip->ili_format.ilf_dsize = ip->i_df.if_broot_bytes;
271 } else { 272 } else {
@@ -280,21 +281,18 @@ xfs_inode_item_format_data_fork(
280 XFS_ILOG_DEV | XFS_ILOG_UUID); 281 XFS_ILOG_DEV | XFS_ILOG_UUID);
281 if ((iip->ili_fields & XFS_ILOG_DDATA) && 282 if ((iip->ili_fields & XFS_ILOG_DDATA) &&
282 ip->i_df.if_bytes > 0) { 283 ip->i_df.if_bytes > 0) {
283 ASSERT(ip->i_df.if_u1.if_data != NULL);
284 ASSERT(ip->i_d.di_size > 0);
285
286 vecp->i_addr = ip->i_df.if_u1.if_data;
287 /* 284 /*
288 * Round i_bytes up to a word boundary. 285 * Round i_bytes up to a word boundary.
289 * The underlying memory is guaranteed to 286 * The underlying memory is guaranteed to
290 * to be there by xfs_idata_realloc(). 287 * to be there by xfs_idata_realloc().
291 */ 288 */
292 data_bytes = roundup(ip->i_df.if_bytes, 4); 289 data_bytes = roundup(ip->i_df.if_bytes, 4);
293 ASSERT((ip->i_df.if_real_bytes == 0) || 290 ASSERT(ip->i_df.if_real_bytes == 0 ||
294 (ip->i_df.if_real_bytes == data_bytes)); 291 ip->i_df.if_real_bytes == data_bytes);
295 vecp->i_len = (int)data_bytes; 292 ASSERT(ip->i_df.if_u1.if_data != NULL);
296 vecp->i_type = XLOG_REG_TYPE_ILOCAL; 293 ASSERT(ip->i_d.di_size > 0);
297 vecp++; 294 xlog_copy_iovec(vecp, XLOG_REG_TYPE_ILOCAL,
295 ip->i_df.if_u1.if_data, data_bytes);
298 (*nvecs)++; 296 (*nvecs)++;
299 iip->ili_format.ilf_dsize = (unsigned)data_bytes; 297 iip->ili_format.ilf_dsize = (unsigned)data_bytes;
300 } else { 298 } else {
@@ -323,14 +321,12 @@ xfs_inode_item_format_data_fork(
323 ASSERT(0); 321 ASSERT(0);
324 break; 322 break;
325 } 323 }
326
327 return vecp;
328} 324}
329 325
330STATIC struct xfs_log_iovec * 326STATIC void
331xfs_inode_item_format_attr_fork( 327xfs_inode_item_format_attr_fork(
332 struct xfs_inode_log_item *iip, 328 struct xfs_inode_log_item *iip,
333 struct xfs_log_iovec *vecp, 329 struct xfs_log_iovec **vecp,
334 int *nvecs) 330 int *nvecs)
335{ 331{
336 struct xfs_inode *ip = iip->ili_inode; 332 struct xfs_inode *ip = iip->ili_inode;
@@ -352,16 +348,16 @@ xfs_inode_item_format_attr_fork(
352 * There are not delayed allocation extents 348 * There are not delayed allocation extents
353 * for attributes, so just point at the array. 349 * for attributes, so just point at the array.
354 */ 350 */
355 vecp->i_addr = ip->i_afp->if_u1.if_extents; 351 xlog_copy_iovec(vecp, XLOG_REG_TYPE_IATTR_EXT,
356 vecp->i_len = ip->i_afp->if_bytes; 352 ip->i_afp->if_u1.if_extents,
357 vecp->i_type = XLOG_REG_TYPE_IATTR_EXT; 353 ip->i_afp->if_bytes);
354 iip->ili_format.ilf_asize = ip->i_afp->if_bytes;
358#else 355#else
359 ASSERT(iip->ili_aextents_buf == NULL); 356 ASSERT(iip->ili_aextents_buf == NULL);
360 xfs_inode_item_format_extents(ip, vecp, 357 iip->ili_format.ilf_asize =
358 xfs_inode_item_format_extents(ip, vecp,
361 XFS_ATTR_FORK, XLOG_REG_TYPE_IATTR_EXT); 359 XFS_ATTR_FORK, XLOG_REG_TYPE_IATTR_EXT);
362#endif 360#endif
363 iip->ili_format.ilf_asize = vecp->i_len;
364 vecp++;
365 (*nvecs)++; 361 (*nvecs)++;
366 } else { 362 } else {
367 iip->ili_fields &= ~XFS_ILOG_AEXT; 363 iip->ili_fields &= ~XFS_ILOG_AEXT;
@@ -375,10 +371,9 @@ xfs_inode_item_format_attr_fork(
375 ip->i_afp->if_broot_bytes > 0) { 371 ip->i_afp->if_broot_bytes > 0) {
376 ASSERT(ip->i_afp->if_broot != NULL); 372 ASSERT(ip->i_afp->if_broot != NULL);
377 373
378 vecp->i_addr = ip->i_afp->if_broot; 374 xlog_copy_iovec(vecp, XLOG_REG_TYPE_IATTR_BROOT,
379 vecp->i_len = ip->i_afp->if_broot_bytes; 375 ip->i_afp->if_broot,
380 vecp->i_type = XLOG_REG_TYPE_IATTR_BROOT; 376 ip->i_afp->if_broot_bytes);
381 vecp++;
382 (*nvecs)++; 377 (*nvecs)++;
383 iip->ili_format.ilf_asize = ip->i_afp->if_broot_bytes; 378 iip->ili_format.ilf_asize = ip->i_afp->if_broot_bytes;
384 } else { 379 } else {
@@ -391,20 +386,18 @@ xfs_inode_item_format_attr_fork(
391 386
392 if ((iip->ili_fields & XFS_ILOG_ADATA) && 387 if ((iip->ili_fields & XFS_ILOG_ADATA) &&
393 ip->i_afp->if_bytes > 0) { 388 ip->i_afp->if_bytes > 0) {
394 ASSERT(ip->i_afp->if_u1.if_data != NULL);
395
396 vecp->i_addr = ip->i_afp->if_u1.if_data;
397 /* 389 /*
398 * Round i_bytes up to a word boundary. 390 * Round i_bytes up to a word boundary.
399 * The underlying memory is guaranteed to 391 * The underlying memory is guaranteed to
400 * to be there by xfs_idata_realloc(). 392 * to be there by xfs_idata_realloc().
401 */ 393 */
402 data_bytes = roundup(ip->i_afp->if_bytes, 4); 394 data_bytes = roundup(ip->i_afp->if_bytes, 4);
403 ASSERT((ip->i_afp->if_real_bytes == 0) || 395 ASSERT(ip->i_afp->if_real_bytes == 0 ||
404 (ip->i_afp->if_real_bytes == data_bytes)); 396 ip->i_afp->if_real_bytes == data_bytes);
405 vecp->i_len = (int)data_bytes; 397 ASSERT(ip->i_afp->if_u1.if_data != NULL);
406 vecp->i_type = XLOG_REG_TYPE_IATTR_LOCAL; 398 xlog_copy_iovec(vecp, XLOG_REG_TYPE_IATTR_LOCAL,
407 vecp++; 399 ip->i_afp->if_u1.if_data,
400 data_bytes);
408 (*nvecs)++; 401 (*nvecs)++;
409 iip->ili_format.ilf_asize = (unsigned)data_bytes; 402 iip->ili_format.ilf_asize = (unsigned)data_bytes;
410 } else { 403 } else {
@@ -415,8 +408,6 @@ xfs_inode_item_format_attr_fork(
415 ASSERT(0); 408 ASSERT(0);
416 break; 409 break;
417 } 410 }
418
419 return vecp;
420} 411}
421 412
422/* 413/*
@@ -435,24 +426,22 @@ xfs_inode_item_format(
435 struct xfs_inode *ip = iip->ili_inode; 426 struct xfs_inode *ip = iip->ili_inode;
436 uint nvecs; 427 uint nvecs;
437 428
438 vecp->i_addr = &iip->ili_format; 429 xlog_copy_iovec(&vecp, XLOG_REG_TYPE_IFORMAT,
439 vecp->i_len = sizeof(xfs_inode_log_format_t); 430 &iip->ili_format,
440 vecp->i_type = XLOG_REG_TYPE_IFORMAT; 431 sizeof(struct xfs_inode_log_format));
441 vecp++; 432 nvecs = 1;
442 nvecs = 1;
443 433
444 vecp->i_addr = &ip->i_d; 434 xlog_copy_iovec(&vecp, XLOG_REG_TYPE_ICORE,
445 vecp->i_len = xfs_icdinode_size(ip->i_d.di_version); 435 &ip->i_d,
446 vecp->i_type = XLOG_REG_TYPE_ICORE; 436 xfs_icdinode_size(ip->i_d.di_version));
447 vecp++;
448 nvecs++; 437 nvecs++;
449 438
450 if (ip->i_d.di_version == 1) 439 if (ip->i_d.di_version == 1)
451 xfs_inode_item_format_v1_inode(ip); 440 xfs_inode_item_format_v1_inode(ip);
452 441
453 vecp = xfs_inode_item_format_data_fork(iip, vecp, &nvecs); 442 xfs_inode_item_format_data_fork(iip, &vecp, &nvecs);
454 if (XFS_IFORK_Q(ip)) { 443 if (XFS_IFORK_Q(ip)) {
455 vecp = xfs_inode_item_format_attr_fork(iip, vecp, &nvecs); 444 xfs_inode_item_format_attr_fork(iip, &vecp, &nvecs);
456 } else { 445 } else {
457 iip->ili_fields &= 446 iip->ili_fields &=
458 ~(XFS_ILOG_ADATA | XFS_ILOG_ABROOT | XFS_ILOG_AEXT); 447 ~(XFS_ILOG_ADATA | XFS_ILOG_ABROOT | XFS_ILOG_AEXT);
diff --git a/fs/xfs/xfs_log.h b/fs/xfs/xfs_log.h
index e148719e0a5d..384c6c469661 100644
--- a/fs/xfs/xfs_log.h
+++ b/fs/xfs/xfs_log.h
@@ -30,6 +30,19 @@ struct xfs_log_vec {
30 30
31#define XFS_LOG_VEC_ORDERED (-1) 31#define XFS_LOG_VEC_ORDERED (-1)
32 32
33static inline void *
34xlog_copy_iovec(struct xfs_log_iovec **vecp, uint type, void *data, int len)
35{
36 struct xfs_log_iovec *vec = *vecp;
37
38 vec->i_type = type;
39 vec->i_addr = data;
40 vec->i_len = len;
41
42 *vecp = vec + 1;
43 return vec->i_addr;
44}
45
33/* 46/*
34 * Structure used to pass callback function and the function's argument 47 * Structure used to pass callback function and the function's argument
35 * to the log manager. 48 * to the log manager.