~ubuntu-branches/ubuntu/saucy/db/saucy-proposed

« back to all changes in this revision

Viewing changes to mp/mp_bh.c

  • Committer: Bazaar Package Importer
  • Author(s): Colin Watson
  • Date: 2010-10-25 22:16:35 UTC
  • mfrom: (13.1.11 sid)
  • Revision ID: james.westby@ubuntu.com-20101025221635-k0o38lxdx9kle3mh
Tags: 5.0.26-3ubuntu1
* Resynchronise with Debian.  Remaining changes:
  - Pass --build/--host to configure to support cross-building, and don't
    override CC.
  - Disable the Java build when cross-building, for now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*-
2
2
 * See the file LICENSE for redistribution information.
3
3
 *
4
 
 * Copyright (c) 1996-2009 Oracle.  All rights reserved.
 
4
 * Copyright (c) 1996, 2010 Oracle and/or its affiliates.  All rights reserved.
5
5
 *
6
6
 * $Id$
7
7
 */
149
149
        if ((ret = __memp_fcreate(env, &dbmfp)) != 0)
150
150
                return (ret);
151
151
        if ((ret = __memp_fopen(dbmfp, mfp,
152
 
            NULL, NULL, DB_DURABLE_UNKNOWN, 0, mfp->stat.st_pagesize)) != 0) {
 
152
            NULL, NULL, DB_DURABLE_UNKNOWN, 0, mfp->pagesize)) != 0) {
153
153
                (void)__memp_fclose(dbmfp, 0);
154
154
 
155
155
                /*
163
163
        }
164
164
 
165
165
pgwrite:
166
 
        MVCC_MPROTECT(bhp->buf, mfp->stat.st_pagesize,
 
166
        MVCC_MPROTECT(bhp->buf, mfp->pagesize,
167
167
            PROT_READ | PROT_WRITE | PROT_EXEC);
168
168
        ret = __memp_pgwrite(env, dbmfp, hp, bhp);
169
169
        if (dbmfp == NULL)
203
203
 
204
204
        env = dbmfp->env;
205
205
        mfp = dbmfp->mfp;
206
 
        pagesize = mfp->stat.st_pagesize;
 
206
        pagesize = mfp->pagesize;
207
207
 
208
208
        /* We should never be called with a dirty or unlocked buffer. */
209
209
        DB_ASSERT(env, !F_ISSET(bhp, BH_DIRTY_CREATE | BH_FROZEN));
210
 
        DB_ASSERT(env, can_create || !F_ISSET(bhp, BH_DIRTY));
 
210
        DB_ASSERT(env, can_create ||
 
211
            F_ISSET(bhp, BH_TRASH) || !F_ISSET(bhp, BH_DIRTY));
211
212
        DB_ASSERT(env, F_ISSET(bhp, BH_EXCLUSIVE));
212
213
 
213
214
        /* Mark the buffer as in transistion. */
254
255
                if (len < pagesize)
255
256
                        memset(bhp->buf + len, CLEAR_BYTE, pagesize - len);
256
257
#endif
257
 
#ifdef HAVE_STATISTICS
258
 
                ++mfp->stat.st_page_create;
 
258
                STAT_INC(env, mpool, page_create, mfp->stat.st_page_create);
259
259
        } else
260
 
                ++mfp->stat.st_page_in;
261
 
#else
262
 
        }
263
 
#endif
 
260
                STAT_INC(env, mpool, page_in, mfp->stat.st_page_in);
264
261
 
265
262
        /* Call any pgin function. */
266
263
        ret = mfp->ftype == 0 ? 0 : __memp_pg(dbmfp, bhp->pgno, bhp->buf, 1);
364
361
                if (!lp->db_log_inmemory &&
365
362
                    LOG_COMPARE(&lp->s_lsn, &LSN(bhp->buf)) <= 0) {
366
363
                        MUTEX_LOCK(env, lp->mtx_flush);
367
 
                        DB_ASSERT(env,
 
364
                        DB_ASSERT(env, F_ISSET(env->dbenv, DB_ENV_NOLOCKING) ||
368
365
                            LOG_COMPARE(&lp->s_lsn, &LSN(bhp->buf)) > 0);
369
366
                        MUTEX_UNLOCK(env, lp->mtx_flush);
370
367
                }
381
378
                if (F_ISSET(bhp, BH_EXCLUSIVE))
382
379
                        F_SET(bhp, BH_TRASH);
383
380
                else {
384
 
                        if ((ret =
385
 
                            __os_malloc(env, mfp->stat.st_pagesize, &buf)) != 0)
 
381
                        if ((ret = __os_malloc(env, mfp->pagesize, &buf)) != 0)
386
382
                                goto err;
387
 
                        memcpy(buf, bhp->buf, mfp->stat.st_pagesize);
 
383
                        memcpy(buf, bhp->buf, mfp->pagesize);
388
384
                }
389
385
                if ((ret = __memp_pg(dbmfp, bhp->pgno, buf, 0)) != 0)
390
386
                        goto err;
391
387
        }
392
388
 
393
389
        /* Write the page. */
394
 
        if ((ret = __os_io(
395
 
            env, DB_IO_WRITE, dbmfp->fhp, bhp->pgno, mfp->stat.st_pagesize,
396
 
            0, mfp->stat.st_pagesize, buf, &nw)) != 0) {
 
390
        if ((ret = __os_io( env, DB_IO_WRITE, dbmfp->fhp, bhp->pgno,
 
391
            mfp->pagesize, 0, mfp->pagesize, buf, &nw)) != 0) {
397
392
                __db_errx(env, "%s: write failed for page %lu",
398
393
                    __memp_fn(dbmfp), (u_long)bhp->pgno);
399
394
                goto err;
541
536
        env = dbmp->env;
542
537
#ifdef DIAG_MVCC
543
538
        if (mfp != NULL)
544
 
                pagesize = mfp->stat.st_pagesize;
 
539
                pagesize = mfp->pagesize;
545
540
#endif
546
541
 
547
542
        DB_ASSERT(env, LF_ISSET(BH_FREE_UNLOCKED) ||
616
611
                MVCC_BHUNALIGN(bhp);
617
612
                __memp_free(infop, bhp);
618
613
                c_mp = infop->primary;
619
 
                c_mp->stat.st_pages--;
 
614
                c_mp->pages--;
620
615
 
621
616
                MPOOL_REGION_UNLOCK(env, infop);
622
617
        }
630
625
         */
631
626
        MUTEX_LOCK(env, mfp->mutex);
632
627
        if (--mfp->block_cnt == 0 && mfp->mpf_cnt == 0) {
633
 
                if ((t_ret = __memp_mf_discard(dbmp, mfp)) != 0 && ret == 0)
 
628
                if ((t_ret = __memp_mf_discard(dbmp, mfp, 0)) != 0 && ret == 0)
634
629
                        ret = t_ret;
635
630
        } else
636
631
                MUTEX_UNLOCK(env, mfp->mutex);