diff options
author | Eric W. Biederman <ebiederm@xmission.com> | 2009-11-20 19:08:54 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-12-11 14:24:54 -0500 |
commit | 06fc0d66f7ed3a3b08e8fcf8c325ecf0b8f93fea (patch) | |
tree | a599fc1cabf3564745ac03bc3e70c7211dc8081e /fs/sysfs/file.c | |
parent | e61ab4ae48fbf477f5b9fcbec9e1b8dc789920d0 (diff) |
sysfs: In sysfs_chmod_file lazily propagate the mode change.
Now that sysfs_getattr and sysfs_permission refresh the vfs
inode there is no need to immediatly push the mode change
into the vfs cache. Reducing the amount of work needed and
simplifying the locking.
Acked-by: Tejun Heo <tj@kernel.org>
Acked-by: Serge Hallyn <serue@us.ibm.com>
Signed-off-by: Eric W. Biederman <ebiederm@aristanetworks.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'fs/sysfs/file.c')
-rw-r--r-- | fs/sysfs/file.c | 31 |
1 files changed, 8 insertions, 23 deletions
diff --git a/fs/sysfs/file.c b/fs/sysfs/file.c index faa1a803caa9..dc30d9e31683 100644 --- a/fs/sysfs/file.c +++ b/fs/sysfs/file.c | |||
@@ -579,38 +579,23 @@ EXPORT_SYMBOL_GPL(sysfs_add_file_to_group); | |||
579 | */ | 579 | */ |
580 | int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode) | 580 | int sysfs_chmod_file(struct kobject *kobj, struct attribute *attr, mode_t mode) |
581 | { | 581 | { |
582 | struct sysfs_dirent *victim_sd = NULL; | 582 | struct sysfs_dirent *sd; |
583 | struct dentry *victim = NULL; | ||
584 | struct inode * inode; | ||
585 | struct iattr newattrs; | 583 | struct iattr newattrs; |
586 | int rc; | 584 | int rc; |
587 | 585 | ||
588 | rc = -ENOENT; | 586 | mutex_lock(&sysfs_mutex); |
589 | victim_sd = sysfs_get_dirent(kobj->sd, attr->name); | ||
590 | if (!victim_sd) | ||
591 | goto out; | ||
592 | 587 | ||
593 | mutex_lock(&sysfs_rename_mutex); | 588 | rc = -ENOENT; |
594 | victim = sysfs_get_dentry(victim_sd); | 589 | sd = sysfs_find_dirent(kobj->sd, attr->name); |
595 | mutex_unlock(&sysfs_rename_mutex); | 590 | if (!sd) |
596 | if (IS_ERR(victim)) { | ||
597 | rc = PTR_ERR(victim); | ||
598 | victim = NULL; | ||
599 | goto out; | 591 | goto out; |
600 | } | ||
601 | |||
602 | inode = victim->d_inode; | ||
603 | 592 | ||
604 | mutex_lock(&inode->i_mutex); | 593 | newattrs.ia_mode = (mode & S_IALLUGO) | (sd->s_mode & ~S_IALLUGO); |
605 | |||
606 | newattrs.ia_mode = (mode & S_IALLUGO) | (inode->i_mode & ~S_IALLUGO); | ||
607 | newattrs.ia_valid = ATTR_MODE; | 594 | newattrs.ia_valid = ATTR_MODE; |
608 | rc = sysfs_setattr(victim, &newattrs); | 595 | rc = sysfs_sd_setattr(sd, &newattrs); |
609 | 596 | ||
610 | mutex_unlock(&inode->i_mutex); | ||
611 | out: | 597 | out: |
612 | dput(victim); | 598 | mutex_unlock(&sysfs_mutex); |
613 | sysfs_put(victim_sd); | ||
614 | return rc; | 599 | return rc; |
615 | } | 600 | } |
616 | EXPORT_SYMBOL_GPL(sysfs_chmod_file); | 601 | EXPORT_SYMBOL_GPL(sysfs_chmod_file); |