aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_buf_item.c
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@infradead.org>2013-12-12 19:34:02 -0500
committerDave Chinner <david@fromorbit.com>2013-12-12 19:34:02 -0500
commitbde7cff67c39227c6ad503394e19e58debdbc5e3 (patch)
tree4325938342c4dece835e387e323106db53fe137d /fs/xfs/xfs_buf_item.c
parent1234351cba958cd5d4338172ccfc869a687cd736 (diff)
xfs: format log items write directly into the linear CIL buffer
Instead of setting up pointers to memory locations in iop_format which then get copied into the CIL linear buffer after return move the copy into the individual inode items. This avoids the need to always have a memory block in the exact same layout that gets written into the log around, and allow the log items to be much more flexible in their in-memory layouts. The only caveat is that we need to properly align the data for each iovec so that don't have structures misaligned in subsequent iovecs. Note that all log item format routines now need to be careful to modify the copy of the item that was placed into the CIL after calls to xlog_copy_iovec instead of the in-memory copy. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs/xfs_buf_item.c')
-rw-r--r--fs/xfs/xfs_buf_item.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/fs/xfs/xfs_buf_item.c b/fs/xfs/xfs_buf_item.c
index d49419d4bb46..764117305438 100644
--- a/fs/xfs/xfs_buf_item.c
+++ b/fs/xfs/xfs_buf_item.c
@@ -184,6 +184,7 @@ xfs_buf_item_size(
184 184
185static inline void 185static inline void
186xfs_buf_item_copy_iovec( 186xfs_buf_item_copy_iovec(
187 struct xfs_log_vec *lv,
187 struct xfs_log_iovec **vecp, 188 struct xfs_log_iovec **vecp,
188 struct xfs_buf *bp, 189 struct xfs_buf *bp,
189 uint offset, 190 uint offset,
@@ -191,7 +192,7 @@ xfs_buf_item_copy_iovec(
191 uint nbits) 192 uint nbits)
192{ 193{
193 offset += first_bit * XFS_BLF_CHUNK; 194 offset += first_bit * XFS_BLF_CHUNK;
194 xlog_copy_iovec(vecp, XLOG_REG_TYPE_BCHUNK, 195 xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_BCHUNK,
195 xfs_buf_offset(bp, offset), 196 xfs_buf_offset(bp, offset),
196 nbits * XFS_BLF_CHUNK); 197 nbits * XFS_BLF_CHUNK);
197} 198}
@@ -211,13 +212,13 @@ xfs_buf_item_straddle(
211static void 212static void
212xfs_buf_item_format_segment( 213xfs_buf_item_format_segment(
213 struct xfs_buf_log_item *bip, 214 struct xfs_buf_log_item *bip,
215 struct xfs_log_vec *lv,
214 struct xfs_log_iovec **vecp, 216 struct xfs_log_iovec **vecp,
215 uint offset, 217 uint offset,
216 struct xfs_buf_log_format *blfp) 218 struct xfs_buf_log_format *blfp)
217{ 219{
218 struct xfs_buf *bp = bip->bli_buf; 220 struct xfs_buf *bp = bip->bli_buf;
219 uint base_size; 221 uint base_size;
220 uint nvecs;
221 int first_bit; 222 int first_bit;
222 int last_bit; 223 int last_bit;
223 int next_bit; 224 int next_bit;
@@ -233,18 +234,17 @@ xfs_buf_item_format_segment(
233 */ 234 */
234 base_size = xfs_buf_log_format_size(blfp); 235 base_size = xfs_buf_log_format_size(blfp);
235 236
236 nvecs = 0;
237 first_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size, 0); 237 first_bit = xfs_next_bit(blfp->blf_data_map, blfp->blf_map_size, 0);
238 if (!(bip->bli_flags & XFS_BLI_STALE) && first_bit == -1) { 238 if (!(bip->bli_flags & XFS_BLI_STALE) && first_bit == -1) {
239 /* 239 /*
240 * If the map is not be dirty in the transaction, mark 240 * If the map is not be dirty in the transaction, mark
241 * the size as zero and do not advance the vector pointer. 241 * the size as zero and do not advance the vector pointer.
242 */ 242 */
243 goto out; 243 return;
244 } 244 }
245 245
246 xlog_copy_iovec(vecp, XLOG_REG_TYPE_BFORMAT, blfp, base_size); 246 blfp = xlog_copy_iovec(lv, vecp, XLOG_REG_TYPE_BFORMAT, blfp, base_size);
247 nvecs = 1; 247 blfp->blf_size = 1;
248 248
249 if (bip->bli_flags & XFS_BLI_STALE) { 249 if (bip->bli_flags & XFS_BLI_STALE) {
250 /* 250 /*
@@ -254,7 +254,7 @@ xfs_buf_item_format_segment(
254 */ 254 */
255 trace_xfs_buf_item_format_stale(bip); 255 trace_xfs_buf_item_format_stale(bip);
256 ASSERT(blfp->blf_flags & XFS_BLF_CANCEL); 256 ASSERT(blfp->blf_flags & XFS_BLF_CANCEL);
257 goto out; 257 return;
258 } 258 }
259 259
260 260
@@ -280,15 +280,15 @@ xfs_buf_item_format_segment(
280 * same set of bits so just keep counting and scanning. 280 * same set of bits so just keep counting and scanning.
281 */ 281 */
282 if (next_bit == -1) { 282 if (next_bit == -1) {
283 xfs_buf_item_copy_iovec(vecp, bp, offset, 283 xfs_buf_item_copy_iovec(lv, vecp, bp, offset,
284 first_bit, nbits); 284 first_bit, nbits);
285 nvecs++; 285 blfp->blf_size++;
286 break; 286 break;
287 } else if (next_bit != last_bit + 1 || 287 } else if (next_bit != last_bit + 1 ||
288 xfs_buf_item_straddle(bp, offset, next_bit, last_bit)) { 288 xfs_buf_item_straddle(bp, offset, next_bit, last_bit)) {
289 xfs_buf_item_copy_iovec(vecp, bp, offset, 289 xfs_buf_item_copy_iovec(lv, vecp, bp, offset,
290 first_bit, nbits); 290 first_bit, nbits);
291 nvecs++; 291 blfp->blf_size++;
292 first_bit = next_bit; 292 first_bit = next_bit;
293 last_bit = next_bit; 293 last_bit = next_bit;
294 nbits = 1; 294 nbits = 1;
@@ -297,8 +297,6 @@ xfs_buf_item_format_segment(
297 nbits++; 297 nbits++;
298 } 298 }
299 } 299 }
300out:
301 blfp->blf_size = nvecs;
302} 300}
303 301
304/* 302/*
@@ -310,10 +308,11 @@ out:
310STATIC void 308STATIC void
311xfs_buf_item_format( 309xfs_buf_item_format(
312 struct xfs_log_item *lip, 310 struct xfs_log_item *lip,
313 struct xfs_log_iovec *vecp) 311 struct xfs_log_vec *lv)
314{ 312{
315 struct xfs_buf_log_item *bip = BUF_ITEM(lip); 313 struct xfs_buf_log_item *bip = BUF_ITEM(lip);
316 struct xfs_buf *bp = bip->bli_buf; 314 struct xfs_buf *bp = bip->bli_buf;
315 struct xfs_log_iovec *vecp = NULL;
317 uint offset = 0; 316 uint offset = 0;
318 int i; 317 int i;
319 318
@@ -354,7 +353,7 @@ xfs_buf_item_format(
354 } 353 }
355 354
356 for (i = 0; i < bip->bli_format_count; i++) { 355 for (i = 0; i < bip->bli_format_count; i++) {
357 xfs_buf_item_format_segment(bip, &vecp, offset, 356 xfs_buf_item_format_segment(bip, lv, &vecp, offset,
358 &bip->bli_formats[i]); 357 &bip->bli_formats[i]);
359 offset += bp->b_maps[i].bm_len; 358 offset += bp->b_maps[i].bm_len;
360 } 359 }