From patchwork Thu Mar 17 19:12:23 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Steve French X-Patchwork-Id: 642001 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p2HJCSnL021419 for ; Thu, 17 Mar 2011 19:12:28 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751369Ab1CQTM1 (ORCPT ); Thu, 17 Mar 2011 15:12:27 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:64896 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755190Ab1CQTM1 (ORCPT ); Thu, 17 Mar 2011 15:12:27 -0400 Received: by fxm17 with SMTP id 17so3018166fxm.19 for ; Thu, 17 Mar 2011 12:12:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:date:message-id:subject:from:to:cc :content-type; bh=DOS/mFRL9F7fcRIsOrXujjI6Ta0UNU2LTX/Chq4dPNI=; b=lXryU2LvVAfFnJz5lrplMMQqKvy1MNyk780Y1z0sqySs4w6u3JlTZgWpYp1L1Vtrw5 FHkjE8irzcuKt3PISD4qzqx9sKXyUYGvUadu7LEvgbjRoUc41nOmvfL87GBT4ddobTb2 qQT4RGq6zzc5Vw/mYMudW1M6BGJRJDJ2YVC+k= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:cc:content-type; b=u7T324yddozHqgJR4IpJ33PoQFy+sdjttir3ey9SN2jmJeYEiU6JZsBLdkyKcPU/xV JC8vshefYihzoaOBRmCvWNuqbna5fgutWVvOVCeGuRliAFhWKvFdsohdiROVCLMJ8RZq jtLwXtAYscSGgmwlv2s1HUU8ZO5gKhhiP/1u8= MIME-Version: 1.0 Received: by 10.223.96.144 with SMTP id h16mr119080fan.142.1300389143990; Thu, 17 Mar 2011 12:12:23 -0700 (PDT) Received: by 10.223.118.15 with HTTP; Thu, 17 Mar 2011 12:12:23 -0700 (PDT) Date: Thu, 17 Mar 2011 14:12:23 -0500 Message-ID: Subject: [CIFS] Cleanup use of CONFIG_CIFS_STATS2 ifdef to make transport routines more readable From: Steve French To: linux-cifs@vger.kernel.org Cc: linux-fsdevel Sender: linux-cifs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-cifs@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter1.kernel.org [140.211.167.41]); Thu, 17 Mar 2011 19:12:28 +0000 (UTC) diff --git a/fs/cifs/cifs_debug.c b/fs/cifs/cifs_debug.c index 69e6e50..6dc9da5 100644 --- a/fs/cifs/cifs_debug.c +++ b/fs/cifs/cifs_debug.c @@ -146,7 +146,7 @@ static void dump_cifs_debug_info(int i, struct seq_file *m, #ifdef CONFIG_CIFS_STATS2 seq_printf(m, " In Send: %d In MaxReq Wait: %d", - atomic_read(&server->inSend), + atomic_read(&server->in_send), atomic_read(&server->num_waiters)); #endif diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index 398f596..04ea75b 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -219,7 +219,7 @@ struct TCP_Server_Info { struct fscache_cookie *fscache; /* client index cache cookie */ #endif #ifdef CONFIG_CIFS_STATS2 - atomic_t inSend; /* requests trying to send */ + atomic_t in_send; /* requests trying to send */ atomic_t num_waiters; /* blocked waiting to get in sendrecv */ #endif #ifdef CONFIG_CIFS_SMB2 @@ -609,6 +609,55 @@ struct mid_q_entry { bool multiEnd:1; /* both received */ }; +/* Make code in transport.c a little cleaner by moving + update of optional stats into function below */ +#ifdef CONFIG_CIFS_STATS2 + +static inline void cifs_in_send_inc(struct TCP_Server_Info *server) +{ + atomic_inc(&server->in_send); +} + +static inline void cifs_in_send_dec(struct TCP_Server_Info *server) +{ + atomic_dec(&server->in_send); +} + +static inline void cifs_num_waiters_inc(struct TCP_Server_Info *server) +{ + atomic_inc(&server->num_waiters); +} + +static inline void cifs_num_waiters_dec(struct TCP_Server_Info *server) +{ + atomic_dec(&server->num_waiters); +} + +static inline void cifs_save_when_sent(struct mid_q_entry *mid) +{ + mid->when_sent = jiffies; +} +#else +static inline void cifs_in_send_inc(struct TCP_Server_Info *server) +{ +} +static inline void cifs_in_send_dec(struct TCP_Server_Info *server) +{ +} + +static inline void cifs_num_waiters_inc(struct TCP_Server_Info *server) +{ +} + +static inline void cifs_num_waiters_dec(struct TCP_Server_Info *server) +{ +} + +static inline void cifs_save_when_sent(struct mid_q_entry *mid) +{ +} +#endif + /* for pending dnotify requests */ struct dir_notify_req { struct list_head lhead; diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index fd43ac6..1b3a9e0 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c @@ -267,28 +267,20 @@ int wait_for_free_request(struct TCP_Server_Info *server, if ((server->is_smb2 == false) && atomic_read(&server->inFlight) >= cifs_max_pending) { spin_unlock(&GlobalMid_Lock); -#ifdef CONFIG_CIFS_STATS2 - atomic_inc(&server->num_waiters); -#endif + cifs_num_waiters_inc(server); wait_event(server->request_q, atomic_read(&server->inFlight) < cifs_max_pending); -#ifdef CONFIG_CIFS_STATS2 - atomic_dec(&server->num_waiters); -#endif + cifs_num_waiters_dec(server); spin_lock(&GlobalMid_Lock); #ifdef CONFIG_CIFS_SMB2 } else if (server->is_smb2 && (atomic_read(&server->credits) < 1)) { spin_unlock(&GlobalMid_Lock); -#ifdef CONFIG_CIFS_STATS2 - atomic_inc(&server->num_waiters); -#endif + cifs_num_waiters_inc(server); wait_event(server->request_q, atomic_read(&server->credits) > 0); -#ifdef CONFIG_CIFS_STATS2 - atomic_dec(&server->num_waiters); -#endif + cifs_num_waiters_dec(server); spin_lock(&GlobalMid_Lock); #endif /* CONFIG_CIFS_SMB2 */ } else { @@ -392,14 +384,10 @@ cifs_call_async(struct TCP_Server_Info *server, struct smb_hdr *in_buf, mid->callback = callback; mid->callback_data = cbdata; mid->midState = MID_REQUEST_SUBMITTED; -#ifdef CONFIG_CIFS_STATS2 - atomic_inc(&server->inSend); -#endif + cifs_in_send_inc(server); rc = smb_send(server, in_buf, be32_to_cpu(in_buf->smb_buf_length)); -#ifdef CONFIG_CIFS_STATS2 - atomic_dec(&server->inSend); - mid->when_sent = jiffies; -#endif + cifs_in_send_dec(server); + cifs_save_when_sent(mid); mutex_unlock(&server->srv_mutex); if (rc)