aboutsummaryrefslogtreecommitdiffstats
path: root/fs/configfs/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/configfs/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/configfs/dir.c')
-rw-r--r--fs/configfs/dir.c54
1 files changed, 27 insertions, 27 deletions
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c
index e48b539243a1..b668ec61527e 100644
--- a/fs/configfs/dir.c
+++ b/fs/configfs/dir.c
@@ -288,10 +288,10 @@ static struct dentry * configfs_lookup(struct inode *dir,
288 288
289/* 289/*
290 * Only subdirectories count here. Files (CONFIGFS_NOT_PINNED) are 290 * Only subdirectories count here. Files (CONFIGFS_NOT_PINNED) are
291 * attributes and are removed by rmdir(). We recurse, taking i_sem 291 * attributes and are removed by rmdir(). We recurse, taking i_mutex
292 * on all children that are candidates for default detach. If the 292 * on all children that are candidates for default detach. If the
293 * result is clean, then configfs_detach_group() will handle dropping 293 * result is clean, then configfs_detach_group() will handle dropping
294 * i_sem. If there is an error, the caller will clean up the i_sem 294 * i_mutex. If there is an error, the caller will clean up the i_mutex
295 * holders via configfs_detach_rollback(). 295 * holders via configfs_detach_rollback().
296 */ 296 */
297static int configfs_detach_prep(struct dentry *dentry) 297static int configfs_detach_prep(struct dentry *dentry)
@@ -309,8 +309,8 @@ static int configfs_detach_prep(struct dentry *dentry)
309 if (sd->s_type & CONFIGFS_NOT_PINNED) 309 if (sd->s_type & CONFIGFS_NOT_PINNED)
310 continue; 310 continue;
311 if (sd->s_type & CONFIGFS_USET_DEFAULT) { 311 if (sd->s_type & CONFIGFS_USET_DEFAULT) {
312 down(&sd->s_dentry->d_inode->i_sem); 312 mutex_lock(&sd->s_dentry->d_inode->i_mutex);
313 /* Mark that we've taken i_sem */ 313 /* Mark that we've taken i_mutex */
314 sd->s_type |= CONFIGFS_USET_DROPPING; 314 sd->s_type |= CONFIGFS_USET_DROPPING;
315 315
316 ret = configfs_detach_prep(sd->s_dentry); 316 ret = configfs_detach_prep(sd->s_dentry);
@@ -327,7 +327,7 @@ out:
327} 327}
328 328
329/* 329/*
330 * Walk the tree, dropping i_sem wherever CONFIGFS_USET_DROPPING is 330 * Walk the tree, dropping i_mutex wherever CONFIGFS_USET_DROPPING is
331 * set. 331 * set.
332 */ 332 */
333static void configfs_detach_rollback(struct dentry *dentry) 333static void configfs_detach_rollback(struct dentry *dentry)
@@ -341,7 +341,7 @@ static void configfs_detach_rollback(struct dentry *dentry)
341 341
342 if (sd->s_type & CONFIGFS_USET_DROPPING) { 342 if (sd->s_type & CONFIGFS_USET_DROPPING) {
343 sd->s_type &= ~CONFIGFS_USET_DROPPING; 343 sd->s_type &= ~CONFIGFS_USET_DROPPING;
344 up(&sd->s_dentry->d_inode->i_sem); 344 mutex_unlock(&sd->s_dentry->d_inode->i_mutex);
345 } 345 }
346 } 346 }
347 } 347 }
@@ -424,11 +424,11 @@ static void detach_groups(struct config_group *group)
424 424
425 /* 425 /*
426 * From rmdir/unregister, a configfs_detach_prep() pass 426 * From rmdir/unregister, a configfs_detach_prep() pass
427 * has taken our i_sem for us. Drop it. 427 * has taken our i_mutex for us. Drop it.
428 * From mkdir/register cleanup, there is no sem held. 428 * From mkdir/register cleanup, there is no sem held.
429 */ 429 */
430 if (sd->s_type & CONFIGFS_USET_DROPPING) 430 if (sd->s_type & CONFIGFS_USET_DROPPING)
431 up(&child->d_inode->i_sem); 431 mutex_unlock(&child->d_inode->i_mutex);
432 432
433 d_delete(child); 433 d_delete(child);
434 dput(child); 434 dput(child);
@@ -493,11 +493,11 @@ static int populate_groups(struct config_group *group)
493 /* FYI, we're faking mkdir here 493 /* FYI, we're faking mkdir here
494 * I'm not sure we need this semaphore, as we're called 494 * I'm not sure we need this semaphore, as we're called
495 * from our parent's mkdir. That holds our parent's 495 * from our parent's mkdir. That holds our parent's
496 * i_sem, so afaik lookup cannot continue through our 496 * i_mutex, so afaik lookup cannot continue through our
497 * parent to find us, let alone mess with our tree. 497 * parent to find us, let alone mess with our tree.
498 * That said, taking our i_sem is closer to mkdir 498 * That said, taking our i_mutex is closer to mkdir
499 * emulation, and shouldn't hurt. */ 499 * emulation, and shouldn't hurt. */
500 down(&dentry->d_inode->i_sem); 500 mutex_lock(&dentry->d_inode->i_mutex);
501 501
502 for (i = 0; group->default_groups[i]; i++) { 502 for (i = 0; group->default_groups[i]; i++) {
503 new_group = group->default_groups[i]; 503 new_group = group->default_groups[i];
@@ -507,7 +507,7 @@ static int populate_groups(struct config_group *group)
507 break; 507 break;
508 } 508 }
509 509
510 up(&dentry->d_inode->i_sem); 510 mutex_unlock(&dentry->d_inode->i_mutex);
511 } 511 }
512 512
513 if (ret) 513 if (ret)
@@ -856,7 +856,7 @@ int configfs_rename_dir(struct config_item * item, const char *new_name)
856 down_write(&configfs_rename_sem); 856 down_write(&configfs_rename_sem);
857 parent = item->parent->dentry; 857 parent = item->parent->dentry;
858 858
859 down(&parent->d_inode->i_sem); 859 mutex_lock(&parent->d_inode->i_mutex);
860 860
861 new_dentry = lookup_one_len(new_name, parent, strlen(new_name)); 861 new_dentry = lookup_one_len(new_name, parent, strlen(new_name));
862 if (!IS_ERR(new_dentry)) { 862 if (!IS_ERR(new_dentry)) {
@@ -872,7 +872,7 @@ int configfs_rename_dir(struct config_item * item, const char *new_name)
872 error = -EEXIST; 872 error = -EEXIST;
873 dput(new_dentry); 873 dput(new_dentry);
874 } 874 }
875 up(&parent->d_inode->i_sem); 875 mutex_unlock(&parent->d_inode->i_mutex);
876 up_write(&configfs_rename_sem); 876 up_write(&configfs_rename_sem);
877 877
878 return error; 878 return error;
@@ -884,9 +884,9 @@ static int configfs_dir_open(struct inode *inode, struct file *file)
884 struct dentry * dentry = file->f_dentry; 884 struct dentry * dentry = file->f_dentry;
885 struct configfs_dirent * parent_sd = dentry->d_fsdata; 885 struct configfs_dirent * parent_sd = dentry->d_fsdata;
886 886
887 down(&dentry->d_inode->i_sem); 887 mutex_lock(&dentry->d_inode->i_mutex);
888 file->private_data = configfs_new_dirent(parent_sd, NULL); 888 file->private_data = configfs_new_dirent(parent_sd, NULL);
889 up(&dentry->d_inode->i_sem); 889 mutex_unlock(&dentry->d_inode->i_mutex);
890 890
891 return file->private_data ? 0 : -ENOMEM; 891 return file->private_data ? 0 : -ENOMEM;
892 892
@@ -897,9 +897,9 @@ static int configfs_dir_close(struct inode *inode, struct file *file)
897 struct dentry * dentry = file->f_dentry; 897 struct dentry * dentry = file->f_dentry;
898 struct configfs_dirent * cursor = file->private_data; 898 struct configfs_dirent * cursor = file->private_data;
899 899
900 down(&dentry->d_inode->i_sem); 900 mutex_lock(&dentry->d_inode->i_mutex);
901 list_del_init(&cursor->s_sibling); 901 list_del_init(&cursor->s_sibling);
902 up(&dentry->d_inode->i_sem); 902 mutex_unlock(&dentry->d_inode->i_mutex);
903 903
904 release_configfs_dirent(cursor); 904 release_configfs_dirent(cursor);
905 905
@@ -975,7 +975,7 @@ static loff_t configfs_dir_lseek(struct file * file, loff_t offset, int origin)
975{ 975{
976 struct dentry * dentry = file->f_dentry; 976 struct dentry * dentry = file->f_dentry;
977 977
978 down(&dentry->d_inode->i_sem); 978 mutex_lock(&dentry->d_inode->i_mutex);
979 switch (origin) { 979 switch (origin) {
980 case 1: 980 case 1:
981 offset += file->f_pos; 981 offset += file->f_pos;
@@ -983,7 +983,7 @@ static loff_t configfs_dir_lseek(struct file * file, loff_t offset, int origin)
983 if (offset >= 0) 983 if (offset >= 0)
984 break; 984 break;
985 default: 985 default:
986 up(&file->f_dentry->d_inode->i_sem); 986 mutex_unlock(&file->f_dentry->d_inode->i_mutex);
987 return -EINVAL; 987 return -EINVAL;
988 } 988 }
989 if (offset != file->f_pos) { 989 if (offset != file->f_pos) {
@@ -1007,7 +1007,7 @@ static loff_t configfs_dir_lseek(struct file * file, loff_t offset, int origin)
1007 list_add_tail(&cursor->s_sibling, p); 1007 list_add_tail(&cursor->s_sibling, p);
1008 } 1008 }
1009 } 1009 }
1010 up(&dentry->d_inode->i_sem); 1010 mutex_unlock(&dentry->d_inode->i_mutex);
1011 return offset; 1011 return offset;
1012} 1012}
1013 1013
@@ -1037,7 +1037,7 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys)
1037 sd = configfs_sb->s_root->d_fsdata; 1037 sd = configfs_sb->s_root->d_fsdata;
1038 link_group(to_config_group(sd->s_element), group); 1038 link_group(to_config_group(sd->s_element), group);
1039 1039
1040 down(&configfs_sb->s_root->d_inode->i_sem); 1040 mutex_lock(&configfs_sb->s_root->d_inode->i_mutex);
1041 1041
1042 name.name = group->cg_item.ci_name; 1042 name.name = group->cg_item.ci_name;
1043 name.len = strlen(name.name); 1043 name.len = strlen(name.name);
@@ -1057,7 +1057,7 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys)
1057 else 1057 else
1058 d_delete(dentry); 1058 d_delete(dentry);
1059 1059
1060 up(&configfs_sb->s_root->d_inode->i_sem); 1060 mutex_unlock(&configfs_sb->s_root->d_inode->i_mutex);
1061 1061
1062 if (dentry) { 1062 if (dentry) {
1063 dput(dentry); 1063 dput(dentry);
@@ -1079,18 +1079,18 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys)
1079 return; 1079 return;
1080 } 1080 }
1081 1081
1082 down(&configfs_sb->s_root->d_inode->i_sem); 1082 mutex_lock(&configfs_sb->s_root->d_inode->i_mutex);
1083 down(&dentry->d_inode->i_sem); 1083 mutex_lock(&dentry->d_inode->i_mutex);
1084 if (configfs_detach_prep(dentry)) { 1084 if (configfs_detach_prep(dentry)) {
1085 printk(KERN_ERR "configfs: Tried to unregister non-empty subsystem!\n"); 1085 printk(KERN_ERR "configfs: Tried to unregister non-empty subsystem!\n");
1086 } 1086 }
1087 configfs_detach_group(&group->cg_item); 1087 configfs_detach_group(&group->cg_item);
1088 dentry->d_inode->i_flags |= S_DEAD; 1088 dentry->d_inode->i_flags |= S_DEAD;
1089 up(&dentry->d_inode->i_sem); 1089 mutex_unlock(&dentry->d_inode->i_mutex);
1090 1090
1091 d_delete(dentry); 1091 d_delete(dentry);
1092 1092
1093 up(&configfs_sb->s_root->d_inode->i_sem); 1093 mutex_unlock(&configfs_sb->s_root->d_inode->i_mutex);
1094 1094
1095 dput(dentry); 1095 dput(dentry);
1096 1096