Project

General

Profile

Actions

Tasks #65964

closed

Tasks #64165: Fix warnings in read_sync()

sync read returns empty file on non-fscrypt dir

Added by Christopher Hoffman almost 2 years ago. Updated almost 2 years 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

When client_debug_force_sync_read is set to True and a non-fscrypt file is written, no data is returned.

This is present in https://github.com/ceph/ceph/pull/52172 and wip-fscrypt branch. This is NOT present in main.

Reproducer:
set client_debug_force_sync_read = true.

non-fscrypt enabled dir:

$ cd /mnt/mycephfs
mycephfs]$ echo test_data > file1
mycephfs]$ cat file1
mycephfs]$ ls -l file1
-rw-------. 1 choffman choffman 10 May 10 17:14 file1

fscrypt enabled dir:
fscrypt_test_unlocked_ffsb]$ echo test_data_enc > enc_file1
fscrypt_test_unlocked_ffsb]$ cat enc_file1
test_data_enc

Actions #1

Updated by Christopher Hoffman almost 2 years ago

In the case of non-fscrypt, bl is an alias for pbl, and it was appending itself to itself.

Patch

diff --git a/src/client/Client.cc b/src/client/Client.cc
index cb77c809b3a..c3fcc3b8f22 100644
--- a/src/client/Client.cc
+++ b/src/client/Client.cc
@@ -11504,10 +11504,10 @@ int Client::_read_sync(Fh *f, uint64_t off, uint64_t len, bufferlist *bl,
       if (r < 0) {
         ldout(cct, 20) << __func__ << "(): failed to decrypt buffer: r=" << r << dendl;
       }
+      bl->claim_append(*pbl);
     }

     read = pbl->length();
-    bl->claim_append(*pbl);
   }
   return read;
 }

Actions

Also available in: Atom PDF