Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 13492
b: refs/heads/master
c: 007583c
h: refs/heads/master
v: v3
  • Loading branch information
NeilBrown authored and Linus Torvalds committed Nov 9, 2005
1 parent 75cf5a6 commit 47cd2f5
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 65 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: 31399d9e56abeec4d819f07eefc97f30b5d5ed75
refs/heads/master: 007583c9253fed363a0bd71b039e9b40a0f6855e
6 changes: 0 additions & 6 deletions trunk/drivers/md/md.c
Original file line number Diff line number Diff line change
Expand Up @@ -1683,12 +1683,6 @@ static void analyze_sbs(mddev_t * mddev)

}

struct md_sysfs_entry {
struct attribute attr;
ssize_t (*show)(mddev_t *, char *);
ssize_t (*store)(mddev_t *, const char *, size_t);
};

static ssize_t
md_show_level(mddev_t *mddev, char *page)
{
Expand Down
72 changes: 15 additions & 57 deletions trunk/drivers/md/raid5.c
Original file line number Diff line number Diff line change
Expand Up @@ -1732,21 +1732,17 @@ static void raid5d (mddev_t *mddev)
PRINTK("--- raid5d inactive\n");
}

struct raid5_sysfs_entry {
struct attribute attr;
ssize_t (*show)(raid5_conf_t *, char *);
ssize_t (*store)(raid5_conf_t *, const char *, ssize_t);
};

static ssize_t
raid5_show_stripe_cache_size(raid5_conf_t *conf, char *page)
raid5_show_stripe_cache_size(mddev_t *mddev, char *page)
{
raid5_conf_t *conf = mddev_to_conf(mddev);
return sprintf(page, "%d\n", conf->max_nr_stripes);
}

static ssize_t
raid5_store_stripe_cache_size(raid5_conf_t *conf, const char *page, ssize_t len)
raid5_store_stripe_cache_size(mddev_t *mddev, const char *page, size_t len)
{
raid5_conf_t *conf = mddev_to_conf(mddev);
char *end;
int new;
if (len >= PAGE_SIZE)
Expand All @@ -1770,68 +1766,33 @@ raid5_store_stripe_cache_size(raid5_conf_t *conf, const char *page, ssize_t len)
}
return len;
}
static struct raid5_sysfs_entry raid5_stripecache_size = {

static struct md_sysfs_entry raid5_stripecache_size = {
.attr = {.name = "stripe_cache_size", .mode = S_IRUGO | S_IWUSR },
.show = raid5_show_stripe_cache_size,
.store = raid5_store_stripe_cache_size,
};

static ssize_t
raid5_show_stripe_cache_active(raid5_conf_t *conf, char *page)
raid5_show_stripe_cache_active(mddev_t *mddev, char *page)
{
raid5_conf_t *conf = mddev_to_conf(mddev);
return sprintf(page, "%d\n", atomic_read(&conf->active_stripes));
}

static struct raid5_sysfs_entry raid5_stripecache_active = {
static struct md_sysfs_entry raid5_stripecache_active = {
.attr = {.name = "stripe_cache_active", .mode = S_IRUGO},
.show = raid5_show_stripe_cache_active,
};

static struct attribute *raid5_default_attrs[] = {
static struct attribute *raid5_attrs[] = {
&raid5_stripecache_size.attr,
&raid5_stripecache_active.attr,
NULL,
};

static ssize_t
raid5_attr_show(struct kobject *kobj, struct attribute *attr, char *page)
{
struct raid5_sysfs_entry *entry = container_of(attr, struct raid5_sysfs_entry, attr);
raid5_conf_t *conf = container_of(kobj, raid5_conf_t, kobj);

if (!entry->show)
return -EIO;
return entry->show(conf, page);
}

static ssize_t
raid5_attr_store(struct kobject *kobj, struct attribute *attr,
const char *page, size_t length)
{
struct raid5_sysfs_entry *entry = container_of(attr, struct raid5_sysfs_entry, attr);
raid5_conf_t *conf = container_of(kobj, raid5_conf_t, kobj);

if (!entry->store)
return -EIO;
return entry->store(conf, page, length);
}

static void raid5_free(struct kobject *ko)
{
raid5_conf_t *conf = container_of(ko, raid5_conf_t, kobj);
kfree(conf);
}


static struct sysfs_ops raid5_sysfs_ops = {
.show = raid5_attr_show,
.store = raid5_attr_store,
};

static struct kobj_type raid5_ktype = {
.release = raid5_free,
.sysfs_ops = &raid5_sysfs_ops,
.default_attrs = raid5_default_attrs,
static struct attribute_group raid5_attrs_group = {
.name = NULL,
.attrs = raid5_attrs,
};

static int run(mddev_t *mddev)
Expand Down Expand Up @@ -1975,10 +1936,7 @@ memory = conf->max_nr_stripes * (sizeof(struct stripe_head) +
}

/* Ok, everything is just fine now */
conf->kobj.parent = &mddev->kobj;
strcpy(conf->kobj.name, "raid5");
conf->kobj.ktype = &raid5_ktype;
kobject_register(&conf->kobj);
sysfs_create_group(&mddev->kobj, &raid5_attrs_group);

if (mddev->bitmap)
mddev->thread->timeout = mddev->bitmap->daemon_sleep * HZ;
Expand Down Expand Up @@ -2012,7 +1970,7 @@ static int stop(mddev_t *mddev)
shrink_stripes(conf);
free_pages((unsigned long) conf->stripe_hashtbl, HASH_PAGES_ORDER);
blk_sync_queue(mddev->queue); /* the unplug fn references 'conf'*/
kobject_unregister(&conf->kobj);
sysfs_remove_group(&mddev->kobj, &raid5_attrs_group);
mddev->private = NULL;
return 0;
}
Expand Down
7 changes: 7 additions & 0 deletions trunk/include/linux/raid/md_k.h
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,13 @@ struct mdk_personality_s
};


struct md_sysfs_entry {
struct attribute attr;
ssize_t (*show)(mddev_t *, char *);
ssize_t (*store)(mddev_t *, const char *, size_t);
};


static inline char * mdname (mddev_t * mddev)
{
return mddev->gendisk ? mddev->gendisk->disk_name : "mdX";
Expand Down
1 change: 0 additions & 1 deletion trunk/include/linux/raid/raid5.h
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,6 @@ struct raid5_private_data {
* Cleared when a sync completes.
*/

struct kobject kobj;
/*
* Free stripes pool
*/
Expand Down

0 comments on commit 47cd2f5

Please sign in to comment.