diff options
author | Christoph Hellwig <hch@lst.de> | 2006-03-20 13:44:40 -0500 |
---|---|---|
committer | Trond Myklebust <Trond.Myklebust@netapp.com> | 2006-03-20 13:44:40 -0500 |
commit | 26bcbf965f857c710adafd16cf424f043006b5dd (patch) | |
tree | fa3c1e4ba07ab3d1e4e61b27c7579c57fd2d5c65 /fs/lockd/clntlock.c | |
parent | 04266473ecf5cdca242201d9f1ed890afe070fb6 (diff) |
lockd: stop abusing file_lock_list
Currently lockd directly access the file_lock_list from fs/locks.c.
It does so to mark locks granted or reclaimable. This is very
suboptimal, because a) lockd needs to poke into locks.c internals, and
b) it needs to iterate over all locks in the system for marking locks
granted or reclaimable.
This patch adds lists for granted and reclaimable locks to the nlm_host
structure instead, and adds locks to those.
nlmclnt_lock:
now adds the lock to h_granted instead of setting the
NFS_LCK_GRANTED, still O(1)
nlmclnt_mark_reclaim:
goes away completely, replaced by a list_splice_init.
Complexity reduced from O(locks in the system) to O(1)
reclaimer:
iterates over h_reclaim now, complexity reduced from
O(locks in the system) to O(locks per nlm_host)
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Diffstat (limited to 'fs/lockd/clntlock.c')
-rw-r--r-- | fs/lockd/clntlock.c | 54 |
1 files changed, 9 insertions, 45 deletions
diff --git a/fs/lockd/clntlock.c b/fs/lockd/clntlock.c index 8ae79ae4b998..0fc0ee267b04 100644 --- a/fs/lockd/clntlock.c +++ b/fs/lockd/clntlock.c | |||
@@ -155,34 +155,6 @@ u32 nlmclnt_grant(const struct sockaddr_in *addr, const struct nlm_lock *lock) | |||
155 | */ | 155 | */ |
156 | 156 | ||
157 | /* | 157 | /* |
158 | * Mark the locks for reclaiming. | ||
159 | * FIXME: In 2.5 we don't want to iterate through any global file_lock_list. | ||
160 | * Maintain NLM lock reclaiming lists in the nlm_host instead. | ||
161 | */ | ||
162 | static | ||
163 | void nlmclnt_mark_reclaim(struct nlm_host *host) | ||
164 | { | ||
165 | struct file_lock *fl; | ||
166 | struct inode *inode; | ||
167 | struct list_head *tmp; | ||
168 | |||
169 | list_for_each(tmp, &file_lock_list) { | ||
170 | fl = list_entry(tmp, struct file_lock, fl_link); | ||
171 | |||
172 | inode = fl->fl_file->f_dentry->d_inode; | ||
173 | if (inode->i_sb->s_magic != NFS_SUPER_MAGIC) | ||
174 | continue; | ||
175 | if (fl->fl_u.nfs_fl.owner == NULL) | ||
176 | continue; | ||
177 | if (fl->fl_u.nfs_fl.owner->host != host) | ||
178 | continue; | ||
179 | if (!(fl->fl_u.nfs_fl.flags & NFS_LCK_GRANTED)) | ||
180 | continue; | ||
181 | fl->fl_u.nfs_fl.flags |= NFS_LCK_RECLAIM; | ||
182 | } | ||
183 | } | ||
184 | |||
185 | /* | ||
186 | * Someone has sent us an SM_NOTIFY. Ensure we bind to the new port number, | 158 | * Someone has sent us an SM_NOTIFY. Ensure we bind to the new port number, |
187 | * that we mark locks for reclaiming, and that we bump the pseudo NSM state. | 159 | * that we mark locks for reclaiming, and that we bump the pseudo NSM state. |
188 | */ | 160 | */ |
@@ -194,7 +166,12 @@ void nlmclnt_prepare_reclaim(struct nlm_host *host, u32 newstate) | |||
194 | host->h_state++; | 166 | host->h_state++; |
195 | host->h_nextrebind = 0; | 167 | host->h_nextrebind = 0; |
196 | nlm_rebind_host(host); | 168 | nlm_rebind_host(host); |
197 | nlmclnt_mark_reclaim(host); | 169 | |
170 | /* | ||
171 | * Mark the locks for reclaiming. | ||
172 | */ | ||
173 | list_splice_init(&host->h_granted, &host->h_reclaim); | ||
174 | |||
198 | dprintk("NLM: reclaiming locks for host %s", host->h_name); | 175 | dprintk("NLM: reclaiming locks for host %s", host->h_name); |
199 | } | 176 | } |
200 | 177 | ||
@@ -223,9 +200,7 @@ reclaimer(void *ptr) | |||
223 | { | 200 | { |
224 | struct nlm_host *host = (struct nlm_host *) ptr; | 201 | struct nlm_host *host = (struct nlm_host *) ptr; |
225 | struct nlm_wait *block; | 202 | struct nlm_wait *block; |
226 | struct list_head *tmp; | 203 | struct file_lock *fl, *next; |
227 | struct file_lock *fl; | ||
228 | struct inode *inode; | ||
229 | 204 | ||
230 | daemonize("%s-reclaim", host->h_name); | 205 | daemonize("%s-reclaim", host->h_name); |
231 | allow_signal(SIGKILL); | 206 | allow_signal(SIGKILL); |
@@ -237,20 +212,9 @@ reclaimer(void *ptr) | |||
237 | 212 | ||
238 | /* First, reclaim all locks that have been marked. */ | 213 | /* First, reclaim all locks that have been marked. */ |
239 | restart: | 214 | restart: |
240 | list_for_each(tmp, &file_lock_list) { | 215 | list_for_each_entry_safe(fl, next, &host->h_reclaim, fl_u.nfs_fl.list) { |
241 | fl = list_entry(tmp, struct file_lock, fl_link); | 216 | list_del(&fl->fl_u.nfs_fl.list); |
242 | |||
243 | inode = fl->fl_file->f_dentry->d_inode; | ||
244 | if (inode->i_sb->s_magic != NFS_SUPER_MAGIC) | ||
245 | continue; | ||
246 | if (fl->fl_u.nfs_fl.owner == NULL) | ||
247 | continue; | ||
248 | if (fl->fl_u.nfs_fl.owner->host != host) | ||
249 | continue; | ||
250 | if (!(fl->fl_u.nfs_fl.flags & NFS_LCK_RECLAIM)) | ||
251 | continue; | ||
252 | 217 | ||
253 | fl->fl_u.nfs_fl.flags &= ~NFS_LCK_RECLAIM; | ||
254 | nlmclnt_reclaim(host, fl); | 218 | nlmclnt_reclaim(host, fl); |
255 | if (signalled()) | 219 | if (signalled()) |
256 | break; | 220 | break; |