public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH] zisofs use mutex instead of semaphore
  2007-07-17  8:54 [PATCH] zisofs use mutex instead of semaphore Dave Young
@ 2007-07-17  1:39 ` H. Peter Anvin
  0 siblings, 0 replies; 2+ messages in thread
From: H. Peter Anvin @ 2007-07-17  1:39 UTC (permalink / raw)
  To: Dave Young; +Cc: linux-kernel, akpm

Dave Young wrote:
> Hi,
> 
> Use mutex instead of semaphore in fs/isofs/compress.c, and remove a
> unnecessary variable.
> 
> Signed-off-by: Dave Young <hidave.darkstar@gmail.com> 

Acked-by: H. Peter Anvin <hpa@zytor.com>

^ permalink raw reply	[flat|nested] 2+ messages in thread

* [PATCH] zisofs use mutex instead of semaphore
@ 2007-07-17  8:54 Dave Young
  2007-07-17  1:39 ` H. Peter Anvin
  0 siblings, 1 reply; 2+ messages in thread
From: Dave Young @ 2007-07-17  8:54 UTC (permalink / raw)
  To: linux-kernel; +Cc: akpm

Hi,

Use mutex instead of semaphore in fs/isofs/compress.c, and remove a
unnecessary variable.

Signed-off-by: Dave Young <hidave.darkstar@gmail.com> 

---
fs/isofs/compress.c |   25 +++++--------------------
1 file changed, 5 insertions(+), 20 deletions(-)

diff -upr linux/fs/isofs/compress.c linux.new/fs/isofs/compress.c
--- linux/fs/isofs/compress.c	2007-07-17 08:39:05.000000000 +0000
+++ linux.new/fs/isofs/compress.c	2007-07-17 08:37:42.000000000 +0000
@@ -33,7 +33,7 @@ static char zisofs_sink_page[PAGE_CACHE_
  * allocation; this avoids failures at block-decompression time.
  */
 static void *zisofs_zlib_workspace;
-static struct semaphore zisofs_zlib_semaphore;
+static DEFINE_MUTEX(zisofs_zlib_lock);
 
 /*
  * When decompressing, we typically obtain more than one page
@@ -180,9 +180,9 @@ static int zisofs_readpage(struct file *
 
 		/* First block is special since it may be fractional.
 		   We also wait for it before grabbing the zlib
-		   semaphore; odds are that the subsequent blocks are
+		   mutex; odds are that the subsequent blocks are
 		   going to come in in short order so we don't hold
-		   the zlib semaphore longer than necessary. */
+		   the zlib mutex longer than necessary. */
 
 		if ( !bh || (wait_on_buffer(bh), !buffer_uptodate(bh)) ) {
 			printk(KERN_DEBUG "zisofs: Hit null buffer, fpage = %d, xpage = %d, csize = %ld\n",
@@ -194,7 +194,7 @@ static int zisofs_readpage(struct file *
 		csize -= stream.avail_in;
 
 		stream.workspace = zisofs_zlib_workspace;
-		down(&zisofs_zlib_semaphore);
+		mutex_lock(&zisofs_zlib_lock);
 		
 		zerr = zlib_inflateInit(&stream);
 		if ( zerr != Z_OK ) {
@@ -281,7 +281,7 @@ static int zisofs_readpage(struct file *
 		zlib_inflateEnd(&stream);
 
 	z_eio:
-		up(&zisofs_zlib_semaphore);
+		mutex_unlock(&zisofs_zlib_lock);
 
 	b_eio:
 		for ( i = 0 ; i < haveblocks ; i++ ) {
@@ -317,31 +317,16 @@ const struct address_space_operations zi
 	/* No bmap operation supported */
 };
 
-static int initialized;
-
 int __init zisofs_init(void)
 {
-	if ( initialized ) {
-		printk("zisofs_init: called more than once\n");
-		return 0;
-	}
-
 	zisofs_zlib_workspace = vmalloc(zlib_inflate_workspacesize());
 	if ( !zisofs_zlib_workspace )
 		return -ENOMEM;
-	init_MUTEX(&zisofs_zlib_semaphore);
 
-	initialized = 1;
 	return 0;
 }
 
 void zisofs_cleanup(void)
 {
-	if ( !initialized ) {
-		printk("zisofs_cleanup: called without initialization\n");
-		return;
-	}
-
 	vfree(zisofs_zlib_workspace);
-	initialized = 0;
 }

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-07-17  1:39 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-07-17  8:54 [PATCH] zisofs use mutex instead of semaphore Dave Young
2007-07-17  1:39 ` H. Peter Anvin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox