patch-2.4.1 linux/fs/nfs/flushd.c
Next file: linux/fs/partitions/msdos.c
Previous file: linux/fs/ncpfs/sock.c
Back to the patch index
Back to the overall index
- Lines: 191
- Date:
Tue Jan 23 15:22:24 2001
- Orig file:
v2.4.0/linux/fs/nfs/flushd.c
- Orig date:
Wed Jun 21 07:25:17 2000
diff -u --recursive --new-file v2.4.0/linux/fs/nfs/flushd.c linux/fs/nfs/flushd.c
@@ -34,7 +34,7 @@
#include <linux/sunrpc/clnt.h>
#include <linux/sunrpc/sched.h>
-#include <linux/spinlock.h>
+#include <linux/smp_lock.h>
#include <linux/nfs.h>
#include <linux/nfs_fs.h>
@@ -53,11 +53,6 @@
static struct rpc_wait_queue flushd_queue = RPC_INIT_WAITQ("nfs_flushd");
/*
- * Spinlock
- */
-spinlock_t nfs_flushd_lock = SPIN_LOCK_UNLOCKED;
-
-/*
* Local function declarations.
*/
static void nfs_flushd(struct rpc_task *);
@@ -68,19 +63,20 @@
{
struct nfs_reqlist *cache;
struct rpc_task *task;
- int status = 0;
+ int status;
dprintk("NFS: writecache_init\n");
- spin_lock(&nfs_flushd_lock);
- cache = server->rw_requests;
- if (cache->task)
+ lock_kernel();
+ status = -ENOMEM;
+ /* Create the RPC task */
+ if (!(task = rpc_new_task(server->client, NULL, RPC_TASK_ASYNC)))
goto out_unlock;
- /* Create the RPC task */
- status = -ENOMEM;
- task = rpc_new_task(server->client, NULL, RPC_TASK_ASYNC);
- if (!task)
+ cache = server->rw_requests;
+
+ status = 0;
+ if (cache->task)
goto out_unlock;
task->tk_calldata = server;
@@ -94,11 +90,13 @@
task->tk_action = nfs_flushd;
task->tk_exit = nfs_flushd_exit;
- spin_unlock(&nfs_flushd_lock);
rpc_execute(task);
+ unlock_kernel();
return 0;
out_unlock:
- spin_unlock(&nfs_flushd_lock);
+ if (task)
+ rpc_release_task(task);
+ unlock_kernel();
return status;
}
@@ -106,23 +104,24 @@
{
struct nfs_reqlist *cache;
+ lock_kernel();
cache = server->rw_requests;
if (!cache)
- return;
+ goto out;
dprintk("NFS: reqlist_exit (ptr %p rpc %p)\n", cache, cache->task);
+
while (cache->task || cache->inodes) {
- spin_lock(&nfs_flushd_lock);
if (!cache->task) {
- spin_unlock(&nfs_flushd_lock);
nfs_reqlist_init(server);
} else {
cache->task->tk_status = -ENOMEM;
rpc_wake_up_task(cache->task);
- spin_unlock(&nfs_flushd_lock);
}
interruptible_sleep_on_timeout(&cache->request_wait, 1 * HZ);
}
+ out:
+ unlock_kernel();
}
int nfs_reqlist_alloc(struct nfs_server *server)
@@ -161,7 +160,6 @@
struct nfs_reqlist *cache = NFS_REQUESTLIST(inode);
struct inode **q;
- spin_lock(&nfs_flushd_lock);
if (NFS_FLAGS(inode) & NFS_INO_FLUSH)
goto out;
inode->u.nfs_i.hash_next = NULL;
@@ -177,7 +175,6 @@
NFS_FLAGS(inode) |= NFS_INO_FLUSH;
atomic_inc(&inode->i_count);
out:
- spin_unlock(&nfs_flushd_lock);
}
void inode_remove_flushd(struct inode *inode)
@@ -185,7 +182,7 @@
struct nfs_reqlist *cache = NFS_REQUESTLIST(inode);
struct inode **q;
- spin_lock(&nfs_flushd_lock);
+ lock_kernel();
if (!(NFS_FLAGS(inode) & NFS_INO_FLUSH))
goto out;
@@ -198,7 +195,7 @@
iput(inode);
}
out:
- spin_unlock(&nfs_flushd_lock);
+ unlock_kernel();
}
void inode_schedule_scan(struct inode *inode, unsigned long time)
@@ -207,6 +204,7 @@
struct rpc_task *task;
unsigned long mintimeout;
+ lock_kernel();
if (time_after(NFS_NEXTSCAN(inode), time))
NFS_NEXTSCAN(inode) = time;
mintimeout = jiffies + 1 * HZ;
@@ -214,16 +212,14 @@
mintimeout = NFS_NEXTSCAN(inode);
inode_append_flushd(inode);
- spin_lock(&nfs_flushd_lock);
task = cache->task;
if (!task) {
- spin_unlock(&nfs_flushd_lock);
nfs_reqlist_init(NFS_SERVER(inode));
} else {
if (time_after(cache->runat, mintimeout))
rpc_wake_up_task(task);
- spin_unlock(&nfs_flushd_lock);
}
+ unlock_kernel();
}
@@ -240,10 +236,8 @@
server = (struct nfs_server *) task->tk_calldata;
cache = server->rw_requests;
- spin_lock(&nfs_flushd_lock);
next = cache->inodes;
cache->inodes = NULL;
- spin_unlock(&nfs_flushd_lock);
while ((inode = next) != NULL) {
next = next->u.nfs_i.hash_next;
@@ -280,13 +274,11 @@
task->tk_timeout = delay;
cache->runat = jiffies + task->tk_timeout;
- spin_lock(&nfs_flushd_lock);
if (!atomic_read(&cache->nr_requests) && !cache->inodes) {
cache->task = NULL;
task->tk_action = NULL;
} else
rpc_sleep_on(&flushd_queue, task, NULL, NULL);
- spin_unlock(&nfs_flushd_lock);
}
static void
@@ -297,10 +289,8 @@
server = (struct nfs_server *) task->tk_calldata;
cache = server->rw_requests;
- spin_lock(&nfs_flushd_lock);
if (cache->task == task)
cache->task = NULL;
- spin_unlock(&nfs_flushd_lock);
wake_up(&cache->request_wait);
}
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen (who was at: slshen@lbl.gov)