11
11
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
13
13
You should have received a copy of the GNU General Public License along with
14
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
15
Place, Suite 330, Boston, MA 02111-1307 USA
14
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
15
St, Fifth Floor, Boston, MA 02110-1301 USA
17
17
*****************************************************************************/
35
36
log_check_log_recs(
36
37
/*===============*/
37
byte* buf, /*!< in: pointer to the start of
38
const byte* buf, /*!< in: pointer to the start of
38
39
the log segment in the
39
40
log_sys->buf log buffer */
40
41
ulint len, /*!< in: segment length in bytes */
41
42
ib_uint64_t buf_start_lsn); /*!< in: buffer start lsn */
43
#endif /* UNIV_LOG_DEBUG */
43
45
/************************************************************//**
44
46
Gets a log block flush bit.
306
308
log_reserve_and_write_fast(
307
309
/*=======================*/
308
byte* str, /*!< in: string */
310
const void* str, /*!< in: string */
309
311
ulint len, /*!< in: string length */
310
ib_uint64_t* start_lsn,/*!< out: start lsn of the log record */
311
ibool* success)/*!< out: TRUE if success */
312
ib_uint64_t* start_lsn)/*!< out: start lsn of the log record */
313
log_t* log = log_sys;
319
mutex_enter(&(log->mutex));
321
data_len = len + log->buf_free % OS_FILE_LOG_BLOCK_SIZE;
315
#ifdef UNIV_LOG_LSN_DEBUG
316
/* length of the LSN pseudo-record */
318
#endif /* UNIV_LOG_LSN_DEBUG */
320
mutex_enter(&log_sys->mutex);
321
#ifdef UNIV_LOG_LSN_DEBUG
323
+ mach_get_compressed_size(log_sys->lsn >> 32)
324
+ mach_get_compressed_size(log_sys->lsn & 0xFFFFFFFFUL);
325
#endif /* UNIV_LOG_LSN_DEBUG */
328
#ifdef UNIV_LOG_LSN_DEBUG
330
#endif /* UNIV_LOG_LSN_DEBUG */
331
+ log_sys->buf_free % OS_FILE_LOG_BLOCK_SIZE;
323
333
if (data_len >= OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_SIZE) {
325
335
/* The string does not fit within the current log block
326
336
or the log block would become full */
330
mutex_exit(&(log->mutex));
338
mutex_exit(&log_sys->mutex);
335
*start_lsn = log->lsn;
337
ut_memcpy(log->buf + log->buf_free, str, len);
339
log_block_set_data_len((byte*) ut_align_down(log->buf + log->buf_free,
343
*start_lsn = log_sys->lsn;
345
#ifdef UNIV_LOG_LSN_DEBUG
347
/* Write the LSN pseudo-record. */
348
byte* b = &log_sys->buf[log_sys->buf_free];
349
*b++ = MLOG_LSN | (MLOG_SINGLE_REC_FLAG & *(const byte*) str);
350
/* Write the LSN in two parts,
351
as a pseudo page number and space id. */
352
b += mach_write_compressed(b, log_sys->lsn >> 32);
353
b += mach_write_compressed(b, log_sys->lsn & 0xFFFFFFFFUL);
354
ut_a(b - lsn_len == &log_sys->buf[log_sys->buf_free]);
359
#else /* UNIV_LOG_LSN_DEBUG */
360
memcpy(log_sys->buf + log_sys->buf_free, str, len);
361
#endif /* UNIV_LOG_LSN_DEBUG */
363
log_block_set_data_len((byte*) ut_align_down(log_sys->buf
340
365
OS_FILE_LOG_BLOCK_SIZE),
342
367
#ifdef UNIV_LOG_DEBUG
343
log->old_buf_free = log->buf_free;
344
log->old_lsn = log->lsn;
368
log_sys->old_buf_free = log_sys->buf_free;
369
log_sys->old_lsn = log_sys->lsn;
346
log->buf_free += len;
348
ut_ad(log->buf_free <= log->buf_size);
350
lsn = log->lsn += len;
371
log_sys->buf_free += len;
373
ut_ad(log_sys->buf_free <= log_sys->buf_size);
352
377
#ifdef UNIV_LOG_DEBUG
353
log_check_log_recs(log->buf + log->old_buf_free,
354
log->buf_free - log->old_buf_free, log->old_lsn);
378
log_check_log_recs(log_sys->buf + log_sys->old_buf_free,
379
log_sys->buf_free - log_sys->old_buf_free,
382
return(log_sys->lsn);
359
385
/***********************************************************************//**