patch-2.4.0-test1 linux/fs/nfs/write.c
Next file: linux/fs/nfsd/nfscache.c
Previous file: linux/fs/nfs/inode.c
Back to the patch index
Back to the overall index
- Lines: 86
- Date:
Wed May 24 09:46:22 2000
- Orig file:
v2.3.99-pre9/linux/fs/nfs/write.c
- Orig date:
Tue May 23 15:31:36 2000
diff -u --recursive --new-file v2.3.99-pre9/linux/fs/nfs/write.c linux/fs/nfs/write.c
@@ -68,7 +68,7 @@
* Spinlock
*/
spinlock_t nfs_wreq_lock = SPIN_LOCK_UNLOCKED;
-static unsigned int nfs_nr_requests = 0;
+static atomic_t nfs_nr_requests = ATOMIC_INIT(0);
/*
* Local structures
@@ -490,9 +490,9 @@
*/
do {
/* If we're over the global soft limit, wake up all requests */
- if (nfs_nr_requests >= MAX_REQUEST_SOFT) {
+ if (atomic_read(&nfs_nr_requests) >= MAX_REQUEST_SOFT) {
dprintk("NFS: hit soft limit (%d requests)\n",
- nfs_nr_requests);
+ atomic_read(&nfs_nr_requests));
if (!cache->task)
nfs_reqlist_init(NFS_SERVER(inode));
nfs_wake_flushd();
@@ -500,7 +500,7 @@
/* If we haven't reached the local hard limit yet,
* try to allocate the request struct */
- if (cache->nr_requests < MAX_REQUEST_HARD) {
+ if (atomic_read(&cache->nr_requests) < MAX_REQUEST_HARD) {
req = nfs_page_alloc();
if (req != NULL)
break;
@@ -508,7 +508,7 @@
/* We're over the hard limit. Wait for better times */
dprintk("NFS: create_request sleeping (total %d pid %d)\n",
- cache->nr_requests, current->pid);
+ atomic_read(&cache->nr_requests), current->pid);
timeout = 1 * HZ;
if (NFS_SERVER(inode)->flags & NFS_MOUNT_INTR) {
@@ -520,7 +520,7 @@
sleep_on_timeout(&cache->request_wait, timeout);
dprintk("NFS: create_request waking up (tot %d pid %d)\n",
- cache->nr_requests, current->pid);
+ atomic_read(&cache->nr_requests), current->pid);
} while (!req);
if (!req)
return NULL;
@@ -539,8 +539,8 @@
req->wb_count = 1;
/* register request's existence */
- cache->nr_requests++;
- nfs_nr_requests++;
+ atomic_inc(&cache->nr_requests);
+ atomic_inc(&nfs_nr_requests);
return req;
}
@@ -580,9 +580,15 @@
page_cache_release(page);
nfs_page_free(req);
/* wake up anyone waiting to allocate a request */
- cache->nr_requests--;
- nfs_nr_requests--;
+ atomic_dec(&cache->nr_requests);
+ atomic_dec(&nfs_nr_requests);
wake_up(&cache->request_wait);
+#ifdef NFS_PARANOIA
+ if (atomic_read(&cache->nr_requests) < 0)
+ BUG();
+ if (atomic_read(&nfs_nr_requests) < 0)
+ BUG();
+#endif
}
/*
@@ -931,7 +937,7 @@
if (dirty >= wpages)
nfs_flush_file(inode, NULL, 0, 0, 0);
if (inode->u.nfs_i.ncommit > NFS_STRATEGY_PAGES * wpages &&
- nfs_nr_requests > MAX_REQUEST_SOFT)
+ atomic_read(&nfs_nr_requests) > MAX_REQUEST_SOFT)
nfs_commit_file(inode, NULL, 0, 0, 0);
}
#else
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)