Skip to contentSkip to conversation

Block: Trouble with kobject initialisation for blk_cmd_filter

PATCH Elias Oltmanns 3 participants 10 messages Sep 5, 2008 – Sep 15, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

Hi all,

current usage of the kobject in struct blk_cmd_filter is flawed. Doing

# modprobe -r sd-mod && modprobe sd-mod
while, for instance, a usb-stick is plugged in currently results in
nasty warnings and a dump_stack(). Since blk_cmd_filter is embedded in
struct request_queue, I don't see the need for a kobject anyway. What
about the much simpler option of a struct attribute_group in this
particular case?

This would imply that the cmd_filter subdirectory would appear under sda/queue/ rather than sda/ (which is probably the right place) but, alas, we have to keep compatibility in mind. So I've made some changes to sysfs along the way in order to provide a legacy symlink. I'd have to seperate these two changes for submission but I wanted to know your opinion about it all first.

Thinking about it now makes me wonder whether this is too much for a rc patch and whether we should just allocate the struct blk_cmd_filter dynamically and have done with it. Anyway, tell me what you think.

Regards,

Elias

---
Applies to 2.6.27-rc5-git7.

 block/blk-sysfs.c      |    6 --
 block/blk.h            |    6 ++
 block/cmd-filter.c     |  113 +++++++++++++++----------------------------------
 fs/sysfs/symlink.c     |   48 ++++++++++++++++----
 include/linux/blkdev.h |    1 
 include/linux/sysfs.h  |    2 
 6 files changed, 81 insertions(+), 95 deletions(-)
block/blk-sysfs.c +0 -6
index 304ec73..0120c8e 100644
@@ -9,12 +9,6 @@
 
 #include "blk.h"
 
-struct queue_sysfs_entry {
-	struct attribute attr;
-	ssize_t (*show)(struct request_queue *, char *);
-	ssize_t (*store)(struct request_queue *, const char *, size_t);
-};
-
 static ssize_t
 queue_var_show(unsigned int var, char *page)
 {
block/blk.h +6 -0
index c79f30e..9ab0d6a 100644
@@ -10,6 +10,12 @@
 extern struct kmem_cache *blk_requestq_cachep;
 extern struct kobj_type blk_queue_ktype;
 
+struct queue_sysfs_entry {
+	struct attribute attr;
+	ssize_t (*show)(struct request_queue *, char *);
+	ssize_t (*store)(struct request_queue *, const char *, size_t);
+};
+
 void init_request_from_bio(struct request *req, struct bio *bio);
 void blk_rq_bio_prep(struct request_queue *q, struct request *rq,
 			struct bio *bio);
block/cmd-filter.c +35 -78

177 lines not on this page · raw message

fs/sysfs/symlink.c +38 -10

84 lines not on this page · raw message

include/linux/blkdev.h +0 -1
index 44710d7..ca616b7 100644
@@ -286,7 +286,6 @@ struct blk_queue_tag {
 struct blk_cmd_filter {
 	unsigned long read_ok[BLK_SCSI_CMD_PER_LONG];
 	unsigned long write_ok[BLK_SCSI_CMD_PER_LONG];
-	struct kobject kobj;
 };
 
 struct request_queue
include/linux/sysfs.h +2 -0
index 37fa241..e9e0971 100644
@@ -116,6 +116,8 @@ int sysfs_add_file_to_group(struct kobject *kobj,
 			const struct attribute *attr, const char *group);
 void sysfs_remove_file_from_group(struct kobject *kobj,
 			const struct attribute *attr, const char *group);
+int sysfs_create_link_to_group(struct kobject *kobj, struct kobject *target,
+			       const char *grpname, const char *linkname);
 
 void sysfs_notify(struct kobject *kobj, char *dir, char *attr);
 
#1 lore raw
Quoted 17 lines · Elias Oltmanns

Hi all,

current usage of the kobject in struct blk_cmd_filter is flawed. Doing

# modprobe -r sd-mod && modprobe sd-mod
while, for instance, a usb-stick is plugged in currently results in
nasty warnings and a dump_stack(). Since blk_cmd_filter is embedded in
struct request_queue, I don't see the need for a kobject anyway. What
about the much simpler option of a struct attribute_group in this
particular case?

This would imply that the cmd_filter subdirectory would appear under sda/queue/ rather than sda/ (which is probably the right place) but, alas, we have to keep compatibility in mind. So I've made some changes to sysfs along the way in order to provide a legacy symlink. I'd have to seperate these two changes for submission but I wanted to know your opinion about it all first.

Quoted 3 lines

Thinking about it now makes me wonder whether this is too much for a rc patch and whether we should just allocate the struct blk_cmd_filter dynamically and have done with it. Anyway, tell me what you think.

I think this patch is a step in the right direction, lets get rid of that pesky kobject just for the cmdfilter. Can you resend the patch _without_ the sysfs changes and link support? We haven't released a kernel with cmd filter support yet, so we can change the location still and not have to worry about compatability.

Signature · 1 line
Jens Axboe
#2 lore raw
Quoted 22 lines · On Tue, 9 Sep 2008 12:28:45 +0200 Jens Axboe <[email protected]> wrote:
Quoted 17 lines · Elias Oltmanns

Hi all,

current usage of the kobject in struct blk_cmd_filter is flawed. Doing

# modprobe -r sd-mod && modprobe sd-mod
while, for instance, a usb-stick is plugged in currently results in
nasty warnings and a dump_stack(). Since blk_cmd_filter is embedded in
struct request_queue, I don't see the need for a kobject anyway. What
about the much simpler option of a struct attribute_group in this
particular case?

This would imply that the cmd_filter subdirectory would appear under sda/queue/ rather than sda/ (which is probably the right place) but, alas, we have to keep compatibility in mind. So I've made some changes to sysfs along the way in order to provide a legacy symlink. I'd have to seperate these two changes for submission but I wanted to know your opinion about it all first.

Quoted 3 lines

Thinking about it now makes me wonder whether this is too much for a rc patch and whether we should just allocate the struct blk_cmd_filter dynamically and have done with it. Anyway, tell me what you think.

Quoted 5 lines

I think this patch is a step in the right direction, lets get rid of that pesky kobject just for the cmdfilter. Can you resend the patch _without_ the sysfs changes and link support? We haven't released a kernel with cmd filter support yet, so we can change the location still and not have to worry about compatability.

The sysfs changes looks too much for 2.6.27-rcX but without the sysfs changes, we have the cmdfilter under /sys/block/sda/queue/, right? We don't need to worry about compatibility, but /sys/block/sda is more appropriate? (though I don't think that the cmd filter is a good idea so I don't care much).

Jens, would it be better to just disable the cmdfilter stuff for 2.6.27? It's too late for another try to fix this broken stuff, I guess.

#3 lore raw
Quoted 31 lines · FUJITA Tomonori
Quoted 22 lines · On Tue, 9 Sep 2008 12:28:45 +0200 Jens Axboe <[email protected]> wrote:
Quoted 17 lines · Elias Oltmanns

Hi all,

current usage of the kobject in struct blk_cmd_filter is flawed. Doing

# modprobe -r sd-mod && modprobe sd-mod
while, for instance, a usb-stick is plugged in currently results in
nasty warnings and a dump_stack(). Since blk_cmd_filter is embedded in
struct request_queue, I don't see the need for a kobject anyway. What
about the much simpler option of a struct attribute_group in this
particular case?

This would imply that the cmd_filter subdirectory would appear under sda/queue/ rather than sda/ (which is probably the right place) but, alas, we have to keep compatibility in mind. So I've made some changes to sysfs along the way in order to provide a legacy symlink. I'd have to seperate these two changes for submission but I wanted to know your opinion about it all first.

Quoted 3 lines

Thinking about it now makes me wonder whether this is too much for a rc patch and whether we should just allocate the struct blk_cmd_filter dynamically and have done with it. Anyway, tell me what you think.

Quoted 5 lines

I think this patch is a step in the right direction, lets get rid of that pesky kobject just for the cmdfilter. Can you resend the patch _without_ the sysfs changes and link support? We haven't released a kernel with cmd filter support yet, so we can change the location still and not have to worry about compatability.

Quoted 5 lines

The sysfs changes looks too much for 2.6.27-rcX but without the sysfs changes, we have the cmdfilter under /sys/block/sda/queue/, right? We don't need to worry about compatibility, but /sys/block/sda is more appropriate? (though I don't think that the cmd filter is a good idea so I don't care much).

I agree, under sda/ makes a lot more sense than under sda/queue/

Quoted 3 lines

Jens, would it be better to just disable the cmdfilter stuff for 2.6.27? It's too late for another try to fix this broken stuff, I guess.

Yeah, it's certainly starting to look like it... The amount of changes to unbreak it are too large to submit now, so lets postpone it until 2.6.28.

Signature · 1 line
Jens Axboe
#4 lore raw
Quoted 1 line · Jens Axboe

On Tue, Sep 09 2008, FUJITA Tomonori wrote:

[...]

Quoted 7 lines
Quoted 5 lines

The sysfs changes looks too much for 2.6.27-rcX but without the sysfs changes, we have the cmdfilter under /sys/block/sda/queue/, right? We don't need to worry about compatibility, but /sys/block/sda is more appropriate? (though I don't think that the cmd filter is a good idea so I don't care much).

I agree, under sda/ makes a lot more sense than under sda/queue/

Well, but why is it in struct request_queue then? Is it going to be moved back to the gendisk eventually?

Quoted 8 lines
Quoted 4 lines

Jens, would it be better to just disable the cmdfilter stuff for 2.6.27? It's too late for another try to fix this broken stuff, I guess.

Yeah, it's certainly starting to look like it... The amount of changes to unbreak it are too large to submit now, so lets postpone it until 2.6.28.

I won't bother with the patch against 2.6.27-rc then. What about 2.6.28 though? Not that I really care whether the cmd_filter appears under sda/ or sda/queue/, I just wanted to point out that the sysfs code can be simplified considerably. The things I do care about, of course, are the two problems that have been fixed by my patch: There are no spurious warnings and stack dumps due to kobject reinitialisation and the cmd_filter sysfs interface inherits proper locking. Please take this into consideration if you decide not to reuse the queue layer sysfs interface. Otherwise, just let me know if you want me to port the patch (just the cmd_filter part or the sysfs stuff as well) to next-200809..

Regards,

Elias

#5 lore raw
Quoted 9 lines · On Tue, 09 Sep 2008 18:57:05 +0200 Elias Oltmanns <[email protected]> wrote:
Quoted 1 line · Jens Axboe

On Tue, Sep 09 2008, FUJITA Tomonori wrote:

[...]

Quoted 6 lines
Quoted 5 lines

The sysfs changes looks too much for 2.6.27-rcX but without the sysfs changes, we have the cmdfilter under /sys/block/sda/queue/, right? We don't need to worry about compatibility, but /sys/block/sda is more appropriate? (though I don't think that the cmd filter is a good idea so I don't care much).

Quoted 4 lines
Quoted 1 line

I agree, under sda/ makes a lot more sense than under sda/queue/

Well, but why is it in struct request_queue then? Is it going to be moved back to the gendisk eventually?

I don't think that we can. It broke many things so I moved it to request_queue.

http://marc.info/?l=linux-scsi&m=121706317031777&w=2

Well, it turned out that it doesn't work too... Sorry about that.

#6 lore raw
In reply to Jens Axboe
Quoted 33 lines · Jens Axboe
Quoted 32 lines · FUJITA Tomonori

On Tue, 9 Sep 2008 12:28:45 +0200

Quoted 27 lines · Jens Axboe
Quoted 17 lines · Elias Oltmanns

Hi all,

current usage of the kobject in struct blk_cmd_filter is flawed. Doing

# modprobe -r sd-mod && modprobe sd-mod
while, for instance, a usb-stick is plugged in currently results in
nasty warnings and a dump_stack(). Since blk_cmd_filter is embedded in
struct request_queue, I don't see the need for a kobject anyway. What
about the much simpler option of a struct attribute_group in this
particular case?

This would imply that the cmd_filter subdirectory would appear under sda/queue/ rather than sda/ (which is probably the right place) but, alas, we have to keep compatibility in mind. So I've made some changes to sysfs along the way in order to provide a legacy symlink. I'd have to seperate these two changes for submission but I wanted to know your opinion about it all first.

Quoted 3 lines

Thinking about it now makes me wonder whether this is too much for a rc patch and whether we should just allocate the struct blk_cmd_filter dynamically and have done with it. Anyway, tell me what you think.

I think this patch is a step in the right direction, lets get rid of that pesky kobject just for the cmdfilter. Can you resend the patch _without_ the sysfs changes and link support? We haven't released a kernel with cmd filter support yet, so we can change the location still and not have to worry about compatability.

Quoted 5 lines
Quoted 5 lines

The sysfs changes looks too much for 2.6.27-rcX but without the sysfs changes, we have the cmdfilter under /sys/block/sda/queue/, right? We don't need to worry about compatibility, but /sys/block/sda is more appropriate? (though I don't think that the cmd filter is a good idea so I don't care much).

What exactly does that mean? Is there any point in fixing this particular bug for 2.6.28 or will the whole cmd-filter infrastructure have to be modified in a more general way in order to address other shortcomings?

Quoted 10 lines

I agree, under sda/ makes a lot more sense than under sda/queue/

Quoted 3 lines

Jens, would it be better to just disable the cmdfilter stuff for 2.6.27? It's too late for another try to fix this broken stuff, I guess.

Yeah, it's certainly starting to look like it... The amount of changes to unbreak it are too large to submit now, so lets postpone it until 2.6.28.

As far as I can make out, nothing has happened yet at this front. I've just verified that reverting the following commits (in that order) seems to be working nicely for me:

2dc75d3c3b4
bb23b431db7
a4a778971b9
4beab5c623f
14e507b852e
abf54393704
06a452e5b95
2b272d4f795
0b07de85a76

Is that what you had in mind? Will you take care of it?

Regards,

Elias

#7 lore raw
Quoted 22 lines · On Mon, 15 Sep 2008 21:55:15 +0200 Elias Oltmanns <[email protected]> wrote:
Quoted 7 lines
Quoted 3 lines

Jens, would it be better to just disable the cmdfilter stuff for 2.6.27? It's too late for another try to fix this broken stuff, I guess.

Yeah, it's certainly starting to look like it... The amount of changes to unbreak it are too large to submit now, so lets postpone it until 2.6.28.

As far as I can make out, nothing has happened yet at this front. I've just verified that reverting the following commits (in that order) seems to be working nicely for me:

2dc75d3c3b4
bb23b431db7
a4a778971b9
4beab5c623f
14e507b852e
abf54393704
06a452e5b95
2b272d4f795
0b07de85a76

Quoted 1 line

Is that what you had in mind? Will you take care of it?

The following commit should disable the command filter feature:

commit 2dc75d3c3b49c64fd26b4832a7efb75546cb3fc5

Author: Jens Axboe <[email protected]>
Date:   Thu Sep 11 14:20:23 2008 +0200

block: disable sysfs parts of the disk command filter

#8 lore raw
Quoted 27 lines · FUJITA Tomonori
Quoted 22 lines · On Mon, 15 Sep 2008 21:55:15 +0200 Elias Oltmanns <[email protected]> wrote:
Quoted 7 lines
Quoted 3 lines

Jens, would it be better to just disable the cmdfilter stuff for 2.6.27? It's too late for another try to fix this broken stuff, I guess.

Yeah, it's certainly starting to look like it... The amount of changes to unbreak it are too large to submit now, so lets postpone it until 2.6.28.

As far as I can make out, nothing has happened yet at this front. I've just verified that reverting the following commits (in that order) seems to be working nicely for me:

2dc75d3c3b4
bb23b431db7
a4a778971b9
4beab5c623f
14e507b852e
abf54393704
06a452e5b95
2b272d4f795
0b07de85a76

Quoted 1 line

Is that what you had in mind? Will you take care of it?

Quoted 7 lines

The following commit should disable the command filter feature:

commit 2dc75d3c3b49c64fd26b4832a7efb75546cb3fc5

Author: Jens Axboe <[email protected]>
Date:   Thu Sep 11 14:20:23 2008 +0200

block: disable sysfs parts of the disk command filter

Right, so it really is only the sysfs interface of the command filter that causes problems, is it? Does that also mean that you are not unhappy with the command filter in linux-next either except for the sysfs interfae? I didn't realise that, sorry for the noise.

Regards,

Elias

#9 lore raw
Quoted 30 lines · On Mon, 15 Sep 2008 22:49:13 +0200 Elias Oltmanns <[email protected]> wrote:
Quoted 29 lines · FUJITA Tomonori
Quoted 22 lines · On Mon, 15 Sep 2008 21:55:15 +0200 Elias Oltmanns <[email protected]> wrote:
Quoted 7 lines
Quoted 3 lines

Jens, would it be better to just disable the cmdfilter stuff for 2.6.27? It's too late for another try to fix this broken stuff, I guess.

Yeah, it's certainly starting to look like it... The amount of changes to unbreak it are too large to submit now, so lets postpone it until 2.6.28.

As far as I can make out, nothing has happened yet at this front. I've just verified that reverting the following commits (in that order) seems to be working nicely for me:

2dc75d3c3b4
bb23b431db7
a4a778971b9
4beab5c623f
14e507b852e
abf54393704
06a452e5b95
2b272d4f795
0b07de85a76

Quoted 1 line

Is that what you had in mind? Will you take care of it?

The following commit should disable the command filter feature:

Quoted 8 lines
Quoted 5 lines

commit 2dc75d3c3b49c64fd26b4832a7efb75546cb3fc5

Author: Jens Axboe <[email protected]>
Date:   Thu Sep 11 14:20:23 2008 +0200

block: disable sysfs parts of the disk command filter

Right, so it really is only the sysfs interface of the command filter that causes problems, is it?

Yeah, the way to use kobject for the sysfs interface caused the problems. In addition, the commit log, 'block: disable sysfs parts of the disk command filter' states that it disables only the sysfs interface but the commit changes all the users not to use the command filter (that is, nobody uses the command filter now). We should not see any problems due to the command filter.

Quoted 3 lines

Does that also mean that you are not
unhappy with the command filter in linux-next either except for the sysfs interfae? I didn't realise that, sorry for the noise.

I guess that it would be better to rethink about how to implement the sysfs interface because the current command filter is different from the initial implementation. We could do better (simpler).