Re: [PATCH 2/4] FUSE: make request_wait_answer() wait for ->end()completion

From: Tejun Heo
Date: Mon Jun 29 2009 - 12:21:09 EST


Hello, Miklos.

Miklos Szeredi wrote:
> On Thu, 18 Jun 2009, Tejun Heo wrote:
>> Previously, a request was marked FINISHED before ->end() is executed
>> and thus request_wait_answer() can return before it's done. This
>> patch makes request_wait_answer() wait for ->end() to finish before
>> returning.
>
> Why is this change needed?

Direct mmap implementation manages fds in the server process using the
end() callback. After each command which needs to manipulate server
fds in some way, the end callback is responsible for doing it and
communicating what happened to the client side which is executing
fuse_file_direct_mmap(), so it needs to wait for end to complete
before proceeding.

>> spin_unlock(&fc->lock);
>> - wake_up(&req->waitq);
>> - if (end)
>> +
>> + if (end) {
>> end(fc, req);
>> + smp_wmb();
>
> Why is this barrier needed?

To separate the changes end() made from setting FUSE_REQ_FINISHED.
The corresponding wait is in wait_answer_interruptible() and the
corresponding barrier is rmb() implied by spin_lock(&fc->lock) in that
function. ie. the barrier makes sure that when
wait_event_interruptible() exits the waiting state because state
equals FUSE_REQ_FINISHED, the caller is guaranteed to see the changes
made by end().

Thanks.

--
tejun
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/