Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 187083
b: refs/heads/master
c: e72ceb8
h: refs/heads/master
i:
  187081: 02fe8af
  187079: 57bc34f
v: v3
  • Loading branch information
Eric W. Biederman authored and Greg Kroah-Hartman committed Mar 8, 2010
1 parent f5c3576 commit d02f516
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 78 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 3c31f07ad0dab02fe17195d32a965d57fd947707
refs/heads/master: e72ceb8ccac5f770b3e696e09bb673dca7024b20
50 changes: 25 additions & 25 deletions trunk/fs/sysfs/bin.c
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ fill_read(struct dentry *dentry, char *buffer, loff_t off, size_t count)
int rc;

/* need attr_sd for attr, its parent for kobj */
if (!sysfs_get_active_two(attr_sd))
if (!sysfs_get_active(attr_sd))
return -ENODEV;

rc = -EIO;
if (attr->read)
rc = attr->read(kobj, attr, buffer, off, count);

sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);

return rc;
}
Expand Down Expand Up @@ -125,14 +125,14 @@ flush_write(struct dentry *dentry, char *buffer, loff_t offset, size_t count)
int rc;

/* need attr_sd for attr, its parent for kobj */
if (!sysfs_get_active_two(attr_sd))
if (!sysfs_get_active(attr_sd))
return -ENODEV;

rc = -EIO;
if (attr->write)
rc = attr->write(kobj, attr, buffer, offset, count);

sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);

return rc;
}
Expand Down Expand Up @@ -184,12 +184,12 @@ static void bin_vma_open(struct vm_area_struct *vma)
if (!bb->vm_ops || !bb->vm_ops->open)
return;

if (!sysfs_get_active_two(attr_sd))
if (!sysfs_get_active(attr_sd))
return;

bb->vm_ops->open(vma);

sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);
}

static void bin_vma_close(struct vm_area_struct *vma)
Expand All @@ -201,12 +201,12 @@ static void bin_vma_close(struct vm_area_struct *vma)
if (!bb->vm_ops || !bb->vm_ops->close)
return;

if (!sysfs_get_active_two(attr_sd))
if (!sysfs_get_active(attr_sd))
return;

bb->vm_ops->close(vma);

sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);
}

static int bin_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
Expand All @@ -219,12 +219,12 @@ static int bin_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
if (!bb->vm_ops || !bb->vm_ops->fault)
return VM_FAULT_SIGBUS;

if (!sysfs_get_active_two(attr_sd))
if (!sysfs_get_active(attr_sd))
return VM_FAULT_SIGBUS;

ret = bb->vm_ops->fault(vma, vmf);

sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);
return ret;
}

Expand All @@ -241,12 +241,12 @@ static int bin_page_mkwrite(struct vm_area_struct *vma, struct vm_fault *vmf)
if (!bb->vm_ops->page_mkwrite)
return 0;

if (!sysfs_get_active_two(attr_sd))
if (!sysfs_get_active(attr_sd))
return VM_FAULT_SIGBUS;

ret = bb->vm_ops->page_mkwrite(vma, vmf);

sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);
return ret;
}

Expand All @@ -261,12 +261,12 @@ static int bin_access(struct vm_area_struct *vma, unsigned long addr,
if (!bb->vm_ops || !bb->vm_ops->access)
return -EINVAL;

if (!sysfs_get_active_two(attr_sd))
if (!sysfs_get_active(attr_sd))
return -EINVAL;

ret = bb->vm_ops->access(vma, addr, buf, len, write);

sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);
return ret;
}

Expand All @@ -281,12 +281,12 @@ static int bin_set_policy(struct vm_area_struct *vma, struct mempolicy *new)
if (!bb->vm_ops || !bb->vm_ops->set_policy)
return 0;

if (!sysfs_get_active_two(attr_sd))
if (!sysfs_get_active(attr_sd))
return -EINVAL;

ret = bb->vm_ops->set_policy(vma, new);

sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);
return ret;
}

Expand All @@ -301,12 +301,12 @@ static struct mempolicy *bin_get_policy(struct vm_area_struct *vma,
if (!bb->vm_ops || !bb->vm_ops->get_policy)
return vma->vm_policy;

if (!sysfs_get_active_two(attr_sd))
if (!sysfs_get_active(attr_sd))
return vma->vm_policy;

pol = bb->vm_ops->get_policy(vma, addr);

sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);
return pol;
}

Expand All @@ -321,12 +321,12 @@ static int bin_migrate(struct vm_area_struct *vma, const nodemask_t *from,
if (!bb->vm_ops || !bb->vm_ops->migrate)
return 0;

if (!sysfs_get_active_two(attr_sd))
if (!sysfs_get_active(attr_sd))
return 0;

ret = bb->vm_ops->migrate(vma, from, to, flags);

sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);
return ret;
}
#endif
Expand Down Expand Up @@ -356,7 +356,7 @@ static int mmap(struct file *file, struct vm_area_struct *vma)

/* need attr_sd for attr, its parent for kobj */
rc = -ENODEV;
if (!sysfs_get_active_two(attr_sd))
if (!sysfs_get_active(attr_sd))
goto out_unlock;

rc = -EINVAL;
Expand Down Expand Up @@ -384,7 +384,7 @@ static int mmap(struct file *file, struct vm_area_struct *vma)
bb->vm_ops = vma->vm_ops;
vma->vm_ops = &bin_vm_ops;
out_put:
sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);
out_unlock:
mutex_unlock(&bb->mutex);

Expand All @@ -399,7 +399,7 @@ static int open(struct inode * inode, struct file * file)
int error;

/* binary file operations requires both @sd and its parent */
if (!sysfs_get_active_two(attr_sd))
if (!sysfs_get_active(attr_sd))
return -ENODEV;

error = -EACCES;
Expand All @@ -426,11 +426,11 @@ static int open(struct inode * inode, struct file * file)
mutex_unlock(&sysfs_bin_lock);

/* open succeeded, put active references */
sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);
return 0;

err_out:
sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);
kfree(bb);
return error;
}
Expand Down
43 changes: 2 additions & 41 deletions trunk/fs/sysfs/dir.c
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ static void sysfs_unlink_sibling(struct sysfs_dirent *sd)
* RETURNS:
* Pointer to @sd on success, NULL on failure.
*/
static struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd)
struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd)
{
if (unlikely(!sd))
return NULL;
Expand Down Expand Up @@ -124,7 +124,7 @@ static struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd)
* Put an active reference to @sd. This function is noop if @sd
* is NULL.
*/
static void sysfs_put_active(struct sysfs_dirent *sd)
void sysfs_put_active(struct sysfs_dirent *sd)
{
struct completion *cmpl;
int v;
Expand All @@ -144,45 +144,6 @@ static void sysfs_put_active(struct sysfs_dirent *sd)
complete(cmpl);
}

/**
* sysfs_get_active_two - get active references to sysfs_dirent and parent
* @sd: sysfs_dirent of interest
*
* Get active reference to @sd and its parent. Parent's active
* reference is grabbed first. This function is noop if @sd is
* NULL.
*
* RETURNS:
* Pointer to @sd on success, NULL on failure.
*/
struct sysfs_dirent *sysfs_get_active_two(struct sysfs_dirent *sd)
{
if (sd) {
if (sd->s_parent && unlikely(!sysfs_get_active(sd->s_parent)))
return NULL;
if (unlikely(!sysfs_get_active(sd))) {
sysfs_put_active(sd->s_parent);
return NULL;
}
}
return sd;
}

/**
* sysfs_put_active_two - put active references to sysfs_dirent and parent
* @sd: sysfs_dirent of interest
*
* Put active references to @sd and its parent. This function is
* noop if @sd is NULL.
*/
void sysfs_put_active_two(struct sysfs_dirent *sd)
{
if (sd) {
sysfs_put_active(sd);
sysfs_put_active(sd->s_parent);
}
}

/**
* sysfs_deactivate - deactivate sysfs_dirent
* @sd: sysfs_dirent to deactivate
Expand Down
18 changes: 9 additions & 9 deletions trunk/fs/sysfs/file.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,13 +85,13 @@ static int fill_read_buffer(struct dentry * dentry, struct sysfs_buffer * buffer
return -ENOMEM;

/* need attr_sd for attr and ops, its parent for kobj */
if (!sysfs_get_active_two(attr_sd))
if (!sysfs_get_active(attr_sd))
return -ENODEV;

buffer->event = atomic_read(&attr_sd->s_attr.open->event);
count = ops->show(kobj, attr_sd->s_attr.attr, buffer->page);

sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);

/*
* The code works fine with PAGE_SIZE return but it's likely to
Expand Down Expand Up @@ -203,12 +203,12 @@ flush_write_buffer(struct dentry * dentry, struct sysfs_buffer * buffer, size_t
int rc;

/* need attr_sd for attr and ops, its parent for kobj */
if (!sysfs_get_active_two(attr_sd))
if (!sysfs_get_active(attr_sd))
return -ENODEV;

rc = ops->store(kobj, attr_sd->s_attr.attr, buffer->page, count);

sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);

return rc;
}
Expand Down Expand Up @@ -344,7 +344,7 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
memmove(last_sysfs_file, p, strlen(p) + 1);

/* need attr_sd for attr and ops, its parent for kobj */
if (!sysfs_get_active_two(attr_sd))
if (!sysfs_get_active(attr_sd))
return -ENODEV;

/* every kobject with an attribute needs a ktype assigned */
Expand Down Expand Up @@ -393,13 +393,13 @@ static int sysfs_open_file(struct inode *inode, struct file *file)
goto err_free;

/* open succeeded, put active references */
sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);
return 0;

err_free:
kfree(buffer);
err_out:
sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);
return error;
}

Expand Down Expand Up @@ -437,12 +437,12 @@ static unsigned int sysfs_poll(struct file *filp, poll_table *wait)
struct sysfs_open_dirent *od = attr_sd->s_attr.open;

/* need parent for the kobj, grab both */
if (!sysfs_get_active_two(attr_sd))
if (!sysfs_get_active(attr_sd))
goto trigger;

poll_wait(filp, &od->poll, wait);

sysfs_put_active_two(attr_sd);
sysfs_put_active(attr_sd);

if (buffer->event != atomic_read(&od->event))
goto trigger;
Expand Down
4 changes: 2 additions & 2 deletions trunk/fs/sysfs/sysfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ extern const struct file_operations sysfs_dir_operations;
extern const struct inode_operations sysfs_dir_inode_operations;

struct dentry *sysfs_get_dentry(struct sysfs_dirent *sd);
struct sysfs_dirent *sysfs_get_active_two(struct sysfs_dirent *sd);
void sysfs_put_active_two(struct sysfs_dirent *sd);
struct sysfs_dirent *sysfs_get_active(struct sysfs_dirent *sd);
void sysfs_put_active(struct sysfs_dirent *sd);
void sysfs_addrm_start(struct sysfs_addrm_cxt *acxt,
struct sysfs_dirent *parent_sd);
int __sysfs_add_one(struct sysfs_addrm_cxt *acxt, struct sysfs_dirent *sd);
Expand Down

0 comments on commit d02f516

Please sign in to comment.