[f2fs] code refactoring: Change error return using zx_status_t (checkpoint.cc, f2fs.h, segment.cc, segment.h)
(comment: #24, #106 https://fuchsia-review.googlesource.com/c/third_party/f2fs/+/520882)
Change-Id: I8e58f4cdec05368a260e15754903f0ad335eb1ae
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/f2fs/+/530801
Reviewed-by: Brett Wilson <brettw@google.com>
diff --git a/checkpoint.cc b/checkpoint.cc
index 76806f3..1c45967 100644
--- a/checkpoint.cc
+++ b/checkpoint.cc
@@ -49,8 +49,8 @@
return page;
}
-int F2fs::F2fsWriteMetaPage(Page *page, WritebackControl *wbc) {
- int err;
+zx_status_t F2fs::F2fsWriteMetaPage(Page *page, WritebackControl *wbc) {
+ zx_status_t err;
WaitOnPageWriteback(page);
@@ -151,10 +151,10 @@
// }
#endif
-int F2fs::CheckOrphanSpace() {
+zx_status_t F2fs::CheckOrphanSpace() {
f2fs_sb_info &sbi = SbInfo();
uint32_t max_orphans;
- int err = 0;
+ zx_status_t err = 0;
/*
* considering 512 blocks in a segment 5 blocks are needed for cp
@@ -165,7 +165,7 @@
max_orphans = (sbi.blocks_per_seg - 5) * F2FS_ORPHANS_PER_BLOCK;
mtx_lock(&sbi.orphan_inode_mutex);
if (sbi.n_orphans >= max_orphans)
- err = -ENOSPC;
+ err = ZX_ERR_NO_SPACE;
mtx_unlock(&sbi.orphan_inode_mutex);
return err;
}
diff --git a/f2fs.h b/f2fs.h
index 7b6d9da..713cddd 100644
--- a/f2fs.h
+++ b/f2fs.h
@@ -143,7 +143,7 @@
// checkpoint.cc
Page *GetMetaPage(pgoff_t index);
Page *GrabMetaPage(pgoff_t index);
- int F2fsWriteMetaPage(Page *page, WritebackControl *wbc);
+ zx_status_t F2fsWriteMetaPage(Page *page, WritebackControl *wbc);
#if 0 // porting needed
// int F2fsWriteMetaPages(address_space *mapping, WritebackControl *wbc);
#endif
@@ -151,7 +151,7 @@
#if 0 // porting needed
// int F2fsSetMetaPageDirty(Page *page);
#endif
- int CheckOrphanSpace();
+ zx_status_t CheckOrphanSpace();
void AddOrphanInode(nid_t ino);
void RemoveOrphanInode(nid_t ino);
void RecoverOrphanInode(nid_t ino);
diff --git a/segment.cc b/segment.cc
index 24c346b..97f4905 100644
--- a/segment.cc
+++ b/segment.cc
@@ -6,6 +6,8 @@
#include <sys/stat.h>
#include "f2fs.h"
+#include "zircon/errors.h"
+#include "zircon/types.h"
namespace f2fs {
@@ -1223,14 +1225,14 @@
mtx_unlock(&curseg->curseg_mutex);
}
-int SegMgr::WriteMetaPage(Page *page, struct WritebackControl *wbc) {
+zx_status_t SegMgr::WriteMetaPage(Page *page, struct WritebackControl *wbc) {
#if 0 // porting needed
// if (wbc && wbc->for_reclaim)
// return kAopWritepageActivate;
#endif
SetPageWriteback(page);
SubmitWritePage(page, page->index, META);
- return 0;
+ return ZX_OK;
}
void SegMgr::WriteNodePage(Page *page, unsigned int nid, block_t old_blkaddr,
diff --git a/segment.h b/segment.h
index 39c03bd..a2dbcb5 100644
--- a/segment.h
+++ b/segment.h
@@ -5,6 +5,7 @@
#ifndef F2FS_SEGMENT_H_
#define F2FS_SEGMENT_H_
+#include "zircon/types.h"
namespace f2fs {
/* constant macro */
@@ -315,7 +316,7 @@
int __GetSegmentType(Page *page, enum page_type p_type);
void DoWritePage(Page *page, block_t old_blkaddr, block_t *new_blkaddr, struct f2fs_summary *sum,
enum page_type p_type);
- int WriteMetaPage(Page *page, struct WritebackControl *wbc);
+ zx_status_t WriteMetaPage(Page *page, struct WritebackControl *wbc);
void WriteNodePage(Page *page, unsigned int nid, block_t old_blkaddr, block_t *new_blkaddr);
void WriteDataPage(VnodeF2fs *vnode, Page *page, struct dnode_of_data *dn, block_t old_blkaddr,
block_t *new_blkaddr);