From fc40f9cf828908e91d9af820e9300a9d42fbbd72 Mon Sep 17 00:00:00 2001 From: Pavel Shilovsky Date: Fri, 17 Feb 2012 17:09:12 +0300 Subject: CIFS: Simplify inFlight logic by making it as unsigned integer and surround access with req_lock from server structure. Reviewed-by: Jeff Layton Signed-off-by: Pavel Shilovsky Signed-off-by: Steve French --- fs/cifs/cifsglob.h | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) (limited to 'fs/cifs/cifsglob.h') diff --git a/fs/cifs/cifsglob.h b/fs/cifs/cifsglob.h index d47d20aac67..fb78bc90388 100644 --- a/fs/cifs/cifsglob.h +++ b/fs/cifs/cifsglob.h @@ -250,7 +250,8 @@ struct TCP_Server_Info { bool noblocksnd; /* use blocking sendmsg */ bool noautotune; /* do not autotune send buf sizes */ bool tcp_nodelay; - atomic_t inFlight; /* number of requests on the wire to server */ + unsigned int in_flight; /* number of requests on the wire to server */ + spinlock_t req_lock; /* protect the value above */ struct mutex srv_mutex; struct task_struct *tsk; char server_GUID[16]; @@ -303,6 +304,24 @@ struct TCP_Server_Info { #endif }; +static inline unsigned int +in_flight(struct TCP_Server_Info *server) +{ + unsigned int num; + spin_lock(&server->req_lock); + num = server->in_flight; + spin_unlock(&server->req_lock); + return num; +} + +static inline void +dec_in_flight(struct TCP_Server_Info *server) +{ + spin_lock(&server->req_lock); + server->in_flight--; + spin_unlock(&server->req_lock); +} + /* * Macros to allow the TCP_Server_Info->net field and related code to drop out * when CONFIG_NET_NS isn't set. -- cgit v1.2.3-70-g09d2