aboutsummaryrefslogtreecommitdiffstats
path: root/fs/sysfs/dir.c
diff options
context:
space:
mode:
authorJes Sorensen <jes@sgi.com>2006-01-09 18:59:24 -0500
committerIngo Molnar <mingo@hera.kernel.org>2006-01-09 18:59:24 -0500
commit1b1dcc1b57a49136f118a0f16367256ff9994a69 (patch)
treeb0b36d4f41d28c9d6514fb309d33c1a084d6309b /fs/sysfs/dir.c
parent794ee1baee1c26be40410233e6c20bceb2b03c08 (diff)
[PATCH] mutex subsystem, semaphore to mutex: VFS, ->i_sem
This patch converts the inode semaphore to a mutex. I have tested it on XFS and compiled as much as one can consider on an ia64. Anyway your luck with it might be different. Modified-by: Ingo Molnar <mingo@elte.hu> (finished the conversion) Signed-off-by: Jes Sorensen <jes@sgi.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
Diffstat (limited to 'fs/sysfs/dir.c')
-rw-r--r--fs/sysfs/dir.c31
1 files changed, 15 insertions, 16 deletions
diff --git a/fs/sysfs/dir.c b/fs/sysfs/dir.c
index d36780382176..49bd219275db 100644
--- a/fs/sysfs/dir.c
+++ b/fs/sysfs/dir.c
@@ -99,7 +99,7 @@ static int create_dir(struct kobject * k, struct dentry * p,
99 int error; 99 int error;
100 umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO; 100 umode_t mode = S_IFDIR| S_IRWXU | S_IRUGO | S_IXUGO;
101 101
102 down(&p->d_inode->i_sem); 102 mutex_lock(&p->d_inode->i_mutex);
103 *d = lookup_one_len(n, p, strlen(n)); 103 *d = lookup_one_len(n, p, strlen(n));
104 if (!IS_ERR(*d)) { 104 if (!IS_ERR(*d)) {
105 error = sysfs_make_dirent(p->d_fsdata, *d, k, mode, SYSFS_DIR); 105 error = sysfs_make_dirent(p->d_fsdata, *d, k, mode, SYSFS_DIR);
@@ -122,7 +122,7 @@ static int create_dir(struct kobject * k, struct dentry * p,
122 dput(*d); 122 dput(*d);
123 } else 123 } else
124 error = PTR_ERR(*d); 124 error = PTR_ERR(*d);
125 up(&p->d_inode->i_sem); 125 mutex_unlock(&p->d_inode->i_mutex);
126 return error; 126 return error;
127} 127}
128 128
@@ -246,7 +246,7 @@ static void remove_dir(struct dentry * d)
246 struct dentry * parent = dget(d->d_parent); 246 struct dentry * parent = dget(d->d_parent);
247 struct sysfs_dirent * sd; 247 struct sysfs_dirent * sd;
248 248
249 down(&parent->d_inode->i_sem); 249 mutex_lock(&parent->d_inode->i_mutex);
250 d_delete(d); 250 d_delete(d);
251 sd = d->d_fsdata; 251 sd = d->d_fsdata;
252 list_del_init(&sd->s_sibling); 252 list_del_init(&sd->s_sibling);
@@ -257,7 +257,7 @@ static void remove_dir(struct dentry * d)
257 pr_debug(" o %s removing done (%d)\n",d->d_name.name, 257 pr_debug(" o %s removing done (%d)\n",d->d_name.name,
258 atomic_read(&d->d_count)); 258 atomic_read(&d->d_count));
259 259
260 up(&parent->d_inode->i_sem); 260 mutex_unlock(&parent->d_inode->i_mutex);
261 dput(parent); 261 dput(parent);
262} 262}
263 263
@@ -286,7 +286,7 @@ void sysfs_remove_dir(struct kobject * kobj)
286 return; 286 return;
287 287
288 pr_debug("sysfs %s: removing dir\n",dentry->d_name.name); 288 pr_debug("sysfs %s: removing dir\n",dentry->d_name.name);
289 down(&dentry->d_inode->i_sem); 289 mutex_lock(&dentry->d_inode->i_mutex);
290 parent_sd = dentry->d_fsdata; 290 parent_sd = dentry->d_fsdata;
291 list_for_each_entry_safe(sd, tmp, &parent_sd->s_children, s_sibling) { 291 list_for_each_entry_safe(sd, tmp, &parent_sd->s_children, s_sibling) {
292 if (!sd->s_element || !(sd->s_type & SYSFS_NOT_PINNED)) 292 if (!sd->s_element || !(sd->s_type & SYSFS_NOT_PINNED))
@@ -295,7 +295,7 @@ void sysfs_remove_dir(struct kobject * kobj)
295 sysfs_drop_dentry(sd, dentry); 295 sysfs_drop_dentry(sd, dentry);
296 sysfs_put(sd); 296 sysfs_put(sd);
297 } 297 }
298 up(&dentry->d_inode->i_sem); 298 mutex_unlock(&dentry->d_inode->i_mutex);
299 299
300 remove_dir(dentry); 300 remove_dir(dentry);
301 /** 301 /**
@@ -318,7 +318,7 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
318 down_write(&sysfs_rename_sem); 318 down_write(&sysfs_rename_sem);
319 parent = kobj->parent->dentry; 319 parent = kobj->parent->dentry;
320 320
321 down(&parent->d_inode->i_sem); 321 mutex_lock(&parent->d_inode->i_mutex);
322 322
323 new_dentry = lookup_one_len(new_name, parent, strlen(new_name)); 323 new_dentry = lookup_one_len(new_name, parent, strlen(new_name));
324 if (!IS_ERR(new_dentry)) { 324 if (!IS_ERR(new_dentry)) {
@@ -334,7 +334,7 @@ int sysfs_rename_dir(struct kobject * kobj, const char *new_name)
334 error = -EEXIST; 334 error = -EEXIST;
335 dput(new_dentry); 335 dput(new_dentry);
336 } 336 }
337 up(&parent->d_inode->i_sem); 337 mutex_unlock(&parent->d_inode->i_mutex);
338 up_write(&sysfs_rename_sem); 338 up_write(&sysfs_rename_sem);
339 339
340 return error; 340 return error;
@@ -345,9 +345,9 @@ static int sysfs_dir_open(struct inode *inode, struct file *file)
345 struct dentry * dentry = file->f_dentry; 345 struct dentry * dentry = file->f_dentry;
346 struct sysfs_dirent * parent_sd = dentry->d_fsdata; 346 struct sysfs_dirent * parent_sd = dentry->d_fsdata;
347 347
348 down(&dentry->d_inode->i_sem); 348 mutex_lock(&dentry->d_inode->i_mutex);
349 file->private_data = sysfs_new_dirent(parent_sd, NULL); 349 file->private_data = sysfs_new_dirent(parent_sd, NULL);
350 up(&dentry->d_inode->i_sem); 350 mutex_unlock(&dentry->d_inode->i_mutex);
351 351
352 return file->private_data ? 0 : -ENOMEM; 352 return file->private_data ? 0 : -ENOMEM;
353 353
@@ -358,9 +358,9 @@ static int sysfs_dir_close(struct inode *inode, struct file *file)
358 struct dentry * dentry = file->f_dentry; 358 struct dentry * dentry = file->f_dentry;
359 struct sysfs_dirent * cursor = file->private_data; 359 struct sysfs_dirent * cursor = file->private_data;
360 360
361 down(&dentry->d_inode->i_sem); 361 mutex_lock(&dentry->d_inode->i_mutex);
362 list_del_init(&cursor->s_sibling); 362 list_del_init(&cursor->s_sibling);
363 up(&dentry->d_inode->i_sem); 363 mutex_unlock(&dentry->d_inode->i_mutex);
364 364
365 release_sysfs_dirent(cursor); 365 release_sysfs_dirent(cursor);
366 366
@@ -436,7 +436,7 @@ static loff_t sysfs_dir_lseek(struct file * file, loff_t offset, int origin)
436{ 436{
437 struct dentry * dentry = file->f_dentry; 437 struct dentry * dentry = file->f_dentry;
438 438
439 down(&dentry->d_inode->i_sem); 439 mutex_lock(&dentry->d_inode->i_mutex);
440 switch (origin) { 440 switch (origin) {
441 case 1: 441 case 1:
442 offset += file->f_pos; 442 offset += file->f_pos;
@@ -444,7 +444,7 @@ static loff_t sysfs_dir_lseek(struct file * file, loff_t offset, int origin)
444 if (offset >= 0) 444 if (offset >= 0)
445 break; 445 break;
446 default: 446 default:
447 up(&file->f_dentry->d_inode->i_sem); 447 mutex_unlock(&file->f_dentry->d_inode->i_mutex);
448 return -EINVAL; 448 return -EINVAL;
449 } 449 }
450 if (offset != file->f_pos) { 450 if (offset != file->f_pos) {
@@ -468,7 +468,7 @@ static loff_t sysfs_dir_lseek(struct file * file, loff_t offset, int origin)
468 list_add_tail(&cursor->s_sibling, p); 468 list_add_tail(&cursor->s_sibling, p);
469 } 469 }
470 } 470 }
471 up(&dentry->d_inode->i_sem); 471 mutex_unlock(&dentry->d_inode->i_mutex);
472 return offset; 472 return offset;
473} 473}
474 474
@@ -483,4 +483,3 @@ struct file_operations sysfs_dir_operations = {
483EXPORT_SYMBOL_GPL(sysfs_create_dir); 483EXPORT_SYMBOL_GPL(sysfs_create_dir);
484EXPORT_SYMBOL_GPL(sysfs_remove_dir); 484EXPORT_SYMBOL_GPL(sysfs_remove_dir);
485EXPORT_SYMBOL_GPL(sysfs_rename_dir); 485EXPORT_SYMBOL_GPL(sysfs_rename_dir);
486