Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Avoid extending the database file when truncating it to the minimum number of blocks required during system shutdown.
Downloads: Tarball | ZIP archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9afc42d70d50444a43e5e1c87a9ad307e6f7617d
User & Date: dan 2013-02-08 15:22:56.537
Context
2013-02-09
16:55
Have worker clients and writers that discard an old in-memory tree update a read-lock slot before concluding their work or write transaction. This is required for read-only clients - which cannot set the value of their own read-lock slot. check-in: 798d9e23be user: dan tags: trunk
05:27
Make LARGEST_UINT64 unsigned. This was causing adjustExponent to fail when compiled with msvc. check-in: 9ff6991d9f user: peterreid tags: num_work
2013-02-08
15:22
Avoid extending the database file when truncating it to the minimum number of blocks required during system shutdown. check-in: 9afc42d70d user: dan tags: trunk
14:39
Changes to lsm_unix.c to build on android: (a) do not use fdatasync() on android and (b) account for the fact that usleep() returns void on android. check-in: 302b222395 user: dan tags: trunk
Changes
Side-by-Side Diff Show Whitespace Changes Patch
Changes to src/lsm_file.c.
549
550
551
552
553
554
555

556
557
558
559
560
561
562
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563







+








/*
** Configure the file-system object according to the current values of
** the LSM_CONFIG_MMAP and LSM_CONFIG_SET_COMPRESSION options.
*/
int lsmFsConfigure(lsm_db *db){
  FileSystem *pFS = db->pFS;
  if( pFS ){
  lsm_env *pEnv = pFS->pEnv;
  Page *pPg;

  assert( pFS->nOut==0 );
  assert( pFS->pWaiting==0 );

  /* Reset any compression/decompression buffers already allocated */
589
590
591
592
593
594
595

596
597
598
599
600
601
602
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604







+







  if( db->compress.xCompress ){
    pFS->pCompress = &db->compress;
    pFS->bUseMmap = 0;
  }else{
    pFS->pCompress = 0;
    pFS->bUseMmap = db->bMmap;
  }
  }

  return LSM_OK;
}

/*
** Close and destroy a FileSystem object.
*/
Changes to src/lsm_main.c.
293
294
295
296
297
298
299
300
301



302
303
304
305
306
307
308
293
294
295
296
297
298
299


300
301
302
303
304
305
306
307
308
309







-
-
+
+
+







      }
      *piVal = pDb->eSafety;
      break;
    }

    case LSM_CONFIG_MMAP: {
      int *piVal = va_arg(ap, int *);
      if( pDb->pDatabase==0 ){
        pDb->bMmap = (LSM_IS_64_BIT && *piVal);
      if( pDb->iReader<0 && *piVal>=0 && *piVal<=1 ){
        pDb->bMmap = *piVal;
        rc = lsmFsConfigure(pDb);
      }
      *piVal = pDb->bMmap;
      break;
    }

    case LSM_CONFIG_USE_LOG: {
      int *piVal = va_arg(ap, int *);
Changes to src/lsm_unix.c.
119
120
121
122
123
124
125

126

127
128

129


130

131
132
133
134
135
136
137
119
120
121
122
123
124
125
126

127
128

129
130
131
132
133
134
135
136
137
138
139
140
141







+
-
+

-
+

+
+

+







  return rc;
}

static int lsmPosixOsTruncate(
  lsm_file *pFile,                /* File to write to */
  lsm_i64 nSize                   /* Size to truncate file to */
){
  PosixFile *p = (PosixFile *)pFile;
  int rc = LSM_OK;
  int rc = LSM_OK;                /* Return code */
  int prc;                        /* Posix Return Code */
  PosixFile *p = (PosixFile *)pFile;
  struct stat sStat;              /* Result of fstat() invocation */

  prc = fstat(p->fd, &sStat);
  if( prc==0 && sStat.st_size>nSize ){
  prc = ftruncate(p->fd, (off_t)nSize);
  }
  if( prc<0 ) rc = lsm_ioerr();

  return rc;
}

static int lsmPosixOsRead(
  lsm_file *pFile,                /* File to read from */
Changes to test/lsm4.test.
1
2
3
4
5
6
7
8
9
10




11
12
13
14
15
16
17
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21










+
+
+
+







# 2013 February 06
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# The focus of this file is testing the LSM library. More specifically,
# it focuses on testing the compression, compression-id and
# compression-factory functionality.
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix lsm4
db close

Added test/lsm5.test.










































1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
# 2013 February 08
#
# The author disclaims copyright to this source code.  In place of
# a legal notice, here is a blessing:
#
#    May you do good and not evil.
#    May you find forgiveness for yourself and forgive others.
#    May you share freely, never taking more than you give.
#
#***********************************************************************
#
# The focus of this file is testing the LSM library. 
#

set testdir [file dirname $argv0]
source $testdir/tester.tcl
set testprefix lsm5
db close

#-------------------------------------------------------------------------
# When the database system is shut down (i.e. when the last connection
# disconnects), an attempt is made to truncate the database file to the
# minimum number of blocks required.
# 
# This test case checks that this process does not actually cause the
# database to grow.
# 
do_test 1.1 {
  lsm_open db test.db
  db config {mmap 0}
} {0}
do_test 1.2 {
  db write 1 one
  db write 2 two
  db close
} {}
do_test 1.3 {
  expr [file size test.db] < (64*1024)
} 1

finish_test

Changes to www/lsmusr.wiki.
1013
1014
1015
1016
1017
1018
1019

1020

1021
1022
1023
1024
1025
1026
1027
1028
1013
1014
1015
1016
1017
1018
1019
1020

1021

1022
1023
1024
1025
1026
1027
1028







+
-
+
-







    always set to 0.
    <p> If it is set to true, the entire database file is memory mapped. Or, if
    it is false, data is accessed using ordinary OS file read and write
    primitives. Memory mapping the database file can significantly improve the
    performance of read operations, as database pages do not have to be copied
    from operating system buffers into user space buffers before they can be
    examined. 
    <p>This option may not be set if there is a read or write transaction
    <p>This option can only be set before lsm_open() is called on the database
    open on the database.
    connection.
    <p>The default value is 1 (true) on a 64-bit platform, and 0 otherwise.

  <dt> <a href=lsmapi.wiki#LSM_CONFIG_MULTIPLE_PROCESSES>LSM_CONFIG_MULTIPLE_PROCESSES</a>
  <dd> <p style=margin-top:0>
    This option may also be set to either 1 (true) or 0 (false).  The default
    value is 1 (true). If it is set to false, then the library assumes that all
    database clients are located within the same process (have access to the