From 5cdc0dede145aeab57c39940b71df4b34520500e Mon Sep 17 00:00:00 2001 From: lly Date: Sun, 8 Aug 2010 21:29:28 -0400 Subject: [PATCH] nfs: patches backported from 2.6 upstream NFS: Fix buglet in fs/nfs/write.c NLM: cleanup for blocked locks --- release/src/linux/linux/fs/lockd/clntlock.c | 20 +++++++------------- release/src/linux/linux/fs/nfs/write.c | 5 ++++- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/release/src/linux/linux/fs/lockd/clntlock.c b/release/src/linux/linux/fs/lockd/clntlock.c index ef0f005459..6ef9b0d528 100644 --- a/release/src/linux/linux/fs/lockd/clntlock.c +++ b/release/src/linux/linux/fs/lockd/clntlock.c @@ -34,7 +34,7 @@ static int reclaimer(void *ptr); * This is the representation of a blocked client lock. */ struct nlm_wait { - struct nlm_wait * b_next; /* linked list */ + struct list_head b_list; /* linked list */ wait_queue_head_t b_wait; /* where to wait on */ struct nlm_host * b_host; struct file_lock * b_lock; /* local file lock */ @@ -42,7 +42,7 @@ struct nlm_wait { u32 b_status; /* grant callback status */ }; -static struct nlm_wait * nlm_blocked; +static LIST_HEAD(nlm_blocked); /* * Block on a lock @@ -50,7 +50,7 @@ static struct nlm_wait * nlm_blocked; int nlmclnt_block(struct nlm_host *host, struct file_lock *fl, u32 *statp) { - struct nlm_wait block, **head; + struct nlm_wait block; int err; u32 pstate; @@ -58,8 +58,7 @@ nlmclnt_block(struct nlm_host *host, struct file_lock *fl, u32 *statp) block.b_lock = fl; init_waitqueue_head(&block.b_wait); block.b_status = NLM_LCK_BLOCKED; - block.b_next = nlm_blocked; - nlm_blocked = █ + list_add(&block.b_list, &nlm_blocked); /* Remember pseudo nsm state */ pstate = host->h_state; @@ -74,12 +73,7 @@ nlmclnt_block(struct nlm_host *host, struct file_lock *fl, u32 *statp) */ sleep_on_timeout(&block.b_wait, 30*HZ); - for (head = &nlm_blocked; *head; head = &(*head)->b_next) { - if (*head == &block) { - *head = block.b_next; - break; - } - } + list_del(&block.b_list); if (!signalled()) { *statp = block.b_status; @@ -108,7 +102,7 @@ nlmclnt_grant(struct nlm_lock *lock) * Look up blocked request based on arguments. * Warning: must not use cookie to match it! */ - for (block = nlm_blocked; block; block = block->b_next) { + list_for_each_entry(block, &nlm_blocked, b_list) { if (nlm_compare_locks(block->b_lock, &lock->fl)) break; } @@ -237,7 +231,7 @@ restart: wake_up(&host->h_gracewait); /* Now, wake up all processes that sleep on a blocked lock */ - for (block = nlm_blocked; block; block = block->b_next) { + list_for_each_entry(block, &nlm_blocked, b_list) { if (block->b_host == host) { block->b_status = NLM_LCK_DENIED_GRACE_PERIOD; wake_up(&block->b_wait); diff --git a/release/src/linux/linux/fs/nfs/write.c b/release/src/linux/linux/fs/nfs/write.c index 01e84fc443..a14a90aa21 100644 --- a/release/src/linux/linux/fs/nfs/write.c +++ b/release/src/linux/linux/fs/nfs/write.c @@ -657,8 +657,11 @@ nfs_update_request(struct file* file, struct inode *inode, struct page *page, spin_unlock(&nfs_wreq_lock); error = nfs_wait_on_request(req); nfs_release_request(req); - if (error < 0) + if (error < 0) { + if (new) + nfs_release_request(new); return ERR_PTR(error); + } continue; } spin_unlock(&nfs_wreq_lock); -- 2.11.4.GIT