diff options
author | Jiri Kosina <jkosina@suse.cz> | 2010-06-16 12:08:13 -0400 |
---|---|---|
committer | Jiri Kosina <jkosina@suse.cz> | 2010-06-16 12:08:13 -0400 |
commit | f1bbbb6912662b9f6070c5bfc4ca9eb1f06a9d5b (patch) | |
tree | c2c130a74be25b0b2dff992e1a195e2728bdaadd /fs/xfs/xfs_trans.h | |
parent | fd0961ff67727482bb20ca7e8ea97b83e9de2ddb (diff) | |
parent | 7e27d6e778cd87b6f2415515d7127eba53fe5d02 (diff) |
Merge branch 'master' into for-next
Diffstat (limited to 'fs/xfs/xfs_trans.h')
-rw-r--r-- | fs/xfs/xfs_trans.h | 455 |
1 files changed, 10 insertions, 445 deletions
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h index c62beee0921e..e639e8e9a2a9 100644 --- a/fs/xfs/xfs_trans.h +++ b/fs/xfs/xfs_trans.h | |||
@@ -106,7 +106,8 @@ typedef struct xfs_trans_header { | |||
106 | #define XFS_TRANS_GROWFSRT_FREE 39 | 106 | #define XFS_TRANS_GROWFSRT_FREE 39 |
107 | #define XFS_TRANS_SWAPEXT 40 | 107 | #define XFS_TRANS_SWAPEXT 40 |
108 | #define XFS_TRANS_SB_COUNT 41 | 108 | #define XFS_TRANS_SB_COUNT 41 |
109 | #define XFS_TRANS_TYPE_MAX 41 | 109 | #define XFS_TRANS_CHECKPOINT 42 |
110 | #define XFS_TRANS_TYPE_MAX 42 | ||
110 | /* new transaction types need to be reflected in xfs_logprint(8) */ | 111 | /* new transaction types need to be reflected in xfs_logprint(8) */ |
111 | 112 | ||
112 | #define XFS_TRANS_TYPES \ | 113 | #define XFS_TRANS_TYPES \ |
@@ -148,6 +149,7 @@ typedef struct xfs_trans_header { | |||
148 | { XFS_TRANS_GROWFSRT_FREE, "GROWFSRT_FREE" }, \ | 149 | { XFS_TRANS_GROWFSRT_FREE, "GROWFSRT_FREE" }, \ |
149 | { XFS_TRANS_SWAPEXT, "SWAPEXT" }, \ | 150 | { XFS_TRANS_SWAPEXT, "SWAPEXT" }, \ |
150 | { XFS_TRANS_SB_COUNT, "SB_COUNT" }, \ | 151 | { XFS_TRANS_SB_COUNT, "SB_COUNT" }, \ |
152 | { XFS_TRANS_CHECKPOINT, "CHECKPOINT" }, \ | ||
151 | { XFS_TRANS_DUMMY1, "DUMMY1" }, \ | 153 | { XFS_TRANS_DUMMY1, "DUMMY1" }, \ |
152 | { XFS_TRANS_DUMMY2, "DUMMY2" }, \ | 154 | { XFS_TRANS_DUMMY2, "DUMMY2" }, \ |
153 | { XLOG_UNMOUNT_REC_TYPE, "UNMOUNT" } | 155 | { XLOG_UNMOUNT_REC_TYPE, "UNMOUNT" } |
@@ -298,24 +300,6 @@ xfs_lic_desc_to_chunk(xfs_log_item_desc_t *dp) | |||
298 | 300 | ||
299 | 301 | ||
300 | /* | 302 | /* |
301 | * Various log reservation values. | ||
302 | * These are based on the size of the file system block | ||
303 | * because that is what most transactions manipulate. | ||
304 | * Each adds in an additional 128 bytes per item logged to | ||
305 | * try to account for the overhead of the transaction mechanism. | ||
306 | * | ||
307 | * Note: | ||
308 | * Most of the reservations underestimate the number of allocation | ||
309 | * groups into which they could free extents in the xfs_bmap_finish() | ||
310 | * call. This is because the number in the worst case is quite high | ||
311 | * and quite unusual. In order to fix this we need to change | ||
312 | * xfs_bmap_finish() to free extents in only a single AG at a time. | ||
313 | * This will require changes to the EFI code as well, however, so that | ||
314 | * the EFI for the extents not freed is logged again in each transaction. | ||
315 | * See bug 261917. | ||
316 | */ | ||
317 | |||
318 | /* | ||
319 | * Per-extent log reservation for the allocation btree changes | 303 | * Per-extent log reservation for the allocation btree changes |
320 | * involved in freeing or allocating an extent. | 304 | * involved in freeing or allocating an extent. |
321 | * 2 trees * (2 blocks/level * max depth - 1) * block size | 305 | * 2 trees * (2 blocks/level * max depth - 1) * block size |
@@ -339,429 +323,36 @@ xfs_lic_desc_to_chunk(xfs_log_item_desc_t *dp) | |||
339 | (XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK) + \ | 323 | (XFS_DAENTER_BLOCKS(mp, XFS_DATA_FORK) + \ |
340 | XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1) | 324 | XFS_DAENTER_BMAPS(mp, XFS_DATA_FORK) + 1) |
341 | 325 | ||
342 | /* | ||
343 | * In a write transaction we can allocate a maximum of 2 | ||
344 | * extents. This gives: | ||
345 | * the inode getting the new extents: inode size | ||
346 | * the inode's bmap btree: max depth * block size | ||
347 | * the agfs of the ags from which the extents are allocated: 2 * sector | ||
348 | * the superblock free block counter: sector size | ||
349 | * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size | ||
350 | * And the bmap_finish transaction can free bmap blocks in a join: | ||
351 | * the agfs of the ags containing the blocks: 2 * sector size | ||
352 | * the agfls of the ags containing the blocks: 2 * sector size | ||
353 | * the super block free block counter: sector size | ||
354 | * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size | ||
355 | */ | ||
356 | #define XFS_CALC_WRITE_LOG_RES(mp) \ | ||
357 | (MAX( \ | ||
358 | ((mp)->m_sb.sb_inodesize + \ | ||
359 | XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK)) + \ | ||
360 | (2 * (mp)->m_sb.sb_sectsize) + \ | ||
361 | (mp)->m_sb.sb_sectsize + \ | ||
362 | XFS_ALLOCFREE_LOG_RES(mp, 2) + \ | ||
363 | (128 * (4 + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) + XFS_ALLOCFREE_LOG_COUNT(mp, 2)))),\ | ||
364 | ((2 * (mp)->m_sb.sb_sectsize) + \ | ||
365 | (2 * (mp)->m_sb.sb_sectsize) + \ | ||
366 | (mp)->m_sb.sb_sectsize + \ | ||
367 | XFS_ALLOCFREE_LOG_RES(mp, 2) + \ | ||
368 | (128 * (5 + XFS_ALLOCFREE_LOG_COUNT(mp, 2)))))) | ||
369 | 326 | ||
370 | #define XFS_WRITE_LOG_RES(mp) ((mp)->m_reservations.tr_write) | 327 | #define XFS_WRITE_LOG_RES(mp) ((mp)->m_reservations.tr_write) |
371 | |||
372 | /* | ||
373 | * In truncating a file we free up to two extents at once. We can modify: | ||
374 | * the inode being truncated: inode size | ||
375 | * the inode's bmap btree: (max depth + 1) * block size | ||
376 | * And the bmap_finish transaction can free the blocks and bmap blocks: | ||
377 | * the agf for each of the ags: 4 * sector size | ||
378 | * the agfl for each of the ags: 4 * sector size | ||
379 | * the super block to reflect the freed blocks: sector size | ||
380 | * worst case split in allocation btrees per extent assuming 4 extents: | ||
381 | * 4 exts * 2 trees * (2 * max depth - 1) * block size | ||
382 | * the inode btree: max depth * blocksize | ||
383 | * the allocation btrees: 2 trees * (max depth - 1) * block size | ||
384 | */ | ||
385 | #define XFS_CALC_ITRUNCATE_LOG_RES(mp) \ | ||
386 | (MAX( \ | ||
387 | ((mp)->m_sb.sb_inodesize + \ | ||
388 | XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) + 1) + \ | ||
389 | (128 * (2 + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK)))), \ | ||
390 | ((4 * (mp)->m_sb.sb_sectsize) + \ | ||
391 | (4 * (mp)->m_sb.sb_sectsize) + \ | ||
392 | (mp)->m_sb.sb_sectsize + \ | ||
393 | XFS_ALLOCFREE_LOG_RES(mp, 4) + \ | ||
394 | (128 * (9 + XFS_ALLOCFREE_LOG_COUNT(mp, 4))) + \ | ||
395 | (128 * 5) + \ | ||
396 | XFS_ALLOCFREE_LOG_RES(mp, 1) + \ | ||
397 | (128 * (2 + XFS_IALLOC_BLOCKS(mp) + (mp)->m_in_maxlevels + \ | ||
398 | XFS_ALLOCFREE_LOG_COUNT(mp, 1)))))) | ||
399 | |||
400 | #define XFS_ITRUNCATE_LOG_RES(mp) ((mp)->m_reservations.tr_itruncate) | 328 | #define XFS_ITRUNCATE_LOG_RES(mp) ((mp)->m_reservations.tr_itruncate) |
401 | |||
402 | /* | ||
403 | * In renaming a files we can modify: | ||
404 | * the four inodes involved: 4 * inode size | ||
405 | * the two directory btrees: 2 * (max depth + v2) * dir block size | ||
406 | * the two directory bmap btrees: 2 * max depth * block size | ||
407 | * And the bmap_finish transaction can free dir and bmap blocks (two sets | ||
408 | * of bmap blocks) giving: | ||
409 | * the agf for the ags in which the blocks live: 3 * sector size | ||
410 | * the agfl for the ags in which the blocks live: 3 * sector size | ||
411 | * the superblock for the free block count: sector size | ||
412 | * the allocation btrees: 3 exts * 2 trees * (2 * max depth - 1) * block size | ||
413 | */ | ||
414 | #define XFS_CALC_RENAME_LOG_RES(mp) \ | ||
415 | (MAX( \ | ||
416 | ((4 * (mp)->m_sb.sb_inodesize) + \ | ||
417 | (2 * XFS_DIROP_LOG_RES(mp)) + \ | ||
418 | (128 * (4 + 2 * XFS_DIROP_LOG_COUNT(mp)))), \ | ||
419 | ((3 * (mp)->m_sb.sb_sectsize) + \ | ||
420 | (3 * (mp)->m_sb.sb_sectsize) + \ | ||
421 | (mp)->m_sb.sb_sectsize + \ | ||
422 | XFS_ALLOCFREE_LOG_RES(mp, 3) + \ | ||
423 | (128 * (7 + XFS_ALLOCFREE_LOG_COUNT(mp, 3)))))) | ||
424 | |||
425 | #define XFS_RENAME_LOG_RES(mp) ((mp)->m_reservations.tr_rename) | 329 | #define XFS_RENAME_LOG_RES(mp) ((mp)->m_reservations.tr_rename) |
426 | |||
427 | /* | ||
428 | * For creating a link to an inode: | ||
429 | * the parent directory inode: inode size | ||
430 | * the linked inode: inode size | ||
431 | * the directory btree could split: (max depth + v2) * dir block size | ||
432 | * the directory bmap btree could join or split: (max depth + v2) * blocksize | ||
433 | * And the bmap_finish transaction can free some bmap blocks giving: | ||
434 | * the agf for the ag in which the blocks live: sector size | ||
435 | * the agfl for the ag in which the blocks live: sector size | ||
436 | * the superblock for the free block count: sector size | ||
437 | * the allocation btrees: 2 trees * (2 * max depth - 1) * block size | ||
438 | */ | ||
439 | #define XFS_CALC_LINK_LOG_RES(mp) \ | ||
440 | (MAX( \ | ||
441 | ((mp)->m_sb.sb_inodesize + \ | ||
442 | (mp)->m_sb.sb_inodesize + \ | ||
443 | XFS_DIROP_LOG_RES(mp) + \ | ||
444 | (128 * (2 + XFS_DIROP_LOG_COUNT(mp)))), \ | ||
445 | ((mp)->m_sb.sb_sectsize + \ | ||
446 | (mp)->m_sb.sb_sectsize + \ | ||
447 | (mp)->m_sb.sb_sectsize + \ | ||
448 | XFS_ALLOCFREE_LOG_RES(mp, 1) + \ | ||
449 | (128 * (3 + XFS_ALLOCFREE_LOG_COUNT(mp, 1)))))) | ||
450 | |||
451 | #define XFS_LINK_LOG_RES(mp) ((mp)->m_reservations.tr_link) | 330 | #define XFS_LINK_LOG_RES(mp) ((mp)->m_reservations.tr_link) |
452 | |||
453 | /* | ||
454 | * For removing a directory entry we can modify: | ||
455 | * the parent directory inode: inode size | ||
456 | * the removed inode: inode size | ||
457 | * the directory btree could join: (max depth + v2) * dir block size | ||
458 | * the directory bmap btree could join or split: (max depth + v2) * blocksize | ||
459 | * And the bmap_finish transaction can free the dir and bmap blocks giving: | ||
460 | * the agf for the ag in which the blocks live: 2 * sector size | ||
461 | * the agfl for the ag in which the blocks live: 2 * sector size | ||
462 | * the superblock for the free block count: sector size | ||
463 | * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size | ||
464 | */ | ||
465 | #define XFS_CALC_REMOVE_LOG_RES(mp) \ | ||
466 | (MAX( \ | ||
467 | ((mp)->m_sb.sb_inodesize + \ | ||
468 | (mp)->m_sb.sb_inodesize + \ | ||
469 | XFS_DIROP_LOG_RES(mp) + \ | ||
470 | (128 * (2 + XFS_DIROP_LOG_COUNT(mp)))), \ | ||
471 | ((2 * (mp)->m_sb.sb_sectsize) + \ | ||
472 | (2 * (mp)->m_sb.sb_sectsize) + \ | ||
473 | (mp)->m_sb.sb_sectsize + \ | ||
474 | XFS_ALLOCFREE_LOG_RES(mp, 2) + \ | ||
475 | (128 * (5 + XFS_ALLOCFREE_LOG_COUNT(mp, 2)))))) | ||
476 | |||
477 | #define XFS_REMOVE_LOG_RES(mp) ((mp)->m_reservations.tr_remove) | 331 | #define XFS_REMOVE_LOG_RES(mp) ((mp)->m_reservations.tr_remove) |
478 | |||
479 | /* | ||
480 | * For symlink we can modify: | ||
481 | * the parent directory inode: inode size | ||
482 | * the new inode: inode size | ||
483 | * the inode btree entry: 1 block | ||
484 | * the directory btree: (max depth + v2) * dir block size | ||
485 | * the directory inode's bmap btree: (max depth + v2) * block size | ||
486 | * the blocks for the symlink: 1 kB | ||
487 | * Or in the first xact we allocate some inodes giving: | ||
488 | * the agi and agf of the ag getting the new inodes: 2 * sectorsize | ||
489 | * the inode blocks allocated: XFS_IALLOC_BLOCKS * blocksize | ||
490 | * the inode btree: max depth * blocksize | ||
491 | * the allocation btrees: 2 trees * (2 * max depth - 1) * block size | ||
492 | */ | ||
493 | #define XFS_CALC_SYMLINK_LOG_RES(mp) \ | ||
494 | (MAX( \ | ||
495 | ((mp)->m_sb.sb_inodesize + \ | ||
496 | (mp)->m_sb.sb_inodesize + \ | ||
497 | XFS_FSB_TO_B(mp, 1) + \ | ||
498 | XFS_DIROP_LOG_RES(mp) + \ | ||
499 | 1024 + \ | ||
500 | (128 * (4 + XFS_DIROP_LOG_COUNT(mp)))), \ | ||
501 | (2 * (mp)->m_sb.sb_sectsize + \ | ||
502 | XFS_FSB_TO_B((mp), XFS_IALLOC_BLOCKS((mp))) + \ | ||
503 | XFS_FSB_TO_B((mp), (mp)->m_in_maxlevels) + \ | ||
504 | XFS_ALLOCFREE_LOG_RES(mp, 1) + \ | ||
505 | (128 * (2 + XFS_IALLOC_BLOCKS(mp) + (mp)->m_in_maxlevels + \ | ||
506 | XFS_ALLOCFREE_LOG_COUNT(mp, 1)))))) | ||
507 | |||
508 | #define XFS_SYMLINK_LOG_RES(mp) ((mp)->m_reservations.tr_symlink) | 332 | #define XFS_SYMLINK_LOG_RES(mp) ((mp)->m_reservations.tr_symlink) |
509 | |||
510 | /* | ||
511 | * For create we can modify: | ||
512 | * the parent directory inode: inode size | ||
513 | * the new inode: inode size | ||
514 | * the inode btree entry: block size | ||
515 | * the superblock for the nlink flag: sector size | ||
516 | * the directory btree: (max depth + v2) * dir block size | ||
517 | * the directory inode's bmap btree: (max depth + v2) * block size | ||
518 | * Or in the first xact we allocate some inodes giving: | ||
519 | * the agi and agf of the ag getting the new inodes: 2 * sectorsize | ||
520 | * the superblock for the nlink flag: sector size | ||
521 | * the inode blocks allocated: XFS_IALLOC_BLOCKS * blocksize | ||
522 | * the inode btree: max depth * blocksize | ||
523 | * the allocation btrees: 2 trees * (max depth - 1) * block size | ||
524 | */ | ||
525 | #define XFS_CALC_CREATE_LOG_RES(mp) \ | ||
526 | (MAX( \ | ||
527 | ((mp)->m_sb.sb_inodesize + \ | ||
528 | (mp)->m_sb.sb_inodesize + \ | ||
529 | (mp)->m_sb.sb_sectsize + \ | ||
530 | XFS_FSB_TO_B(mp, 1) + \ | ||
531 | XFS_DIROP_LOG_RES(mp) + \ | ||
532 | (128 * (3 + XFS_DIROP_LOG_COUNT(mp)))), \ | ||
533 | (3 * (mp)->m_sb.sb_sectsize + \ | ||
534 | XFS_FSB_TO_B((mp), XFS_IALLOC_BLOCKS((mp))) + \ | ||
535 | XFS_FSB_TO_B((mp), (mp)->m_in_maxlevels) + \ | ||
536 | XFS_ALLOCFREE_LOG_RES(mp, 1) + \ | ||
537 | (128 * (2 + XFS_IALLOC_BLOCKS(mp) + (mp)->m_in_maxlevels + \ | ||
538 | XFS_ALLOCFREE_LOG_COUNT(mp, 1)))))) | ||
539 | |||
540 | #define XFS_CREATE_LOG_RES(mp) ((mp)->m_reservations.tr_create) | 333 | #define XFS_CREATE_LOG_RES(mp) ((mp)->m_reservations.tr_create) |
541 | |||
542 | /* | ||
543 | * Making a new directory is the same as creating a new file. | ||
544 | */ | ||
545 | #define XFS_CALC_MKDIR_LOG_RES(mp) XFS_CALC_CREATE_LOG_RES(mp) | ||
546 | |||
547 | #define XFS_MKDIR_LOG_RES(mp) ((mp)->m_reservations.tr_mkdir) | 334 | #define XFS_MKDIR_LOG_RES(mp) ((mp)->m_reservations.tr_mkdir) |
548 | |||
549 | /* | ||
550 | * In freeing an inode we can modify: | ||
551 | * the inode being freed: inode size | ||
552 | * the super block free inode counter: sector size | ||
553 | * the agi hash list and counters: sector size | ||
554 | * the inode btree entry: block size | ||
555 | * the on disk inode before ours in the agi hash list: inode cluster size | ||
556 | * the inode btree: max depth * blocksize | ||
557 | * the allocation btrees: 2 trees * (max depth - 1) * block size | ||
558 | */ | ||
559 | #define XFS_CALC_IFREE_LOG_RES(mp) \ | ||
560 | ((mp)->m_sb.sb_inodesize + \ | ||
561 | (mp)->m_sb.sb_sectsize + \ | ||
562 | (mp)->m_sb.sb_sectsize + \ | ||
563 | XFS_FSB_TO_B((mp), 1) + \ | ||
564 | MAX((__uint16_t)XFS_FSB_TO_B((mp), 1), XFS_INODE_CLUSTER_SIZE(mp)) + \ | ||
565 | (128 * 5) + \ | ||
566 | XFS_ALLOCFREE_LOG_RES(mp, 1) + \ | ||
567 | (128 * (2 + XFS_IALLOC_BLOCKS(mp) + (mp)->m_in_maxlevels + \ | ||
568 | XFS_ALLOCFREE_LOG_COUNT(mp, 1)))) | ||
569 | |||
570 | |||
571 | #define XFS_IFREE_LOG_RES(mp) ((mp)->m_reservations.tr_ifree) | 335 | #define XFS_IFREE_LOG_RES(mp) ((mp)->m_reservations.tr_ifree) |
572 | |||
573 | /* | ||
574 | * When only changing the inode we log the inode and possibly the superblock | ||
575 | * We also add a bit of slop for the transaction stuff. | ||
576 | */ | ||
577 | #define XFS_CALC_ICHANGE_LOG_RES(mp) ((mp)->m_sb.sb_inodesize + \ | ||
578 | (mp)->m_sb.sb_sectsize + 512) | ||
579 | |||
580 | #define XFS_ICHANGE_LOG_RES(mp) ((mp)->m_reservations.tr_ichange) | 336 | #define XFS_ICHANGE_LOG_RES(mp) ((mp)->m_reservations.tr_ichange) |
581 | |||
582 | /* | ||
583 | * Growing the data section of the filesystem. | ||
584 | * superblock | ||
585 | * agi and agf | ||
586 | * allocation btrees | ||
587 | */ | ||
588 | #define XFS_CALC_GROWDATA_LOG_RES(mp) \ | ||
589 | ((mp)->m_sb.sb_sectsize * 3 + \ | ||
590 | XFS_ALLOCFREE_LOG_RES(mp, 1) + \ | ||
591 | (128 * (3 + XFS_ALLOCFREE_LOG_COUNT(mp, 1)))) | ||
592 | |||
593 | #define XFS_GROWDATA_LOG_RES(mp) ((mp)->m_reservations.tr_growdata) | 337 | #define XFS_GROWDATA_LOG_RES(mp) ((mp)->m_reservations.tr_growdata) |
594 | |||
595 | /* | ||
596 | * Growing the rt section of the filesystem. | ||
597 | * In the first set of transactions (ALLOC) we allocate space to the | ||
598 | * bitmap or summary files. | ||
599 | * superblock: sector size | ||
600 | * agf of the ag from which the extent is allocated: sector size | ||
601 | * bmap btree for bitmap/summary inode: max depth * blocksize | ||
602 | * bitmap/summary inode: inode size | ||
603 | * allocation btrees for 1 block alloc: 2 * (2 * maxdepth - 1) * blocksize | ||
604 | */ | ||
605 | #define XFS_CALC_GROWRTALLOC_LOG_RES(mp) \ | ||
606 | (2 * (mp)->m_sb.sb_sectsize + \ | ||
607 | XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK)) + \ | ||
608 | (mp)->m_sb.sb_inodesize + \ | ||
609 | XFS_ALLOCFREE_LOG_RES(mp, 1) + \ | ||
610 | (128 * \ | ||
611 | (3 + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK) + \ | ||
612 | XFS_ALLOCFREE_LOG_COUNT(mp, 1)))) | ||
613 | |||
614 | #define XFS_GROWRTALLOC_LOG_RES(mp) ((mp)->m_reservations.tr_growrtalloc) | 338 | #define XFS_GROWRTALLOC_LOG_RES(mp) ((mp)->m_reservations.tr_growrtalloc) |
615 | |||
616 | /* | ||
617 | * Growing the rt section of the filesystem. | ||
618 | * In the second set of transactions (ZERO) we zero the new metadata blocks. | ||
619 | * one bitmap/summary block: blocksize | ||
620 | */ | ||
621 | #define XFS_CALC_GROWRTZERO_LOG_RES(mp) \ | ||
622 | ((mp)->m_sb.sb_blocksize + 128) | ||
623 | |||
624 | #define XFS_GROWRTZERO_LOG_RES(mp) ((mp)->m_reservations.tr_growrtzero) | 339 | #define XFS_GROWRTZERO_LOG_RES(mp) ((mp)->m_reservations.tr_growrtzero) |
625 | |||
626 | /* | ||
627 | * Growing the rt section of the filesystem. | ||
628 | * In the third set of transactions (FREE) we update metadata without | ||
629 | * allocating any new blocks. | ||
630 | * superblock: sector size | ||
631 | * bitmap inode: inode size | ||
632 | * summary inode: inode size | ||
633 | * one bitmap block: blocksize | ||
634 | * summary blocks: new summary size | ||
635 | */ | ||
636 | #define XFS_CALC_GROWRTFREE_LOG_RES(mp) \ | ||
637 | ((mp)->m_sb.sb_sectsize + \ | ||
638 | 2 * (mp)->m_sb.sb_inodesize + \ | ||
639 | (mp)->m_sb.sb_blocksize + \ | ||
640 | (mp)->m_rsumsize + \ | ||
641 | (128 * 5)) | ||
642 | |||
643 | #define XFS_GROWRTFREE_LOG_RES(mp) ((mp)->m_reservations.tr_growrtfree) | 340 | #define XFS_GROWRTFREE_LOG_RES(mp) ((mp)->m_reservations.tr_growrtfree) |
644 | |||
645 | /* | ||
646 | * Logging the inode modification timestamp on a synchronous write. | ||
647 | * inode | ||
648 | */ | ||
649 | #define XFS_CALC_SWRITE_LOG_RES(mp) \ | ||
650 | ((mp)->m_sb.sb_inodesize + 128) | ||
651 | |||
652 | #define XFS_SWRITE_LOG_RES(mp) ((mp)->m_reservations.tr_swrite) | 341 | #define XFS_SWRITE_LOG_RES(mp) ((mp)->m_reservations.tr_swrite) |
653 | |||
654 | /* | 342 | /* |
655 | * Logging the inode timestamps on an fsync -- same as SWRITE | 343 | * Logging the inode timestamps on an fsync -- same as SWRITE |
656 | * as long as SWRITE logs the entire inode core | 344 | * as long as SWRITE logs the entire inode core |
657 | */ | 345 | */ |
658 | #define XFS_FSYNC_TS_LOG_RES(mp) ((mp)->m_reservations.tr_swrite) | 346 | #define XFS_FSYNC_TS_LOG_RES(mp) ((mp)->m_reservations.tr_swrite) |
659 | |||
660 | /* | ||
661 | * Logging the inode mode bits when writing a setuid/setgid file | ||
662 | * inode | ||
663 | */ | ||
664 | #define XFS_CALC_WRITEID_LOG_RES(mp) \ | ||
665 | ((mp)->m_sb.sb_inodesize + 128) | ||
666 | |||
667 | #define XFS_WRITEID_LOG_RES(mp) ((mp)->m_reservations.tr_swrite) | 347 | #define XFS_WRITEID_LOG_RES(mp) ((mp)->m_reservations.tr_swrite) |
668 | |||
669 | /* | ||
670 | * Converting the inode from non-attributed to attributed. | ||
671 | * the inode being converted: inode size | ||
672 | * agf block and superblock (for block allocation) | ||
673 | * the new block (directory sized) | ||
674 | * bmap blocks for the new directory block | ||
675 | * allocation btrees | ||
676 | */ | ||
677 | #define XFS_CALC_ADDAFORK_LOG_RES(mp) \ | ||
678 | ((mp)->m_sb.sb_inodesize + \ | ||
679 | (mp)->m_sb.sb_sectsize * 2 + \ | ||
680 | (mp)->m_dirblksize + \ | ||
681 | XFS_FSB_TO_B(mp, (XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1)) + \ | ||
682 | XFS_ALLOCFREE_LOG_RES(mp, 1) + \ | ||
683 | (128 * (4 + (XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1) + \ | ||
684 | XFS_ALLOCFREE_LOG_COUNT(mp, 1)))) | ||
685 | |||
686 | #define XFS_ADDAFORK_LOG_RES(mp) ((mp)->m_reservations.tr_addafork) | 348 | #define XFS_ADDAFORK_LOG_RES(mp) ((mp)->m_reservations.tr_addafork) |
687 | |||
688 | /* | ||
689 | * Removing the attribute fork of a file | ||
690 | * the inode being truncated: inode size | ||
691 | * the inode's bmap btree: max depth * block size | ||
692 | * And the bmap_finish transaction can free the blocks and bmap blocks: | ||
693 | * the agf for each of the ags: 4 * sector size | ||
694 | * the agfl for each of the ags: 4 * sector size | ||
695 | * the super block to reflect the freed blocks: sector size | ||
696 | * worst case split in allocation btrees per extent assuming 4 extents: | ||
697 | * 4 exts * 2 trees * (2 * max depth - 1) * block size | ||
698 | */ | ||
699 | #define XFS_CALC_ATTRINVAL_LOG_RES(mp) \ | ||
700 | (MAX( \ | ||
701 | ((mp)->m_sb.sb_inodesize + \ | ||
702 | XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)) + \ | ||
703 | (128 * (1 + XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)))), \ | ||
704 | ((4 * (mp)->m_sb.sb_sectsize) + \ | ||
705 | (4 * (mp)->m_sb.sb_sectsize) + \ | ||
706 | (mp)->m_sb.sb_sectsize + \ | ||
707 | XFS_ALLOCFREE_LOG_RES(mp, 4) + \ | ||
708 | (128 * (9 + XFS_ALLOCFREE_LOG_COUNT(mp, 4)))))) | ||
709 | |||
710 | #define XFS_ATTRINVAL_LOG_RES(mp) ((mp)->m_reservations.tr_attrinval) | 349 | #define XFS_ATTRINVAL_LOG_RES(mp) ((mp)->m_reservations.tr_attrinval) |
711 | |||
712 | /* | ||
713 | * Setting an attribute. | ||
714 | * the inode getting the attribute | ||
715 | * the superblock for allocations | ||
716 | * the agfs extents are allocated from | ||
717 | * the attribute btree * max depth | ||
718 | * the inode allocation btree | ||
719 | * Since attribute transaction space is dependent on the size of the attribute, | ||
720 | * the calculation is done partially at mount time and partially at runtime. | ||
721 | */ | ||
722 | #define XFS_CALC_ATTRSET_LOG_RES(mp) \ | ||
723 | ((mp)->m_sb.sb_inodesize + \ | ||
724 | (mp)->m_sb.sb_sectsize + \ | ||
725 | XFS_FSB_TO_B((mp), XFS_DA_NODE_MAXDEPTH) + \ | ||
726 | (128 * (2 + XFS_DA_NODE_MAXDEPTH))) | ||
727 | |||
728 | #define XFS_ATTRSET_LOG_RES(mp, ext) \ | 350 | #define XFS_ATTRSET_LOG_RES(mp, ext) \ |
729 | ((mp)->m_reservations.tr_attrset + \ | 351 | ((mp)->m_reservations.tr_attrset + \ |
730 | (ext * (mp)->m_sb.sb_sectsize) + \ | 352 | (ext * (mp)->m_sb.sb_sectsize) + \ |
731 | (ext * XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK))) + \ | 353 | (ext * XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK))) + \ |
732 | (128 * (ext + (ext * XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK))))) | 354 | (128 * (ext + (ext * XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK))))) |
733 | |||
734 | /* | ||
735 | * Removing an attribute. | ||
736 | * the inode: inode size | ||
737 | * the attribute btree could join: max depth * block size | ||
738 | * the inode bmap btree could join or split: max depth * block size | ||
739 | * And the bmap_finish transaction can free the attr blocks freed giving: | ||
740 | * the agf for the ag in which the blocks live: 2 * sector size | ||
741 | * the agfl for the ag in which the blocks live: 2 * sector size | ||
742 | * the superblock for the free block count: sector size | ||
743 | * the allocation btrees: 2 exts * 2 trees * (2 * max depth - 1) * block size | ||
744 | */ | ||
745 | #define XFS_CALC_ATTRRM_LOG_RES(mp) \ | ||
746 | (MAX( \ | ||
747 | ((mp)->m_sb.sb_inodesize + \ | ||
748 | XFS_FSB_TO_B((mp), XFS_DA_NODE_MAXDEPTH) + \ | ||
749 | XFS_FSB_TO_B((mp), XFS_BM_MAXLEVELS(mp, XFS_ATTR_FORK)) + \ | ||
750 | (128 * (1 + XFS_DA_NODE_MAXDEPTH + XFS_BM_MAXLEVELS(mp, XFS_DATA_FORK)))), \ | ||
751 | ((2 * (mp)->m_sb.sb_sectsize) + \ | ||
752 | (2 * (mp)->m_sb.sb_sectsize) + \ | ||
753 | (mp)->m_sb.sb_sectsize + \ | ||
754 | XFS_ALLOCFREE_LOG_RES(mp, 2) + \ | ||
755 | (128 * (5 + XFS_ALLOCFREE_LOG_COUNT(mp, 2)))))) | ||
756 | |||
757 | #define XFS_ATTRRM_LOG_RES(mp) ((mp)->m_reservations.tr_attrrm) | 355 | #define XFS_ATTRRM_LOG_RES(mp) ((mp)->m_reservations.tr_attrrm) |
758 | |||
759 | /* | ||
760 | * Clearing a bad agino number in an agi hash bucket. | ||
761 | */ | ||
762 | #define XFS_CALC_CLEAR_AGI_BUCKET_LOG_RES(mp) \ | ||
763 | ((mp)->m_sb.sb_sectsize + 128) | ||
764 | |||
765 | #define XFS_CLEAR_AGI_BUCKET_LOG_RES(mp) ((mp)->m_reservations.tr_clearagi) | 356 | #define XFS_CLEAR_AGI_BUCKET_LOG_RES(mp) ((mp)->m_reservations.tr_clearagi) |
766 | 357 | ||
767 | 358 | ||
@@ -813,6 +404,7 @@ struct xfs_log_item_desc; | |||
813 | struct xfs_mount; | 404 | struct xfs_mount; |
814 | struct xfs_trans; | 405 | struct xfs_trans; |
815 | struct xfs_dquot_acct; | 406 | struct xfs_dquot_acct; |
407 | struct xfs_busy_extent; | ||
816 | 408 | ||
817 | typedef struct xfs_log_item { | 409 | typedef struct xfs_log_item { |
818 | struct list_head li_ail; /* AIL pointers */ | 410 | struct list_head li_ail; /* AIL pointers */ |
@@ -828,6 +420,11 @@ typedef struct xfs_log_item { | |||
828 | /* buffer item iodone */ | 420 | /* buffer item iodone */ |
829 | /* callback func */ | 421 | /* callback func */ |
830 | struct xfs_item_ops *li_ops; /* function list */ | 422 | struct xfs_item_ops *li_ops; /* function list */ |
423 | |||
424 | /* delayed logging */ | ||
425 | struct list_head li_cil; /* CIL pointers */ | ||
426 | struct xfs_log_vec *li_lv; /* active log vector */ | ||
427 | xfs_lsn_t li_seq; /* CIL commit seq */ | ||
831 | } xfs_log_item_t; | 428 | } xfs_log_item_t; |
832 | 429 | ||
833 | #define XFS_LI_IN_AIL 0x1 | 430 | #define XFS_LI_IN_AIL 0x1 |
@@ -872,34 +469,6 @@ typedef struct xfs_item_ops { | |||
872 | #define XFS_ITEM_PUSHBUF 3 | 469 | #define XFS_ITEM_PUSHBUF 3 |
873 | 470 | ||
874 | /* | 471 | /* |
875 | * This structure is used to maintain a list of block ranges that have been | ||
876 | * freed in the transaction. The ranges are listed in the perag[] busy list | ||
877 | * between when they're freed and the transaction is committed to disk. | ||
878 | */ | ||
879 | |||
880 | typedef struct xfs_log_busy_slot { | ||
881 | xfs_agnumber_t lbc_ag; | ||
882 | ushort lbc_idx; /* index in perag.busy[] */ | ||
883 | } xfs_log_busy_slot_t; | ||
884 | |||
885 | #define XFS_LBC_NUM_SLOTS 31 | ||
886 | typedef struct xfs_log_busy_chunk { | ||
887 | struct xfs_log_busy_chunk *lbc_next; | ||
888 | uint lbc_free; /* free slots bitmask */ | ||
889 | ushort lbc_unused; /* first unused */ | ||
890 | xfs_log_busy_slot_t lbc_busy[XFS_LBC_NUM_SLOTS]; | ||
891 | } xfs_log_busy_chunk_t; | ||
892 | |||
893 | #define XFS_LBC_MAX_SLOT (XFS_LBC_NUM_SLOTS - 1) | ||
894 | #define XFS_LBC_FREEMASK ((1U << XFS_LBC_NUM_SLOTS) - 1) | ||
895 | |||
896 | #define XFS_LBC_INIT(cp) ((cp)->lbc_free = XFS_LBC_FREEMASK) | ||
897 | #define XFS_LBC_CLAIM(cp, slot) ((cp)->lbc_free &= ~(1 << (slot))) | ||
898 | #define XFS_LBC_SLOT(cp, slot) (&((cp)->lbc_busy[(slot)])) | ||
899 | #define XFS_LBC_VACANCY(cp) (((cp)->lbc_free) & XFS_LBC_FREEMASK) | ||
900 | #define XFS_LBC_ISFREE(cp, slot) ((cp)->lbc_free & (1 << (slot))) | ||
901 | |||
902 | /* | ||
903 | * This is the type of function which can be given to xfs_trans_callback() | 472 | * This is the type of function which can be given to xfs_trans_callback() |
904 | * to be called upon the transaction's commit to disk. | 473 | * to be called upon the transaction's commit to disk. |
905 | */ | 474 | */ |
@@ -950,8 +519,7 @@ typedef struct xfs_trans { | |||
950 | unsigned int t_items_free; /* log item descs free */ | 519 | unsigned int t_items_free; /* log item descs free */ |
951 | xfs_log_item_chunk_t t_items; /* first log item desc chunk */ | 520 | xfs_log_item_chunk_t t_items; /* first log item desc chunk */ |
952 | xfs_trans_header_t t_header; /* header for in-log trans */ | 521 | xfs_trans_header_t t_header; /* header for in-log trans */ |
953 | unsigned int t_busy_free; /* busy descs free */ | 522 | struct list_head t_busy; /* list of busy extents */ |
954 | xfs_log_busy_chunk_t t_busy; /* busy/async free blocks */ | ||
955 | unsigned long t_pflags; /* saved process flags state */ | 523 | unsigned long t_pflags; /* saved process flags state */ |
956 | } xfs_trans_t; | 524 | } xfs_trans_t; |
957 | 525 | ||
@@ -1025,9 +593,6 @@ int _xfs_trans_commit(xfs_trans_t *, | |||
1025 | void xfs_trans_cancel(xfs_trans_t *, int); | 593 | void xfs_trans_cancel(xfs_trans_t *, int); |
1026 | int xfs_trans_ail_init(struct xfs_mount *); | 594 | int xfs_trans_ail_init(struct xfs_mount *); |
1027 | void xfs_trans_ail_destroy(struct xfs_mount *); | 595 | void xfs_trans_ail_destroy(struct xfs_mount *); |
1028 | xfs_log_busy_slot_t *xfs_trans_add_busy(xfs_trans_t *tp, | ||
1029 | xfs_agnumber_t ag, | ||
1030 | xfs_extlen_t idx); | ||
1031 | 596 | ||
1032 | extern kmem_zone_t *xfs_trans_zone; | 597 | extern kmem_zone_t *xfs_trans_zone; |
1033 | 598 | ||