All of lore.kernel.org
 help / color / mirror / Atom feed
* Can read and write on the same connection at the same time?
@ 2011-10-13 13:27 程茂
  2011-10-13 15:29 ` Sage Weil
  0 siblings, 1 reply; 2+ messages in thread
From: 程茂 @ 2011-10-13 13:27 UTC (permalink / raw)
  To: ceph-devel

kclient will establish only one connection with each osd,but there is
a mutex in the ceph_connection.

partial code about con_work

static void con_work(struct work_struct *work)
{
struct ceph_connection *con = container_of(work, struct ceph_connection,
  work.work);
mutex_lock(&con->mutex);
……
      if (test_and_clear_bit(SOCK_CLOSED, &con->state) ||
   try_read(con) < 0 ||
   try_write(con) < 0) {
mutex_unlock(&con->mutex);
bsdocfs_fault(con);     /* error/fault path */
goto done_unlocked;
}
……
}

if kclient read data from osdN,can kclient write data to osdN at the same time?
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Can read and write on the same connection at the same time?
  2011-10-13 13:27 Can read and write on the same connection at the same time? 程茂
@ 2011-10-13 15:29 ` Sage Weil
  0 siblings, 0 replies; 2+ messages in thread
From: Sage Weil @ 2011-10-13 15:29 UTC (permalink / raw)
  To: 程茂; +Cc: ceph-devel

[-- Attachment #1: Type: TEXT/PLAIN, Size: 1219 bytes --]

On Thu, 13 Oct 2011,  wrote:
> kclient will establish only one connection with each osdÿÿbut there is
> a mutex in the ceph_connection.
> 
> partial code about con_work
> 
> static void con_work(struct work_struct *work)
> {
> struct ceph_connection *con = container_of(work, struct ceph_connection,
>   work.work);
> mutex_lock(&con->mutex);
> ÿÿÿÿ
>       if (test_and_clear_bit(SOCK_CLOSED, &con->state) ||
>    try_read(con) < 0 ||
>    try_write(con) < 0) {
> mutex_unlock(&con->mutex);
> bsdocfs_fault(con);     /* error/fault path */
> goto done_unlocked;
> }
> ÿÿÿÿ
> }
> 
> if kclient read data from osdNÿÿcan kclient write data to osdN at the 
> same timeÿÿ

Yes.  The messenger code wakes up whenever there is new data queued to 
send, or new data available on the socket.  We only ever read or write as 
much data as we can without emptying or filling the socket buffer at a 
time.  We never block on network IO, so the mutex is only ever held for 
very short periods.  The model is asynchronous message passing.  We have a 
queue of outgoing messages that we send as quickly as the socket will 
accept them, and when a complete incoming message is read we process it.

sage

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-10-13 15:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-10-13 13:27 Can read and write on the same connection at the same time? 程茂
2011-10-13 15:29 ` Sage Weil

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.