~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/log0log.ic

  • Committer: Andy Lester
  • Date: 2008-08-10 02:15:48 UTC
  • mto: (266.1.31 use-replace-funcs)
  • mto: This revision was merged to the branch mainline in revision 295.
  • Revision ID: andy@petdance.com-20080810021548-0zx8nhzva6al10k3
Added a proper const qualifer.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
/**********************************************************
14
14
Checks by parsing that the catenated log segment for a single mtr is
15
15
consistent. */
16
 
UNIV_INTERN
 
16
 
17
17
ibool
18
18
log_check_log_recs(
19
19
/*===============*/
20
 
        byte*           buf,            /* in: pointer to the start of
21
 
                                        the log segment in the
22
 
                                        log_sys->buf log buffer */
23
 
        ulint           len,            /* in: segment length in bytes */
24
 
        ib_uint64_t     buf_start_lsn); /* in: buffer start lsn */
 
20
        byte*   buf,            /* in: pointer to the start of the log segment
 
21
                                in the log_sys->buf log buffer */
 
22
        ulint   len,            /* in: segment length in bytes */
 
23
        dulint  buf_start_lsn); /* in: buffer start lsn */
25
24
 
26
25
/****************************************************************
27
26
Gets a log block flush bit. */
163
162
void
164
163
log_block_set_checkpoint_no(
165
164
/*========================*/
166
 
        byte*           log_block,      /* in: log block */
167
 
        ib_uint64_t     no)             /* in: checkpoint no */
 
165
        byte*   log_block,      /* in: log block */
 
166
        dulint  no)             /* in: checkpoint no */
168
167
{
169
 
        mach_write_to_4(log_block + LOG_BLOCK_CHECKPOINT_NO, (ulint) no);
 
168
        mach_write_to_4(log_block + LOG_BLOCK_CHECKPOINT_NO,
 
169
                        ut_dulint_get_low(no));
170
170
}
171
171
 
172
172
/****************************************************************
175
175
ulint
176
176
log_block_convert_lsn_to_no(
177
177
/*========================*/
178
 
                                /* out: log block number,
179
 
                                it is > 0 and <= 1G */
180
 
        ib_uint64_t     lsn)    /* in: lsn of a byte within the block */
 
178
                        /* out: log block number, it is > 0 and <= 1G */
 
179
        dulint  lsn)    /* in: lsn of a byte within the block */
181
180
{
182
 
        return(((ulint) (lsn / OS_FILE_LOG_BLOCK_SIZE) & 0x3FFFFFFFUL) + 1);
 
181
        ulint   no;
 
182
 
 
183
        no = ut_dulint_get_low(lsn) / OS_FILE_LOG_BLOCK_SIZE;
 
184
        no += (ut_dulint_get_high(lsn) % OS_FILE_LOG_BLOCK_SIZE)
 
185
                * 2 * (0x80000000UL / OS_FILE_LOG_BLOCK_SIZE);
 
186
 
 
187
        no = no & 0x3FFFFFFFUL;
 
188
 
 
189
        return(no + 1);
183
190
}
184
191
 
185
192
/****************************************************************
188
195
ulint
189
196
log_block_calc_checksum(
190
197
/*====================*/
191
 
                                /* out: checksum */
192
 
        const byte*     block)  /* in: log block */
 
198
                        /* out: checksum */
 
199
        byte*   block)  /* in: log block */
193
200
{
194
201
        ulint   sum;
195
202
        ulint   sh;
199
206
        sh = 0;
200
207
 
201
208
        for (i = 0; i < OS_FILE_LOG_BLOCK_SIZE - LOG_BLOCK_TRL_SIZE; i++) {
202
 
                ulint   b = (ulint) block[i];
203
 
                sum &= 0x7FFFFFFFUL;
204
 
                sum += b;
205
 
                sum += b << sh;
 
209
                sum = sum & 0x7FFFFFFFUL;
 
210
                sum += (((ulint)(*(block + i))) << sh) + (ulint)(*(block + i));
206
211
                sh++;
207
212
                if (sh > 24) {
208
213
                        sh = 0;
218
223
ulint
219
224
log_block_get_checksum(
220
225
/*===================*/
221
 
                                        /* out: checksum */
222
 
        const byte*     log_block)      /* in: log block */
 
226
                                /* out: checksum */
 
227
        byte*   log_block)      /* in: log block */
223
228
{
224
229
        return(mach_read_from_4(log_block + OS_FILE_LOG_BLOCK_SIZE
225
230
                                - LOG_BLOCK_CHECKSUM));
245
250
void
246
251
log_block_init(
247
252
/*===========*/
248
 
        byte*           log_block,      /* in: pointer to the log buffer */
249
 
        ib_uint64_t     lsn)            /* in: lsn within the log block */
 
253
        byte*   log_block,      /* in: pointer to the log buffer */
 
254
        dulint  lsn)            /* in: lsn within the log block */
250
255
{
251
256
        ulint   no;
252
257
 
267
272
void
268
273
log_block_init_in_old_format(
269
274
/*=========================*/
270
 
        byte*           log_block,      /* in: pointer to the log buffer */
271
 
        ib_uint64_t     lsn)            /* in: lsn within the log block */
 
275
        byte*   log_block,      /* in: pointer to the log buffer */
 
276
        dulint  lsn)            /* in: lsn within the log block */
272
277
{
273
278
        ulint   no;
274
279
 
287
292
Writes to the log the string given. The log must be released with
288
293
log_release. */
289
294
UNIV_INLINE
290
 
ib_uint64_t
 
295
dulint
291
296
log_reserve_and_write_fast(
292
297
/*=======================*/
293
 
                                /* out: end lsn of the log record,
294
 
                                zero if did not succeed */
295
 
        byte*           str,    /* in: string */
296
 
        ulint           len,    /* in: string length */
297
 
        ib_uint64_t*    start_lsn,/* out: start lsn of the log record */
298
 
        ibool*          success)/* out: TRUE if success */
 
298
                        /* out: end lsn of the log record, ut_dulint_zero if
 
299
                        did not succeed */
 
300
        byte*   str,    /* in: string */
 
301
        ulint   len,    /* in: string length */
 
302
        dulint* start_lsn,/* out: start lsn of the log record */
 
303
        ibool*  success)/* out: TRUE if success */
299
304
{
300
 
        log_t*          log     = log_sys;
301
 
        ulint           data_len;
302
 
        ib_uint64_t     lsn;
 
305
        log_t*  log     = log_sys;
 
306
        ulint   data_len;
 
307
        dulint  lsn;
303
308
 
304
309
        *success = TRUE;
305
310
 
316
321
 
317
322
                mutex_exit(&(log->mutex));
318
323
 
319
 
                return(0);
 
324
                return(ut_dulint_zero);
320
325
        }
321
326
 
322
327
        *start_lsn = log->lsn;
323
328
 
324
329
        ut_memcpy(log->buf + log->buf_free, str, len);
325
330
 
326
 
        log_block_set_data_len((byte*) ut_align_down(log->buf + log->buf_free,
327
 
                                                     OS_FILE_LOG_BLOCK_SIZE),
 
331
        log_block_set_data_len(ut_align_down(log->buf + log->buf_free,
 
332
                                             OS_FILE_LOG_BLOCK_SIZE),
328
333
                               data_len);
329
334
#ifdef UNIV_LOG_DEBUG
330
335
        log->old_buf_free = log->buf_free;
334
339
 
335
340
        ut_ad(log->buf_free <= log->buf_size);
336
341
 
337
 
        lsn = log->lsn += len;
 
342
        lsn = ut_dulint_add(log->lsn, len);
 
343
 
 
344
        log->lsn = lsn;
338
345
 
339
346
#ifdef UNIV_LOG_DEBUG
340
347
        log_check_log_recs(log->buf + log->old_buf_free,
356
363
/****************************************************************
357
364
Gets the current lsn. */
358
365
UNIV_INLINE
359
 
ib_uint64_t
 
366
dulint
360
367
log_get_lsn(void)
361
368
/*=============*/
362
369
                        /* out: current lsn */
363
370
{
364
 
        ib_uint64_t     lsn;
 
371
        dulint  lsn;
365
372
 
366
373
        mutex_enter(&(log_sys->mutex));
367
374