Offhand I am not sure why you are getting this - mainly because I am not
sure what you are actually viewing.  I would tend to suspect that the
logging code isn't always displaying something when a request is started,
but that's just a guess.

-Eric

----- Original Message -----
From: "P.Basker" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Monday, May 29, 2000 2:31 AM
Subject: scsi buffer head write capturing


> hello all,
>
> I have this problem with scsi buffer cache mechanism. Im running
> 2.2.14-5.0smp on a dual processor i686, from the RH 6.2 distro.
>
> Im trying to capture the request function registered by the scsi device
> driver in 'struct blk_dev'. The following code captures the function and
> invokes itself before the real request function. Im also logging the
> number of buffer_heads requested for writes.
>
> But, when I write a file like "/etc/termcap"(size 620k) on sda10
> partition, I observe less number(around 221 blocks of 1k size) of blocks
> being captured by my test code. The "df" command shows more number of
> blocks being written on the disk partition.
>
> My question is why is my test code not able to trap all the write IOs,
> though, when I run a similar code for the IDE it shows me correct results.
> Here is my test code. Please enlighten me..
>
> TIA
>
> Animesh Singh.
>
>
> #define MODULE
> #define __KERNEL__
> #define __SMP__
>
> #include <linux/module.h>
> #include <linux/version.h>
> #include <linux/proc_fs.h>
> #include <asm/system.h>
> #include <linux/sched.h>
> #include <linux/string.h>
> #include <linux/delay.h>
> #include <linux/version.h>
> #include <asm/irq.h>
> #include <linux/kdev_t.h>
> #include <linux/blk.h>
>
> void (*readwrite_old)(void);
> kdev_t source_kdev_t;
> static int counter;
> void readwrite_new(void){
> int flags;
> struct request *req_head;
> struct buffer_head *bh_ptr;
>
> for(req_head = blk_dev[SCSI_DISK0_MAJOR].current_request;
>     req_head;
>     req_head = req_head->next){
> if(req_head->rq_dev == source_kdev_t){
> printk(KERN_CRIT "\n");
> for(bh_ptr = req_head->bh;
>         bh_ptr;
>         bh_ptr = bh_ptr->b_next)
> if(req_head->cmd == WRITE)
> ++counter;
> file://printk(KERN_CRIT "blocknr = %ld\n",bh_ptr->b_blocknr);
> }
> }
> printk(KERN_CRIT "blocknr = %d\n",counter);
> readwrite_old();
> }
>
> static struct scsi_device *marker;
>
> int init_module(void){
> int flags;
> source_kdev_t = MKDEV(SCSI_DISK0_MAJOR,10);
> spin_lock_irqsave(&io_request_lock, flags);
> readwrite_old = blk_dev[SCSI_DISK0_MAJOR].request_fn;
> blk_dev[SCSI_DISK0_MAJOR].request_fn = readwrite_new;
> spin_unlock_irqrestore(&io_request_lock,flags);
>         return(0);
> }
> void cleanup_module(void){
> int flags;
> spin_lock_irqsave(&io_request_lock, flags);
> blk_dev[SCSI_DISK0_MAJOR].request_fn = readwrite_old;
> spin_unlock_irqrestore(&io_request_lock,flags);
>         printk("Cleaning Up and Leaving %d\n",counter);
> }
>
>
>
>
>
>
> -
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to [EMAIL PROTECTED]
>


-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]

Reply via email to