diff options
author | Dave Young <hidave.darkstar@gmail.com> | 2007-10-17 02:26:10 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2007-10-17 11:42:47 -0400 |
commit | a36a151e79be1562d6fea3ec4698f23e7102a26f (patch) | |
tree | 78a8b9a5cab718521229b452739ab3f27e0457e1 /fs/isofs | |
parent | 040b5c6f9503f2d6b35c335f8537bb3035d35547 (diff) |
zisofs use mutex instead of semaphore
Use mutex instead of semaphore in fs/isofs/compress.c, and remove an
unnecessary variable.
Signed-off-by: Dave Young <hidave.darkstar@gmail.com>
Acked-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/isofs')
-rw-r--r-- | fs/isofs/compress.c | 25 |
1 files changed, 5 insertions, 20 deletions
diff --git a/fs/isofs/compress.c b/fs/isofs/compress.c index 6bbbdb53581d..37dbd6404787 100644 --- a/fs/isofs/compress.c +++ b/fs/isofs/compress.c | |||
@@ -33,7 +33,7 @@ static char zisofs_sink_page[PAGE_CACHE_SIZE]; | |||
33 | * allocation; this avoids failures at block-decompression time. | 33 | * allocation; this avoids failures at block-decompression time. |
34 | */ | 34 | */ |
35 | static void *zisofs_zlib_workspace; | 35 | static void *zisofs_zlib_workspace; |
36 | static struct semaphore zisofs_zlib_semaphore; | 36 | static DEFINE_MUTEX(zisofs_zlib_lock); |
37 | 37 | ||
38 | /* | 38 | /* |
39 | * When decompressing, we typically obtain more than one page | 39 | * When decompressing, we typically obtain more than one page |
@@ -180,9 +180,9 @@ static int zisofs_readpage(struct file *file, struct page *page) | |||
180 | 180 | ||
181 | /* First block is special since it may be fractional. | 181 | /* First block is special since it may be fractional. |
182 | We also wait for it before grabbing the zlib | 182 | We also wait for it before grabbing the zlib |
183 | semaphore; odds are that the subsequent blocks are | 183 | mutex; odds are that the subsequent blocks are |
184 | going to come in in short order so we don't hold | 184 | going to come in in short order so we don't hold |
185 | the zlib semaphore longer than necessary. */ | 185 | the zlib mutex longer than necessary. */ |
186 | 186 | ||
187 | if ( !bh || (wait_on_buffer(bh), !buffer_uptodate(bh)) ) { | 187 | if ( !bh || (wait_on_buffer(bh), !buffer_uptodate(bh)) ) { |
188 | printk(KERN_DEBUG "zisofs: Hit null buffer, fpage = %d, xpage = %d, csize = %ld\n", | 188 | printk(KERN_DEBUG "zisofs: Hit null buffer, fpage = %d, xpage = %d, csize = %ld\n", |
@@ -194,7 +194,7 @@ static int zisofs_readpage(struct file *file, struct page *page) | |||
194 | csize -= stream.avail_in; | 194 | csize -= stream.avail_in; |
195 | 195 | ||
196 | stream.workspace = zisofs_zlib_workspace; | 196 | stream.workspace = zisofs_zlib_workspace; |
197 | down(&zisofs_zlib_semaphore); | 197 | mutex_lock(&zisofs_zlib_lock); |
198 | 198 | ||
199 | zerr = zlib_inflateInit(&stream); | 199 | zerr = zlib_inflateInit(&stream); |
200 | if ( zerr != Z_OK ) { | 200 | if ( zerr != Z_OK ) { |
@@ -281,7 +281,7 @@ static int zisofs_readpage(struct file *file, struct page *page) | |||
281 | zlib_inflateEnd(&stream); | 281 | zlib_inflateEnd(&stream); |
282 | 282 | ||
283 | z_eio: | 283 | z_eio: |
284 | up(&zisofs_zlib_semaphore); | 284 | mutex_unlock(&zisofs_zlib_lock); |
285 | 285 | ||
286 | b_eio: | 286 | b_eio: |
287 | for ( i = 0 ; i < haveblocks ; i++ ) { | 287 | for ( i = 0 ; i < haveblocks ; i++ ) { |
@@ -317,31 +317,16 @@ const struct address_space_operations zisofs_aops = { | |||
317 | /* No bmap operation supported */ | 317 | /* No bmap operation supported */ |
318 | }; | 318 | }; |
319 | 319 | ||
320 | static int initialized; | ||
321 | |||
322 | int __init zisofs_init(void) | 320 | int __init zisofs_init(void) |
323 | { | 321 | { |
324 | if ( initialized ) { | ||
325 | printk("zisofs_init: called more than once\n"); | ||
326 | return 0; | ||
327 | } | ||
328 | |||
329 | zisofs_zlib_workspace = vmalloc(zlib_inflate_workspacesize()); | 322 | zisofs_zlib_workspace = vmalloc(zlib_inflate_workspacesize()); |
330 | if ( !zisofs_zlib_workspace ) | 323 | if ( !zisofs_zlib_workspace ) |
331 | return -ENOMEM; | 324 | return -ENOMEM; |
332 | init_MUTEX(&zisofs_zlib_semaphore); | ||
333 | 325 | ||
334 | initialized = 1; | ||
335 | return 0; | 326 | return 0; |
336 | } | 327 | } |
337 | 328 | ||
338 | void zisofs_cleanup(void) | 329 | void zisofs_cleanup(void) |
339 | { | 330 | { |
340 | if ( !initialized ) { | ||
341 | printk("zisofs_cleanup: called without initialization\n"); | ||
342 | return; | ||
343 | } | ||
344 | |||
345 | vfree(zisofs_zlib_workspace); | 331 | vfree(zisofs_zlib_workspace); |
346 | initialized = 0; | ||
347 | } | 332 | } |