From patchwork Sat Feb 6 12:06:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: cifs/connect.c: use list_for_each_entry instead of list_for_each From: Matthias Kaehlcke X-Patchwork-Id: 53747 Message-Id: <20100206120603.GB19106@darwin> To: Steve French , Jeff Layton Cc: samba-technical@lists.samba.org, linux-cifs-client@lists.samba.org Date: Sat, 6 Feb 2010 13:06:03 +0100 cifs/connect.c: use list_for_each_entry instead of list_for_each Signed-off-by: Matthias Kaehlcke --- fs/cifs/connect.c | 44 +++++++++++--------------------------------- 1 files changed, 11 insertions(+), 33 deletions(-) diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 3bbcaa7..31bfa49 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -118,7 +118,6 @@ static int cifs_reconnect(struct TCP_Server_Info *server) { int rc = 0; - struct list_head *tmp, *tmp2; struct cifsSesInfo *ses; struct cifsTconInfo *tcon; struct mid_q_entry *mid_entry; @@ -139,12 +138,10 @@ cifs_reconnect(struct TCP_Server_Info *server) /* before reconnecting the tcp session, mark the smb session (uid) and the tid bad so they are not used until reconnected */ read_lock(&cifs_tcp_ses_lock); - list_for_each(tmp, &server->smb_ses_list) { - ses = list_entry(tmp, struct cifsSesInfo, smb_ses_list); + list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) { ses->need_reconnect = true; ses->ipc_tid = 0; - list_for_each(tmp2, &ses->tcon_list) { - tcon = list_entry(tmp2, struct cifsTconInfo, tcon_list); + list_for_each_entry(tcon, &ses->tcon_list, tcon_list) { tcon->need_reconnect = true; } } @@ -163,10 +160,7 @@ cifs_reconnect(struct TCP_Server_Info *server) } spin_lock(&GlobalMid_Lock); - list_for_each(tmp, &server->pending_mid_q) { - mid_entry = list_entry(tmp, struct - mid_q_entry, - qhead); + list_for_each_entry(mid_entry, &server->pending_mid_q, qhead) { if (mid_entry->midState == MID_REQUEST_SUBMITTED) { /* Mark other intransit requests as needing retry so we do not immediately mark the @@ -328,7 +322,6 @@ cifs_demultiplex_thread(struct TCP_Server_Info *server) struct msghdr smb_msg; struct kvec iov; struct socket *csocket = server->ssocket; - struct list_head *tmp; struct cifsSesInfo *ses; struct task_struct *task_to_wake = NULL; struct mid_q_entry *mid_entry; @@ -563,9 +556,7 @@ incomplete_rcv: task_to_wake = NULL; spin_lock(&GlobalMid_Lock); - list_for_each(tmp, &server->pending_mid_q) { - mid_entry = list_entry(tmp, struct mid_q_entry, qhead); - + list_for_each_entry(mid_entry, &server->pending_mid_q, qhead) { if ((mid_entry->mid == smb_buffer->Mid) && (mid_entry->midState == MID_REQUEST_SUBMITTED) && (mid_entry->command == smb_buffer->Command)) { @@ -686,9 +677,7 @@ multi_t2_fnd: if (list_empty(&server->pending_mid_q)) { /* loop through server session structures attached to this and mark them dead */ - list_for_each(tmp, &server->smb_ses_list) { - ses = list_entry(tmp, struct cifsSesInfo, - smb_ses_list); + list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) { ses->status = CifsExiting; ses->server = NULL; } @@ -697,15 +686,12 @@ multi_t2_fnd: /* although we can not zero the server struct pointer yet, since there are active requests which may depnd on them, mark the corresponding SMB sessions as exiting too */ - list_for_each(tmp, &server->smb_ses_list) { - ses = list_entry(tmp, struct cifsSesInfo, - smb_ses_list); + list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) { ses->status = CifsExiting; } spin_lock(&GlobalMid_Lock); - list_for_each(tmp, &server->pending_mid_q) { - mid_entry = list_entry(tmp, struct mid_q_entry, qhead); + list_for_each_entry(mid_entry, &server->pending_mid_q, qhead) { if (mid_entry->midState == MID_REQUEST_SUBMITTED) { cFYI(1, ("Clearing Mid 0x%x - waking up ", mid_entry->mid)); @@ -739,8 +725,7 @@ multi_t2_fnd: kernel thread explicitly this might happen) */ /* BB: This shouldn't be necessary, see above */ read_lock(&cifs_tcp_ses_lock); - list_for_each(tmp, &server->smb_ses_list) { - ses = list_entry(tmp, struct cifsSesInfo, smb_ses_list); + list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) { ses->server = NULL; } read_unlock(&cifs_tcp_ses_lock); @@ -1379,15 +1364,12 @@ cifs_parse_mount_options(char *options, const char *devname, static struct TCP_Server_Info * cifs_find_tcp_session(struct sockaddr_storage *addr, unsigned short int port) { - struct list_head *tmp; struct TCP_Server_Info *server; struct sockaddr_in *addr4 = (struct sockaddr_in *) addr; struct sockaddr_in6 *addr6 = (struct sockaddr_in6 *) addr; write_lock(&cifs_tcp_ses_lock); - list_for_each(tmp, &cifs_tcp_ses_list) { - server = list_entry(tmp, struct TCP_Server_Info, - tcp_ses_list); + list_for_each_entry(server, &cifs_tcp_ses_list, tcp_ses_list) { /* * the demux thread can exit on its own while still in CifsNew * so don't accept any sockets in that state. Since the @@ -1589,12 +1571,10 @@ out_err: static struct cifsSesInfo * cifs_find_smb_ses(struct TCP_Server_Info *server, char *username) { - struct list_head *tmp; struct cifsSesInfo *ses; write_lock(&cifs_tcp_ses_lock); - list_for_each(tmp, &server->smb_ses_list) { - ses = list_entry(tmp, struct cifsSesInfo, smb_ses_list); + list_for_each_entry(ses, &server->smb_ses_list, smb_ses_list) { if (strncmp(ses->userName, username, MAX_USERNAME_SIZE)) continue; @@ -1633,12 +1613,10 @@ cifs_put_smb_ses(struct cifsSesInfo *ses) static struct cifsTconInfo * cifs_find_tcon(struct cifsSesInfo *ses, const char *unc) { - struct list_head *tmp; struct cifsTconInfo *tcon; write_lock(&cifs_tcp_ses_lock); - list_for_each(tmp, &ses->tcon_list) { - tcon = list_entry(tmp, struct cifsTconInfo, tcon_list); + list_for_each_entry(tcon, &ses->tcon_list, tcon_list) { if (tcon->tidStatus == CifsExiting) continue; if (strncmp(tcon->treeName, unc, MAX_TREE_SIZE))