Hi Mike, Thank you so much for your help!
Regards, Jack On Jan 29, 11:56 am, Mike Christie <[email protected]> wrote: > On 01/27/2010 02:41 AM, Jack Z wrote: > > > > > Hi group, > > > I'm looking at the following code and come up with some questions.... > > > In this function, > > > static void iscsi_sw_tcp_write_space(struct sock *sk) > > { > > struct iscsi_conn *conn = (struct iscsi_conn*)sk->sk_user_data; > > struct iscsi_tcp_conn *tcp_conn = conn->dd_data; > > struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data; > > > tcp_sw_conn->old_write_space(sk); > > ISCSI_SW_TCP_DBG(conn, "iscsi_write_space\n"); > > iscsi_conn_queue_work(conn); > > } > > > tcp_sw_conn->old_write_space() is called. And in the following > > function, tcp_sw_conn->old_write_space() seems to be assigned to the > > original value of "sk->sk_write_space"... > > > Could anyone show me which function does "sk->sk_write_space" point to > > before it is assigned to "iscsi_sw_tcp_write_space;" later in the same > > function? > > I believe it is sk_stream_write_space. For tcp v4 sockets see > tcp_v4_init_sock. > > > > > > > static void iscsi_sw_tcp_conn_set_callbacks(struct iscsi_conn *conn) > > { > > struct iscsi_tcp_conn *tcp_conn = conn->dd_data; > > struct iscsi_sw_tcp_conn *tcp_sw_conn = tcp_conn->dd_data; > > struct sock *sk = tcp_sw_conn->sock->sk; > > > /* assign new callbacks */ > > ...... > > tcp_sw_conn->old_write_space = sk->sk_write_space; > > > // assignment of "sk->sk_write_space" but after its value was assigned > > to "tcp_sw_conn->old_write_space"... > > > sk->sk_write_space = iscsi_sw_tcp_write_space; > > write_unlock_bh(&sk->sk_callback_lock); > > } > > > Another question is: Now that we have "sk->sk_write_space = > > iscsi_sw_tcp_write_space" why do we have to call "tcp_sw_conn- > >> old_write_space(sk);" in "iscsi_sw_tcp_write_space()"? Which function > > We override it so the iscsi layer can start up its send code if needed, > and we call the old tcp function so it can do its processing (possibly > wake up threads waiting for space to open up). > > > > > is actually called when we do "tcp_sw_conn->old_write_space(sk);"? > > > And also in fuction "static void iscsi_sw_tcp_write_space(struct sock > > *sk)", the last instruction is "iscsi_conn_queue_work(conn);". When I > > trace down I found > > > inline void iscsi_conn_queue_work(struct iscsi_conn *conn) > > { > > struct Scsi_Host *shost = conn->session->host; > > struct iscsi_host *ihost = shost_priv(shost); > > > if (ihost->workq) > > queue_work(ihost->workq,&conn->xmitwork); > > } > > > But I couldn't find more details about "queue_work(ihost->workq,&conn- > >> xmitwork);" in the source code (ver 2.0.871). Could anyone maybe > > point me to the code of "queu_work"? > > It is in the kernel source. Get the kernel and look at > kernel/workqueue.c. It basically wakes up a thread and has it process > some work. For iscsi it wakes up our xmit thread in case it had slept > due to there not being any write space. -- You received this message because you are subscribed to the Google Groups "open-iscsi" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/open-iscsi?hl=en.
