Skip to content

Commit 7d135a5

Browse files
mkaehlcketorvalds
authored andcommitted
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: 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>
1 parent 1956a96 commit 7d135a5

3 files changed

Lines changed: 12 additions & 11 deletions

File tree

‎fs/affs/affs.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
#include <linux/fs.h>
33
#include <linux/buffer_head.h>
44
#include <linux/amigaffs.h>
5+
#include <linux/mutex.h>
56

67
/* AmigaOS allows file names with up to 30 characters length.
78
* Names longer than that will be silently truncated. If you
@@ -98,7 +99,7 @@ struct affs_sb_info {
9899
gid_t s_gid; /* gid to override */
99100
umode_t s_mode; /* mode to override */
100101
struct buffer_head *s_root_bh; /* Cached root block. */
101-
struct semaphore s_bmlock; /* Protects bitmap access. */
102+
struct mutex s_bmlock; /* Protects bitmap access. */
102103
struct affs_bm_info *s_bitmap; /* Bitmap infos. */
103104
u32 s_bmap_count; /* # of bitmap blocks. */
104105
u32 s_bmap_bits; /* # of bits in one bitmap blocks */

‎fs/affs/bitmap.c‎

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,14 @@ affs_count_free_blocks(struct super_block *sb)
4545
if (sb->s_flags & MS_RDONLY)
4646
return 0;
4747

48-
down(&AFFS_SB(sb)->s_bmlock);
48+
mutex_lock(&AFFS_SB(sb)->s_bmlock);
4949

5050
bm = AFFS_SB(sb)->s_bitmap;
5151
free = 0;
5252
for (i = AFFS_SB(sb)->s_bmap_count; i > 0; bm++, i--)
5353
free += bm->bm_free;
5454

55-
up(&AFFS_SB(sb)->s_bmlock);
55+
mutex_unlock(&AFFS_SB(sb)->s_bmlock);
5656

5757
return free;
5858
}
@@ -76,7 +76,7 @@ affs_free_block(struct super_block *sb, u32 block)
7676
bit = blk % sbi->s_bmap_bits;
7777
bm = &sbi->s_bitmap[bmap];
7878

79-
down(&sbi->s_bmlock);
79+
mutex_lock(&sbi->s_bmlock);
8080

8181
bh = sbi->s_bmap_bh;
8282
if (sbi->s_last_bmap != bmap) {
@@ -105,19 +105,19 @@ affs_free_block(struct super_block *sb, u32 block)
105105
sb->s_dirt = 1;
106106
bm->bm_free++;
107107

108-
up(&sbi->s_bmlock);
108+
mutex_unlock(&sbi->s_bmlock);
109109
return;
110110

111111
err_free:
112112
affs_warning(sb,"affs_free_block","Trying to free block %u which is already free", block);
113-
up(&sbi->s_bmlock);
113+
mutex_unlock(&sbi->s_bmlock);
114114
return;
115115

116116
err_bh_read:
117117
affs_error(sb,"affs_free_block","Cannot read bitmap block %u", bm->bm_key);
118118
sbi->s_bmap_bh = NULL;
119119
sbi->s_last_bmap = ~0;
120-
up(&sbi->s_bmlock);
120+
mutex_unlock(&sbi->s_bmlock);
121121
return;
122122

123123
err_range:
@@ -168,7 +168,7 @@ affs_alloc_block(struct inode *inode, u32 goal)
168168
bmap = blk / sbi->s_bmap_bits;
169169
bm = &sbi->s_bitmap[bmap];
170170

171-
down(&sbi->s_bmlock);
171+
mutex_lock(&sbi->s_bmlock);
172172

173173
if (bm->bm_free)
174174
goto find_bmap_bit;
@@ -249,7 +249,7 @@ affs_alloc_block(struct inode *inode, u32 goal)
249249
mark_buffer_dirty(bh);
250250
sb->s_dirt = 1;
251251

252-
up(&sbi->s_bmlock);
252+
mutex_unlock(&sbi->s_bmlock);
253253

254254
pr_debug("%d\n", blk);
255255
return blk;
@@ -259,7 +259,7 @@ affs_alloc_block(struct inode *inode, u32 goal)
259259
sbi->s_bmap_bh = NULL;
260260
sbi->s_last_bmap = ~0;
261261
err_full:
262-
up(&sbi->s_bmlock);
262+
mutex_unlock(&sbi->s_bmlock);
263263
pr_debug("failed\n");
264264
return 0;
265265
}

‎fs/affs/super.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ static int affs_fill_super(struct super_block *sb, void *data, int silent)
290290
if (!sbi)
291291
return -ENOMEM;
292292
sb->s_fs_info = sbi;
293-
init_MUTEX(&sbi->s_bmlock);
293+
mutex_init(&sbi->s_bmlock);
294294

295295
if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block,
296296
&blocksize,&sbi->s_prefix,

0 commit comments

Comments
 (0)