public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [patch 0/2] HFS: Convert bitmap_lock and extents_lock in mutexes
@ 2008-05-11 17:43 matthias
  2008-05-11 17:43 ` [patch 1/2] HFS: Convert bitmap_lock in a mutex matthias
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: matthias @ 2008-05-11 17:43 UTC (permalink / raw)
  To: zippel; +Cc: linux-kernel, akpm

Apple Macintosh file system: The semaphores bitmap_lock and extents_lock are used as mutexes. Convert them to the mutex API

-- 
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona

              We build too many walls and not enough bridges
                             (Isaac Newton)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

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

* [patch 1/2] HFS: Convert bitmap_lock in a mutex
  2008-05-11 17:43 [patch 0/2] HFS: Convert bitmap_lock and extents_lock in mutexes matthias
@ 2008-05-11 17:43 ` matthias
  2008-05-11 18:15   ` Matthias Kaehlcke
  2008-05-11 17:43 ` [patch 2/2] HFS: Convert extents_lock " matthias
  2008-05-11 18:06 ` [patch 0/2] HFS: Convert bitmap_lock and extents_lock in mutexes Matthias Kaehlcke
  2 siblings, 1 reply; 6+ messages in thread
From: matthias @ 2008-05-11 17:43 UTC (permalink / raw)
  To: zippel; +Cc: linux-kernel, akpm, Matthias Kaehlcke

[-- Attachment #1: fs-hfs-bitmap_lock-to-mutex.diff --]
[-- Type: text/plain, Size: 2568 bytes --]

Apple Macintosh file system: The semaphore bitmap_lock is used as a mutex. 
Convert it to the mutex API

Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>


Index: hfs/bitmap.c
===================================================================
--- hfs.orig/bitmap.c	2008-05-11 19:10:19.000000000 +0200
+++ hfs/bitmap.c	2008-05-11 19:11:17.000000000 +0200
@@ -145,7 +145,7 @@
 	if (!*num_bits)
 		return 0;
 
-	down(&HFS_SB(sb)->bitmap_lock);
+	mutex_lock(&HFS_SB(sb)->bitmap_lock);
 	bitmap = HFS_SB(sb)->bitmap;
 
 	pos = hfs_find_set_zero_bits(bitmap, HFS_SB(sb)->fs_ablocks, goal, num_bits);
@@ -162,7 +162,7 @@
 	HFS_SB(sb)->free_ablocks -= *num_bits;
 	hfs_bitmap_dirty(sb);
 out:
-	up(&HFS_SB(sb)->bitmap_lock);
+	mutex_unlock(&HFS_SB(sb)->bitmap_lock);
 	return pos;
 }
 
@@ -205,7 +205,7 @@
 	if ((start + count) > HFS_SB(sb)->fs_ablocks)
 		return -2;
 
-	down(&HFS_SB(sb)->bitmap_lock);
+	mutex_lock(&HFS_SB(sb)->bitmap_lock);
 	/* bitmap is always on a 32-bit boundary */
 	curr = HFS_SB(sb)->bitmap + (start / 32);
 	len = count;
@@ -236,7 +236,7 @@
 	}
 out:
 	HFS_SB(sb)->free_ablocks += len;
-	up(&HFS_SB(sb)->bitmap_lock);
+	mutex_unlock(&HFS_SB(sb)->bitmap_lock);
 	hfs_bitmap_dirty(sb);
 
 	return 0;
Index: hfs/hfs_fs.h
===================================================================
--- hfs.orig/hfs_fs.h	2008-05-11 19:10:40.000000000 +0200
+++ hfs/hfs_fs.h	2008-05-11 19:11:58.000000000 +0200
@@ -11,6 +11,7 @@
 
 #include <linux/slab.h>
 #include <linux/types.h>
+#include <linux/mutex.h>
 #include <linux/buffer_head.h>
 #include <linux/fs.h>
 
@@ -139,7 +140,7 @@
 
 	struct nls_table *nls_io, *nls_disk;
 
-	struct semaphore bitmap_lock;
+	struct mutex bitmap_lock;
 
 	unsigned long flags;
 
Index: hfs/super.c
===================================================================
--- hfs.orig/super.c	2008-05-11 19:10:34.000000000 +0200
+++ hfs/super.c	2008-05-11 19:12:13.000000000 +0200
@@ -372,7 +372,7 @@
 
 	sb->s_op = &hfs_super_operations;
 	sb->s_flags |= MS_NODIRATIME;
-	init_MUTEX(&sbi->bitmap_lock);
+	mutex_init(&sbi->bitmap_lock);
 
 	res = hfs_mdb_get(sb);
 	if (res) {

-- 
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona

              We build too many walls and not enough bridges
                             (Isaac Newton)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

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

* [patch 2/2] HFS: Convert extents_lock in a mutex
  2008-05-11 17:43 [patch 0/2] HFS: Convert bitmap_lock and extents_lock in mutexes matthias
  2008-05-11 17:43 ` [patch 1/2] HFS: Convert bitmap_lock in a mutex matthias
@ 2008-05-11 17:43 ` matthias
  2008-05-11 18:16   ` Matthias Kaehlcke
  2008-05-11 18:06 ` [patch 0/2] HFS: Convert bitmap_lock and extents_lock in mutexes Matthias Kaehlcke
  2 siblings, 1 reply; 6+ messages in thread
From: matthias @ 2008-05-11 17:43 UTC (permalink / raw)
  To: zippel; +Cc: linux-kernel, akpm, Matthias Kaehlcke

[-- Attachment #1: fs-hfs-extents_lock-to-mutex.diff --]
[-- Type: text/plain, Size: 3922 bytes --]

Apple Macintosh file system: The semaphore extens_lock is used as a mutex.
Convert it to the mutex API

Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>

Index: hfs/btree.c
===================================================================
--- hfs.orig/btree.c	2008-05-11 19:28:16.000000000 +0200
+++ hfs/btree.c	2008-05-11 19:28:46.000000000 +0200
@@ -40,7 +40,7 @@
 	{
 	struct hfs_mdb *mdb = HFS_SB(sb)->mdb;
 	HFS_I(tree->inode)->flags = 0;
-	init_MUTEX(&HFS_I(tree->inode)->extents_lock);
+	mutex_init(&HFS_I(tree->inode)->extents_lock);
 	switch (id) {
 	case HFS_EXT_CNID:
 		hfs_inode_read_fork(tree->inode, mdb->drXTExtRec, mdb->drXTFlSize,
Index: hfs/extent.c
===================================================================
--- hfs.orig/extent.c	2008-05-11 19:28:16.000000000 +0200
+++ hfs/extent.c	2008-05-11 19:29:43.000000000 +0200
@@ -343,16 +343,16 @@
 		goto done;
 	}
 
-	down(&HFS_I(inode)->extents_lock);
+	mutex_lock(&HFS_I(inode)->extents_lock);
 	res = hfs_ext_read_extent(inode, ablock);
 	if (!res)
 		dblock = hfs_ext_find_block(HFS_I(inode)->cached_extents,
 					    ablock - HFS_I(inode)->cached_start);
 	else {
-		up(&HFS_I(inode)->extents_lock);
+		mutex_unlock(&HFS_I(inode)->extents_lock);
 		return -EIO;
 	}
-	up(&HFS_I(inode)->extents_lock);
+	mutex_unlock(&HFS_I(inode)->extents_lock);
 
 done:
 	map_bh(bh_result, sb, HFS_SB(sb)->fs_start +
@@ -375,7 +375,7 @@
 	u32 start, len, goal;
 	int res;
 
-	down(&HFS_I(inode)->extents_lock);
+	mutex_lock(&HFS_I(inode)->extents_lock);
 	if (HFS_I(inode)->alloc_blocks == HFS_I(inode)->first_blocks)
 		goal = hfs_ext_lastblock(HFS_I(inode)->first_extents);
 	else {
@@ -425,7 +425,7 @@
 			goto insert_extent;
 	}
 out:
-	up(&HFS_I(inode)->extents_lock);
+	mutex_unlock(&HFS_I(inode)->extents_lock);
 	if (!res) {
 		HFS_I(inode)->alloc_blocks += len;
 		mark_inode_dirty(inode);
@@ -487,7 +487,7 @@
 	if (blk_cnt == alloc_cnt)
 		goto out;
 
-	down(&HFS_I(inode)->extents_lock);
+	mutex_lock(&HFS_I(inode)->extents_lock);
 	hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
 	while (1) {
 		if (alloc_cnt == HFS_I(inode)->first_blocks) {
@@ -514,7 +514,7 @@
 		hfs_brec_remove(&fd);
 	}
 	hfs_find_exit(&fd);
-	up(&HFS_I(inode)->extents_lock);
+	mutex_unlock(&HFS_I(inode)->extents_lock);
 
 	HFS_I(inode)->alloc_blocks = blk_cnt;
 out:
Index: hfs/hfs_fs.h
===================================================================
--- hfs.orig/hfs_fs.h	2008-05-11 19:28:17.000000000 +0200
+++ hfs/hfs_fs.h	2008-05-11 19:30:11.000000000 +0200
@@ -54,7 +54,7 @@
 	struct list_head open_dir_list;
 	struct inode *rsrc_inode;
 
-	struct semaphore extents_lock;
+	struct mutex extents_lock;
 
 	u16 alloc_blocks, clump_blocks;
 	sector_t fs_blocks;
Index: hfs/inode.c
===================================================================
--- hfs.orig/inode.c	2008-05-11 19:28:17.000000000 +0200
+++ hfs/inode.c	2008-05-11 19:30:44.000000000 +0200
@@ -150,7 +150,7 @@
 	if (!inode)
 		return NULL;
 
-	init_MUTEX(&HFS_I(inode)->extents_lock);
+	mutex_init(&HFS_I(inode)->extents_lock);
 	INIT_LIST_HEAD(&HFS_I(inode)->open_dir_list);
 	hfs_cat_build_key(sb, (btree_key *)&HFS_I(inode)->cat_key, dir->i_ino, name);
 	inode->i_ino = HFS_SB(sb)->next_id++;
@@ -281,7 +281,7 @@
 
 	HFS_I(inode)->flags = 0;
 	HFS_I(inode)->rsrc_inode = NULL;
-	init_MUTEX(&HFS_I(inode)->extents_lock);
+	mutex_init(&HFS_I(inode)->extents_lock);
 	INIT_LIST_HEAD(&HFS_I(inode)->open_dir_list);
 
 	/* Initialize the inode */

-- 
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona

              We build too many walls and not enough bridges
                             (Isaac Newton)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

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

* Re: [patch 0/2] HFS: Convert bitmap_lock and extents_lock in mutexes
  2008-05-11 17:43 [patch 0/2] HFS: Convert bitmap_lock and extents_lock in mutexes matthias
  2008-05-11 17:43 ` [patch 1/2] HFS: Convert bitmap_lock in a mutex matthias
  2008-05-11 17:43 ` [patch 2/2] HFS: Convert extents_lock " matthias
@ 2008-05-11 18:06 ` Matthias Kaehlcke
  2 siblings, 0 replies; 6+ messages in thread
From: Matthias Kaehlcke @ 2008-05-11 18:06 UTC (permalink / raw)
  To: zippel; +Cc: linux-kernel, akpm

El Sun, May 11, 2008 at 07:43:31PM +0200 matthias@kaehlcke.net ha dit:

> Apple Macintosh file system: The semaphores bitmap_lock and extents_lock are used as mutexes. Convert them to the mutex API

sorry, i just realized that the patches use relative paths. i'm going
to submit a fix

-- 
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona


   Usually when people are sad, they don't do anything. They just cry over
     their condition. But when they get angry, they bring about a change
                              (Malcolm X)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

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

* Re: [patch 1/2] HFS: Convert bitmap_lock in a mutex
  2008-05-11 17:43 ` [patch 1/2] HFS: Convert bitmap_lock in a mutex matthias
@ 2008-05-11 18:15   ` Matthias Kaehlcke
  0 siblings, 0 replies; 6+ messages in thread
From: Matthias Kaehlcke @ 2008-05-11 18:15 UTC (permalink / raw)
  To: zippel; +Cc: linux-kernel, akpm

Apple Macintosh file system: The semaphore bitmap_lock is used as a mutex. 
Convert it to the mutex API

Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>

--

Index: linux-2.6/fs/hfs/bitmap.c
===================================================================
--- linux-2.6.orig/fs/hfs/bitmap.c	2008-05-11 20:10:11.000000000 +0200
+++ linux-2.6/fs/hfs/bitmap.c	2008-05-11 20:10:18.000000000 +0200
@@ -145,7 +145,7 @@
 	if (!*num_bits)
 		return 0;
 
-	down(&HFS_SB(sb)->bitmap_lock);
+	mutex_lock(&HFS_SB(sb)->bitmap_lock);
 	bitmap = HFS_SB(sb)->bitmap;
 
 	pos = hfs_find_set_zero_bits(bitmap, HFS_SB(sb)->fs_ablocks, goal, num_bits);
@@ -162,7 +162,7 @@
 	HFS_SB(sb)->free_ablocks -= *num_bits;
 	hfs_bitmap_dirty(sb);
 out:
-	up(&HFS_SB(sb)->bitmap_lock);
+	mutex_unlock(&HFS_SB(sb)->bitmap_lock);
 	return pos;
 }
 
@@ -205,7 +205,7 @@
 	if ((start + count) > HFS_SB(sb)->fs_ablocks)
 		return -2;
 
-	down(&HFS_SB(sb)->bitmap_lock);
+	mutex_lock(&HFS_SB(sb)->bitmap_lock);
 	/* bitmap is always on a 32-bit boundary */
 	curr = HFS_SB(sb)->bitmap + (start / 32);
 	len = count;
@@ -236,7 +236,7 @@
 	}
 out:
 	HFS_SB(sb)->free_ablocks += len;
-	up(&HFS_SB(sb)->bitmap_lock);
+	mutex_unlock(&HFS_SB(sb)->bitmap_lock);
 	hfs_bitmap_dirty(sb);
 
 	return 0;
Index: linux-2.6/fs/hfs/hfs_fs.h
===================================================================
--- linux-2.6.orig/fs/hfs/hfs_fs.h	2008-05-11 20:10:11.000000000 +0200
+++ linux-2.6/fs/hfs/hfs_fs.h	2008-05-11 20:14:08.000000000 +0200
@@ -11,6 +11,7 @@
 
 #include <linux/slab.h>
 #include <linux/types.h>
+#include <linux/mutex.h>
 #include <linux/buffer_head.h>
 #include <linux/fs.h>
 
@@ -139,7 +140,7 @@
 
 	struct nls_table *nls_io, *nls_disk;
 
-	struct semaphore bitmap_lock;
+	struct mutex bitmap_lock;
 
 	unsigned long flags;
 
Index: linux-2.6/fs/hfs/super.c
===================================================================
--- linux-2.6.orig/fs/hfs/super.c	2008-05-11 20:10:11.000000000 +0200
+++ linux-2.6/fs/hfs/super.c	2008-05-11 20:10:18.000000000 +0200
@@ -372,7 +372,7 @@
 
 	sb->s_op = &hfs_super_operations;
 	sb->s_flags |= MS_NODIRATIME;
-	init_MUTEX(&sbi->bitmap_lock);
+	mutex_init(&sbi->bitmap_lock);
 
 	res = hfs_mdb_get(sb);
 	if (res) {

-- 
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona

              La posibilidad de realizar un suenyo es lo
                 que hace que la vida sea interesante
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

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

* Re: [patch 2/2] HFS: Convert extents_lock in a mutex
  2008-05-11 17:43 ` [patch 2/2] HFS: Convert extents_lock " matthias
@ 2008-05-11 18:16   ` Matthias Kaehlcke
  0 siblings, 0 replies; 6+ messages in thread
From: Matthias Kaehlcke @ 2008-05-11 18:16 UTC (permalink / raw)
  To: zippel; +Cc: linux-kernel, akpm

Apple Macintosh file system: The semaphore extens_lock is used as a mutex.
Convert it to the mutex API
 
Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>

--

Index: linux-2.6/fs/hfs/btree.c
===================================================================
--- linux-2.6.orig/fs/hfs/btree.c	2008-05-11 20:11:54.000000000 +0200
+++ linux-2.6/fs/hfs/btree.c	2008-05-11 20:11:59.000000000 +0200
@@ -40,7 +40,7 @@
 	{
 	struct hfs_mdb *mdb = HFS_SB(sb)->mdb;
 	HFS_I(tree->inode)->flags = 0;
-	init_MUTEX(&HFS_I(tree->inode)->extents_lock);
+	mutex_init(&HFS_I(tree->inode)->extents_lock);
 	switch (id) {
 	case HFS_EXT_CNID:
 		hfs_inode_read_fork(tree->inode, mdb->drXTExtRec, mdb->drXTFlSize,
Index: linux-2.6/fs/hfs/extent.c
===================================================================
--- linux-2.6.orig/fs/hfs/extent.c	2008-05-11 20:11:54.000000000 +0200
+++ linux-2.6/fs/hfs/extent.c	2008-05-11 20:11:59.000000000 +0200
@@ -343,16 +343,16 @@
 		goto done;
 	}
 
-	down(&HFS_I(inode)->extents_lock);
+	mutex_lock(&HFS_I(inode)->extents_lock);
 	res = hfs_ext_read_extent(inode, ablock);
 	if (!res)
 		dblock = hfs_ext_find_block(HFS_I(inode)->cached_extents,
 					    ablock - HFS_I(inode)->cached_start);
 	else {
-		up(&HFS_I(inode)->extents_lock);
+		mutex_unlock(&HFS_I(inode)->extents_lock);
 		return -EIO;
 	}
-	up(&HFS_I(inode)->extents_lock);
+	mutex_unlock(&HFS_I(inode)->extents_lock);
 
 done:
 	map_bh(bh_result, sb, HFS_SB(sb)->fs_start +
@@ -375,7 +375,7 @@
 	u32 start, len, goal;
 	int res;
 
-	down(&HFS_I(inode)->extents_lock);
+	mutex_lock(&HFS_I(inode)->extents_lock);
 	if (HFS_I(inode)->alloc_blocks == HFS_I(inode)->first_blocks)
 		goal = hfs_ext_lastblock(HFS_I(inode)->first_extents);
 	else {
@@ -425,7 +425,7 @@
 			goto insert_extent;
 	}
 out:
-	up(&HFS_I(inode)->extents_lock);
+	mutex_unlock(&HFS_I(inode)->extents_lock);
 	if (!res) {
 		HFS_I(inode)->alloc_blocks += len;
 		mark_inode_dirty(inode);
@@ -487,7 +487,7 @@
 	if (blk_cnt == alloc_cnt)
 		goto out;
 
-	down(&HFS_I(inode)->extents_lock);
+	mutex_lock(&HFS_I(inode)->extents_lock);
 	hfs_find_init(HFS_SB(sb)->ext_tree, &fd);
 	while (1) {
 		if (alloc_cnt == HFS_I(inode)->first_blocks) {
@@ -514,7 +514,7 @@
 		hfs_brec_remove(&fd);
 	}
 	hfs_find_exit(&fd);
-	up(&HFS_I(inode)->extents_lock);
+	mutex_unlock(&HFS_I(inode)->extents_lock);
 
 	HFS_I(inode)->alloc_blocks = blk_cnt;
 out:
Index: linux-2.6/fs/hfs/hfs_fs.h
===================================================================
--- linux-2.6.orig/fs/hfs/hfs_fs.h	2008-05-11 20:11:54.000000000 +0200
+++ linux-2.6/fs/hfs/hfs_fs.h	2008-05-11 20:11:59.000000000 +0200
@@ -54,7 +54,7 @@
 	struct list_head open_dir_list;
 	struct inode *rsrc_inode;
 
-	struct semaphore extents_lock;
+	struct mutex extents_lock;
 
 	u16 alloc_blocks, clump_blocks;
 	sector_t fs_blocks;
Index: linux-2.6/fs/hfs/inode.c
===================================================================
--- linux-2.6.orig/fs/hfs/inode.c	2008-05-11 20:11:54.000000000 +0200
+++ linux-2.6/fs/hfs/inode.c	2008-05-11 20:11:59.000000000 +0200
@@ -150,7 +150,7 @@
 	if (!inode)
 		return NULL;
 
-	init_MUTEX(&HFS_I(inode)->extents_lock);
+	mutex_init(&HFS_I(inode)->extents_lock);
 	INIT_LIST_HEAD(&HFS_I(inode)->open_dir_list);
 	hfs_cat_build_key(sb, (btree_key *)&HFS_I(inode)->cat_key, dir->i_ino, name);
 	inode->i_ino = HFS_SB(sb)->next_id++;
@@ -281,7 +281,7 @@
 
 	HFS_I(inode)->flags = 0;
 	HFS_I(inode)->rsrc_inode = NULL;
-	init_MUTEX(&HFS_I(inode)->extents_lock);
+	mutex_init(&HFS_I(inode)->extents_lock);
 	INIT_LIST_HEAD(&HFS_I(inode)->open_dir_list);
 
 	/* Initialize the inode */

-- 
Matthias Kaehlcke
Embedded Linux Engineer
Barcelona

                Don't walk behind me, I may not lead
             Don't walk in front of me, I may not follow
                Just walk beside me and be my friend
                          (Albert Camus)
                                                                 .''`.
    using free software / Debian GNU/Linux | http://debian.org  : :'  :
                                                                `. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4                  `-

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

end of thread, other threads:[~2008-05-11 18:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-05-11 17:43 [patch 0/2] HFS: Convert bitmap_lock and extents_lock in mutexes matthias
2008-05-11 17:43 ` [patch 1/2] HFS: Convert bitmap_lock in a mutex matthias
2008-05-11 18:15   ` Matthias Kaehlcke
2008-05-11 17:43 ` [patch 2/2] HFS: Convert extents_lock " matthias
2008-05-11 18:16   ` Matthias Kaehlcke
2008-05-11 18:06 ` [patch 0/2] HFS: Convert bitmap_lock and extents_lock in mutexes Matthias Kaehlcke

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