diff options
Diffstat (limited to 'fs/xfs/xfs_log.c')
-rw-r--r-- | fs/xfs/xfs_log.c | 223 |
1 files changed, 137 insertions, 86 deletions
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index d90d4a388609..7f4f9370d0e7 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -45,51 +45,85 @@ xlog_commit_record( | |||
45 | struct xlog_in_core **iclog, | 45 | struct xlog_in_core **iclog, |
46 | xfs_lsn_t *commitlsnp); | 46 | xfs_lsn_t *commitlsnp); |
47 | 47 | ||
48 | STATIC xlog_t * xlog_alloc_log(xfs_mount_t *mp, | 48 | STATIC struct xlog * |
49 | xfs_buftarg_t *log_target, | 49 | xlog_alloc_log( |
50 | xfs_daddr_t blk_offset, | 50 | struct xfs_mount *mp, |
51 | int num_bblks); | 51 | struct xfs_buftarg *log_target, |
52 | xfs_daddr_t blk_offset, | ||
53 | int num_bblks); | ||
52 | STATIC int | 54 | STATIC int |
53 | xlog_space_left( | 55 | xlog_space_left( |
54 | struct xlog *log, | 56 | struct xlog *log, |
55 | atomic64_t *head); | 57 | atomic64_t *head); |
56 | STATIC int xlog_sync(xlog_t *log, xlog_in_core_t *iclog); | 58 | STATIC int |
57 | STATIC void xlog_dealloc_log(xlog_t *log); | 59 | xlog_sync( |
60 | struct xlog *log, | ||
61 | struct xlog_in_core *iclog); | ||
62 | STATIC void | ||
63 | xlog_dealloc_log( | ||
64 | struct xlog *log); | ||
58 | 65 | ||
59 | /* local state machine functions */ | 66 | /* local state machine functions */ |
60 | STATIC void xlog_state_done_syncing(xlog_in_core_t *iclog, int); | 67 | STATIC void xlog_state_done_syncing(xlog_in_core_t *iclog, int); |
61 | STATIC void xlog_state_do_callback(xlog_t *log,int aborted, xlog_in_core_t *iclog); | 68 | STATIC void |
62 | STATIC int xlog_state_get_iclog_space(xlog_t *log, | 69 | xlog_state_do_callback( |
63 | int len, | 70 | struct xlog *log, |
64 | xlog_in_core_t **iclog, | 71 | int aborted, |
65 | xlog_ticket_t *ticket, | 72 | struct xlog_in_core *iclog); |
66 | int *continued_write, | 73 | STATIC int |
67 | int *logoffsetp); | 74 | xlog_state_get_iclog_space( |
68 | STATIC int xlog_state_release_iclog(xlog_t *log, | 75 | struct xlog *log, |
69 | xlog_in_core_t *iclog); | 76 | int len, |
70 | STATIC void xlog_state_switch_iclogs(xlog_t *log, | 77 | struct xlog_in_core **iclog, |
71 | xlog_in_core_t *iclog, | 78 | struct xlog_ticket *ticket, |
72 | int eventual_size); | 79 | int *continued_write, |
73 | STATIC void xlog_state_want_sync(xlog_t *log, xlog_in_core_t *iclog); | 80 | int *logoffsetp); |
81 | STATIC int | ||
82 | xlog_state_release_iclog( | ||
83 | struct xlog *log, | ||
84 | struct xlog_in_core *iclog); | ||
85 | STATIC void | ||
86 | xlog_state_switch_iclogs( | ||
87 | struct xlog *log, | ||
88 | struct xlog_in_core *iclog, | ||
89 | int eventual_size); | ||
90 | STATIC void | ||
91 | xlog_state_want_sync( | ||
92 | struct xlog *log, | ||
93 | struct xlog_in_core *iclog); | ||
74 | 94 | ||
75 | STATIC void | 95 | STATIC void |
76 | xlog_grant_push_ail( | 96 | xlog_grant_push_ail( |
77 | struct xlog *log, | 97 | struct xlog *log, |
78 | int need_bytes); | 98 | int need_bytes); |
79 | STATIC void xlog_regrant_reserve_log_space(xlog_t *log, | 99 | STATIC void |
80 | xlog_ticket_t *ticket); | 100 | xlog_regrant_reserve_log_space( |
81 | STATIC void xlog_ungrant_log_space(xlog_t *log, | 101 | struct xlog *log, |
82 | xlog_ticket_t *ticket); | 102 | struct xlog_ticket *ticket); |
103 | STATIC void | ||
104 | xlog_ungrant_log_space( | ||
105 | struct xlog *log, | ||
106 | struct xlog_ticket *ticket); | ||
83 | 107 | ||
84 | #if defined(DEBUG) | 108 | #if defined(DEBUG) |
85 | STATIC void xlog_verify_dest_ptr(xlog_t *log, char *ptr); | 109 | STATIC void |
110 | xlog_verify_dest_ptr( | ||
111 | struct xlog *log, | ||
112 | char *ptr); | ||
86 | STATIC void | 113 | STATIC void |
87 | xlog_verify_grant_tail( | 114 | xlog_verify_grant_tail( |
88 | struct xlog *log); | 115 | struct xlog *log); |
89 | STATIC void xlog_verify_iclog(xlog_t *log, xlog_in_core_t *iclog, | 116 | STATIC void |
90 | int count, boolean_t syncing); | 117 | xlog_verify_iclog( |
91 | STATIC void xlog_verify_tail_lsn(xlog_t *log, xlog_in_core_t *iclog, | 118 | struct xlog *log, |
92 | xfs_lsn_t tail_lsn); | 119 | struct xlog_in_core *iclog, |
120 | int count, | ||
121 | boolean_t syncing); | ||
122 | STATIC void | ||
123 | xlog_verify_tail_lsn( | ||
124 | struct xlog *log, | ||
125 | struct xlog_in_core *iclog, | ||
126 | xfs_lsn_t tail_lsn); | ||
93 | #else | 127 | #else |
94 | #define xlog_verify_dest_ptr(a,b) | 128 | #define xlog_verify_dest_ptr(a,b) |
95 | #define xlog_verify_grant_tail(a) | 129 | #define xlog_verify_grant_tail(a) |
@@ -97,7 +131,9 @@ STATIC void xlog_verify_tail_lsn(xlog_t *log, xlog_in_core_t *iclog, | |||
97 | #define xlog_verify_tail_lsn(a,b,c) | 131 | #define xlog_verify_tail_lsn(a,b,c) |
98 | #endif | 132 | #endif |
99 | 133 | ||
100 | STATIC int xlog_iclogs_empty(xlog_t *log); | 134 | STATIC int |
135 | xlog_iclogs_empty( | ||
136 | struct xlog *log); | ||
101 | 137 | ||
102 | static void | 138 | static void |
103 | xlog_grant_sub_space( | 139 | xlog_grant_sub_space( |
@@ -684,7 +720,7 @@ xfs_log_mount_finish(xfs_mount_t *mp) | |||
684 | int | 720 | int |
685 | xfs_log_unmount_write(xfs_mount_t *mp) | 721 | xfs_log_unmount_write(xfs_mount_t *mp) |
686 | { | 722 | { |
687 | xlog_t *log = mp->m_log; | 723 | struct xlog *log = mp->m_log; |
688 | xlog_in_core_t *iclog; | 724 | xlog_in_core_t *iclog; |
689 | #ifdef DEBUG | 725 | #ifdef DEBUG |
690 | xlog_in_core_t *first_iclog; | 726 | xlog_in_core_t *first_iclog; |
@@ -893,7 +929,7 @@ int | |||
893 | xfs_log_need_covered(xfs_mount_t *mp) | 929 | xfs_log_need_covered(xfs_mount_t *mp) |
894 | { | 930 | { |
895 | int needed = 0; | 931 | int needed = 0; |
896 | xlog_t *log = mp->m_log; | 932 | struct xlog *log = mp->m_log; |
897 | 933 | ||
898 | if (!xfs_fs_writable(mp)) | 934 | if (!xfs_fs_writable(mp)) |
899 | return 0; | 935 | return 0; |
@@ -1024,9 +1060,9 @@ xlog_space_left( | |||
1024 | void | 1060 | void |
1025 | xlog_iodone(xfs_buf_t *bp) | 1061 | xlog_iodone(xfs_buf_t *bp) |
1026 | { | 1062 | { |
1027 | xlog_in_core_t *iclog = bp->b_fspriv; | 1063 | struct xlog_in_core *iclog = bp->b_fspriv; |
1028 | xlog_t *l = iclog->ic_log; | 1064 | struct xlog *l = iclog->ic_log; |
1029 | int aborted = 0; | 1065 | int aborted = 0; |
1030 | 1066 | ||
1031 | /* | 1067 | /* |
1032 | * Race to shutdown the filesystem if we see an error. | 1068 | * Race to shutdown the filesystem if we see an error. |
@@ -1067,8 +1103,9 @@ xlog_iodone(xfs_buf_t *bp) | |||
1067 | */ | 1103 | */ |
1068 | 1104 | ||
1069 | STATIC void | 1105 | STATIC void |
1070 | xlog_get_iclog_buffer_size(xfs_mount_t *mp, | 1106 | xlog_get_iclog_buffer_size( |
1071 | xlog_t *log) | 1107 | struct xfs_mount *mp, |
1108 | struct xlog *log) | ||
1072 | { | 1109 | { |
1073 | int size; | 1110 | int size; |
1074 | int xhdrs; | 1111 | int xhdrs; |
@@ -1129,13 +1166,14 @@ done: | |||
1129 | * Its primary purpose is to fill in enough, so recovery can occur. However, | 1166 | * Its primary purpose is to fill in enough, so recovery can occur. However, |
1130 | * some other stuff may be filled in too. | 1167 | * some other stuff may be filled in too. |
1131 | */ | 1168 | */ |
1132 | STATIC xlog_t * | 1169 | STATIC struct xlog * |
1133 | xlog_alloc_log(xfs_mount_t *mp, | 1170 | xlog_alloc_log( |
1134 | xfs_buftarg_t *log_target, | 1171 | struct xfs_mount *mp, |
1135 | xfs_daddr_t blk_offset, | 1172 | struct xfs_buftarg *log_target, |
1136 | int num_bblks) | 1173 | xfs_daddr_t blk_offset, |
1174 | int num_bblks) | ||
1137 | { | 1175 | { |
1138 | xlog_t *log; | 1176 | struct xlog *log; |
1139 | xlog_rec_header_t *head; | 1177 | xlog_rec_header_t *head; |
1140 | xlog_in_core_t **iclogp; | 1178 | xlog_in_core_t **iclogp; |
1141 | xlog_in_core_t *iclog, *prev_iclog=NULL; | 1179 | xlog_in_core_t *iclog, *prev_iclog=NULL; |
@@ -1144,7 +1182,7 @@ xlog_alloc_log(xfs_mount_t *mp, | |||
1144 | int error = ENOMEM; | 1182 | int error = ENOMEM; |
1145 | uint log2_size = 0; | 1183 | uint log2_size = 0; |
1146 | 1184 | ||
1147 | log = kmem_zalloc(sizeof(xlog_t), KM_MAYFAIL); | 1185 | log = kmem_zalloc(sizeof(struct xlog), KM_MAYFAIL); |
1148 | if (!log) { | 1186 | if (!log) { |
1149 | xfs_warn(mp, "Log allocation failed: No memory!"); | 1187 | xfs_warn(mp, "Log allocation failed: No memory!"); |
1150 | goto out; | 1188 | goto out; |
@@ -1434,8 +1472,9 @@ xlog_bdstrat( | |||
1434 | */ | 1472 | */ |
1435 | 1473 | ||
1436 | STATIC int | 1474 | STATIC int |
1437 | xlog_sync(xlog_t *log, | 1475 | xlog_sync( |
1438 | xlog_in_core_t *iclog) | 1476 | struct xlog *log, |
1477 | struct xlog_in_core *iclog) | ||
1439 | { | 1478 | { |
1440 | xfs_caddr_t dptr; /* pointer to byte sized element */ | 1479 | xfs_caddr_t dptr; /* pointer to byte sized element */ |
1441 | xfs_buf_t *bp; | 1480 | xfs_buf_t *bp; |
@@ -1584,7 +1623,8 @@ xlog_sync(xlog_t *log, | |||
1584 | * Deallocate a log structure | 1623 | * Deallocate a log structure |
1585 | */ | 1624 | */ |
1586 | STATIC void | 1625 | STATIC void |
1587 | xlog_dealloc_log(xlog_t *log) | 1626 | xlog_dealloc_log( |
1627 | struct xlog *log) | ||
1588 | { | 1628 | { |
1589 | xlog_in_core_t *iclog, *next_iclog; | 1629 | xlog_in_core_t *iclog, *next_iclog; |
1590 | int i; | 1630 | int i; |
@@ -1616,10 +1656,11 @@ xlog_dealloc_log(xlog_t *log) | |||
1616 | */ | 1656 | */ |
1617 | /* ARGSUSED */ | 1657 | /* ARGSUSED */ |
1618 | static inline void | 1658 | static inline void |
1619 | xlog_state_finish_copy(xlog_t *log, | 1659 | xlog_state_finish_copy( |
1620 | xlog_in_core_t *iclog, | 1660 | struct xlog *log, |
1621 | int record_cnt, | 1661 | struct xlog_in_core *iclog, |
1622 | int copy_bytes) | 1662 | int record_cnt, |
1663 | int copy_bytes) | ||
1623 | { | 1664 | { |
1624 | spin_lock(&log->l_icloglock); | 1665 | spin_lock(&log->l_icloglock); |
1625 | 1666 | ||
@@ -2142,7 +2183,8 @@ xlog_write( | |||
2142 | * State Change: DIRTY -> ACTIVE | 2183 | * State Change: DIRTY -> ACTIVE |
2143 | */ | 2184 | */ |
2144 | STATIC void | 2185 | STATIC void |
2145 | xlog_state_clean_log(xlog_t *log) | 2186 | xlog_state_clean_log( |
2187 | struct xlog *log) | ||
2146 | { | 2188 | { |
2147 | xlog_in_core_t *iclog; | 2189 | xlog_in_core_t *iclog; |
2148 | int changed = 0; | 2190 | int changed = 0; |
@@ -2222,7 +2264,7 @@ xlog_state_clean_log(xlog_t *log) | |||
2222 | 2264 | ||
2223 | STATIC xfs_lsn_t | 2265 | STATIC xfs_lsn_t |
2224 | xlog_get_lowest_lsn( | 2266 | xlog_get_lowest_lsn( |
2225 | xlog_t *log) | 2267 | struct xlog *log) |
2226 | { | 2268 | { |
2227 | xlog_in_core_t *lsn_log; | 2269 | xlog_in_core_t *lsn_log; |
2228 | xfs_lsn_t lowest_lsn, lsn; | 2270 | xfs_lsn_t lowest_lsn, lsn; |
@@ -2245,9 +2287,9 @@ xlog_get_lowest_lsn( | |||
2245 | 2287 | ||
2246 | STATIC void | 2288 | STATIC void |
2247 | xlog_state_do_callback( | 2289 | xlog_state_do_callback( |
2248 | xlog_t *log, | 2290 | struct xlog *log, |
2249 | int aborted, | 2291 | int aborted, |
2250 | xlog_in_core_t *ciclog) | 2292 | struct xlog_in_core *ciclog) |
2251 | { | 2293 | { |
2252 | xlog_in_core_t *iclog; | 2294 | xlog_in_core_t *iclog; |
2253 | xlog_in_core_t *first_iclog; /* used to know when we've | 2295 | xlog_in_core_t *first_iclog; /* used to know when we've |
@@ -2467,7 +2509,7 @@ xlog_state_done_syncing( | |||
2467 | xlog_in_core_t *iclog, | 2509 | xlog_in_core_t *iclog, |
2468 | int aborted) | 2510 | int aborted) |
2469 | { | 2511 | { |
2470 | xlog_t *log = iclog->ic_log; | 2512 | struct xlog *log = iclog->ic_log; |
2471 | 2513 | ||
2472 | spin_lock(&log->l_icloglock); | 2514 | spin_lock(&log->l_icloglock); |
2473 | 2515 | ||
@@ -2521,12 +2563,13 @@ xlog_state_done_syncing( | |||
2521 | * is copied. | 2563 | * is copied. |
2522 | */ | 2564 | */ |
2523 | STATIC int | 2565 | STATIC int |
2524 | xlog_state_get_iclog_space(xlog_t *log, | 2566 | xlog_state_get_iclog_space( |
2525 | int len, | 2567 | struct xlog *log, |
2526 | xlog_in_core_t **iclogp, | 2568 | int len, |
2527 | xlog_ticket_t *ticket, | 2569 | struct xlog_in_core **iclogp, |
2528 | int *continued_write, | 2570 | struct xlog_ticket *ticket, |
2529 | int *logoffsetp) | 2571 | int *continued_write, |
2572 | int *logoffsetp) | ||
2530 | { | 2573 | { |
2531 | int log_offset; | 2574 | int log_offset; |
2532 | xlog_rec_header_t *head; | 2575 | xlog_rec_header_t *head; |
@@ -2631,8 +2674,9 @@ restart: | |||
2631 | * move grant reservation head forward. | 2674 | * move grant reservation head forward. |
2632 | */ | 2675 | */ |
2633 | STATIC void | 2676 | STATIC void |
2634 | xlog_regrant_reserve_log_space(xlog_t *log, | 2677 | xlog_regrant_reserve_log_space( |
2635 | xlog_ticket_t *ticket) | 2678 | struct xlog *log, |
2679 | struct xlog_ticket *ticket) | ||
2636 | { | 2680 | { |
2637 | trace_xfs_log_regrant_reserve_enter(log, ticket); | 2681 | trace_xfs_log_regrant_reserve_enter(log, ticket); |
2638 | 2682 | ||
@@ -2677,8 +2721,9 @@ xlog_regrant_reserve_log_space(xlog_t *log, | |||
2677 | * in the current reservation field. | 2721 | * in the current reservation field. |
2678 | */ | 2722 | */ |
2679 | STATIC void | 2723 | STATIC void |
2680 | xlog_ungrant_log_space(xlog_t *log, | 2724 | xlog_ungrant_log_space( |
2681 | xlog_ticket_t *ticket) | 2725 | struct xlog *log, |
2726 | struct xlog_ticket *ticket) | ||
2682 | { | 2727 | { |
2683 | int bytes; | 2728 | int bytes; |
2684 | 2729 | ||
@@ -2717,8 +2762,8 @@ xlog_ungrant_log_space(xlog_t *log, | |||
2717 | */ | 2762 | */ |
2718 | STATIC int | 2763 | STATIC int |
2719 | xlog_state_release_iclog( | 2764 | xlog_state_release_iclog( |
2720 | xlog_t *log, | 2765 | struct xlog *log, |
2721 | xlog_in_core_t *iclog) | 2766 | struct xlog_in_core *iclog) |
2722 | { | 2767 | { |
2723 | int sync = 0; /* do we sync? */ | 2768 | int sync = 0; /* do we sync? */ |
2724 | 2769 | ||
@@ -2768,9 +2813,10 @@ xlog_state_release_iclog( | |||
2768 | * that every data block. We have run out of space in this log record. | 2813 | * that every data block. We have run out of space in this log record. |
2769 | */ | 2814 | */ |
2770 | STATIC void | 2815 | STATIC void |
2771 | xlog_state_switch_iclogs(xlog_t *log, | 2816 | xlog_state_switch_iclogs( |
2772 | xlog_in_core_t *iclog, | 2817 | struct xlog *log, |
2773 | int eventual_size) | 2818 | struct xlog_in_core *iclog, |
2819 | int eventual_size) | ||
2774 | { | 2820 | { |
2775 | ASSERT(iclog->ic_state == XLOG_STATE_ACTIVE); | 2821 | ASSERT(iclog->ic_state == XLOG_STATE_ACTIVE); |
2776 | if (!eventual_size) | 2822 | if (!eventual_size) |
@@ -3114,7 +3160,9 @@ xfs_log_force_lsn( | |||
3114 | * disk. | 3160 | * disk. |
3115 | */ | 3161 | */ |
3116 | STATIC void | 3162 | STATIC void |
3117 | xlog_state_want_sync(xlog_t *log, xlog_in_core_t *iclog) | 3163 | xlog_state_want_sync( |
3164 | struct xlog *log, | ||
3165 | struct xlog_in_core *iclog) | ||
3118 | { | 3166 | { |
3119 | assert_spin_locked(&log->l_icloglock); | 3167 | assert_spin_locked(&log->l_icloglock); |
3120 | 3168 | ||
@@ -3158,7 +3206,7 @@ xfs_log_ticket_get( | |||
3158 | /* | 3206 | /* |
3159 | * Allocate and initialise a new log ticket. | 3207 | * Allocate and initialise a new log ticket. |
3160 | */ | 3208 | */ |
3161 | xlog_ticket_t * | 3209 | struct xlog_ticket * |
3162 | xlog_ticket_alloc( | 3210 | xlog_ticket_alloc( |
3163 | struct xlog *log, | 3211 | struct xlog *log, |
3164 | int unit_bytes, | 3212 | int unit_bytes, |
@@ -3346,9 +3394,10 @@ xlog_verify_grant_tail( | |||
3346 | 3394 | ||
3347 | /* check if it will fit */ | 3395 | /* check if it will fit */ |
3348 | STATIC void | 3396 | STATIC void |
3349 | xlog_verify_tail_lsn(xlog_t *log, | 3397 | xlog_verify_tail_lsn( |
3350 | xlog_in_core_t *iclog, | 3398 | struct xlog *log, |
3351 | xfs_lsn_t tail_lsn) | 3399 | struct xlog_in_core *iclog, |
3400 | xfs_lsn_t tail_lsn) | ||
3352 | { | 3401 | { |
3353 | int blocks; | 3402 | int blocks; |
3354 | 3403 | ||
@@ -3385,10 +3434,11 @@ xlog_verify_tail_lsn(xlog_t *log, | |||
3385 | * the cycle numbers agree with the current cycle number. | 3434 | * the cycle numbers agree with the current cycle number. |
3386 | */ | 3435 | */ |
3387 | STATIC void | 3436 | STATIC void |
3388 | xlog_verify_iclog(xlog_t *log, | 3437 | xlog_verify_iclog( |
3389 | xlog_in_core_t *iclog, | 3438 | struct xlog *log, |
3390 | int count, | 3439 | struct xlog_in_core *iclog, |
3391 | boolean_t syncing) | 3440 | int count, |
3441 | boolean_t syncing) | ||
3392 | { | 3442 | { |
3393 | xlog_op_header_t *ophead; | 3443 | xlog_op_header_t *ophead; |
3394 | xlog_in_core_t *icptr; | 3444 | xlog_in_core_t *icptr; |
@@ -3482,7 +3532,7 @@ xlog_verify_iclog(xlog_t *log, | |||
3482 | */ | 3532 | */ |
3483 | STATIC int | 3533 | STATIC int |
3484 | xlog_state_ioerror( | 3534 | xlog_state_ioerror( |
3485 | xlog_t *log) | 3535 | struct xlog *log) |
3486 | { | 3536 | { |
3487 | xlog_in_core_t *iclog, *ic; | 3537 | xlog_in_core_t *iclog, *ic; |
3488 | 3538 | ||
@@ -3527,7 +3577,7 @@ xfs_log_force_umount( | |||
3527 | struct xfs_mount *mp, | 3577 | struct xfs_mount *mp, |
3528 | int logerror) | 3578 | int logerror) |
3529 | { | 3579 | { |
3530 | xlog_t *log; | 3580 | struct xlog *log; |
3531 | int retval; | 3581 | int retval; |
3532 | 3582 | ||
3533 | log = mp->m_log; | 3583 | log = mp->m_log; |
@@ -3634,7 +3684,8 @@ xfs_log_force_umount( | |||
3634 | } | 3684 | } |
3635 | 3685 | ||
3636 | STATIC int | 3686 | STATIC int |
3637 | xlog_iclogs_empty(xlog_t *log) | 3687 | xlog_iclogs_empty( |
3688 | struct xlog *log) | ||
3638 | { | 3689 | { |
3639 | xlog_in_core_t *iclog; | 3690 | xlog_in_core_t *iclog; |
3640 | 3691 | ||