forked from facebookarchive/nfusr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NfsCachedClient.h
66 lines (62 loc) · 1.74 KB
/
NfsCachedClient.h
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
/**
* Copyright (c) 2016-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#pragma once
#include "NfsClient.h"
#include <unistd.h>
#define CACHEBLOCKSIZE 1024
struct CacheBlock;
class NfsCachedClient : public NfsClient {
public:
NfsCachedClient(
std::vector<std::string>& urls,
const char* hostscript,
const int script_refresh_seconds,
size_t targetConnections,
int nfsTimeout,
std::shared_ptr<nfusr::Logger> logger,
std::shared_ptr<ClientStats> stats,
bool errorInjection,
NfsClientPermissionMode permMode)
: NfsClient(
urls,
hostscript,
script_refresh_seconds,
targetConnections,
nfsTimeout,
logger,
stats,
errorInjection,
permMode) {}
~NfsCachedClient() override;
void replyEntry(
RpcContext* ctx,
const nfs_fh3* fh,
const struct fattr3* attr,
const struct fuse_file_info* file,
std::shared_ptr<std::string> local_cache_path,
const char* caller,
fuse_ino_t parent,
const char* name) override;
void read(
fuse_req_t req,
fuse_ino_t inode,
size_t size,
off_t off,
struct fuse_file_info* file) override;
std::unique_ptr<CacheBlock> readCache(
std::shared_ptr<std::string> data_fname,
size_t size,
off_t offset);
void writeCache(
std::shared_ptr<std::string> data_fname,
size_t size,
off_t offset,
const char* data,
u_int data_len);
};