Sfoglia il codice sorgente

hfsplus: convert the extents_lock in a mutex

Apple Extended HFS file system: The semaphore extents lock is used as a
mutex.  Convert it to the mutex API.

Signed-off-by: Matthias Kaehlcke <matthias@kaehlcke.net>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Matthias Kaehlcke 17 anni fa
parent
commit
895c23f8c3
4 ha cambiato i file con 12 aggiunte e 11 eliminazioni
  1. 7 7
      fs/hfsplus/extents.c
  2. 2 1
      fs/hfsplus/hfsplus_fs.h
  3. 2 2
      fs/hfsplus/inode.c
  4. 1 1
      fs/hfsplus/super.c

+ 7 - 7
fs/hfsplus/extents.c

@@ -199,16 +199,16 @@ int hfsplus_get_block(struct inode *inode, sector_t iblock,
 		goto done;
 		goto done;
 	}
 	}
 
 
-	down(&HFSPLUS_I(inode).extents_lock);
+	mutex_lock(&HFSPLUS_I(inode).extents_lock);
 	res = hfsplus_ext_read_extent(inode, ablock);
 	res = hfsplus_ext_read_extent(inode, ablock);
 	if (!res) {
 	if (!res) {
 		dblock = hfsplus_ext_find_block(HFSPLUS_I(inode).cached_extents, ablock -
 		dblock = hfsplus_ext_find_block(HFSPLUS_I(inode).cached_extents, ablock -
 					     HFSPLUS_I(inode).cached_start);
 					     HFSPLUS_I(inode).cached_start);
 	} else {
 	} else {
-		up(&HFSPLUS_I(inode).extents_lock);
+		mutex_unlock(&HFSPLUS_I(inode).extents_lock);
 		return -EIO;
 		return -EIO;
 	}
 	}
-	up(&HFSPLUS_I(inode).extents_lock);
+	mutex_unlock(&HFSPLUS_I(inode).extents_lock);
 
 
 done:
 done:
 	dprint(DBG_EXTENT, "get_block(%lu): %llu - %u\n", inode->i_ino, (long long)iblock, dblock);
 	dprint(DBG_EXTENT, "get_block(%lu): %llu - %u\n", inode->i_ino, (long long)iblock, dblock);
@@ -355,7 +355,7 @@ int hfsplus_file_extend(struct inode *inode)
 		return -ENOSPC;
 		return -ENOSPC;
 	}
 	}
 
 
-	down(&HFSPLUS_I(inode).extents_lock);
+	mutex_lock(&HFSPLUS_I(inode).extents_lock);
 	if (HFSPLUS_I(inode).alloc_blocks == HFSPLUS_I(inode).first_blocks)
 	if (HFSPLUS_I(inode).alloc_blocks == HFSPLUS_I(inode).first_blocks)
 		goal = hfsplus_ext_lastblock(HFSPLUS_I(inode).first_extents);
 		goal = hfsplus_ext_lastblock(HFSPLUS_I(inode).first_extents);
 	else {
 	else {
@@ -408,7 +408,7 @@ int hfsplus_file_extend(struct inode *inode)
 			goto insert_extent;
 			goto insert_extent;
 	}
 	}
 out:
 out:
-	up(&HFSPLUS_I(inode).extents_lock);
+	mutex_unlock(&HFSPLUS_I(inode).extents_lock);
 	if (!res) {
 	if (!res) {
 		HFSPLUS_I(inode).alloc_blocks += len;
 		HFSPLUS_I(inode).alloc_blocks += len;
 		mark_inode_dirty(inode);
 		mark_inode_dirty(inode);
@@ -465,7 +465,7 @@ void hfsplus_file_truncate(struct inode *inode)
 	if (blk_cnt == alloc_cnt)
 	if (blk_cnt == alloc_cnt)
 		goto out;
 		goto out;
 
 
-	down(&HFSPLUS_I(inode).extents_lock);
+	mutex_lock(&HFSPLUS_I(inode).extents_lock);
 	hfs_find_init(HFSPLUS_SB(sb).ext_tree, &fd);
 	hfs_find_init(HFSPLUS_SB(sb).ext_tree, &fd);
 	while (1) {
 	while (1) {
 		if (alloc_cnt == HFSPLUS_I(inode).first_blocks) {
 		if (alloc_cnt == HFSPLUS_I(inode).first_blocks) {
@@ -492,7 +492,7 @@ void hfsplus_file_truncate(struct inode *inode)
 		hfs_brec_remove(&fd);
 		hfs_brec_remove(&fd);
 	}
 	}
 	hfs_find_exit(&fd);
 	hfs_find_exit(&fd);
-	up(&HFSPLUS_I(inode).extents_lock);
+	mutex_unlock(&HFSPLUS_I(inode).extents_lock);
 
 
 	HFSPLUS_I(inode).alloc_blocks = blk_cnt;
 	HFSPLUS_I(inode).alloc_blocks = blk_cnt;
 out:
 out:

+ 2 - 1
fs/hfsplus/hfsplus_fs.h

@@ -11,6 +11,7 @@
 #define _LINUX_HFSPLUS_FS_H
 #define _LINUX_HFSPLUS_FS_H
 
 
 #include <linux/fs.h>
 #include <linux/fs.h>
+#include <linux/mutex.h>
 #include <linux/buffer_head.h>
 #include <linux/buffer_head.h>
 #include "hfsplus_raw.h"
 #include "hfsplus_raw.h"
 
 
@@ -154,7 +155,7 @@ struct hfsplus_sb_info {
 
 
 
 
 struct hfsplus_inode_info {
 struct hfsplus_inode_info {
-	struct semaphore extents_lock;
+	struct mutex extents_lock;
 	u32 clump_blocks, alloc_blocks;
 	u32 clump_blocks, alloc_blocks;
 	sector_t fs_blocks;
 	sector_t fs_blocks;
 	/* Allocation extents from catalog record or volume header */
 	/* Allocation extents from catalog record or volume header */

+ 2 - 2
fs/hfsplus/inode.c

@@ -163,7 +163,7 @@ static struct dentry *hfsplus_file_lookup(struct inode *dir, struct dentry *dent
 
 
 	inode->i_ino = dir->i_ino;
 	inode->i_ino = dir->i_ino;
 	INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list);
 	INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list);
-	init_MUTEX(&HFSPLUS_I(inode).extents_lock);
+	mutex_init(&HFSPLUS_I(inode).extents_lock);
 	HFSPLUS_I(inode).flags = HFSPLUS_FLG_RSRC;
 	HFSPLUS_I(inode).flags = HFSPLUS_FLG_RSRC;
 
 
 	hfs_find_init(HFSPLUS_SB(sb).cat_tree, &fd);
 	hfs_find_init(HFSPLUS_SB(sb).cat_tree, &fd);
@@ -316,7 +316,7 @@ struct inode *hfsplus_new_inode(struct super_block *sb, int mode)
 	inode->i_nlink = 1;
 	inode->i_nlink = 1;
 	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
 	inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME_SEC;
 	INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list);
 	INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list);
-	init_MUTEX(&HFSPLUS_I(inode).extents_lock);
+	mutex_init(&HFSPLUS_I(inode).extents_lock);
 	atomic_set(&HFSPLUS_I(inode).opencnt, 0);
 	atomic_set(&HFSPLUS_I(inode).opencnt, 0);
 	HFSPLUS_I(inode).flags = 0;
 	HFSPLUS_I(inode).flags = 0;
 	memset(HFSPLUS_I(inode).first_extents, 0, sizeof(hfsplus_extent_rec));
 	memset(HFSPLUS_I(inode).first_extents, 0, sizeof(hfsplus_extent_rec));

+ 1 - 1
fs/hfsplus/super.c

@@ -34,7 +34,7 @@ struct inode *hfsplus_iget(struct super_block *sb, unsigned long ino)
 		return inode;
 		return inode;
 
 
 	INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list);
 	INIT_LIST_HEAD(&HFSPLUS_I(inode).open_dir_list);
-	init_MUTEX(&HFSPLUS_I(inode).extents_lock);
+	mutex_init(&HFSPLUS_I(inode).extents_lock);
 	HFSPLUS_I(inode).flags = 0;
 	HFSPLUS_I(inode).flags = 0;
 	HFSPLUS_I(inode).rsrc_inode = NULL;
 	HFSPLUS_I(inode).rsrc_inode = NULL;
 	atomic_set(&HFSPLUS_I(inode).opencnt, 0);
 	atomic_set(&HFSPLUS_I(inode).opencnt, 0);