Skip to content

Commit 353ab6e

Browse files
Ingo MolnarLinus Torvalds
authored andcommitted
[PATCH] sem2mutex: fs/
Semaphore to mutex conversion. The conversion was generated via scripts, and the result was validated automatically via a script as well. Signed-off-by: Ingo Molnar <mingo@elte.hu> Cc: Eric Van Hensbergen <ericvh@ericvh.myip.org> Cc: Robert Love <rml@tech9.net> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: David Woodhouse <dwmw2@infradead.org> Cc: Neil Brown <neilb@cse.unsw.edu.au> Cc: Trond Myklebust <trond.myklebust@fys.uio.no> Cc: Dave Kleikamp <shaggy@austin.ibm.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent e655a25 commit 353ab6e

11 files changed

Lines changed: 99 additions & 89 deletions

File tree

‎fs/cramfs/inode.c‎

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include <linux/cramfs_fs_sb.h>
2323
#include <linux/buffer_head.h>
2424
#include <linux/vfs.h>
25+
#include <linux/mutex.h>
2526
#include <asm/semaphore.h>
2627

2728
#include <asm/uaccess.h>
@@ -31,7 +32,7 @@ static struct inode_operations cramfs_dir_inode_operations;
3132
static struct file_operations cramfs_directory_operations;
3233
static struct address_space_operations cramfs_aops;
3334

34-
static DECLARE_MUTEX(read_mutex);
35+
static DEFINE_MUTEX(read_mutex);
3536

3637

3738
/* These two macros may change in future, to provide better st_ino
@@ -250,20 +251,20 @@ static int cramfs_fill_super(struct super_block *sb, void *data, int silent)
250251
memset(sbi, 0, sizeof(struct cramfs_sb_info));
251252

252253
/* Invalidate the read buffers on mount: think disk change.. */
253-
down(&read_mutex);
254+
mutex_lock(&read_mutex);
254255
for (i = 0; i < READ_BUFFERS; i++)
255256
buffer_blocknr[i] = -1;
256257

257258
/* Read the first block and get the superblock from it */
258259
memcpy(&super, cramfs_read(sb, 0, sizeof(super)), sizeof(super));
259-
up(&read_mutex);
260+
mutex_unlock(&read_mutex);
260261

261262
/* Do sanity checks on the superblock */
262263
if (super.magic != CRAMFS_MAGIC) {
263264
/* check at 512 byte offset */
264-
down(&read_mutex);
265+
mutex_lock(&read_mutex);
265266
memcpy(&super, cramfs_read(sb, 512, sizeof(super)), sizeof(super));
266-
up(&read_mutex);
267+
mutex_unlock(&read_mutex);
267268
if (super.magic != CRAMFS_MAGIC) {
268269
if (!silent)
269270
printk(KERN_ERR "cramfs: wrong magic\n");
@@ -366,7 +367,7 @@ static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
366367
mode_t mode;
367368
int namelen, error;
368369

369-
down(&read_mutex);
370+
mutex_lock(&read_mutex);
370371
de = cramfs_read(sb, OFFSET(inode) + offset, sizeof(*de)+256);
371372
name = (char *)(de+1);
372373

@@ -379,7 +380,7 @@ static int cramfs_readdir(struct file *filp, void *dirent, filldir_t filldir)
379380
memcpy(buf, name, namelen);
380381
ino = CRAMINO(de);
381382
mode = de->mode;
382-
up(&read_mutex);
383+
mutex_unlock(&read_mutex);
383384
nextoffset = offset + sizeof(*de) + namelen;
384385
for (;;) {
385386
if (!namelen) {
@@ -410,7 +411,7 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s
410411
unsigned int offset = 0;
411412
int sorted;
412413

413-
down(&read_mutex);
414+
mutex_lock(&read_mutex);
414415
sorted = CRAMFS_SB(dir->i_sb)->flags & CRAMFS_FLAG_SORTED_DIRS;
415416
while (offset < dir->i_size) {
416417
struct cramfs_inode *de;
@@ -433,7 +434,7 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s
433434

434435
for (;;) {
435436
if (!namelen) {
436-
up(&read_mutex);
437+
mutex_unlock(&read_mutex);
437438
return ERR_PTR(-EIO);
438439
}
439440
if (name[namelen-1])
@@ -447,15 +448,15 @@ static struct dentry * cramfs_lookup(struct inode *dir, struct dentry *dentry, s
447448
continue;
448449
if (!retval) {
449450
struct cramfs_inode entry = *de;
450-
up(&read_mutex);
451+
mutex_unlock(&read_mutex);
451452
d_add(dentry, get_cramfs_inode(dir->i_sb, &entry));
452453
return NULL;
453454
}
454455
/* else (retval < 0) */
455456
if (sorted)
456457
break;
457458
}
458-
up(&read_mutex);
459+
mutex_unlock(&read_mutex);
459460
d_add(dentry, NULL);
460461
return NULL;
461462
}
@@ -474,21 +475,21 @@ static int cramfs_readpage(struct file *file, struct page * page)
474475
u32 start_offset, compr_len;
475476

476477
start_offset = OFFSET(inode) + maxblock*4;
477-
down(&read_mutex);
478+
mutex_lock(&read_mutex);
478479
if (page->index)
479480
start_offset = *(u32 *) cramfs_read(sb, blkptr_offset-4, 4);
480481
compr_len = (*(u32 *) cramfs_read(sb, blkptr_offset, 4) - start_offset);
481-
up(&read_mutex);
482+
mutex_unlock(&read_mutex);
482483
pgdata = kmap(page);
483484
if (compr_len == 0)
484485
; /* hole */
485486
else {
486-
down(&read_mutex);
487+
mutex_lock(&read_mutex);
487488
bytes_filled = cramfs_uncompress_block(pgdata,
488489
PAGE_CACHE_SIZE,
489490
cramfs_read(sb, start_offset, compr_len),
490491
compr_len);
491-
up(&read_mutex);
492+
mutex_unlock(&read_mutex);
492493
}
493494
} else
494495
pgdata = kmap(page);

‎fs/dcookies.c‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include <linux/mm.h>
2424
#include <linux/errno.h>
2525
#include <linux/dcookies.h>
26+
#include <linux/mutex.h>
2627
#include <asm/uaccess.h>
2728

2829
/* The dcookies are allocated from a kmem_cache and
@@ -36,7 +37,7 @@ struct dcookie_struct {
3637
};
3738

3839
static LIST_HEAD(dcookie_users);
39-
static DECLARE_MUTEX(dcookie_sem);
40+
static DEFINE_MUTEX(dcookie_mutex);
4041
static kmem_cache_t * dcookie_cache;
4142
static struct list_head * dcookie_hashtable;
4243
static size_t hash_size;
@@ -114,7 +115,7 @@ int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt,
114115
int err = 0;
115116
struct dcookie_struct * dcs;
116117

117-
down(&dcookie_sem);
118+
mutex_lock(&dcookie_mutex);
118119

119120
if (!is_live()) {
120121
err = -EINVAL;
@@ -134,7 +135,7 @@ int get_dcookie(struct dentry * dentry, struct vfsmount * vfsmnt,
134135
*cookie = dcookie_value(dcs);
135136

136137
out:
137-
up(&dcookie_sem);
138+
mutex_unlock(&dcookie_mutex);
138139
return err;
139140
}
140141

@@ -157,7 +158,7 @@ asmlinkage long sys_lookup_dcookie(u64 cookie64, char __user * buf, size_t len)
157158
if (!capable(CAP_SYS_ADMIN))
158159
return -EPERM;
159160

160-
down(&dcookie_sem);
161+
mutex_lock(&dcookie_mutex);
161162

162163
if (!is_live()) {
163164
err = -EINVAL;
@@ -192,7 +193,7 @@ asmlinkage long sys_lookup_dcookie(u64 cookie64, char __user * buf, size_t len)
192193
out_free:
193194
kfree(kbuf);
194195
out:
195-
up(&dcookie_sem);
196+
mutex_unlock(&dcookie_mutex);
196197
return err;
197198
}
198199

@@ -290,7 +291,7 @@ struct dcookie_user * dcookie_register(void)
290291
{
291292
struct dcookie_user * user;
292293

293-
down(&dcookie_sem);
294+
mutex_lock(&dcookie_mutex);
294295

295296
user = kmalloc(sizeof(struct dcookie_user), GFP_KERNEL);
296297
if (!user)
@@ -302,7 +303,7 @@ struct dcookie_user * dcookie_register(void)
302303
list_add(&user->next, &dcookie_users);
303304

304305
out:
305-
up(&dcookie_sem);
306+
mutex_unlock(&dcookie_mutex);
306307
return user;
307308
out_free:
308309
kfree(user);
@@ -313,15 +314,15 @@ struct dcookie_user * dcookie_register(void)
313314

314315
void dcookie_unregister(struct dcookie_user * user)
315316
{
316-
down(&dcookie_sem);
317+
mutex_lock(&dcookie_mutex);
317318

318319
list_del(&user->next);
319320
kfree(user);
320321

321322
if (!is_live())
322323
dcookie_exit();
323324

324-
up(&dcookie_sem);
325+
mutex_unlock(&dcookie_mutex);
325326
}
326327

327328
EXPORT_SYMBOL_GPL(dcookie_register);

‎fs/jffs2/compr_zlib.c‎

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@
3333
*/
3434
#define STREAM_END_SPACE 12
3535

36-
static DECLARE_MUTEX(deflate_sem);
37-
static DECLARE_MUTEX(inflate_sem);
36+
static DEFINE_MUTEX(deflate_mutex);
37+
static DEFINE_MUTEX(inflate_mutex);
3838
static z_stream inf_strm, def_strm;
3939

4040
#ifdef __KERNEL__ /* Linux-only */
4141
#include <linux/vmalloc.h>
4242
#include <linux/init.h>
43+
#include <linux/mutex.h>
4344

4445
static int __init alloc_workspaces(void)
4546
{
@@ -79,11 +80,11 @@ static int jffs2_zlib_compress(unsigned char *data_in,
7980
if (*dstlen <= STREAM_END_SPACE)
8081
return -1;
8182

82-
down(&deflate_sem);
83+
mutex_lock(&deflate_mutex);
8384

8485
if (Z_OK != zlib_deflateInit(&def_strm, 3)) {
8586
printk(KERN_WARNING "deflateInit failed\n");
86-
up(&deflate_sem);
87+
mutex_unlock(&deflate_mutex);
8788
return -1;
8889
}
8990

@@ -104,7 +105,7 @@ static int jffs2_zlib_compress(unsigned char *data_in,
104105
if (ret != Z_OK) {
105106
D1(printk(KERN_DEBUG "deflate in loop returned %d\n", ret));
106107
zlib_deflateEnd(&def_strm);
107-
up(&deflate_sem);
108+
mutex_unlock(&deflate_mutex);
108109
return -1;
109110
}
110111
}
@@ -133,7 +134,7 @@ static int jffs2_zlib_compress(unsigned char *data_in,
133134
*sourcelen = def_strm.total_in;
134135
ret = 0;
135136
out:
136-
up(&deflate_sem);
137+
mutex_unlock(&deflate_mutex);
137138
return ret;
138139
}
139140

@@ -145,7 +146,7 @@ static int jffs2_zlib_decompress(unsigned char *data_in,
145146
int ret;
146147
int wbits = MAX_WBITS;
147148

148-
down(&inflate_sem);
149+
mutex_lock(&inflate_mutex);
149150

150151
inf_strm.next_in = data_in;
151152
inf_strm.avail_in = srclen;
@@ -173,7 +174,7 @@ static int jffs2_zlib_decompress(unsigned char *data_in,
173174

174175
if (Z_OK != zlib_inflateInit2(&inf_strm, wbits)) {
175176
printk(KERN_WARNING "inflateInit failed\n");
176-
up(&inflate_sem);
177+
mutex_unlock(&inflate_mutex);
177178
return 1;
178179
}
179180

@@ -183,7 +184,7 @@ static int jffs2_zlib_decompress(unsigned char *data_in,
183184
printk(KERN_NOTICE "inflate returned %d\n", ret);
184185
}
185186
zlib_inflateEnd(&inf_strm);
186-
up(&inflate_sem);
187+
mutex_unlock(&inflate_mutex);
187188
return 0;
188189
}
189190

0 commit comments

Comments
 (0)