Skip to content

Commit 39013e0

Browse files
authored
Merge pull request #218 from liulanzheng/main
update photon to v0.6.1 and fix zfile open
2 parents 86c2505 + 799d835 commit 39013e0

File tree

10 files changed

+18
-109
lines changed

10 files changed

+18
-109
lines changed

.github/workflows/release/build.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ if [[ ${OS} =~ "ubuntu" ]]; then
2929
export DEBIAN_FRONTEND="noninteractive"
3030
export TZ="Etc/UTC"
3131
apt-get update -y
32-
apt-get install -y libgflags-dev libcurl4-openssl-dev libssl-dev libaio-dev libnl-3-dev libnl-genl-3-dev rpm wget make g++ git dpkg-dev sudo
32+
apt-get install -y libgflags-dev libcurl4-openssl-dev libssl-dev libaio-dev libnl-3-dev libnl-genl-3-dev rpm wget make g++ git dpkg-dev sudo pkg-config
3333
apt-get install -y uuid-dev libjson-c-dev libkmod-dev libsystemd-dev autoconf automake libtool libpci-dev nasm libzstd-dev libext2fs-dev zlib1g-dev
3434

3535
DISTRO=${OS/:/1~}

CMake/Findphoton.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ set(FETCHCONTENT_QUIET false)
44
FetchContent_Declare(
55
photon
66
GIT_REPOSITORY https://github.com/alibaba/PhotonLibOS.git
7-
GIT_TAG v0.5.7
7+
GIT_TAG v0.6.1
88
)
99

1010
if(BUILD_TESTING)

src/overlaybd/cache/download_cache/download_cache.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
#include <photon/thread/thread.h>
2828
#include <photon/common/io-alloc.h>
2929
#include <photon/common/expirecontainer.h>
30-
#include "thread_range_lock.h"
30+
#include <photon/common/range-lock.h>
3131

3232
#define SET_LOCAL_DIR 118
3333
#define SET_SIZE 119
@@ -50,7 +50,7 @@ class DownloadCacheStore : public ForwardFile_Ownership {
5050
using ForwardFile_Ownership::pwritev;
5151

5252
int fallocate(int mode, off_t offset, off_t len) override {
53-
ThreadScopedRangeLock lock(m_range_lock, offset, len);
53+
ScopedRangeLock lock(m_range_lock, offset, len);
5454
return m_file->fallocate(mode, offset, len);
5555
}
5656
int ftruncate(off_t length) override {
@@ -64,14 +64,14 @@ class DownloadCacheStore : public ForwardFile_Ownership {
6464
return m_range_lock.try_lock_wait(offset, length);
6565
}
6666
void lock(uint64_t offset, uint64_t length) {
67-
return m_range_lock.lock(offset, length);
67+
m_range_lock.lock(offset, length);
6868
}
6969
void unlock(uint64_t offset, uint64_t length) {
7070
m_range_lock.unlock(offset, length);
7171
}
7272

7373
private:
74-
ThreadRangeLock m_range_lock;
74+
RangeLock m_range_lock;
7575
DownloadCacheFs *m_fs;
7676
};
7777

src/overlaybd/cache/download_cache/thread_range_lock.h

Lines changed: 0 additions & 94 deletions
This file was deleted.

src/overlaybd/cache/full_file_cache/cache_store.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,7 @@ int FileCacheStore::evict(off_t offset, size_t count) {
161161
#ifndef FALLOC_FL_PUNCH_HOLE
162162
#define FALLOC_FL_PUNCH_HOLE 0x02 /* de-allocates range */
163163
#endif
164+
ScopedRangeLock lock(rangeLock_, offset, count);
164165
int mode = FALLOC_FL_PUNCH_HOLE | FALLOC_FL_KEEP_SIZE;
165166
return localFile_->fallocate(mode, offset, count);
166167
}

src/overlaybd/cache/ocf_cache/ocf_namespace.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ class OcfNamespaceOnFs : public OcfNamespace {
142142
.info = info,
143143
};
144144

145-
auto tmp_file_path = file_path + ".tmp";
145+
auto tmp_file_path = estring().appends(file_path, ".tmp");
146146
{
147147
auto tmp_file = m_fs->open(tmp_file_path.c_str(), O_WRONLY | O_TRUNC | O_CREAT, 0644);
148148
if (tmp_file == nullptr) {

src/overlaybd/cache/ocf_cache/test/ocf_perf_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ static int single_file_file_cache(IOAlloc *io_alloc, photon::fs::IFileSystem *sr
232232

233233
estring filename = FLAGS_src_file;
234234
if (!filename.starts_with("/")) {
235-
filename = "/" + filename;
235+
filename = estring().appends("/", filename);
236236
}
237237

238238
auto file = cached_fs->open(filename.c_str(), O_RDONLY, 0644);

src/overlaybd/registryfs/registryfs.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class RegistryFSImpl : public RegistryFS {
127127
//use p2p proxy
128128
estring accelerate_url;
129129
if (m_accelerate.size() > 0) {
130-
accelerate_url = m_accelerate + "/" + actual_url;
130+
accelerate_url = estring().appends(m_accelerate, "/", estring(actual_url));
131131
actual_url = accelerate_url.data();
132132
LOG_DEBUG("p2p_url: `", actual_url);
133133
}
@@ -365,8 +365,8 @@ class RegistryFSImpl : public RegistryFS {
365365
challengeLine);
366366
}
367367
*scope = estring(kv["scope"]);
368-
*auth_url = estring(kv["realm"]) + "?service=" + estring(kv["service"]) +
369-
"&scope=" + estring(kv["scope"]);
368+
*auth_url = estring().appends(kv["realm"], "?service=", kv["service"],
369+
"&scope=", kv["scope"]);
370370
return true;
371371
}
372372
}; // namespace FileSystem
@@ -520,4 +520,3 @@ IFileSystem *new_registryfs_v1(PasswordCB callback, const char *caFile,
520520
LOG_ERROR_RETURN(EINVAL, nullptr, "password callback not set");
521521
return new RegistryFSImpl(callback, caFile ? caFile : "", timeout);
522522
}
523-

src/overlaybd/registryfs/registryfs_v2.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ class RegistryFSImpl_v2 : public RegistryFS {
130130
//use p2p proxy
131131
estring accelerate_url;
132132
if(m_accelerate.size() > 0) {
133-
accelerate_url = m_accelerate + "/" + *actual_url;
133+
accelerate_url = estring().appends(m_accelerate, "/", *actual_url);
134134
actual_url = &accelerate_url;
135135
LOG_DEBUG("p2p_url: `", *actual_url);
136136
}
@@ -280,8 +280,8 @@ class RegistryFSImpl_v2 : public RegistryFS {
280280
challengeLine);
281281
}
282282
*scope = estring(kv["scope"]);
283-
*authurl = estring(kv["realm"]) + "?service=" + estring(kv["service"]) +
284-
"&scope=" + estring(kv["scope"]);
283+
*authurl = estring().appends(kv["realm"], "?service=", kv["service"],
284+
"&scope=", kv["scope"]);
285285
return 0;
286286
}
287287

src/overlaybd/zfile/zfile.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,9 @@ bool load_jump_table(IFile *file, CompressionFile::HeaderTrailer *pheader_traile
678678
auto ibuf = std::unique_ptr<uint32_t[]>(new uint32_t[pht->index_size]);
679679
LOG_DEBUG("index_offset: `", pht->index_offset);
680680
ret = file->pread((void *)(ibuf.get()), index_bytes, pht->index_offset);
681+
if (ret < index_bytes) {
682+
LOG_ERRNO_RETURN(0, false, "failed to read index");
683+
}
681684
jump_table.build(ibuf.get(), pht->index_size,
682685
CompressionFile::HeaderTrailer::SPACE + pht->opt.dict_size,
683686
pht->opt.block_size);

0 commit comments

Comments
 (0)