Find the answer to your Linux question:
Results 1 to 2 of 2
I am playing with a block driver code for ndas. The full code and latest is here: linux.ximeta.com:8000/trac/ticket/1142 The problem is the schedule request fails and the machine freezes. The ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jan 2011
    Posts
    2

    Block Driver scheduler request "entry->store" fails


    I am playing with a block driver code for ndas. The full code and latest is here: linux.ximeta.com:8000/trac/ticket/1142

    The problem is the schedule request fails and the machine freezes.

    The code that fails:
    Code:
    #if CONFIG_SYSFS
        sal_assert(slot->queue->kobj.ktype);
        sal_assert(slot->queue->kobj.ktype->default_attrs);
        {
            struct queue_sysfs_entry {
            	struct attribute attr;
            	ssize_t (*show)(struct request_queue *, char *);
            	ssize_t (*store)(struct request_queue *, const char *, size_t);
            };
            struct attribute *attr = slot->queue->kobj.ktype->default_attrs[4];
            struct queue_sysfs_entry *entry = container_of(attr , struct queue_sysfs_entry, attr);
    
    //line below will crash the computer.   
          entry->store(slot->queue,NDAS_QUEUE_SCHEDULER,strlen(NDAS_QUEUE_SCHEDULER));
            
        }
    #else
    I think this code is a hacked version of the Linux/block/blk-sysfs.c functions. Especially from the function "queue_attr_store" in the Linux/block/blk-sysfs.c section.

    reference /lxr.free-electrons.com/source/block/blk-sysfs.c?v=2.6.30#L316

    When I further copy the code from the reference, in my attempt to create the entry, there were compilation errors. For example i added some lines that look like the code in the original function.

    Code:
    struct request_queue *qq= container_of(slot->queue->kobj, struct request_queue, slot->queue->kobj);;
    ssize_t resqq;
    
    if (!entry->store)
    	return -EIO;
    
    qq = container_of(slot->queue->kobj, struct request_queue, slot->queue->kobj);
    
    resqq = entry->store(qq, NDAS_QUEUE_SCHEDULER, strlen(NDAS_QUEUE_SCHEDULER));
    This makes an error on compiling "request_queue has no member names slot"

    So I tried to copy to copy the original a little closer by simply changing a couple lines:
    Code:
    ssize_t resqq;
    
    if (!entry->store)
    	return -EIO;
    
    resqq = entry->store(slot->queue, NDAS_QUEUE_SCHEDULER, strlen(NDAS_QUEUE_SCHEDULER));
    This one compiles, but it jumps out at the EIO error, so the schedule is not entered and the device does not register.

    QUEUE_SCHEDUELER is "noob"
    slot-queue is defined earlier in the function:
    Code:
        slot->queue = blk_init_queue(
            nblk_request_proc, 
            &slot->lock
        );
    So, i wonder if anyone can help me get slot->queue to be noticed in my first failure, so that it will compile and use the resqq option.

    Or can you show me how to make entry->store available on the second?

    Or maybe there is a way to avoid this code and use just send the parameters:
    slot->queue, attr, NDAS_QUEUE_SCHEDULER, and strlen(NDAS_QUEUE_SCHEDULER
    to the original kernel function "queue_attr_store"?

    By the way, if I simply skip this block of code, the driver works, but there is a warning in the code that the driver does not work well with QFS above version 2.6.18, so I was hoping to implement this scheduler call in order to have the optimum operation efficiency.

    Thanks for any help, or possibly sending me to a link for detailed information about using the blk-sysfs functions from inside this driver code.

  2. #2
    Just Joined!
    Join Date
    Jan 2011
    Posts
    2

    Solved

    I think I have an acceptable solution for the freeze up problem.

    I will deprecate the sysfs call from the kernel and use the ndasadmin script to set the block scheduler.

    According to this post at another forum, it is the much more acceptable way to do this by not changing that from the kernel.

    http : / / stackoverflow.com/questions/4405670/how-to-use-sysfs-inside-kernel-module

    In fact, the post absolutely discourages the previous method.

    I loaded the module and set the noop scheduler by creating a function that runs right after the slot is enabled.

    More details can be found here: http : / / linux.ximeta.com:8000/trac/ticket/1142

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •