Commit 52e036ee authored by Brian King's avatar Brian King Committed by James Bottomley

[PATCH] ipr: Use kref instead of a kobject

The following patch converts ipr to use a kref rather than a kobject to
do reference counting on an internal data structure. The added overhead
of a kobject is not needed.
Signed-off-by: default avatarBrian King <brking@us.ibm.com>
Signed-off-by: default avatarJames Bottomley <James.Bottomley@SteelEye.com>
parent 00ce9055
...@@ -1791,13 +1791,13 @@ static void ipr_worker_thread(void *data) ...@@ -1791,13 +1791,13 @@ static void ipr_worker_thread(void *data)
if (ioa_cfg->sdt_state == GET_DUMP) { if (ioa_cfg->sdt_state == GET_DUMP) {
dump = ioa_cfg->dump; dump = ioa_cfg->dump;
if (!dump || !kobject_get(&dump->kobj)) { if (!dump || !kref_get(&dump->kref)) {
spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
return; return;
} }
spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
ipr_get_ioa_dump(ioa_cfg, dump); ipr_get_ioa_dump(ioa_cfg, dump);
kobject_put(&dump->kobj); kref_put(&dump->kref);
spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
if (ioa_cfg->sdt_state == DUMP_OBTAINED) if (ioa_cfg->sdt_state == DUMP_OBTAINED)
...@@ -2392,7 +2392,7 @@ static ssize_t ipr_read_dump(struct kobject *kobj, char *buf, ...@@ -2392,7 +2392,7 @@ static ssize_t ipr_read_dump(struct kobject *kobj, char *buf,
spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
dump = ioa_cfg->dump; dump = ioa_cfg->dump;
if (ioa_cfg->sdt_state != DUMP_OBTAINED || !dump || !kobject_get(&dump->kobj)) { if (ioa_cfg->sdt_state != DUMP_OBTAINED || !dump || !kref_get(&dump->kref)) {
spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
return 0; return 0;
} }
...@@ -2400,7 +2400,7 @@ static ssize_t ipr_read_dump(struct kobject *kobj, char *buf, ...@@ -2400,7 +2400,7 @@ static ssize_t ipr_read_dump(struct kobject *kobj, char *buf,
spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
if (off > dump->driver_dump.hdr.len) { if (off > dump->driver_dump.hdr.len) {
kobject_put(&dump->kobj); kref_put(&dump->kref);
return 0; return 0;
} }
...@@ -2450,20 +2450,20 @@ static ssize_t ipr_read_dump(struct kobject *kobj, char *buf, ...@@ -2450,20 +2450,20 @@ static ssize_t ipr_read_dump(struct kobject *kobj, char *buf,
count -= len; count -= len;
} }
kobject_put(&dump->kobj); kref_put(&dump->kref);
return rc; return rc;
} }
/** /**
* ipr_release_dump - Free adapter dump memory * ipr_release_dump - Free adapter dump memory
* @kobj: kobject struct * @kref: kref struct
* *
* Return value: * Return value:
* nothing * nothing
**/ **/
static void ipr_release_dump(struct kobject *kobj) static void ipr_release_dump(struct kref *kref)
{ {
struct ipr_dump *dump = container_of(kobj,struct ipr_dump,kobj); struct ipr_dump *dump = container_of(kref,struct ipr_dump,kref);
struct ipr_ioa_cfg *ioa_cfg = dump->ioa_cfg; struct ipr_ioa_cfg *ioa_cfg = dump->ioa_cfg;
unsigned long lock_flags = 0; unsigned long lock_flags = 0;
int i; int i;
...@@ -2481,10 +2481,6 @@ static void ipr_release_dump(struct kobject *kobj) ...@@ -2481,10 +2481,6 @@ static void ipr_release_dump(struct kobject *kobj)
LEAVE; LEAVE;
} }
static struct kobj_type ipr_dump_kobj_type = {
.release = ipr_release_dump,
};
/** /**
* ipr_alloc_dump - Prepare for adapter dump * ipr_alloc_dump - Prepare for adapter dump
* @ioa_cfg: ioa config struct * @ioa_cfg: ioa config struct
...@@ -2506,8 +2502,7 @@ static int ipr_alloc_dump(struct ipr_ioa_cfg *ioa_cfg) ...@@ -2506,8 +2502,7 @@ static int ipr_alloc_dump(struct ipr_ioa_cfg *ioa_cfg)
} }
memset(dump, 0, sizeof(struct ipr_dump)); memset(dump, 0, sizeof(struct ipr_dump));
kobject_init(&dump->kobj); kref_init(&dump->kref, ipr_release_dump);
dump->kobj.ktype = &ipr_dump_kobj_type;
dump->ioa_cfg = ioa_cfg; dump->ioa_cfg = ioa_cfg;
spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags); spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
...@@ -2554,7 +2549,7 @@ static int ipr_free_dump(struct ipr_ioa_cfg *ioa_cfg) ...@@ -2554,7 +2549,7 @@ static int ipr_free_dump(struct ipr_ioa_cfg *ioa_cfg)
ioa_cfg->dump = NULL; ioa_cfg->dump = NULL;
spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags); spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
kobject_put(&dump->kobj); kref_put(&dump->kref);
LEAVE; LEAVE;
return 0; return 0;
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/types.h> #include <linux/types.h>
#include <linux/completion.h> #include <linux/completion.h>
#include <linux/list.h> #include <linux/list.h>
#include <linux/kref.h>
#include <scsi/scsi.h> #include <scsi/scsi.h>
#include <scsi/scsi_cmnd.h> #include <scsi/scsi_cmnd.h>
#ifdef CONFIG_KDB #ifdef CONFIG_KDB
...@@ -1030,7 +1031,7 @@ struct ipr_ioa_dump { ...@@ -1030,7 +1031,7 @@ struct ipr_ioa_dump {
}__attribute__((packed, aligned (4))); }__attribute__((packed, aligned (4)));
struct ipr_dump { struct ipr_dump {
struct kobject kobj; struct kref kref;
struct ipr_ioa_cfg *ioa_cfg; struct ipr_ioa_cfg *ioa_cfg;
struct ipr_driver_dump driver_dump; struct ipr_driver_dump driver_dump;
struct ipr_ioa_dump ioa_dump; struct ipr_ioa_dump ioa_dump;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment