diff options
Diffstat (limited to 'fs/xfs/xfs_log.c')
-rw-r--r-- | fs/xfs/xfs_log.c | 154 |
1 files changed, 27 insertions, 127 deletions
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index a9e0c38d18a4..29af51275ca9 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -111,8 +111,7 @@ STATIC xlog_ticket_t *xlog_ticket_get(xlog_t *log, | |||
111 | uint flags); | 111 | uint flags); |
112 | STATIC void xlog_ticket_put(xlog_t *log, xlog_ticket_t *ticket); | 112 | STATIC void xlog_ticket_put(xlog_t *log, xlog_ticket_t *ticket); |
113 | 113 | ||
114 | /* local debug functions */ | 114 | #if defined(DEBUG) |
115 | #if defined(DEBUG) && !defined(XLOG_NOLOG) | ||
116 | STATIC void xlog_verify_dest_ptr(xlog_t *log, __psint_t ptr); | 115 | STATIC void xlog_verify_dest_ptr(xlog_t *log, __psint_t ptr); |
117 | STATIC void xlog_verify_grant_head(xlog_t *log, int equals); | 116 | STATIC void xlog_verify_grant_head(xlog_t *log, int equals); |
118 | STATIC void xlog_verify_iclog(xlog_t *log, xlog_in_core_t *iclog, | 117 | STATIC void xlog_verify_iclog(xlog_t *log, xlog_in_core_t *iclog, |
@@ -128,26 +127,7 @@ STATIC void xlog_verify_tail_lsn(xlog_t *log, xlog_in_core_t *iclog, | |||
128 | 127 | ||
129 | STATIC int xlog_iclogs_empty(xlog_t *log); | 128 | STATIC int xlog_iclogs_empty(xlog_t *log); |
130 | 129 | ||
131 | #ifdef DEBUG | ||
132 | int xlog_do_error = 0; | ||
133 | int xlog_req_num = 0; | ||
134 | int xlog_error_mod = 33; | ||
135 | #endif | ||
136 | |||
137 | #define XLOG_FORCED_SHUTDOWN(log) (log->l_flags & XLOG_IO_ERROR) | ||
138 | |||
139 | /* | ||
140 | * 0 => disable log manager | ||
141 | * 1 => enable log manager | ||
142 | * 2 => enable log manager and log debugging | ||
143 | */ | ||
144 | #if defined(XLOG_NOLOG) || defined(DEBUG) | ||
145 | int xlog_debug = 1; | ||
146 | xfs_buftarg_t *xlog_target; | ||
147 | #endif | ||
148 | |||
149 | #if defined(XFS_LOG_TRACE) | 130 | #if defined(XFS_LOG_TRACE) |
150 | |||
151 | void | 131 | void |
152 | xlog_trace_loggrant(xlog_t *log, xlog_ticket_t *tic, xfs_caddr_t string) | 132 | xlog_trace_loggrant(xlog_t *log, xlog_ticket_t *tic, xfs_caddr_t string) |
153 | { | 133 | { |
@@ -183,31 +163,16 @@ xlog_trace_loggrant(xlog_t *log, xlog_ticket_t *tic, xfs_caddr_t string) | |||
183 | void | 163 | void |
184 | xlog_trace_iclog(xlog_in_core_t *iclog, uint state) | 164 | xlog_trace_iclog(xlog_in_core_t *iclog, uint state) |
185 | { | 165 | { |
186 | pid_t pid; | ||
187 | |||
188 | pid = current_pid(); | ||
189 | |||
190 | if (!iclog->ic_trace) | 166 | if (!iclog->ic_trace) |
191 | iclog->ic_trace = ktrace_alloc(256, KM_SLEEP); | 167 | iclog->ic_trace = ktrace_alloc(256, KM_SLEEP); |
192 | ktrace_enter(iclog->ic_trace, | 168 | ktrace_enter(iclog->ic_trace, |
193 | (void *)((unsigned long)state), | 169 | (void *)((unsigned long)state), |
194 | (void *)((unsigned long)pid), | 170 | (void *)((unsigned long)current_pid()), |
195 | (void *)0, | 171 | (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, |
196 | (void *)0, | 172 | (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, |
197 | (void *)0, | 173 | (void *)NULL, (void *)NULL, (void *)NULL, (void *)NULL, |
198 | (void *)0, | 174 | (void *)NULL, (void *)NULL); |
199 | (void *)0, | ||
200 | (void *)0, | ||
201 | (void *)0, | ||
202 | (void *)0, | ||
203 | (void *)0, | ||
204 | (void *)0, | ||
205 | (void *)0, | ||
206 | (void *)0, | ||
207 | (void *)0, | ||
208 | (void *)0); | ||
209 | } | 175 | } |
210 | |||
211 | #else | 176 | #else |
212 | #define xlog_trace_loggrant(log,tic,string) | 177 | #define xlog_trace_loggrant(log,tic,string) |
213 | #define xlog_trace_iclog(iclog,state) | 178 | #define xlog_trace_iclog(iclog,state) |
@@ -244,11 +209,6 @@ xfs_log_done(xfs_mount_t *mp, | |||
244 | xlog_ticket_t *ticket = (xfs_log_ticket_t) xtic; | 209 | xlog_ticket_t *ticket = (xfs_log_ticket_t) xtic; |
245 | xfs_lsn_t lsn = 0; | 210 | xfs_lsn_t lsn = 0; |
246 | 211 | ||
247 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
248 | if (!xlog_debug && xlog_target == log->l_targ) | ||
249 | return 0; | ||
250 | #endif | ||
251 | |||
252 | if (XLOG_FORCED_SHUTDOWN(log) || | 212 | if (XLOG_FORCED_SHUTDOWN(log) || |
253 | /* | 213 | /* |
254 | * If nothing was ever written, don't write out commit record. | 214 | * If nothing was ever written, don't write out commit record. |
@@ -316,11 +276,6 @@ _xfs_log_force( | |||
316 | if (!log_flushed) | 276 | if (!log_flushed) |
317 | log_flushed = &dummy; | 277 | log_flushed = &dummy; |
318 | 278 | ||
319 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
320 | if (!xlog_debug && xlog_target == log->l_targ) | ||
321 | return 0; | ||
322 | #endif | ||
323 | |||
324 | ASSERT(flags & XFS_LOG_FORCE); | 279 | ASSERT(flags & XFS_LOG_FORCE); |
325 | 280 | ||
326 | XFS_STATS_INC(xs_log_force); | 281 | XFS_STATS_INC(xs_log_force); |
@@ -348,10 +303,6 @@ xfs_log_notify(xfs_mount_t *mp, /* mount of partition */ | |||
348 | xlog_in_core_t *iclog = (xlog_in_core_t *)iclog_hndl; | 303 | xlog_in_core_t *iclog = (xlog_in_core_t *)iclog_hndl; |
349 | int abortflg, spl; | 304 | int abortflg, spl; |
350 | 305 | ||
351 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
352 | if (!xlog_debug && xlog_target == log->l_targ) | ||
353 | return 0; | ||
354 | #endif | ||
355 | cb->cb_next = NULL; | 306 | cb->cb_next = NULL; |
356 | spl = LOG_LOCK(log); | 307 | spl = LOG_LOCK(log); |
357 | abortflg = (iclog->ic_state & XLOG_STATE_IOERROR); | 308 | abortflg = (iclog->ic_state & XLOG_STATE_IOERROR); |
@@ -402,13 +353,8 @@ xfs_log_reserve(xfs_mount_t *mp, | |||
402 | { | 353 | { |
403 | xlog_t *log = mp->m_log; | 354 | xlog_t *log = mp->m_log; |
404 | xlog_ticket_t *internal_ticket; | 355 | xlog_ticket_t *internal_ticket; |
405 | int retval; | 356 | int retval = 0; |
406 | 357 | ||
407 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
408 | if (!xlog_debug && xlog_target == log->l_targ) | ||
409 | return 0; | ||
410 | #endif | ||
411 | retval = 0; | ||
412 | ASSERT(client == XFS_TRANSACTION || client == XFS_LOG); | 358 | ASSERT(client == XFS_TRANSACTION || client == XFS_LOG); |
413 | ASSERT((flags & XFS_LOG_NOSLEEP) == 0); | 359 | ASSERT((flags & XFS_LOG_NOSLEEP) == 0); |
414 | 360 | ||
@@ -470,13 +416,6 @@ xfs_log_mount(xfs_mount_t *mp, | |||
470 | 416 | ||
471 | mp->m_log = xlog_alloc_log(mp, log_target, blk_offset, num_bblks); | 417 | mp->m_log = xlog_alloc_log(mp, log_target, blk_offset, num_bblks); |
472 | 418 | ||
473 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
474 | if (!xlog_debug) { | ||
475 | cmn_err(CE_NOTE, "logdev: %s", mp->m_logname ? | ||
476 | mp->m_logname : "internal"); | ||
477 | return 0; | ||
478 | } | ||
479 | #endif | ||
480 | /* | 419 | /* |
481 | * skip log recovery on a norecovery mount. pretend it all | 420 | * skip log recovery on a norecovery mount. pretend it all |
482 | * just worked. | 421 | * just worked. |
@@ -580,11 +519,6 @@ xfs_log_unmount_write(xfs_mount_t *mp) | |||
580 | __uint32_t pad2; /* may as well make it 64 bits */ | 519 | __uint32_t pad2; /* may as well make it 64 bits */ |
581 | } magic = { XLOG_UNMOUNT_TYPE, 0, 0 }; | 520 | } magic = { XLOG_UNMOUNT_TYPE, 0, 0 }; |
582 | 521 | ||
583 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
584 | if (!xlog_debug && xlog_target == log->l_targ) | ||
585 | return 0; | ||
586 | #endif | ||
587 | |||
588 | /* | 522 | /* |
589 | * Don't write out unmount record on read-only mounts. | 523 | * Don't write out unmount record on read-only mounts. |
590 | * Or, if we are doing a forced umount (typically because of IO errors). | 524 | * Or, if we are doing a forced umount (typically because of IO errors). |
@@ -711,12 +645,6 @@ xfs_log_write(xfs_mount_t * mp, | |||
711 | int error; | 645 | int error; |
712 | xlog_t *log = mp->m_log; | 646 | xlog_t *log = mp->m_log; |
713 | 647 | ||
714 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
715 | if (!xlog_debug && xlog_target == log->l_targ) { | ||
716 | *start_lsn = 0; | ||
717 | return 0; | ||
718 | } | ||
719 | #endif | ||
720 | if (XLOG_FORCED_SHUTDOWN(log)) | 648 | if (XLOG_FORCED_SHUTDOWN(log)) |
721 | return XFS_ERROR(EIO); | 649 | return XFS_ERROR(EIO); |
722 | 650 | ||
@@ -736,11 +664,6 @@ xfs_log_move_tail(xfs_mount_t *mp, | |||
736 | int need_bytes, free_bytes, cycle, bytes; | 664 | int need_bytes, free_bytes, cycle, bytes; |
737 | SPLDECL(s); | 665 | SPLDECL(s); |
738 | 666 | ||
739 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
740 | if (!xlog_debug && xlog_target == log->l_targ) | ||
741 | return; | ||
742 | #endif | ||
743 | /* XXXsup tmp */ | ||
744 | if (XLOG_FORCED_SHUTDOWN(log)) | 667 | if (XLOG_FORCED_SHUTDOWN(log)) |
745 | return; | 668 | return; |
746 | ASSERT(!XFS_FORCED_SHUTDOWN(mp)); | 669 | ASSERT(!XFS_FORCED_SHUTDOWN(mp)); |
@@ -1027,51 +950,22 @@ xlog_get_iclog_buffer_size(xfs_mount_t *mp, | |||
1027 | int size; | 950 | int size; |
1028 | int xhdrs; | 951 | int xhdrs; |
1029 | 952 | ||
1030 | #if defined(DEBUG) || defined(XLOG_NOLOG) | 953 | if (mp->m_logbufs <= 0) { |
1031 | /* | 954 | if (xfs_physmem <= btoc(128*1024*1024)) { |
1032 | * When logbufs == 0, someone has disabled the log from the FSTAB | 955 | log->l_iclog_bufs = XLOG_MIN_ICLOGS; |
1033 | * file. This is not a documented feature. We need to set xlog_debug | 956 | } else if (xfs_physmem <= btoc(400*1024*1024)) { |
1034 | * to zero (this deactivates the log) and set xlog_target to the | 957 | log->l_iclog_bufs = XLOG_MED_ICLOGS; |
1035 | * appropriate device. Only one filesystem may be affected as such | 958 | } else { /* 256K with 32K bufs */ |
1036 | * since this is just a performance hack to test what we might be able | 959 | log->l_iclog_bufs = XLOG_MAX_ICLOGS; |
1037 | * to get if the log were not present. | ||
1038 | */ | ||
1039 | if (mp->m_logbufs == 0) { | ||
1040 | xlog_debug = 0; | ||
1041 | xlog_target = log->l_targ; | ||
1042 | log->l_iclog_bufs = XLOG_MIN_ICLOGS; | ||
1043 | } else | ||
1044 | #endif | ||
1045 | { | ||
1046 | /* | ||
1047 | * This is the normal path. If m_logbufs == -1, then the | ||
1048 | * admin has chosen to use the system defaults for logbuffers. | ||
1049 | */ | ||
1050 | if (mp->m_logbufs == -1) { | ||
1051 | if (xfs_physmem <= btoc(128*1024*1024)) { | ||
1052 | log->l_iclog_bufs = XLOG_MIN_ICLOGS; | ||
1053 | } else if (xfs_physmem <= btoc(400*1024*1024)) { | ||
1054 | log->l_iclog_bufs = XLOG_MED_ICLOGS; | ||
1055 | } else { | ||
1056 | /* 256K with 32K bufs */ | ||
1057 | log->l_iclog_bufs = XLOG_MAX_ICLOGS; | ||
1058 | } | ||
1059 | } else | ||
1060 | log->l_iclog_bufs = mp->m_logbufs; | ||
1061 | |||
1062 | #if defined(DEBUG) || defined(XLOG_NOLOG) | ||
1063 | /* We are reactivating a filesystem after it was inactive */ | ||
1064 | if (log->l_targ == xlog_target) { | ||
1065 | xlog_target = NULL; | ||
1066 | xlog_debug = 1; | ||
1067 | } | 960 | } |
1068 | #endif | 961 | } else { |
962 | log->l_iclog_bufs = mp->m_logbufs; | ||
1069 | } | 963 | } |
1070 | 964 | ||
1071 | /* | 965 | /* |
1072 | * Buffer size passed in from mount system call. | 966 | * Buffer size passed in from mount system call. |
1073 | */ | 967 | */ |
1074 | if (mp->m_logbsize != -1) { | 968 | if (mp->m_logbsize > 0) { |
1075 | size = log->l_iclog_size = mp->m_logbsize; | 969 | size = log->l_iclog_size = mp->m_logbsize; |
1076 | log->l_iclog_size_log = 0; | 970 | log->l_iclog_size_log = 0; |
1077 | while (size != 1) { | 971 | while (size != 1) { |
@@ -1094,7 +988,7 @@ xlog_get_iclog_buffer_size(xfs_mount_t *mp, | |||
1094 | log->l_iclog_hsize = BBSIZE; | 988 | log->l_iclog_hsize = BBSIZE; |
1095 | log->l_iclog_heads = 1; | 989 | log->l_iclog_heads = 1; |
1096 | } | 990 | } |
1097 | return; | 991 | goto done; |
1098 | } | 992 | } |
1099 | 993 | ||
1100 | /* | 994 | /* |
@@ -1121,7 +1015,7 @@ xlog_get_iclog_buffer_size(xfs_mount_t *mp, | |||
1121 | if (mp->m_sb.sb_blocksize >= 16*1024) { | 1015 | if (mp->m_sb.sb_blocksize >= 16*1024) { |
1122 | log->l_iclog_size = XLOG_BIG_RECORD_BSIZE; | 1016 | log->l_iclog_size = XLOG_BIG_RECORD_BSIZE; |
1123 | log->l_iclog_size_log = XLOG_BIG_RECORD_BSHIFT; | 1017 | log->l_iclog_size_log = XLOG_BIG_RECORD_BSHIFT; |
1124 | if (mp->m_logbufs == -1) { | 1018 | if (mp->m_logbufs <= 0) { |
1125 | switch (mp->m_sb.sb_blocksize) { | 1019 | switch (mp->m_sb.sb_blocksize) { |
1126 | case 16*1024: /* 16 KB */ | 1020 | case 16*1024: /* 16 KB */ |
1127 | log->l_iclog_bufs = 3; | 1021 | log->l_iclog_bufs = 3; |
@@ -1138,6 +1032,12 @@ xlog_get_iclog_buffer_size(xfs_mount_t *mp, | |||
1138 | } | 1032 | } |
1139 | } | 1033 | } |
1140 | } | 1034 | } |
1035 | |||
1036 | done: /* are we being asked to make the sizes selected above visible? */ | ||
1037 | if (mp->m_logbufs == 0) | ||
1038 | mp->m_logbufs = log->l_iclog_bufs; | ||
1039 | if (mp->m_logbsize == 0) | ||
1040 | mp->m_logbsize = log->l_iclog_size; | ||
1141 | } /* xlog_get_iclog_buffer_size */ | 1041 | } /* xlog_get_iclog_buffer_size */ |
1142 | 1042 | ||
1143 | 1043 | ||
@@ -3390,7 +3290,7 @@ xlog_ticket_get(xlog_t *log, | |||
3390 | * | 3290 | * |
3391 | ****************************************************************************** | 3291 | ****************************************************************************** |
3392 | */ | 3292 | */ |
3393 | #if defined(DEBUG) && !defined(XLOG_NOLOG) | 3293 | #if defined(DEBUG) |
3394 | /* | 3294 | /* |
3395 | * Make sure that the destination ptr is within the valid data region of | 3295 | * Make sure that the destination ptr is within the valid data region of |
3396 | * one of the iclogs. This uses backup pointers stored in a different | 3296 | * one of the iclogs. This uses backup pointers stored in a different |
@@ -3554,7 +3454,7 @@ xlog_verify_iclog(xlog_t *log, | |||
3554 | ptr += sizeof(xlog_op_header_t) + op_len; | 3454 | ptr += sizeof(xlog_op_header_t) + op_len; |
3555 | } | 3455 | } |
3556 | } /* xlog_verify_iclog */ | 3456 | } /* xlog_verify_iclog */ |
3557 | #endif /* DEBUG && !XLOG_NOLOG */ | 3457 | #endif |
3558 | 3458 | ||
3559 | /* | 3459 | /* |
3560 | * Mark all iclogs IOERROR. LOG_LOCK is held by the caller. | 3460 | * Mark all iclogs IOERROR. LOG_LOCK is held by the caller. |