From 7e24387fa3689af2ab811ca2c114f7c4e06eaba8 Mon Sep 17 00:00:00 2001 From: Ajeet Yadav Date: Tue, 27 Dec 2011 15:10:04 +0530 Subject: [PATCH] --- yaml --- r: 284470 b: refs/heads/master c: d7fbd893388d9e86d29b7cfbd5457bcf03496fbf h: refs/heads/master v: v3 --- [refs] | 2 +- trunk/fs/squashfs/cache.c | 11 ++++++++--- trunk/fs/squashfs/squashfs_fs_sb.h | 1 + 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/[refs] b/[refs] index 0e2647060572..edd5345843e8 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: 89cab5b5727d3139adc247e3a3d4ee5b10e3eda5 +refs/heads/master: d7fbd893388d9e86d29b7cfbd5457bcf03496fbf diff --git a/trunk/fs/squashfs/cache.c b/trunk/fs/squashfs/cache.c index ea6e798e548b..af0b73802592 100644 --- a/trunk/fs/squashfs/cache.c +++ b/trunk/fs/squashfs/cache.c @@ -70,11 +70,15 @@ struct squashfs_cache_entry *squashfs_cache_get(struct super_block *sb, spin_lock(&cache->lock); while (1) { - for (i = 0; i < cache->entries; i++) - if (cache->entry[i].block == block) + for (i = cache->curr_blk, n = 0; n < cache->entries; n++) { + if (cache->entry[i].block == block) { + cache->curr_blk = i; break; + } + i = (i + 1) % cache->entries; + } - if (i == cache->entries) { + if (n == cache->entries) { /* * Block not in cache, if all cache entries are used * go to sleep waiting for one to become available. @@ -245,6 +249,7 @@ struct squashfs_cache *squashfs_cache_init(char *name, int entries, goto cleanup; } + cache->curr_blk = 0; cache->next_blk = 0; cache->unused = entries; cache->entries = entries; diff --git a/trunk/fs/squashfs/squashfs_fs_sb.h b/trunk/fs/squashfs/squashfs_fs_sb.h index 651f0b31d296..52934a22f296 100644 --- a/trunk/fs/squashfs/squashfs_fs_sb.h +++ b/trunk/fs/squashfs/squashfs_fs_sb.h @@ -28,6 +28,7 @@ struct squashfs_cache { char *name; int entries; + int curr_blk; int next_blk; int num_waiters; int unused;