diff options
Diffstat (limited to 'fs/nfs/nfs4proc.c')
-rw-r--r-- | fs/nfs/nfs4proc.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c index c9618080317e..b6308f6740ec 100644 --- a/fs/nfs/nfs4proc.c +++ b/fs/nfs/nfs4proc.c | |||
@@ -274,6 +274,42 @@ static void renew_lease(const struct nfs_server *server, unsigned long timestamp | |||
274 | #if defined(CONFIG_NFS_V4_1) | 274 | #if defined(CONFIG_NFS_V4_1) |
275 | 275 | ||
276 | /* | 276 | /* |
277 | * nfs4_free_slot - free a slot and efficiently update slot table. | ||
278 | * | ||
279 | * freeing a slot is trivially done by clearing its respective bit | ||
280 | * in the bitmap. | ||
281 | * If the freed slotid equals highest_used_slotid we want to update it | ||
282 | * so that the server would be able to size down the slot table if needed, | ||
283 | * otherwise we know that the highest_used_slotid is still in use. | ||
284 | * When updating highest_used_slotid there may be "holes" in the bitmap | ||
285 | * so we need to scan down from highest_used_slotid to 0 looking for the now | ||
286 | * highest slotid in use. | ||
287 | * If none found, highest_used_slotid is set to -1. | ||
288 | */ | ||
289 | static void | ||
290 | nfs4_free_slot(struct nfs4_slot_table *tbl, u8 free_slotid) | ||
291 | { | ||
292 | int slotid = free_slotid; | ||
293 | |||
294 | spin_lock(&tbl->slot_tbl_lock); | ||
295 | /* clear used bit in bitmap */ | ||
296 | __clear_bit(slotid, tbl->used_slots); | ||
297 | |||
298 | /* update highest_used_slotid when it is freed */ | ||
299 | if (slotid == tbl->highest_used_slotid) { | ||
300 | slotid = find_last_bit(tbl->used_slots, tbl->max_slots); | ||
301 | if (slotid >= 0 && slotid < tbl->max_slots) | ||
302 | tbl->highest_used_slotid = slotid; | ||
303 | else | ||
304 | tbl->highest_used_slotid = -1; | ||
305 | } | ||
306 | rpc_wake_up_next(&tbl->slot_tbl_waitq); | ||
307 | spin_unlock(&tbl->slot_tbl_lock); | ||
308 | dprintk("%s: free_slotid %u highest_used_slotid %d\n", __func__, | ||
309 | free_slotid, tbl->highest_used_slotid); | ||
310 | } | ||
311 | |||
312 | /* | ||
277 | * nfs4_find_slot - efficiently look for a free slot | 313 | * nfs4_find_slot - efficiently look for a free slot |
278 | * | 314 | * |
279 | * nfs4_find_slot looks for an unset bit in the used_slots bitmap. | 315 | * nfs4_find_slot looks for an unset bit in the used_slots bitmap. |