Project

General

Profile

Actions

Tasks #72143

closed

Tasks #63293: Implement fscrypt in libcephfs and cephfs-fuse

cthon tests fail with client_oc off

Added by Christopher Hoffman 8 months ago. Updated 8 months ago.

Status:
Resolved
Priority:
Normal
Category:
-
Target version:
-
% Done:

0%

Reviewed:
Affected Versions:
Component(FS):
Labels (FS):
Pull request ID:
Tags (freeform):
Merge Commit:
Fixed In:
Released In:
Upkeep Timestamp:

Description

$ sh ./runtests  -a -t /mnt/mycephfs/enc1/jul15-tests

Starting BASIC tests: test directory /mnt/mycephfs/enc1/jul15-tests (arg: -t)

./test1: File and directory creation test
        created 155 files 62 directories 5 levels deep in 0.81 seconds
        ./test1 ok.

./test2: File and directory removal test
        removed 155 files 62 directories 5 levels deep in 1.2  seconds
        ./test2 ok.

./test3: lookups across mount point
        500 getcwd and stat calls in 0.34 seconds
        ./test3 ok.

./test4: setattr, getattr, and lookup
        1000 chmods and stats on 10 files in 1.93 seconds
        ./test4 ok.

./test5: read and write
        wrote 1048576 byte file 10 times in 10.5  seconds (1042677 bytes/sec)
        read 1048576 byte file 10 times in 0.32 seconds (32021889 bytes/sec)
        ./test5 ok.

./test6: readdir
        20500 entries read, 200 files in 6.32 seconds
        ./test6 ok.

./test7: link and rename
        200 renames and links on 10 files in 4.19 seconds
        ./test7 ok.

./test8: symlink and readlink
        400 symlinks and readlinks on 10 files in 1.52 seconds
        ./test8 ok.

./test9: statfs
        1500 statfs calls in 1.5  seconds
        ./test9 ok.

Congratulations, you passed the basic tests!

GENERAL TESTS: directory /mnt/mycephfs/enc1/jul15-tests
if test ! -x runtests; then chmod a+x runtests; fi
cd /mnt/mycephfs/enc1/jul15-tests; rm -f Makefile runtests runtests.wrk *.sh *.c mkdummy rmdummy nroff.in makefile.tst
cp Makefile runtests runtests.wrk *.sh *.c mkdummy rmdummy nroff.in makefile.tst /mnt/mycephfs/enc1/jul15-tests

Small Compile
runtests.wrk: line 63: ./stat: cannot execute binary file: Exec format error
general tests failed


Related issues 2 (0 open2 closed)

Related to CephFS - Tasks #72133: linux build fails when client_oc is offClosedChristopher Hoffman

Actions
Related to CephFS - Tasks #72113: linux build fails when using read_syncClosedChristopher Hoffman

Actions
Actions #1

Updated by Christopher Hoffman 8 months ago

  • Subject changed from cython tests fail with client_oc off to cthon tests fail with client_oc off
Actions #2

Updated by Christopher Hoffman 8 months ago

I was able to track it down to this command failing

gcc -DLINUX -DHAVE_SOCKLEN_T -DGLIBC=22 -DMMAP -DSTDARG-I/usr/include/tirpc -w -o stat stat.c -lm

Then tracing this compilation the syscalls to reproduce are

import os

file = "test_file" 
fd = os.open(file, os.O_CREAT | os.O_RDWR | os.O_TRUNC, 0o644)

os.lseek(fd, 8192, os.SEEK_SET)
os.write(fd, b"\1\0\2\0")
os.lseek(fd, 8192, os.SEEK_SET)
os.read(fd, 8192)

os.lseek(fd, 3, os.SEEK_CUR)
os.write(fd, b"\10\0\0\0\20\0\0\0\0\1\0\0GA$\0013a1\0\360\20@\0\0\0\0\0\26\21@\0\0\0\0\0")
os.write(fd, b"\10\0\0\0\20\0\0\0\0\1\0\0GA$\0013a1\0%\21@\0\0\0\0\0%\21@\0\0\0\0\0\10\0\0\0\20\0\0\0\0\1\0\0GA$\0013a1\0\0\20@\0\0\0\0\0\26\20@\0\0\0\0\0\10\0\0\0\20\0\0\0\0\1\0\0GA$\0013a1\0P\31@\0\0\0\0\0X\31@\0\0\0\0\0")

os.close(fd)

Then if you run this file in fscrypt enabled dir "enc1" and non-fscrypt dir

enc1]$ python /mnt/mycephfs/enc1/bug.py ; md5sum test_file 
edf215736be19cb81df77bd0afc64fdb  test_file
enc1]$ cd ..
mycephfs]$ python /mnt/mycephfs/enc1/bug.py ; md5sum test_file 
7b8f64091dd65db1507b3e27ff358b00  test_file

Actions #3

Updated by Christopher Hoffman 8 months ago

  • Related to Tasks #72133: linux build fails when client_oc is off added
Actions #4

Updated by Christopher Hoffman 8 months ago

  • Related to Tasks #72113: linux build fails when using read_sync added
Actions #5

Updated by Christopher Hoffman 8 months ago

  • Status changed from In Progress to Resolved
commit cbe8ecd6393a5ef75e5cc15d67854b4a7416a5fe
Author: Christopher Hoffman <choffman@redhat.com>
Date:   Thu Jul 17 19:40:59 2025 +0000

    client: During fscrypt rmw (write) use correct read type

    During fscrypt rmw use internal Client::_read to utilize
    correct buffered or non buffered reads based on client wide
    options. For example, if client_oc = false, use only
    non-buffered reads in rmw.

    Fixes: https://tracker.ceph.com/issues/72143
    Signed-off-by: Christopher Hoffman <choffman@redhat.com>

diff --git a/src/client/Client.cc b/src/client/Client.cc
index e313d1c4e78..e0f4a2f4a6c 100644
--- a/src/client/Client.cc
+++ b/src/client/Client.cc
@@ -11329,7 +11329,7 @@ error:
 }

 int64_t Client::_read(Fh *f, int64_t offset, uint64_t size, bufferlist *bl,
-                      Context *onfinish)
+                      Context *onfinish, bool read_for_write)
 {
   ceph_assert(ceph_mutex_is_locked_by_me(client_lock));

@@ -11346,7 +11346,7 @@ int64_t Client::_read(Fh *f, int64_t offset, uint64_t size, bufferlist *bl,

   ldout(cct, 10) << __func__ << " " << *in << " " << offset << "~" << size << dendl;

-  if ((f->mode & CEPH_FILE_MODE_RD) == 0)
+  if ((f->mode & CEPH_FILE_MODE_RD) == 0 && !read_for_write)
     return -EBADF;
   //bool lazy = f->mode == CEPH_FILE_MODE_LAZY;

@@ -12125,10 +12125,10 @@ int Client::WriteEncMgr::init()
   return 0;
 }

-int Client::WriteEncMgr::read_async(uint64_t off, uint64_t len, bufferlist *bl,
+int Client::WriteEncMgr::read(uint64_t off, uint64_t len, bufferlist *bl,
                                      iofinish_method_ctx<WriteEncMgr> *ioctx)
 {
-  ldout(cct, 10) << __func__ << dendl;
+  ldout(cct, 20) << __func__ << dendl;
   get();

   if (off >= in->size) {
@@ -12136,7 +12136,7 @@ int Client::WriteEncMgr::read_async(uint64_t off, uint64_t len, bufferlist *bl,
     return 0;
   }

-  int r = clnt->_read_async(f, off, len, bl, ioctx->ctx());
+  int r = clnt->_read(f, off, len, bl, ioctx->ctx(), true);
   if (r < 0) {
     ioctx->cancel(r);
     put();
@@ -12182,7 +12182,7 @@ int Client::WriteEncMgr::read_modify_write(Context *_iofinish)
   if (read_start_size > 0) {
     finish_read_start_ctx.reset(new iofinish_method_ctx<WriteEncMgr>(*this, &WriteEncMgr::finish_read_start_cb, &aioc));

-    r = read_async(start_block_ofs, read_start_size, &startbl, finish_read_start_ctx.get());
+    r = read(start_block_ofs, read_start_size, &startbl, finish_read_start_ctx.get());
     if (r < 0) {
       finish_read_start_ctx.reset();

@@ -12194,7 +12194,7 @@ int Client::WriteEncMgr::read_modify_write(Context *_iofinish)
   if (need_read_end) {
     finish_read_end_ctx.reset(new iofinish_method_ctx<WriteEncMgr>(*this, &WriteEncMgr::finish_read_end_cb, &aioc));

-    r = read_async(end_block_ofs, FSCRYPT_BLOCK_SIZE, &endbl, finish_read_end_ctx.get());
+    r = read(end_block_ofs, FSCRYPT_BLOCK_SIZE, &endbl, finish_read_end_ctx.get());
     if (r < 0) {
       finish_read_end_ctx.reset();

diff --git a/src/client/Client.h b/src/client/Client.h
index c506f81c05d..3ef49195e61 100644
--- a/src/client/Client.h
+++ b/src/client/Client.h
@@ -1719,7 +1719,7 @@ private:
       return is_finished;
     }

-    int read_async(uint64_t off, uint64_t len, bufferlist *bl, iofinish_method_ctx<WriteEncMgr> *ioctx);
+    int read(uint64_t off, uint64_t len, bufferlist *bl, iofinish_method_ctx<WriteEncMgr> *ioctx);

   protected:
     virtual int do_write() = 0;
@@ -2076,7 +2076,7 @@ private:

   loff_t _lseek(Fh *fh, loff_t offset, int whence);
   int64_t _read(Fh *fh, int64_t offset, uint64_t size, bufferlist *bl,
-               Context *onfinish = nullptr);
+               Context *onfinish = nullptr, bool read_for_write = false);
   void do_readahead(Fh *f, Inode *in, uint64_t off, uint64_t len);
   int64_t _write_success(Fh *fh, utime_t start, uint64_t fpos,
                          int64_t request_offset, uint64_t request_size,

Actions #6

Updated by Christopher Hoffman 8 months ago

Author: Christopher Hoffman <choffman@redhat.com>
Date:   Wed Jul 23 19:08:08 2025 +0000

    client: Match functionality of nonblocking_read_sync read_sync

    If ENOENT is returned from OSDs, set r = 0 to match read_sync
    functionality.

    Fixes: https://tracker.ceph.com/issues/72143
    Signed-off-by: Christopher Hoffman <choffman@redhat.com>

diff --git a/src/client/Client.cc b/src/client/Client.cc
index e0f4a2f4a6c..f403c235895 100644
--- a/src/client/Client.cc
+++ b/src/client/Client.cc
@@ -11251,7 +11251,7 @@ void Client::C_Read_Sync_NonBlocking::finish(int r)

   if (r == -ENOENT) {
     // if we get ENOENT from OSD, assume 0 bytes returned
-    goto success;
+    r = 0;
   } else if (r < 0) {
     // pass error to caller
     goto error;

Actions

Also available in: Atom PDF