Skip to content

Commit

Permalink
client: Fix libcephfs aio metadata corruption.
Browse files Browse the repository at this point in the history
Problem:
With cephfs nfs-ganesha, there were following
asserts hit while doing write on a file.

1. FAILED ceph_assert((bool)_front == (bool)_size)
2. FAILED ceph_assert(cap_refs[c] > 0)

Cause:
In aio path, the client_lock was not being held
in the internal callback after the io is done where
it's expected to be taken leading to corruption.

Fix:
Take client_lock in the callback

Fixes: https://tracker.ceph.com/issues/68146
Signed-off-by: Kotresh HR <khiremat@redhat.com>
  • Loading branch information
kotreshhr committed Sep 26, 2024
1 parent 624f695 commit 42f75b2
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/client/Client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10716,7 +10716,7 @@ void Client::C_Read_Finisher::finish_io(int r)
{
utime_t lat;

// Caller holds client_lock so we don't need to take it.
std::scoped_lock lock(clnt->client_lock);

if (r >= 0) {
if (is_read_async) {
Expand Down Expand Up @@ -11403,6 +11403,8 @@ void Client::C_Write_Finisher::finish_io(int r)
{
bool fini;

std::scoped_lock lock(clnt->client_lock);

clnt->put_cap_ref(in, CEPH_CAP_FILE_BUFFER);

if (r >= 0) {
Expand Down Expand Up @@ -11438,6 +11440,8 @@ void Client::C_Write_Finisher::finish_fsync(int r)
bool fini;
client_t const whoami = clnt->whoami; // For the benefit of ldout prefix

ceph_assert(ceph_mutex_is_locked_by_me(clnt->client_lock));

ldout(clnt->cct, 3) << "finish_fsync r = " << r << dendl;

fsync_finished = true;
Expand Down

0 comments on commit 42f75b2

Please sign in to comment.