Re: Hunting for the block id bug in NDAS for linux

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi again from David!


On 04/10/2012 12:42 PM, Prashant Shah wrote:
Sorry for delay I was bit busy this week.
Busy Busy!
It is good to be busy. Keeps us out of trouble



I am also stumped on how to proceed. I will still keep working on it.
Stumped like me! :)

For a little more investigation, I did a diff with a ndas-1.1-23 which I found in the back of a hard disk around here. The changes were pretty minimal. I'll paste them at the end in case you'd like to see.

All the changes in that case have been there from the beginning, and the blkid bug came up with kernel 2.6.25, so one of those changes might be related.

I think I am going to add a debug statment by every "request" , "req" , "queue" , "(q)" etc. and see what it outputs after compiling again on the different fedoras.

Maybe this will give me a clue where the processing gets a hold of the wrong request or queue or if it the requests are just formed incorrectly.

Pray for success!




On Thu, Apr 5, 2012 at 7:37 AM, linux at iocellnetworks
<linux@xxxxxxxxxxxxxxxxxx>  wrote:
Hi Prahsant!



On Mon, Apr 2, 2012 at 10:18 PM, Prashant Shah<pshah.mumbai@xxxxxxxxx>
wrote:
Hi,

Log of how the driver loads itself (all the function calls are
listed). If I have some doubts regarding the LPX I will ask.

Thanks for that. It is pretty high over my head, but I think It will be a
good start for some higher level documentation.

On my side, I did a cut and paste of many lines from the linux loop device
and the AOE function that is equvalent of our slot_enable.

The driver did recognize and prepare two block devices at the right place.
However, there was no list of partitions after the disk was created, and
when I did disable and "sh ndas stop" the computer froze.

So the blkid cure is still a ways off.

I think the block device io is not automatically directed.

I will get back to scripting the pogo plug installation right now. I had
some orders to fill last couple days.


Here is my hacked slot_enable() in case you'd like to plug it in for crash.

/*
    Create system device file for the enabled slot.
*/
ndas_error_t slot_enable(int s)
{
        ndas_error_t ret = NDAS_ERROR_INTERNAL;
        int got;

        struct ndas_slot *slot = NDAS_GET_SLOT_DEV(s);
        struct gendisk *ud;
        char short_serial[NDAS_SERIAL_SHORT_LENGTH + 1];

        got = try_module_get(THIS_MODULE);
        MOD_INC_USE_COUNT;

        dbgl_blk(4, "enabling slot int s#=%d slot=%p",s, slot);
        if ( slot == NULL)
                goto out1;

        if ( slot->enabled ) {
                dbgl_blk(1, "already enabled");
                ret = NDAS_OK;
                goto out;
        }

        ret = ndas_query_slot(s,&slot->info);
        if ( !NDAS_SUCCESS(ret) ) {
                dbgl_blk(1, "fail ndas_query_slot");
                goto out;
        }

        dbgl_blk(1, "mode=%d", slot->info.mode);

        slot->enabled = 1;

        slot->queue = blk_alloc_queue(GFP_KERNEL);
        if (!slot->queue)
                goto out_free_dev;

        dbgl_blk(1, "slot->queue allocated for slot# %d", s);

        ud = slot->disk = alloc_disk(NR_PARTITION); /* slot->disk = NULL; */
        if (!ud) {
                slot->enabled = 0;
                dbgl_blk(1, "fail alloc disk for slot=%d\n", s);
                goto out_free_queue;
        }

        dbgl_blk(1, "slot->disk @ud created for slot# %d", s);

        spin_lock_init(&slot->lock);
        ud->major = NDAS_BLK_MAJOR;
        ud->first_minor = (s - NDAS_FIRST_SLOT_NR)<<    PARTN_BITS;
        ud->fops =&ndas_fops;
        ud->queue = slot->queue;
        ud->private_data = (void*) (long)s;
        slot->queue_flags = 0;

        dbgl_blk(4, "mode=%d", slot->info.mode);

        /*
         * Extended serial number is too long as sysfs object name.
         * Use last 8 digit only
         */
        if (strlen(slot->info.ndas_serial)>    8) {
                strncpy( short_serial, slot->info.ndas_serial +
                        ( NDAS_SERIAL_EXTEND_LENGTH -
NDAS_SERIAL_SHORT_LENGTH), 8);
        } else {
                strncpy(short_serial, slot->info.ndas_serial, 8);
        }
        short_serial[8] = 0;

        snprintf(slot->devname, sizeof(slot->devname)-1,
                "ndas-%s-%d", short_serial, slot->info.unit);

        strcpy(ud->disk_name, slot->devname);
        dbgl_blk(4, "strcopy  ud->disk_name=%s, slot->devname=%s",
                ud->disk_name, slot->devname );

        set_capacity(ud, slot->info.sectors);
        dbgl_blk(4, "just set capacity ud->disk, slot->info.sectors:%llu",
                slot->info.sectors);

        dbgl_blk(1, "adding ndas unit disk: slot=%d, first_minor=%d,
capacity=%llu", s,
                slot->disk->first_minor, slot->info.sectors);

        add_disk(ud);

        dbgl_blk(4, "added disk: slot=%d", s);

        printk("ndas: /dev/%s enabled\n", slot->devname);

        dbgl_blk(4, "done");
        return NDAS_OK;

out_free_queue:
        if ( got ) module_put(THIS_MODULE);
        MOD_DEC_USE_COUNT;
        blk_cleanup_queue(slot->queue);
        return NDAS_OK;

out_free_dev:
        if ( got ) module_put(THIS_MODULE);
        MOD_DEC_USE_COUNT;
        kfree(slot);
        return NDAS_OK;

out1:
        if ( got ) module_put(THIS_MODULE);
        MOD_DEC_USE_COUNT;

out:
        if ( got ) module_put(THIS_MODULE);
        MOD_DEC_USE_COUNT;
        return ret;

}





******************************
Diff from version 1.1.-22 & 1.1-24
******************************

diff -rupN ndas-1.1-22/block/block26.c ndas-1.1-24/block/block26.c
--- ndas-1.1-22/block/block26.c 2008-04-24 18:05:43.000000000 -0400
+++ ndas-1.1-24/block/block26.c 2008-06-30 21:27:19.000000000 -0400

@@ -40,6 +40,9 @@
 #include "block.h"
 #include "ops.h"

+#if ( LINUX_VERSION_CODE>= KERNEL_VERSION(2,6,25) )
+#include<linux/ide.h>
+#endif
 //
 // IDE command code
 //


@@ -263,14 +266,22 @@ _end_io(ndas_error_t err, struct request
 {
     unsigned long flags;
     struct request_queue *q = req->q;
+#if ( LINUX_VERSION_CODE>= KERNEL_VERSION(2,6,25) )
+    int error = NDAS_SUCCESS(err) ? 0 : -EIO;
+#else
     int uptodate = NDAS_SUCCESS(err) ? 1 : 0;
+#endif

 #if 0
     _dump_ioreq(req);
 #endif

     spin_lock_irqsave(q->queue_lock, flags);
+#if ( LINUX_VERSION_CODE>= KERNEL_VERSION(2,6,25) )
+    if ( error ) {
+#else
     if ( !uptodate ) {
+#endif
         printk("ndas: IO error occurred at sector %d(slot %d): %s\n",
             (int)req->sector,
             SLOT_R(req),


@@ -287,10 +298,13 @@ _end_io(ndas_error_t err, struct request
     }

 //    _print_request(req);
+#if ( LINUX_VERSION_CODE>= KERNEL_VERSION(2,6,25) )
+    __blk_end_request(req, error, nr_sectors<<  9);
+#else
      if(!end_that_request_first(req, uptodate, nr_sectors)) {
         END_THAT_REQUEST_LAST(req, uptodate);
     }
-
+#endif
     spin_unlock_irqrestore(q->queue_lock, flags);
 }
 /* signalled when the NDAS io is completed


@@ -358,8 +372,9 @@ ndas_error_t nblk_handle_io(struct reque
     ndas_req->done_arg = NULL;
 #endif

-
-#if (LINUX_VERSION_CODE>= KERNEL_VERSION(2,6,19))
+#if ( LINUX_VERSION_CODE>= KERNEL_VERSION(2,6,25) )
+   if ( req->cmd_type == REQ_TYPE_ATA_TASKFILE )
+#elif (LINUX_VERSION_CODE>= KERNEL_VERSION(2,6,19))
     if(req->cmd_type == REQ_TYPE_ATA_TASK)
 #else
     if(REQUEST_FLAGS(req)&  (REQ_DRIVE_TASK))
@@ -421,13 +436,19 @@ void nblk_request_proc(struct request_qu
             REQUEST_FLAGS(req) |= REQ_QUIET;
             REQUEST_FLAGS(req) |= REQ_FAILFAST; /* do not retry */
             REQUEST_FLAGS(req) |= REQ_FAILED;
+#if ( LINUX_VERSION_CODE>= KERNEL_VERSION(2,6,25) )
+            __blk_end_request(req, -EIO, req->nr_sectors<<  9);
+#else
             while (end_that_request_first(req, 0, req->nr_sectors))
                      ;
             END_THAT_REQUEST_LAST(req, 0);
-
+#endif
             continue;
         }
-#if (LINUX_VERSION_CODE>= KERNEL_VERSION(2,6,19))
+
+#if ( LINUX_VERSION_CODE>= KERNEL_VERSION(2,6,25) )
+       if (!BLK_CHECK_VALID_STATUS(req)&&  req->cmd_type != REQ_TYPE_ATA_TASKFILE)
+#elif (LINUX_VERSION_CODE>= KERNEL_VERSION(2,6,19))
         if (!BLK_CHECK_VALID_STATUS(req)&&  req->cmd_type != REQ_TYPE_ATA_TASK)
 #elif (LINUX_VERSION_CODE>= KERNEL_VERSION(2,6,16))
         if (!BLK_CHECK_VALID_STATUS(req)&&  !(REQUEST_FLAGS(req)&  (REQ_DRIVE_TASK)))


@@ -466,7 +487,9 @@ void nblk_prepare_flush(request_queue_t

     // Indicate IDE task command reqest.
     // We adopt IDE task command for NDAS block device's flush command.
-#if (LINUX_VERSION_CODE>= KERNEL_VERSION(2,6,19))
+#if ( LINUX_VERSION_CODE>= KERNEL_VERSION(2,6,25) )
+    req->cmd_type = REQ_TYPE_ATA_TASKFILE;
+#elif (LINUX_VERSION_CODE>= KERNEL_VERSION(2,6,19))
     req->cmd_type = REQ_TYPE_ATA_TASK;
 #else
     REQUEST_FLAGS(req) |= REQ_DRIVE_TASK;


diff -rupN ndas-1.1-22/block/ctrldev.c ndas-1.1-24/block/ctrldev.c
--- ndas-1.1-22/block/ctrldev.c 2008-04-24 18:05:43.000000000 -0400
+++ ndas-1.1-24/block/ctrldev.c 2008-06-30 21:27:19.000000000 -0400

@@ -1118,9 +1118,16 @@ int ndas_ctrldev_init(void)
         return PTR_ERR(ndas_ctrldev_class);
     }

+#if LINUX_VERSION_HAS_DEVICE_CREATE
+    device_create_drvdata(ndas_ctrldev_class, NULL,
+        MKDEV(NDAS_CHR_DEV_MAJOR, NDAS_CHR_DEV_MINOR),
+        NULL, "ndas");
+#else
     class_device_create(ndas_ctrldev_class, NULL,
         MKDEV(NDAS_CHR_DEV_MAJOR, NDAS_CHR_DEV_MINOR),
         NULL, "ndas");
+#endif //#if LINUX_VERSION_HAS_DEVICE_CREATE
+
 #else
     ndas_ctrldev_class = class_simple_create(THIS_MODULE, "ndas");
     if (IS_ERR(ndas_ctrldev_class)) {


@@ -1144,7 +1151,13 @@ int ndas_ctrldev_cleanup(void)
 {
 #if LINUX_VERSION_25_ABOVE
 #if LINUX_VERSION_HAS_CLASS_CREATE
+
+#if LINUX_VERSION_HAS_DEVICE_CREATE
+    device_destroy(ndas_ctrldev_class, MKDEV(NDAS_CHR_DEV_MAJOR, NDAS_CHR_DEV_MINOR));
+#else
     class_device_destroy(ndas_ctrldev_class, MKDEV(NDAS_CHR_DEV_MAJOR, NDAS_CHR_DEV_MINOR));
+#endif //#if LINUX_VERSION_HAS_DEVICE_CREATE
+
     class_destroy(ndas_ctrldev_class);
 #else
     class_simple_device_remove(MKDEV(NDAS_CHR_DEV_MAJOR, NDAS_CHR_DEV_MINOR));
(END)


_______________________________________________
devel mailing list
devel@xxxxxxxxxxxxxxxxxxxxxx
http://driverdev.linuxdriverproject.org/mailman/listinfo/devel


[Index of Archives]     [Linux Driver Backports]     [DMA Engine]     [Linux GPIO]     [Linux SPI]     [Video for Linux]     [Linux USB Devel]     [Linux Coverity]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux