difference between f2fs of linux and fuchsia

137 views
Skip to first unread message

weird wu

unread,
Mar 16, 2022, 12:05:58 PM3/16/22
to aba...@google.com, surajm...@google.com, mlin...@google.com, stora...@fuchsia.dev, wei_...@126.com
I maked an f2fs filesystem using ubuntu tools,and writed a text file,then I mounted it on fuchsia.but i can not read the text file content(binary files can be readed  normaly ).
I'm confusing.Maybe there a incompatible problem. Is there docs describe the difference? 
I know may be it is complicated . Any advice would be appreciated!
Thanks!

Dongjin Kim

unread,
Mar 16, 2022, 10:53:21 PM3/16/22
to storage-dev, weird wu, Suraj Malhotra, Martin Lindsay, stora...@fuchsia.dev, wei_...@126.com, Adam Barth
Hello. Thanks for sharing the issue.
Unfortunately, Fuchsia F2FS is currently under development and some features are not supported.
(The list of features can be found in "Limitations" of "src/storage/f2fs/Readme.md" of Fuchsia source code.)
It depends on the version of Linux F2FS, but if you used the latest version, it seems that it is related to inline data, which is not yet supported by Fuchsia F2FS. The feature will be reflected this month.
For now, it is recommended to disable the feature by adding "noinline_data" in the mount option of Linux F2FS.

2022년 3월 17일 목요일 오전 1시 5분 58초 UTC+9에 weird wu님이 작성:

weird wu

unread,
Mar 23, 2022, 11:52:28 PM3/23/22
to Dongjin Kim, storage-dev, Suraj Malhotra, Martin Lindsay, wei_...@126.com, Adam Barth
Thanks very much for you advise,this way can resolve text file read problem(md5 value of linux f2fs and fuchsia f2fs is same),but md5 value of binary files betwen linux f2fs and fuchsia f2fs is different.
do you have any suggestion?

Dongjin Kim

unread,
Mar 24, 2022, 10:59:13 PM3/24/22
to storage-dev, weird wu, storage-dev, Suraj Malhotra, Martin Lindsay, wei_...@126.com, Adam Barth, Dongjin Kim
Hello.
As described in the readme, Fuchsia F2FS does not support xattr yet. This includes both inline and noinline xattr.
For now, it is recommended to disable the feature by adding "noinline_xattr" as well in the mount option of Linux F2FS.

2022년 3월 24일 목요일 오후 12시 52분 28초 UTC+9에 weird wu님이 작성:

weird wu

unread,
Mar 29, 2022, 7:01:42 AM3/29/22
to Dongjin Kim, storage-dev, Suraj Malhotra, Martin Lindsay, wei_...@126.com, Adam Barth
I use the follow option to mount f2fs(unbntu),and copy some binary files.
mount  -o noinline_xattr -o noinline_data  test.img ./mnt
then mounted test.img on fuchsia and read one of the binary files.I can read more data(zero) than read the same file on linux.

may be there is a bug here.After use the following code,the fault is not reproduced.

can you help me check the code?

git diff src/storage/f2fs/file.cc
diff --git a/src/storage/f2fs/file.cc b/src/storage/f2fs/file.cc
index 74f6f57c8..b81720c49 100644
--- a/src/storage/f2fs/file.cc
+++ b/src/storage/f2fs/file.cc
@@ -324,6 +324,7 @@ zx_status_t File::Read(void *data, size_t len, size_t off, size_t *out_actual) {
   void *data_buf = nullptr;
   size_t left = len;
   uint64_t npages = (GetSize() + kBlockSize - 1) / kBlockSize;
+  size_t act_left = GetSize() - off; //real left

   if (off >= GetSize()) {
     *out_actual = 0;
@@ -344,8 +345,10 @@ zx_status_t File::Read(void *data, size_t len, size_t off, size_t *out_actual) {

     size_t cur_len = std::min(static_cast<size_t>(kBlockSize - off_in_block), left);
     if (n == npages - 1) {
-      if (GetSize() % kBlockSize > 0)
+      if (GetSize() % kBlockSize > 0){
         cur_len = std::min(cur_len, static_cast<size_t>(GetSize() % kBlockSize));
+        cur_len = std::min(cur_len, act_left);
+      }

Dongjin Kim

unread,
Mar 30, 2022, 4:40:36 AM3/30/22
to storage-dev, weird wu, storage-dev, Suraj Malhotra, Martin Lindsay, wei_...@126.com, Adam Barth, Dongjin Kim
It seems that it is a bug.
The initial value of |left| is changed in the below patch, based on your comments.
Would you please try it?

diff --git a/src/storage/f2fs/file.cc b/src/storage/f2fs/file.cc
index e288ed36145..04cc0c97718 100644
--- a/src/storage/f2fs/file.cc
+++ b/src/storage/f2fs/file.cc
@@ -307,7 +307,6 @@ zx_status_t File::Read(void *data, size_t len, size_t off, size_t *out_actual) {
   size_t off_in_block = off % kBlockSize;
   size_t off_in_buf = 0;
   fbl::RefPtr<Page> data_page;
-  size_t left = len;

   uint64_t npages = (GetSize() + kBlockSize - 1) / kBlockSize;

   if (off >= GetSize()) {
@@ -315,6 +314,8 @@ zx_status_t File::Read(void *data, size_t len, size_t off, size_t *out_actual) {
     return ZX_OK;
   }

+  size_t left = std::min(len, GetSize() - off);
+
   for (pgoff_t n = blk_start; n <= blk_end; ++n) {
     bool is_empty_page = false;
     if (zx_status_t ret = GetLockDataPage(n, &data_page); ret != ZX_OK) {


2022년 3월 29일 화요일 오후 8시 1분 42초 UTC+9에 weird wu님이 작성:

weird wu

unread,
Mar 30, 2022, 5:45:48 AM3/30/22
to Dongjin Kim, storage-dev, Suraj Malhotra, Martin Lindsay, wei_...@126.com, Adam Barth
thanks for your patch.
it works fine,i have tried.
Reply all
Reply to author
Forward
0 new messages