From patchwork Sat Feb 6 12:06:03 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthias Kaehlcke X-Patchwork-Id: 102653 Received: from lists.samba.org (fn.samba.org [216.83.154.106]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o4RCZlDD013176 for ; Thu, 27 May 2010 12:36:40 GMT Received: from fn.samba.org (localhost [127.0.0.1]) by lists.samba.org (Postfix) with ESMTP id EF34346652; Thu, 27 May 2010 06:35:26 -0600 (MDT) X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on fn.samba.org X-Spam-Level: X-Spam-Status: No, score=-6.6 required=3.8 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.2.5 X-Original-To: linux-cifs-client@lists.samba.org Delivered-To: linux-cifs-client@lists.samba.org Received: from slow3-v.mail.gandi.net (slow3-v.mail.gandi.net [217.70.178.89]) by lists.samba.org (Postfix) with ESMTP id C1ACF465D0; Sat, 6 Feb 2010 05:30:01 -0700 (MST) Received: from relay4-v.mail.gandi.net (relay4-v.mail.gandi.net [217.70.178.78]) by slow3-v.mail.gandi.net (Postfix) with ESMTP id 868DA859F8; Sat, 6 Feb 2010 13:06:50 +0100 (CET) Received: from d4rwin.no-ip.org (unknown [193.153.49.185]) by relay4-v.mail.gandi.net (Postfix) with ESMTP id 4A483BA0E; Sat, 6 Feb 2010 13:06:15 +0100 (CET) Received: by d4rwin.no-ip.org (Postfix, from userid 1000) id 894894C4EE; Sat, 6 Feb 2010 13:06:03 +0100 (CET) Date: Sat, 6 Feb 2010 13:06:03 +0100 From: Matthias Kaehlcke To: Steve French , Jeff Layton Message-ID: <20100206120603.GB19106@darwin> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.20 (2009-06-14) X-Mailman-Approved-At: Thu, 27 May 2010 06:34:18 -0600 Cc: samba-technical@lists.samba.org, linux-cifs-client@lists.samba.org Subject: [linux-cifs-client] [PATCH] cifs/connect.c: use list_for_each_entry instead of list_for_each X-BeenThere: linux-cifs-client@lists.samba.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: The Linux CIFS VFS client List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-cifs-client-bounces@lists.samba.org Errors-To: linux-cifs-client-bounces@lists.samba.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 27 May 2010 12:36:40 +0000 (UTC) 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))