summaryrefslogtreecommitdiff
blob: 6739a2754b63e29ac8bbaa72f97168f90fb674ba (plain)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
From: Christoph Cullmann <cullmann@kde.org>
Date: Sun, 11 Sep 2016 16:54:58 +0000
Subject: Increase size limit of baloo index for 64-bit machines
X-Git-Url: http://quickgit.kde.org/?p=baloo.git&a=commitdiff&h=b0890aca71aa4f0fdabe65ee7b7fbd0bc844d8b8
---
Increase size limit of baloo index for 64-bit machines

CHANGELOG: On 64-bit systems baloo allows now > 5 GB index storage.

Increase size limit of baloo index for 64-bit machines to avoid crashs after > 5GB of index size.
(Better would be additional out-of-space handling, but ATM baloo has zero checks for that)

The size limit for 32-bit is still 1GB, like before (there was a silent overflow from 5GB to 1GB in the computation), people with large homes will still get random segfaults on 32-bit.

Patch based on patch from Hao Zhang, Bug 364475

REVIEW: 128885
BUG: 364475
---


--- a/src/engine/database.cpp
+++ b/src/engine/database.cpp
@@ -93,8 +93,18 @@
         return false;
     }
 
+    /**
+     * maximal number of allowed named databases, must match number of databases we create below
+     * each additional one leads to overhead
+     */
     mdb_env_set_maxdbs(m_env, 12);
-    mdb_env_set_mapsize(m_env, static_cast<size_t>(1024) * 1024 * 1024 * 5); // 5 gb
+
+    /**
+     * size limit for database == size limit of mmap
+     * use 1 GB on 32-bit, use 256 GB on 64-bit
+     */
+    const size_t maximalSizeInBytes = size_t((sizeof(size_t) == 4) ? 1 : 256) * size_t(1024) * size_t(1024) * size_t(1024);
+    mdb_env_set_mapsize(m_env, maximalSizeInBytes);
 
     // The directory needs to be created before opening the environment
     QByteArray arr = QFile::encodeName(indexInfo.absoluteFilePath());

--- a/src/engine/databasesize.h
+++ b/src/engine/databasesize.h
@@ -31,30 +31,30 @@
      * This is the size which is computed with all the pages used from all the
      * individual database pages
      */
-    uint expectedSize;
+    size_t expectedSize;
 
     /**
      * This is the size based on the MDB_env and the total number of pages used
      */
-    uint actualSize;
+    size_t actualSize;
 
-    uint postingDb;
-    uint positionDb;
+    size_t postingDb;
+    size_t positionDb;
 
-    uint docTerms;
-    uint docFilenameTerms;
-    uint docXattrTerms;
+    size_t docTerms;
+    size_t docFilenameTerms;
+    size_t docXattrTerms;
 
-    uint idTree;
-    uint idFilename;
+    size_t idTree;
+    size_t idFilename;
 
-    uint docTime;
-    uint docData;
+    size_t docTime;
+    size_t docData;
 
-    uint contentIndexingIds;
-    uint failedIds;
+    size_t contentIndexingIds;
+    size_t failedIds;
 
-    uint mtimeDb;
+    size_t mtimeDb;
 };
 
 }

--- a/src/engine/transaction.cpp
+++ b/src/engine/transaction.cpp
@@ -402,7 +402,7 @@
 //
 // File Size
 //
-static uint dbiSize(MDB_txn* txn, MDB_dbi dbi)
+static size_t dbiSize(MDB_txn* txn, MDB_dbi dbi)
 {
     MDB_stat stat;
     mdb_stat(txn, dbi, &stat);

--- a/src/tools/balooctl/statuscommand.cpp
+++ b/src/tools/balooctl/statuscommand.cpp
@@ -92,8 +92,8 @@
 
         const QString path = fileIndexDbPath();
 
-        QFileInfo indexInfo(path + QLatin1String("/index"));
-        quint32 size = indexInfo.size();
+        const QFileInfo indexInfo(path + QLatin1String("/index"));
+        const auto size = indexInfo.size();
         KFormat format(QLocale::system());
         if (size) {
             out << "Current size of index is " << format.formatByteSize(size, 2) << endl;