diff options
author | Al Viro <viro@zeniv.linux.org.uk> | 2016-01-22 15:40:57 -0500 |
---|---|---|
committer | Al Viro <viro@zeniv.linux.org.uk> | 2016-01-22 18:04:28 -0500 |
commit | 5955102c9984fa081b2d570cfac75c97eecf8f3b (patch) | |
tree | a4744386eac4b916e847eb4eedfada158f6527b4 /fs/configfs | |
parent | 57b8f112cfe6622ddddb8c2641206bb5fa8a112d (diff) |
wrappers for ->i_mutex access
parallel to mutex_{lock,unlock,trylock,is_locked,lock_nested},
inode_foo(inode) being mutex_foo(&inode->i_mutex).
Please, use those for access to ->i_mutex; over the coming cycle
->i_mutex will become rwsem, with ->lookup() done with it held
only shared.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Diffstat (limited to 'fs/configfs')
-rw-r--r-- | fs/configfs/dir.c | 58 | ||||
-rw-r--r-- | fs/configfs/file.c | 8 | ||||
-rw-r--r-- | fs/configfs/inode.c | 4 |
3 files changed, 35 insertions, 35 deletions
diff --git a/fs/configfs/dir.c b/fs/configfs/dir.c index cab612b2ae76..f419519ec41f 100644 --- a/fs/configfs/dir.c +++ b/fs/configfs/dir.c | |||
@@ -640,13 +640,13 @@ static void detach_groups(struct config_group *group) | |||
640 | 640 | ||
641 | child = sd->s_dentry; | 641 | child = sd->s_dentry; |
642 | 642 | ||
643 | mutex_lock(&d_inode(child)->i_mutex); | 643 | inode_lock(d_inode(child)); |
644 | 644 | ||
645 | configfs_detach_group(sd->s_element); | 645 | configfs_detach_group(sd->s_element); |
646 | d_inode(child)->i_flags |= S_DEAD; | 646 | d_inode(child)->i_flags |= S_DEAD; |
647 | dont_mount(child); | 647 | dont_mount(child); |
648 | 648 | ||
649 | mutex_unlock(&d_inode(child)->i_mutex); | 649 | inode_unlock(d_inode(child)); |
650 | 650 | ||
651 | d_delete(child); | 651 | d_delete(child); |
652 | dput(child); | 652 | dput(child); |
@@ -834,11 +834,11 @@ static int configfs_attach_item(struct config_item *parent_item, | |||
834 | * the VFS may already have hit and used them. Thus, | 834 | * the VFS may already have hit and used them. Thus, |
835 | * we must lock them as rmdir() would. | 835 | * we must lock them as rmdir() would. |
836 | */ | 836 | */ |
837 | mutex_lock(&d_inode(dentry)->i_mutex); | 837 | inode_lock(d_inode(dentry)); |
838 | configfs_remove_dir(item); | 838 | configfs_remove_dir(item); |
839 | d_inode(dentry)->i_flags |= S_DEAD; | 839 | d_inode(dentry)->i_flags |= S_DEAD; |
840 | dont_mount(dentry); | 840 | dont_mount(dentry); |
841 | mutex_unlock(&d_inode(dentry)->i_mutex); | 841 | inode_unlock(d_inode(dentry)); |
842 | d_delete(dentry); | 842 | d_delete(dentry); |
843 | } | 843 | } |
844 | } | 844 | } |
@@ -874,7 +874,7 @@ static int configfs_attach_group(struct config_item *parent_item, | |||
874 | * We must also lock the inode to remove it safely in case of | 874 | * We must also lock the inode to remove it safely in case of |
875 | * error, as rmdir() would. | 875 | * error, as rmdir() would. |
876 | */ | 876 | */ |
877 | mutex_lock_nested(&d_inode(dentry)->i_mutex, I_MUTEX_CHILD); | 877 | inode_lock_nested(d_inode(dentry), I_MUTEX_CHILD); |
878 | configfs_adjust_dir_dirent_depth_before_populate(sd); | 878 | configfs_adjust_dir_dirent_depth_before_populate(sd); |
879 | ret = populate_groups(to_config_group(item)); | 879 | ret = populate_groups(to_config_group(item)); |
880 | if (ret) { | 880 | if (ret) { |
@@ -883,7 +883,7 @@ static int configfs_attach_group(struct config_item *parent_item, | |||
883 | dont_mount(dentry); | 883 | dont_mount(dentry); |
884 | } | 884 | } |
885 | configfs_adjust_dir_dirent_depth_after_populate(sd); | 885 | configfs_adjust_dir_dirent_depth_after_populate(sd); |
886 | mutex_unlock(&d_inode(dentry)->i_mutex); | 886 | inode_unlock(d_inode(dentry)); |
887 | if (ret) | 887 | if (ret) |
888 | d_delete(dentry); | 888 | d_delete(dentry); |
889 | } | 889 | } |
@@ -1135,7 +1135,7 @@ int configfs_depend_item(struct configfs_subsystem *subsys, | |||
1135 | * subsystem is really registered, and so we need to lock out | 1135 | * subsystem is really registered, and so we need to lock out |
1136 | * configfs_[un]register_subsystem(). | 1136 | * configfs_[un]register_subsystem(). |
1137 | */ | 1137 | */ |
1138 | mutex_lock(&d_inode(root)->i_mutex); | 1138 | inode_lock(d_inode(root)); |
1139 | 1139 | ||
1140 | subsys_sd = configfs_find_subsys_dentry(root->d_fsdata, s_item); | 1140 | subsys_sd = configfs_find_subsys_dentry(root->d_fsdata, s_item); |
1141 | if (!subsys_sd) { | 1141 | if (!subsys_sd) { |
@@ -1147,7 +1147,7 @@ int configfs_depend_item(struct configfs_subsystem *subsys, | |||
1147 | ret = configfs_do_depend_item(subsys_sd->s_dentry, target); | 1147 | ret = configfs_do_depend_item(subsys_sd->s_dentry, target); |
1148 | 1148 | ||
1149 | out_unlock_fs: | 1149 | out_unlock_fs: |
1150 | mutex_unlock(&d_inode(root)->i_mutex); | 1150 | inode_unlock(d_inode(root)); |
1151 | 1151 | ||
1152 | /* | 1152 | /* |
1153 | * If we succeeded, the fs is pinned via other methods. If not, | 1153 | * If we succeeded, the fs is pinned via other methods. If not, |
@@ -1230,7 +1230,7 @@ int configfs_depend_item_unlocked(struct configfs_subsystem *caller_subsys, | |||
1230 | * additional locking to prevent other subsystem from being | 1230 | * additional locking to prevent other subsystem from being |
1231 | * unregistered | 1231 | * unregistered |
1232 | */ | 1232 | */ |
1233 | mutex_lock(&d_inode(root->cg_item.ci_dentry)->i_mutex); | 1233 | inode_lock(d_inode(root->cg_item.ci_dentry)); |
1234 | 1234 | ||
1235 | /* | 1235 | /* |
1236 | * As we are trying to depend item from other subsystem | 1236 | * As we are trying to depend item from other subsystem |
@@ -1254,7 +1254,7 @@ out_root_unlock: | |||
1254 | * We were called from subsystem other than our target so we | 1254 | * We were called from subsystem other than our target so we |
1255 | * took some locks so now it's time to release them | 1255 | * took some locks so now it's time to release them |
1256 | */ | 1256 | */ |
1257 | mutex_unlock(&d_inode(root->cg_item.ci_dentry)->i_mutex); | 1257 | inode_unlock(d_inode(root->cg_item.ci_dentry)); |
1258 | 1258 | ||
1259 | return ret; | 1259 | return ret; |
1260 | } | 1260 | } |
@@ -1561,7 +1561,7 @@ int configfs_rename_dir(struct config_item * item, const char *new_name) | |||
1561 | down_write(&configfs_rename_sem); | 1561 | down_write(&configfs_rename_sem); |
1562 | parent = item->parent->dentry; | 1562 | parent = item->parent->dentry; |
1563 | 1563 | ||
1564 | mutex_lock(&d_inode(parent)->i_mutex); | 1564 | inode_lock(d_inode(parent)); |
1565 | 1565 | ||
1566 | new_dentry = lookup_one_len(new_name, parent, strlen(new_name)); | 1566 | new_dentry = lookup_one_len(new_name, parent, strlen(new_name)); |
1567 | if (!IS_ERR(new_dentry)) { | 1567 | if (!IS_ERR(new_dentry)) { |
@@ -1577,7 +1577,7 @@ int configfs_rename_dir(struct config_item * item, const char *new_name) | |||
1577 | error = -EEXIST; | 1577 | error = -EEXIST; |
1578 | dput(new_dentry); | 1578 | dput(new_dentry); |
1579 | } | 1579 | } |
1580 | mutex_unlock(&d_inode(parent)->i_mutex); | 1580 | inode_unlock(d_inode(parent)); |
1581 | up_write(&configfs_rename_sem); | 1581 | up_write(&configfs_rename_sem); |
1582 | 1582 | ||
1583 | return error; | 1583 | return error; |
@@ -1590,7 +1590,7 @@ static int configfs_dir_open(struct inode *inode, struct file *file) | |||
1590 | struct configfs_dirent * parent_sd = dentry->d_fsdata; | 1590 | struct configfs_dirent * parent_sd = dentry->d_fsdata; |
1591 | int err; | 1591 | int err; |
1592 | 1592 | ||
1593 | mutex_lock(&d_inode(dentry)->i_mutex); | 1593 | inode_lock(d_inode(dentry)); |
1594 | /* | 1594 | /* |
1595 | * Fake invisibility if dir belongs to a group/default groups hierarchy | 1595 | * Fake invisibility if dir belongs to a group/default groups hierarchy |
1596 | * being attached | 1596 | * being attached |
@@ -1603,7 +1603,7 @@ static int configfs_dir_open(struct inode *inode, struct file *file) | |||
1603 | else | 1603 | else |
1604 | err = 0; | 1604 | err = 0; |
1605 | } | 1605 | } |
1606 | mutex_unlock(&d_inode(dentry)->i_mutex); | 1606 | inode_unlock(d_inode(dentry)); |
1607 | 1607 | ||
1608 | return err; | 1608 | return err; |
1609 | } | 1609 | } |
@@ -1613,11 +1613,11 @@ static int configfs_dir_close(struct inode *inode, struct file *file) | |||
1613 | struct dentry * dentry = file->f_path.dentry; | 1613 | struct dentry * dentry = file->f_path.dentry; |
1614 | struct configfs_dirent * cursor = file->private_data; | 1614 | struct configfs_dirent * cursor = file->private_data; |
1615 | 1615 | ||
1616 | mutex_lock(&d_inode(dentry)->i_mutex); | 1616 | inode_lock(d_inode(dentry)); |
1617 | spin_lock(&configfs_dirent_lock); | 1617 | spin_lock(&configfs_dirent_lock); |
1618 | list_del_init(&cursor->s_sibling); | 1618 | list_del_init(&cursor->s_sibling); |
1619 | spin_unlock(&configfs_dirent_lock); | 1619 | spin_unlock(&configfs_dirent_lock); |
1620 | mutex_unlock(&d_inode(dentry)->i_mutex); | 1620 | inode_unlock(d_inode(dentry)); |
1621 | 1621 | ||
1622 | release_configfs_dirent(cursor); | 1622 | release_configfs_dirent(cursor); |
1623 | 1623 | ||
@@ -1698,7 +1698,7 @@ static loff_t configfs_dir_lseek(struct file *file, loff_t offset, int whence) | |||
1698 | { | 1698 | { |
1699 | struct dentry * dentry = file->f_path.dentry; | 1699 | struct dentry * dentry = file->f_path.dentry; |
1700 | 1700 | ||
1701 | mutex_lock(&d_inode(dentry)->i_mutex); | 1701 | inode_lock(d_inode(dentry)); |
1702 | switch (whence) { | 1702 | switch (whence) { |
1703 | case 1: | 1703 | case 1: |
1704 | offset += file->f_pos; | 1704 | offset += file->f_pos; |
@@ -1706,7 +1706,7 @@ static loff_t configfs_dir_lseek(struct file *file, loff_t offset, int whence) | |||
1706 | if (offset >= 0) | 1706 | if (offset >= 0) |
1707 | break; | 1707 | break; |
1708 | default: | 1708 | default: |
1709 | mutex_unlock(&d_inode(dentry)->i_mutex); | 1709 | inode_unlock(d_inode(dentry)); |
1710 | return -EINVAL; | 1710 | return -EINVAL; |
1711 | } | 1711 | } |
1712 | if (offset != file->f_pos) { | 1712 | if (offset != file->f_pos) { |
@@ -1732,7 +1732,7 @@ static loff_t configfs_dir_lseek(struct file *file, loff_t offset, int whence) | |||
1732 | spin_unlock(&configfs_dirent_lock); | 1732 | spin_unlock(&configfs_dirent_lock); |
1733 | } | 1733 | } |
1734 | } | 1734 | } |
1735 | mutex_unlock(&d_inode(dentry)->i_mutex); | 1735 | inode_unlock(d_inode(dentry)); |
1736 | return offset; | 1736 | return offset; |
1737 | } | 1737 | } |
1738 | 1738 | ||
@@ -1767,14 +1767,14 @@ int configfs_register_group(struct config_group *parent_group, | |||
1767 | 1767 | ||
1768 | parent = parent_group->cg_item.ci_dentry; | 1768 | parent = parent_group->cg_item.ci_dentry; |
1769 | 1769 | ||
1770 | mutex_lock_nested(&d_inode(parent)->i_mutex, I_MUTEX_PARENT); | 1770 | inode_lock_nested(d_inode(parent), I_MUTEX_PARENT); |
1771 | ret = create_default_group(parent_group, group); | 1771 | ret = create_default_group(parent_group, group); |
1772 | if (!ret) { | 1772 | if (!ret) { |
1773 | spin_lock(&configfs_dirent_lock); | 1773 | spin_lock(&configfs_dirent_lock); |
1774 | configfs_dir_set_ready(group->cg_item.ci_dentry->d_fsdata); | 1774 | configfs_dir_set_ready(group->cg_item.ci_dentry->d_fsdata); |
1775 | spin_unlock(&configfs_dirent_lock); | 1775 | spin_unlock(&configfs_dirent_lock); |
1776 | } | 1776 | } |
1777 | mutex_unlock(&d_inode(parent)->i_mutex); | 1777 | inode_unlock(d_inode(parent)); |
1778 | return ret; | 1778 | return ret; |
1779 | } | 1779 | } |
1780 | EXPORT_SYMBOL(configfs_register_group); | 1780 | EXPORT_SYMBOL(configfs_register_group); |
@@ -1791,7 +1791,7 @@ void configfs_unregister_group(struct config_group *group) | |||
1791 | struct dentry *dentry = group->cg_item.ci_dentry; | 1791 | struct dentry *dentry = group->cg_item.ci_dentry; |
1792 | struct dentry *parent = group->cg_item.ci_parent->ci_dentry; | 1792 | struct dentry *parent = group->cg_item.ci_parent->ci_dentry; |
1793 | 1793 | ||
1794 | mutex_lock_nested(&d_inode(parent)->i_mutex, I_MUTEX_PARENT); | 1794 | inode_lock_nested(d_inode(parent), I_MUTEX_PARENT); |
1795 | spin_lock(&configfs_dirent_lock); | 1795 | spin_lock(&configfs_dirent_lock); |
1796 | configfs_detach_prep(dentry, NULL); | 1796 | configfs_detach_prep(dentry, NULL); |
1797 | spin_unlock(&configfs_dirent_lock); | 1797 | spin_unlock(&configfs_dirent_lock); |
@@ -1800,7 +1800,7 @@ void configfs_unregister_group(struct config_group *group) | |||
1800 | d_inode(dentry)->i_flags |= S_DEAD; | 1800 | d_inode(dentry)->i_flags |= S_DEAD; |
1801 | dont_mount(dentry); | 1801 | dont_mount(dentry); |
1802 | d_delete(dentry); | 1802 | d_delete(dentry); |
1803 | mutex_unlock(&d_inode(parent)->i_mutex); | 1803 | inode_unlock(d_inode(parent)); |
1804 | 1804 | ||
1805 | dput(dentry); | 1805 | dput(dentry); |
1806 | 1806 | ||
@@ -1872,7 +1872,7 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys) | |||
1872 | sd = root->d_fsdata; | 1872 | sd = root->d_fsdata; |
1873 | link_group(to_config_group(sd->s_element), group); | 1873 | link_group(to_config_group(sd->s_element), group); |
1874 | 1874 | ||
1875 | mutex_lock_nested(&d_inode(root)->i_mutex, I_MUTEX_PARENT); | 1875 | inode_lock_nested(d_inode(root), I_MUTEX_PARENT); |
1876 | 1876 | ||
1877 | err = -ENOMEM; | 1877 | err = -ENOMEM; |
1878 | dentry = d_alloc_name(root, group->cg_item.ci_name); | 1878 | dentry = d_alloc_name(root, group->cg_item.ci_name); |
@@ -1892,7 +1892,7 @@ int configfs_register_subsystem(struct configfs_subsystem *subsys) | |||
1892 | } | 1892 | } |
1893 | } | 1893 | } |
1894 | 1894 | ||
1895 | mutex_unlock(&d_inode(root)->i_mutex); | 1895 | inode_unlock(d_inode(root)); |
1896 | 1896 | ||
1897 | if (err) { | 1897 | if (err) { |
1898 | unlink_group(group); | 1898 | unlink_group(group); |
@@ -1913,9 +1913,9 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys) | |||
1913 | return; | 1913 | return; |
1914 | } | 1914 | } |
1915 | 1915 | ||
1916 | mutex_lock_nested(&d_inode(root)->i_mutex, | 1916 | inode_lock_nested(d_inode(root), |
1917 | I_MUTEX_PARENT); | 1917 | I_MUTEX_PARENT); |
1918 | mutex_lock_nested(&d_inode(dentry)->i_mutex, I_MUTEX_CHILD); | 1918 | inode_lock_nested(d_inode(dentry), I_MUTEX_CHILD); |
1919 | mutex_lock(&configfs_symlink_mutex); | 1919 | mutex_lock(&configfs_symlink_mutex); |
1920 | spin_lock(&configfs_dirent_lock); | 1920 | spin_lock(&configfs_dirent_lock); |
1921 | if (configfs_detach_prep(dentry, NULL)) { | 1921 | if (configfs_detach_prep(dentry, NULL)) { |
@@ -1926,11 +1926,11 @@ void configfs_unregister_subsystem(struct configfs_subsystem *subsys) | |||
1926 | configfs_detach_group(&group->cg_item); | 1926 | configfs_detach_group(&group->cg_item); |
1927 | d_inode(dentry)->i_flags |= S_DEAD; | 1927 | d_inode(dentry)->i_flags |= S_DEAD; |
1928 | dont_mount(dentry); | 1928 | dont_mount(dentry); |
1929 | mutex_unlock(&d_inode(dentry)->i_mutex); | 1929 | inode_unlock(d_inode(dentry)); |
1930 | 1930 | ||
1931 | d_delete(dentry); | 1931 | d_delete(dentry); |
1932 | 1932 | ||
1933 | mutex_unlock(&d_inode(root)->i_mutex); | 1933 | inode_unlock(d_inode(root)); |
1934 | 1934 | ||
1935 | dput(dentry); | 1935 | dput(dentry); |
1936 | 1936 | ||
diff --git a/fs/configfs/file.c b/fs/configfs/file.c index 3687187c8ea5..33b7ee34eda5 100644 --- a/fs/configfs/file.c +++ b/fs/configfs/file.c | |||
@@ -540,10 +540,10 @@ int configfs_create_file(struct config_item * item, const struct configfs_attrib | |||
540 | umode_t mode = (attr->ca_mode & S_IALLUGO) | S_IFREG; | 540 | umode_t mode = (attr->ca_mode & S_IALLUGO) | S_IFREG; |
541 | int error = 0; | 541 | int error = 0; |
542 | 542 | ||
543 | mutex_lock_nested(&d_inode(dir)->i_mutex, I_MUTEX_NORMAL); | 543 | inode_lock_nested(d_inode(dir), I_MUTEX_NORMAL); |
544 | error = configfs_make_dirent(parent_sd, NULL, (void *) attr, mode, | 544 | error = configfs_make_dirent(parent_sd, NULL, (void *) attr, mode, |
545 | CONFIGFS_ITEM_ATTR); | 545 | CONFIGFS_ITEM_ATTR); |
546 | mutex_unlock(&d_inode(dir)->i_mutex); | 546 | inode_unlock(d_inode(dir)); |
547 | 547 | ||
548 | return error; | 548 | return error; |
549 | } | 549 | } |
@@ -562,10 +562,10 @@ int configfs_create_bin_file(struct config_item *item, | |||
562 | umode_t mode = (bin_attr->cb_attr.ca_mode & S_IALLUGO) | S_IFREG; | 562 | umode_t mode = (bin_attr->cb_attr.ca_mode & S_IALLUGO) | S_IFREG; |
563 | int error = 0; | 563 | int error = 0; |
564 | 564 | ||
565 | mutex_lock_nested(&dir->d_inode->i_mutex, I_MUTEX_NORMAL); | 565 | inode_lock_nested(dir->d_inode, I_MUTEX_NORMAL); |
566 | error = configfs_make_dirent(parent_sd, NULL, (void *) bin_attr, mode, | 566 | error = configfs_make_dirent(parent_sd, NULL, (void *) bin_attr, mode, |
567 | CONFIGFS_ITEM_BIN_ATTR); | 567 | CONFIGFS_ITEM_BIN_ATTR); |
568 | mutex_unlock(&dir->d_inode->i_mutex); | 568 | inode_unlock(dir->d_inode); |
569 | 569 | ||
570 | return error; | 570 | return error; |
571 | } | 571 | } |
diff --git a/fs/configfs/inode.c b/fs/configfs/inode.c index 0cc810e9dccc..cee087d8f7e0 100644 --- a/fs/configfs/inode.c +++ b/fs/configfs/inode.c | |||
@@ -255,7 +255,7 @@ void configfs_hash_and_remove(struct dentry * dir, const char * name) | |||
255 | /* no inode means this hasn't been made visible yet */ | 255 | /* no inode means this hasn't been made visible yet */ |
256 | return; | 256 | return; |
257 | 257 | ||
258 | mutex_lock(&d_inode(dir)->i_mutex); | 258 | inode_lock(d_inode(dir)); |
259 | list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { | 259 | list_for_each_entry(sd, &parent_sd->s_children, s_sibling) { |
260 | if (!sd->s_element) | 260 | if (!sd->s_element) |
261 | continue; | 261 | continue; |
@@ -268,5 +268,5 @@ void configfs_hash_and_remove(struct dentry * dir, const char * name) | |||
268 | break; | 268 | break; |
269 | } | 269 | } |
270 | } | 270 | } |
271 | mutex_unlock(&d_inode(dir)->i_mutex); | 271 | inode_unlock(d_inode(dir)); |
272 | } | 272 | } |