[patch 04/10] hfs: Convert tree_lock to mutex

Thomas Gleixner
2010-01-29T20:39:16Z

[-- Attachment #1: hfs-convert-sema.patch --]
[-- Type: text/plain, Size: 1871 bytes --]

The tree_lock semaphore is used as mutex. Convert it to a real mutex.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>
---
fs/hfs/bfind.c | 4 ++--
fs/hfs/btree.c | 2 +-
fs/hfs/btree.h | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)

Index: linux-2.6-tip/fs/hfs/bfind.c
===================================================================
--- linux-2.6-tip.orig/fs/hfs/bfind.c
+++ linux-2.6-tip/fs/hfs/bfind.c
@@ -23,7 +23,7 @@ int hfs_find_init(struct hfs_btree *tree
fd->search_key = ptr;
fd->key = ptr + tree->max_key_len + 2;
dprint(DBG_BNODE_REFS, "find_init: %d (%p)\n", tree->cnid, __builtin_return_address(0));
- down(&tree->tree_lock);
+ mutex_lock(&tree->tree_lock);
return 0;
}

@@ -32,7 +32,7 @@ void hfs_find_exit(struct hfs_find_data
hfs_bnode_put(fd->bnode);
kfree(fd->search_key);
dprint(DBG_BNODE_REFS, "find_exit: %d (%p)\n", fd->tree->cnid, __builtin_return_address(0));
- up(&fd->tree->tree_lock);
+ mutex_unlock(&fd->tree->tree_lock);
fd->tree = NULL;
}

Index: linux-2.6-tip/fs/hfs/btree.c
===================================================================
--- linux-2.6-tip.orig/fs/hfs/btree.c
+++ linux-2.6-tip/fs/hfs/btree.c
@@ -26,7 +26,7 @@ struct hfs_btree *hfs_btree_open(struct
if (!tree)
return NULL;

- init_MUTEX(&tree->tree_lock);
+ mutex_init(&tree->tree_lock);
spin_lock_init(&tree->hash_lock);
/* Set the correct compare function */
tree->sb = sb;
Index: linux-2.6-tip/fs/hfs/btree.h
===================================================================
--- linux-2.6-tip.orig/fs/hfs/btree.h
+++ linux-2.6-tip/fs/hfs/btree.h
@@ -33,7 +33,7 @@ struct hfs_btree {
unsigned int depth;

//unsigned int map1_size, map_size;
- struct semaphore tree_lock;
+ struct mutex tree_lock;

unsigned int pages_per_bnode;
spinlock_t hash_lock;