[f2fs] Moves the HEAD of main fuchsia to the commit of
change-Id Iffeb8c803893e5bcd49314a4c714020c1bdee439
It makes modifications to rebase on the HEAD.
Change-Id: I998c7b1198f7f32ba8ff4f39a50e451107df5d5c
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/f2fs/+/536501
Reviewed-by: Brett Wilson <brettw@google.com>
diff --git a/bcache.cc b/bcache.cc
index 5f2a86b..853a5b0 100644
--- a/bcache.cc
+++ b/bcache.cc
@@ -82,10 +82,9 @@
return status;
}
fdio_cpp::UnownedFdioCaller caller(fd.get());
- status =
- ::fuchsia_io::Node::Call::Clone(zx::unowned_channel(caller.borrow_channel()),
- ::fuchsia_io::wire::CLONE_FLAG_SAME_RIGHTS, std::move(server))
- .status();
+ status = fidl::WireCall<fuchsia_io::Node>(zx::unowned_channel(caller.borrow_channel()))
+ .Clone(fuchsia_io::wire::kCloneFlagSameRights, std::move(server))
+ .status();
if (status != ZX_OK) {
return status;
}
diff --git a/data.cc b/data.cc
index c0c0d5d..7c70972 100644
--- a/data.cc
+++ b/data.cc
@@ -669,15 +669,6 @@
if ((len == kPageCacheSize) || PageUptodate(*pagep))
return ZX_OK;
- if ((static_cast<loff_t>(pos) & kPageCacheMask) >= i_size_) {
- unsigned start = pos & (kPageCacheSize - 1);
- unsigned end = start + len;
-
- /* Reading beyond i_size is simple: memset to zero */
- ZeroUserSegments(*pagep, 0, start, end, kPageCacheSize);
- return ZX_OK;
- }
-
if (dn.data_blkaddr == kNewAddr) {
ZeroUserSegment(*pagep, 0, kPageCacheSize);
} else {
diff --git a/dir.cc b/dir.cc
index 9f35f45..ac49e8a 100644
--- a/dir.cc
+++ b/dir.cc
@@ -95,7 +95,7 @@
return de;
}
-DirEntry *Dir::FindInLevel(unsigned int level, fbl::StringPiece name, int namelen,
+DirEntry *Dir::FindInLevel(unsigned int level, std::string_view name, int namelen,
f2fs_hash_t namehash, Page **res_page) {
int s = (namelen + kNameLen - 1) / kNameLen;
unsigned int nbucket, nblock;
@@ -143,7 +143,7 @@
* and the entry itself. Page is returned mapped and unlocked.
* Entry is guaranteed to be valid.
*/
-DirEntry *Dir::FindEntry(fbl::StringPiece name, Page **res_page) {
+DirEntry *Dir::FindEntry(std::string_view name, Page **res_page) {
uint64_t npages = DirBlocks();
DirEntry *de = nullptr;
f2fs_hash_t name_hash;
@@ -189,7 +189,7 @@
return de;
}
-ino_t Dir::InodeByName(fbl::StringPiece name) {
+ino_t Dir::InodeByName(std::string_view name) {
ino_t res = 0;
DirEntry *de;
Page *page;
@@ -342,7 +342,7 @@
}
}
-zx_status_t Dir::AddLink(fbl::StringPiece name, VnodeF2fs *vnode) {
+zx_status_t Dir::AddLink(std::string_view name, VnodeF2fs *vnode) {
unsigned int bit_pos;
unsigned int level;
unsigned int current_depth;
@@ -640,7 +640,7 @@
if (types && de->file_type < static_cast<uint8_t>(FileType::kFtMax))
d_type = types[de->file_type];
- fbl::StringPiece name(reinterpret_cast<char *>(dentry_blk->filename[bit_pos]),
+ std::string_view name(reinterpret_cast<char *>(dentry_blk->filename[bit_pos]),
LeToCpu(de->name_len));
if ((ret = df.Next(name, d_type, LeToCpu(de->ino))) != ZX_OK) {
diff --git a/dir.h b/dir.h
index c6fe2fb..0d66888 100644
--- a/dir.h
+++ b/dir.h
@@ -39,13 +39,13 @@
explicit Dir(F2fs *fs, ino_t ino);
~Dir() = default;
- zx_status_t Lookup(fbl::StringPiece name, fbl::RefPtr<fs::Vnode> *out) final;
+ zx_status_t Lookup(std::string_view name, fbl::RefPtr<fs::Vnode> *out) final;
zx_status_t Readdir(fs::VdirCookie *cookie, void *dirents, size_t len, size_t *out_actual) final;
- zx_status_t Create(fbl::StringPiece name, uint32_t mode, fbl::RefPtr<fs::Vnode> *out) final;
- zx_status_t Link(fbl::StringPiece name, fbl::RefPtr<fs::Vnode> _target) final;
- zx_status_t Unlink(fbl::StringPiece name, bool must_be_dir) final;
- zx_status_t Rename(fbl::RefPtr<fs::Vnode> _newdir, fbl::StringPiece oldname,
- fbl::StringPiece newname, bool src_must_be_dir, bool dst_must_be_dir);
+ zx_status_t Create(std::string_view name, uint32_t mode, fbl::RefPtr<fs::Vnode> *out) final;
+ zx_status_t Link(std::string_view name, fbl::RefPtr<fs::Vnode> _target) final;
+ zx_status_t Unlink(std::string_view name, bool must_be_dir) final;
+ zx_status_t Rename(fbl::RefPtr<fs::Vnode> _newdir, std::string_view oldname,
+ std::string_view newname, bool src_must_be_dir, bool dst_must_be_dir);
uint64_t DirBlocks();
static unsigned int DirBuckets(unsigned int level);
@@ -55,11 +55,11 @@
bool EarlyMatchName(const char *name, int namelen, f2fs_hash_t namehash, DirEntry *de);
DirEntry *FindInBlock(Page *dentry_page, const char *name, int namelen, int *max_slots,
f2fs_hash_t namehash, Page **res_page);
- DirEntry *FindInLevel(unsigned int level, fbl::StringPiece name, int namelen,
+ DirEntry *FindInLevel(unsigned int level, std::string_view name, int namelen,
f2fs_hash_t namehash, Page **res_page);
- DirEntry *FindEntry(fbl::StringPiece name, Page **res_page);
+ DirEntry *FindEntry(std::string_view name, Page **res_page);
DirEntry *ParentDir(Page **p);
- ino_t InodeByName(fbl::StringPiece name);
+ ino_t InodeByName(std::string_view name);
void SetLink(DirEntry *de, Page *page, VnodeF2fs *inode);
void InitDentInode(VnodeF2fs *vnode, Page *ipage);
#if 0 // porting needed
@@ -69,7 +69,7 @@
#endif
void UpdateParentMetadata(VnodeF2fs *inode, unsigned int current_depth);
int RoomForFilename(DentryBlock *dentry_blk, int slots);
- zx_status_t AddLink(fbl::StringPiece name, VnodeF2fs *vnode);
+ zx_status_t AddLink(std::string_view name, VnodeF2fs *vnode);
void DeleteEntry(DirEntry *dentry, Page *page, VnodeF2fs *vnode);
zx_status_t MakeEmpty(VnodeF2fs *vnode, VnodeF2fs *parent);
bool IsEmptyDir();
@@ -77,21 +77,21 @@
zx_status_t NewInode(uint32_t mode, fbl::RefPtr<VnodeF2fs> *out);
int IsMultimediaFile(const char *s, const char *sub);
void SetColdFile(const char *name);
- zx_status_t DoCreate(fbl::StringPiece name, uint32_t mode, fbl::RefPtr<fs::Vnode> *out);
+ zx_status_t DoCreate(std::string_view name, uint32_t mode, fbl::RefPtr<fs::Vnode> *out);
#if 0 // porting needed
// int F2fsLink(dentry *old_dentry, dentry *dentry);
// dentry *F2fsGetParent(dentry *child);
#endif
- zx_status_t DoUnlink(VnodeF2fs *vnode, fbl::StringPiece name);
+ zx_status_t DoUnlink(VnodeF2fs *vnode, std::string_view name);
#if 0 // porting needed
// int F2fsSymlink(dentry *dentry, const char *symname);
#endif
- zx_status_t Mkdir(fbl::StringPiece name, uint32_t mode, fbl::RefPtr<fs::Vnode> *out);
- zx_status_t Rmdir(Dir *vnode, fbl::StringPiece name);
+ zx_status_t Mkdir(std::string_view name, uint32_t mode, fbl::RefPtr<fs::Vnode> *out);
+ zx_status_t Rmdir(Dir *vnode, std::string_view name);
#if 0 // porting needed
// int F2fsMknod(dentry *dentry, umode_t mode, dev_t rdev);
#endif
- zx_status_t DoLookup(fbl::StringPiece name, fbl::RefPtr<fs::Vnode> *out);
+ zx_status_t DoLookup(std::string_view name, fbl::RefPtr<fs::Vnode> *out);
};
} // namespace f2fs
diff --git a/f2fs.h b/f2fs.h
index 6259989..d3ffa4f 100644
--- a/f2fs.h
+++ b/f2fs.h
@@ -189,7 +189,7 @@
private:
using HashTable = fbl::HashTable<ino_t, VnodeF2fs *>;
fbl::Mutex vnode_table_lock_;
- HashTable vnode_table_ FS_TA_GUARDED(vnode_table_lock_){};
+ HashTable vnode_table_ __TA_GUARDED(vnode_table_lock_){};
fbl::RefPtr<VnodeF2fs> root_vnode_;
diff --git a/f2fs_types.h b/f2fs_types.h
index 02b2092..a24be4c 100644
--- a/f2fs_types.h
+++ b/f2fs_types.h
@@ -51,7 +51,6 @@
constexpr size_t kBitsPerByte = 8;
constexpr size_t kPageCacheShift = 12;
constexpr size_t kF2fsSuperMagic = 0xF2F52010;
-constexpr size_t kPageCacheMask = (kPageSize - 1);
constexpr size_t kCrcPolyLe = 0xedb88320;
constexpr size_t kAopWritepageActivate = 0x80000;
diff --git a/file.cc b/file.cc
index e17f251..61f5b54 100644
--- a/file.cc
+++ b/file.cc
@@ -448,7 +448,8 @@
}
data_buf = PageAddress(data_page);
- memcpy(static_cast<char *>(data) + off_in_buf, data_buf, cur_len);
+ memcpy(static_cast<char *>(data) + off_in_buf, static_cast<char *>(data_buf) + off_in_block,
+ cur_len);
off_in_buf += cur_len;
left -= cur_len;
diff --git a/namei.cc b/namei.cc
index 42e9281..74d9b81 100644
--- a/namei.cc
+++ b/namei.cc
@@ -92,7 +92,7 @@
}
}
-zx_status_t Dir::DoCreate(fbl::StringPiece name, uint32_t mode, fbl::RefPtr<fs::Vnode> *out) {
+zx_status_t Dir::DoCreate(std::string_view name, uint32_t mode, fbl::RefPtr<fs::Vnode> *out) {
SbInfo &sbi = Vfs()->GetSbInfo();
fbl::RefPtr<VnodeF2fs> vnode_refptr;
VnodeF2fs *vnode = nullptr;
@@ -129,7 +129,7 @@
return ZX_OK;
}
-zx_status_t Dir::Link(fbl::StringPiece name, fbl::RefPtr<fs::Vnode> _target) {
+zx_status_t Dir::Link(std::string_view name, fbl::RefPtr<fs::Vnode> _target) {
VnodeF2fs *target = static_cast<VnodeF2fs *>(_target.get());
auto cur_time = time(nullptr);
@@ -170,7 +170,7 @@
// }
#endif
-zx_status_t Dir::DoLookup(fbl::StringPiece name, fbl::RefPtr<fs::Vnode> *out) {
+zx_status_t Dir::DoLookup(std::string_view name, fbl::RefPtr<fs::Vnode> *out) {
fbl::RefPtr<VnodeF2fs> vn;
DirEntry *de;
Page *page;
@@ -197,12 +197,12 @@
return ZX_ERR_NOT_FOUND;
}
-zx_status_t Dir::Lookup(fbl::StringPiece name, fbl::RefPtr<fs::Vnode> *out) {
+zx_status_t Dir::Lookup(std::string_view name, fbl::RefPtr<fs::Vnode> *out) {
fbl::AutoLock lock(&i_mutex_);
return DoLookup(name, out);
}
-zx_status_t Dir::DoUnlink(VnodeF2fs *vnode, fbl::StringPiece name) {
+zx_status_t Dir::DoUnlink(VnodeF2fs *vnode, std::string_view name) {
DirEntry *de;
Page *page;
@@ -265,7 +265,7 @@
// }
#endif
-zx_status_t Dir::Mkdir(fbl::StringPiece name, uint32_t mode, fbl::RefPtr<fs::Vnode> *out) {
+zx_status_t Dir::Mkdir(std::string_view name, uint32_t mode, fbl::RefPtr<fs::Vnode> *out) {
fbl::RefPtr<VnodeF2fs> vnode_refptr;
VnodeF2fs *vnode = nullptr;
@@ -302,7 +302,7 @@
return ZX_OK;
}
-zx_status_t Dir::Rmdir(Dir *vnode, fbl::StringPiece name) {
+zx_status_t Dir::Rmdir(Dir *vnode, std::string_view name) {
if (vnode->IsEmptyDir())
return DoUnlink(vnode, name);
return ZX_ERR_NOT_EMPTY;
@@ -345,8 +345,8 @@
// }
#endif
-zx_status_t Dir::Rename(fbl::RefPtr<fs::Vnode> _newdir, fbl::StringPiece oldname,
- fbl::StringPiece newname, bool src_must_be_dir, bool dst_must_be_dir) {
+zx_status_t Dir::Rename(fbl::RefPtr<fs::Vnode> _newdir, std::string_view oldname,
+ std::string_view newname, bool src_must_be_dir, bool dst_must_be_dir) {
SbInfo &sbi = Vfs()->GetSbInfo();
fbl::RefPtr<VnodeF2fs> old_vn_ref;
fbl::RefPtr<VnodeF2fs> new_vn_ref;
@@ -502,7 +502,7 @@
return ZX_OK;
}
-zx_status_t Dir::Create(fbl::StringPiece name, uint32_t mode, fbl::RefPtr<fs::Vnode> *out) {
+zx_status_t Dir::Create(std::string_view name, uint32_t mode, fbl::RefPtr<fs::Vnode> *out) {
Page *page;
fbl::AutoLock lock(&i_mutex_);
@@ -516,7 +516,7 @@
return DoCreate(name, mode, out);
}
-zx_status_t Dir::Unlink(fbl::StringPiece name, bool must_be_dir) {
+zx_status_t Dir::Unlink(std::string_view name, bool must_be_dir) {
fbl::RefPtr<fs::Vnode> vn;
fbl::AutoLock lock(&i_mutex_);
diff --git a/tools/BUILD.gn b/tools/BUILD.gn
index af8a479..69d7580 100644
--- a/tools/BUILD.gn
+++ b/tools/BUILD.gn
@@ -6,7 +6,7 @@
# is located at `//tools/create/templates/component-v2/BUILD.gn.tmpl-cpp`.
# If you find something broken, we are eager to review fixes.
-import("//src/sys/build/components.gni")
+import("//build/components.gni")
group("f2fs-tools") {
deps = [ ":package" ]
diff --git a/vnode.cc b/vnode.cc
index 8388a96..fb99172 100644
--- a/vnode.cc
+++ b/vnode.cc
@@ -124,7 +124,7 @@
RwlockInit(&vnode->fi_.ext.ext_lock);
GetExtentInfo(&vnode->fi_.ext, ri->i_ext);
- fbl::StringPiece name(reinterpret_cast<char *>(ri->i_name), ri->i_namelen);
+ std::string_view name(reinterpret_cast<char *>(ri->i_name), ri->i_namelen);
vnode->i_name_sp_ = name;
F2fsPutPage(node_page, 1);
@@ -547,7 +547,7 @@
}
}
-zx_status_t VnodeF2fs::QueryFilesystem(::fuchsia_io::wire::FilesystemInfo *info) {
+zx_status_t VnodeF2fs::QueryFilesystem(fuchsia_io::wire::FilesystemInfo *info) {
SbInfo &sbi = Vfs()->GetSbInfo();
*info = {};
info->block_size = kBlockSize;
@@ -560,9 +560,9 @@
info->used_nodes = sbi.total_valid_inode_count;
constexpr std::string_view kFsName = "f2fs";
- static_assert(kFsName.size() + 1 < ::fuchsia_io::wire::MAX_FS_NAME_BUFFER, "F2fs name too long");
+ static_assert(kFsName.size() + 1 < fuchsia_io::wire::kMaxFsNameBuffer, "f2fs name too long");
info->name[kFsName.copy(reinterpret_cast<char *>(info->name.data()),
- ::fuchsia_io::wire::MAX_FS_NAME_BUFFER - 1)] = '\0';
+ fuchsia_io::wire::kMaxFsNameBuffer - 1)] = '\0';
// TODO(unknown): Fill info->free_shared_pool_bytes using fvm info
diff --git a/vnode.h b/vnode.h
index 2e29ce1..7cd5d09 100644
--- a/vnode.h
+++ b/vnode.h
@@ -26,12 +26,12 @@
static size_t GetHash(ino_t key) { return fnv1a_tiny(key, kHashBits); }
using fs::Vnode::Open;
- zx_status_t Open(ValidatedOptions options, fbl::RefPtr<Vnode> *out_redirect) final;
- zx_status_t Close() final;
+ zx_status_t Open(ValidatedOptions options, fbl::RefPtr<Vnode> *out_redirect);
+ zx_status_t Close();
void Sync(SyncCallback closure) final;
- zx_status_t QueryFilesystem(::fuchsia_io::wire::FilesystemInfo *info) final;
+ zx_status_t QueryFilesystem(fuchsia_io::wire::FilesystemInfo *info) final;
void fbl_recycle() override;
@@ -132,7 +132,7 @@
uint64_t i_state_;
- fbl::StringPiece i_name_sp_;
+ std::string_view i_name_sp_;
InodeInfo fi_;