GCC Code Coverage Report


Directory: cvmfs/
File: cvmfs/nfs_maps_sqlite.h
Date: 2025-06-22 02:36:02
Exec Total Coverage
Lines: 0 1 0.0%
Branches: 0 0 -%

Line Branch Exec Source
1 /**
2 * This file is part of the CernVM File System.
3 */
4
5 #ifndef CVMFS_NFS_MAPS_SQLITE_H_
6 #define CVMFS_NFS_MAPS_SQLITE_H_
7
8 #include <pthread.h>
9
10 #include <string>
11
12 #include "crypto/hash.h"
13 #include "duplex_sqlite3.h"
14 #include "nfs_maps.h"
15 #include "shortstring.h"
16 #include "util/atomic.h"
17 #include "util/prng.h"
18
19 namespace perf {
20 class Counter;
21 class Statistics;
22 } // namespace perf
23
24 class NfsMapsSqlite : public NfsMaps {
25 public:
26 virtual ~NfsMapsSqlite();
27 virtual uint64_t GetInode(const PathString &path);
28 virtual bool GetPath(const uint64_t inode, PathString *path);
29
30 static NfsMapsSqlite *Create(const std::string &db_dir,
31 const uint64_t root_inode,
32 const bool rebuild,
33 perf::Statistics *statistics_);
34
35 private:
36 static const char *kSqlCreateTable;
37 static const char *kSqlAddRoot;
38 static const char *kSqlAddInode;
39 static const char *kSqlGetInode;
40 static const char *kSqlGetPath;
41
42 struct BusyHandlerInfo {
43 BusyHandlerInfo() : accumulated_ms(0) { prng.InitLocaltime(); }
44
45 static const unsigned kMaxWaitMs = 60000;
46 static const unsigned kMaxBackoffMs = 100;
47 unsigned accumulated_ms;
48 Prng prng;
49 };
50
51 static int BusyHandler(void *data, int attempt);
52
53 NfsMapsSqlite();
54 uint64_t FindInode(const PathString &path);
55 uint64_t IssueInode(const PathString &path);
56 uint64_t RetryGetInode(const PathString &path, int attempt);
57
58 sqlite3 *db_;
59 sqlite3_stmt *stmt_get_path_;
60 sqlite3_stmt *stmt_get_inode_;
61 sqlite3_stmt *stmt_add_;
62 pthread_mutex_t *lock_;
63
64 BusyHandlerInfo busy_handler_info_;
65
66 perf::Counter *n_db_seq_;
67 perf::Counter *n_db_added_;
68 perf::Counter *n_db_path_found_;
69 perf::Counter *n_db_inode_found_;
70 };
71
72 #endif // CVMFS_NFS_MAPS_SQLITE_H_
73