Commit 7d135a5d authored by Matthias Kaehlcke's avatar Matthias Kaehlcke Committed by Linus Torvalds

affs: convert s_bmlock into a mutex

The semaphore s_bmlock is used as a mutex.  Convert it to the mutex API.
Signed-off-by: default avatarMatthias Kaehlcke <matthias@kaehlcke.net>
Cc: Roman Zippel <zippel@linux-m68k.org>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1956a96d
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#include <linux/fs.h> #include <linux/fs.h>
#include <linux/buffer_head.h> #include <linux/buffer_head.h>
#include <linux/amigaffs.h> #include <linux/amigaffs.h>
#include <linux/mutex.h>
/* AmigaOS allows file names with up to 30 characters length. /* AmigaOS allows file names with up to 30 characters length.
* Names longer than that will be silently truncated. If you * Names longer than that will be silently truncated. If you
...@@ -98,7 +99,7 @@ struct affs_sb_info { ...@@ -98,7 +99,7 @@ struct affs_sb_info {
gid_t s_gid; /* gid to override */ gid_t s_gid; /* gid to override */
umode_t s_mode; /* mode to override */ umode_t s_mode; /* mode to override */
struct buffer_head *s_root_bh; /* Cached root block. */ struct buffer_head *s_root_bh; /* Cached root block. */
struct semaphore s_bmlock; /* Protects bitmap access. */ struct mutex s_bmlock; /* Protects bitmap access. */
struct affs_bm_info *s_bitmap; /* Bitmap infos. */ struct affs_bm_info *s_bitmap; /* Bitmap infos. */
u32 s_bmap_count; /* # of bitmap blocks. */ u32 s_bmap_count; /* # of bitmap blocks. */
u32 s_bmap_bits; /* # of bits in one bitmap blocks */ u32 s_bmap_bits; /* # of bits in one bitmap blocks */
......
...@@ -45,14 +45,14 @@ affs_count_free_blocks(struct super_block *sb) ...@@ -45,14 +45,14 @@ affs_count_free_blocks(struct super_block *sb)
if (sb->s_flags & MS_RDONLY) if (sb->s_flags & MS_RDONLY)
return 0; return 0;
down(&AFFS_SB(sb)->s_bmlock); mutex_lock(&AFFS_SB(sb)->s_bmlock);
bm = AFFS_SB(sb)->s_bitmap; bm = AFFS_SB(sb)->s_bitmap;
free = 0; free = 0;
for (i = AFFS_SB(sb)->s_bmap_count; i > 0; bm++, i--) for (i = AFFS_SB(sb)->s_bmap_count; i > 0; bm++, i--)
free += bm->bm_free; free += bm->bm_free;
up(&AFFS_SB(sb)->s_bmlock); mutex_unlock(&AFFS_SB(sb)->s_bmlock);
return free; return free;
} }
...@@ -76,7 +76,7 @@ affs_free_block(struct super_block *sb, u32 block) ...@@ -76,7 +76,7 @@ affs_free_block(struct super_block *sb, u32 block)
bit = blk % sbi->s_bmap_bits; bit = blk % sbi->s_bmap_bits;
bm = &sbi->s_bitmap[bmap]; bm = &sbi->s_bitmap[bmap];
down(&sbi->s_bmlock); mutex_lock(&sbi->s_bmlock);
bh = sbi->s_bmap_bh; bh = sbi->s_bmap_bh;
if (sbi->s_last_bmap != bmap) { if (sbi->s_last_bmap != bmap) {
...@@ -105,19 +105,19 @@ affs_free_block(struct super_block *sb, u32 block) ...@@ -105,19 +105,19 @@ affs_free_block(struct super_block *sb, u32 block)
sb->s_dirt = 1; sb->s_dirt = 1;
bm->bm_free++; bm->bm_free++;
up(&sbi->s_bmlock); mutex_unlock(&sbi->s_bmlock);
return; return;
err_free: err_free:
affs_warning(sb,"affs_free_block","Trying to free block %u which is already free", block); affs_warning(sb,"affs_free_block","Trying to free block %u which is already free", block);
up(&sbi->s_bmlock); mutex_unlock(&sbi->s_bmlock);
return; return;
err_bh_read: err_bh_read:
affs_error(sb,"affs_free_block","Cannot read bitmap block %u", bm->bm_key); affs_error(sb,"affs_free_block","Cannot read bitmap block %u", bm->bm_key);
sbi->s_bmap_bh = NULL; sbi->s_bmap_bh = NULL;
sbi->s_last_bmap = ~0; sbi->s_last_bmap = ~0;
up(&sbi->s_bmlock); mutex_unlock(&sbi->s_bmlock);
return; return;
err_range: err_range:
...@@ -168,7 +168,7 @@ affs_alloc_block(struct inode *inode, u32 goal) ...@@ -168,7 +168,7 @@ affs_alloc_block(struct inode *inode, u32 goal)
bmap = blk / sbi->s_bmap_bits; bmap = blk / sbi->s_bmap_bits;
bm = &sbi->s_bitmap[bmap]; bm = &sbi->s_bitmap[bmap];
down(&sbi->s_bmlock); mutex_lock(&sbi->s_bmlock);
if (bm->bm_free) if (bm->bm_free)
goto find_bmap_bit; goto find_bmap_bit;
...@@ -249,7 +249,7 @@ find_bit: ...@@ -249,7 +249,7 @@ find_bit:
mark_buffer_dirty(bh); mark_buffer_dirty(bh);
sb->s_dirt = 1; sb->s_dirt = 1;
up(&sbi->s_bmlock); mutex_unlock(&sbi->s_bmlock);
pr_debug("%d\n", blk); pr_debug("%d\n", blk);
return blk; return blk;
...@@ -259,7 +259,7 @@ err_bh_read: ...@@ -259,7 +259,7 @@ err_bh_read:
sbi->s_bmap_bh = NULL; sbi->s_bmap_bh = NULL;
sbi->s_last_bmap = ~0; sbi->s_last_bmap = ~0;
err_full: err_full:
up(&sbi->s_bmlock); mutex_unlock(&sbi->s_bmlock);
pr_debug("failed\n"); pr_debug("failed\n");
return 0; return 0;
} }
......
...@@ -290,7 +290,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent) ...@@ -290,7 +290,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
if (!sbi) if (!sbi)
return -ENOMEM; return -ENOMEM;
sb->s_fs_info = sbi; sb->s_fs_info = sbi;
init_MUTEX(&sbi->s_bmlock); mutex_init(&sbi->s_bmlock);
if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block, if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block,
&blocksize,&sbi->s_prefix, &blocksize,&sbi->s_prefix,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment