~vlad-lesin/percona-server/i_s-innodb-log-tracking-status

« back to all changes in this revision

Viewing changes to Percona-Server/storage/innodb_plugin/include/log0log.ic

  • Committer: Vlad Lesin
  • Date: 2012-11-08 15:24:56 UTC
  • Revision ID: vladislav.lesin@percona.com-20121108152456-fo5l7cd5ayoj7jtc
Holes detection is added.

Show diffs side-by-side

added added

removed removed

Lines of Context:
445
445
}
446
446
#endif /* !UNIV_HOTBACKUP */
447
447
 
 
448
UNIV_INLINE
 
449
void
 
450
log_set_thread_safe_uint64(
 
451
/*==============*/
 
452
        ib_uint64_t*    dst,
 
453
        ib_uint64_t     src,
 
454
        mutex_t*        mutex)
 
455
{
 
456
#ifdef HAVE_ATOMIC_BUILTINS_64
 
457
        ib_uint64_t old_value;
 
458
#endif
 
459
        ut_ad(dst);
 
460
        ut_ad(mutex);
 
461
 
 
462
#ifdef HAVE_ATOMIC_BUILTINS_64
 
463
        /* Single writer, no data race here */
 
464
        (void)mutex;
 
465
        old_value
 
466
                = os_atomic_increment_uint64(dst, 0);
 
467
        os_atomic_increment_uint64(dst,
 
468
                                   src - old_value);
 
469
#else
 
470
        mutex_enter(mutex);
 
471
        *dst = src;
 
472
        mutex_exit(mutex);
 
473
#endif
 
474
}
 
475
 
 
476
 
 
477
UNIV_INLINE
 
478
ib_uint64_t
 
479
log_get_thread_safe_uint64(
 
480
        ib_uint64_t*    value,
 
481
        mutex_t*        mutex)
 
482
{
 
483
#ifdef HAVE_ATOMIC_BUILTINS_64
 
484
        (void)mutex;
 
485
        return os_atomic_increment_uint64(value, 0);
 
486
#else
 
487
        ut_ad(mutex_own(mutex));
 
488
        return *value;
 
489
#endif
 
490
}
 
491
 
 
492
 
448
493
/****************************************************************//**
449
494
Safely reads the log_sys->tracked_lsn value.  Uses atomic operations
450
495
if available, otherwise this field is protected with the log system
456
501
ib_uint64_t
457
502
log_get_tracked_lsn()
458
503
{
459
 
#ifdef HAVE_ATOMIC_BUILTINS_64
460
 
        return os_atomic_increment_uint64(&log_sys->tracked_lsn, 0);
461
 
#else
462
 
        ut_ad(mutex_own(&(log_sys->mutex)));
463
 
        return log_sys->tracked_lsn;
464
 
#endif
 
504
        return log_get_thread_safe_uint64(&log_sys->tracked_lsn,
 
505
                                          &log_sys->mutex);
 
506
}
 
507
 
 
508
 
 
509
UNIV_INLINE
 
510
ib_uint64_t
 
511
log_get_tracked_end_lsn()
 
512
{
 
513
        return log_get_thread_safe_uint64(&log_sys->tracked_end_lsn,
 
514
                                          &log_sys->mutex);
 
515
}
 
516
 
 
517
 
 
518
UNIV_INLINE
 
519
void
 
520
log_set_tracked_end_lsn(
 
521
/*================*/
 
522
        ib_uint64_t     tracked_end_lsn)        /*!<in: new value */
 
523
{
 
524
        log_set_thread_safe_uint64(&log_sys->tracked_end_lsn,
 
525
                                   tracked_end_lsn,
 
526
                                   &log_sys->mutex);
465
527
}