Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Matthias Kaehlcke and committed by
Linus Torvalds
7d135a5d 1956a96d

+12 -11
+2 -1
fs/affs/affs.h
··· 2 2 #include <linux/fs.h> 3 3 #include <linux/buffer_head.h> 4 4 #include <linux/amigaffs.h> 5 + #include <linux/mutex.h> 5 6 6 7 /* AmigaOS allows file names with up to 30 characters length. 7 8 * Names longer than that will be silently truncated. If you ··· 99 98 gid_t s_gid; /* gid to override */ 100 99 umode_t s_mode; /* mode to override */ 101 100 struct buffer_head *s_root_bh; /* Cached root block. */ 102 - struct semaphore s_bmlock; /* Protects bitmap access. */ 101 + struct mutex s_bmlock; /* Protects bitmap access. */ 103 102 struct affs_bm_info *s_bitmap; /* Bitmap infos. */ 104 103 u32 s_bmap_count; /* # of bitmap blocks. */ 105 104 u32 s_bmap_bits; /* # of bits in one bitmap blocks */
+9 -9
fs/affs/bitmap.c
··· 45 45 if (sb->s_flags & MS_RDONLY) 46 46 return 0; 47 47 48 - down(&AFFS_SB(sb)->s_bmlock); 48 + mutex_lock(&AFFS_SB(sb)->s_bmlock); 49 49 50 50 bm = AFFS_SB(sb)->s_bitmap; 51 51 free = 0; 52 52 for (i = AFFS_SB(sb)->s_bmap_count; i > 0; bm++, i--) 53 53 free += bm->bm_free; 54 54 55 - up(&AFFS_SB(sb)->s_bmlock); 55 + mutex_unlock(&AFFS_SB(sb)->s_bmlock); 56 56 57 57 return free; 58 58 } ··· 76 76 bit = blk % sbi->s_bmap_bits; 77 77 bm = &sbi->s_bitmap[bmap]; 78 78 79 - down(&sbi->s_bmlock); 79 + mutex_lock(&sbi->s_bmlock); 80 80 81 81 bh = sbi->s_bmap_bh; 82 82 if (sbi->s_last_bmap != bmap) { ··· 105 105 sb->s_dirt = 1; 106 106 bm->bm_free++; 107 107 108 - up(&sbi->s_bmlock); 108 + mutex_unlock(&sbi->s_bmlock); 109 109 return; 110 110 111 111 err_free: 112 112 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); 114 114 return; 115 115 116 116 err_bh_read: 117 117 affs_error(sb,"affs_free_block","Cannot read bitmap block %u", bm->bm_key); 118 118 sbi->s_bmap_bh = NULL; 119 119 sbi->s_last_bmap = ~0; 120 - up(&sbi->s_bmlock); 120 + mutex_unlock(&sbi->s_bmlock); 121 121 return; 122 122 123 123 err_range: ··· 168 168 bmap = blk / sbi->s_bmap_bits; 169 169 bm = &sbi->s_bitmap[bmap]; 170 170 171 - down(&sbi->s_bmlock); 171 + mutex_lock(&sbi->s_bmlock); 172 172 173 173 if (bm->bm_free) 174 174 goto find_bmap_bit; ··· 249 249 mark_buffer_dirty(bh); 250 250 sb->s_dirt = 1; 251 251 252 - up(&sbi->s_bmlock); 252 + mutex_unlock(&sbi->s_bmlock); 253 253 254 254 pr_debug("%d\n", blk); 255 255 return blk; ··· 259 259 sbi->s_bmap_bh = NULL; 260 260 sbi->s_last_bmap = ~0; 261 261 err_full: 262 - up(&sbi->s_bmlock); 262 + mutex_unlock(&sbi->s_bmlock); 263 263 pr_debug("failed\n"); 264 264 return 0; 265 265 }
+1 -1
fs/affs/super.c
··· 290 290 if (!sbi) 291 291 return -ENOMEM; 292 292 sb->s_fs_info = sbi; 293 - init_MUTEX(&sbi->s_bmlock); 293 + mutex_init(&sbi->s_bmlock); 294 294 295 295 if (!parse_options(data,&uid,&gid,&i,&reserved,&root_block, 296 296 &blocksize,&sbi->s_prefix,