[PATCH] Update disk statistics for cciss and cpqarray devices

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

 



The request functions for cciss and cpqarray drivers do not update
statistics upon request completion.  This would normally be done in
end_that_request_first(), but this function is not used by these
drivers, so the number of sectors read/written (as reported
in /proc/diskstat and consequently also by utilities like iostat) is
always zero.

The following patch adds correct statistics for both drivers.

Signed-off-by: Petr Tesarik <[email protected]>

diff --git a/drivers/block/cciss.c b/drivers/block/cciss.c
index 6ffe2b2..235ecce 100644
--- a/drivers/block/cciss.c
+++ b/drivers/block/cciss.c
@@ -1298,6 +1298,12 @@ static void cciss_softirq_done(struct re
 		pci_unmap_page(h->pdev, temp64.val, cmd->SG[i].Len, ddir);
 	}
 
+	if (blk_fs_request(rq)) {
+                const int rw = rq_data_dir(rq);
+
+                disk_stat_add(rq->rq_disk, sectors[rw], bio_sectors(rq->bio));
+	}
+
 	complete_buffers(rq->bio, rq->errors);
 
 #ifdef CCISS_DEBUG
diff --git a/drivers/block/cpqarray.c b/drivers/block/cpqarray.c
index 570d2f0..902155d 100644
--- a/drivers/block/cpqarray.c
+++ b/drivers/block/cpqarray.c
@@ -998,6 +998,7 @@ static inline void complete_buffers(stru
  */
 static inline void complete_command(cmdlist_t *cmd, int timeout)
 {
+	struct request *rq = cmd->rq;
 	int ok=1;
 	int i, ddir;
 
@@ -1029,12 +1030,18 @@ static inline void complete_command(cmdl
                 pci_unmap_page(hba[cmd->ctlr]->pci_dev, cmd->req.sg[i].addr,
 				cmd->req.sg[i].size, ddir);
 
-	complete_buffers(cmd->rq->bio, ok);
+	if (blk_fs_request(rq)) {
+                const int rw = rq_data_dir(rq);
 
-	add_disk_randomness(cmd->rq->rq_disk);
+                disk_stat_add(rq->rq_disk, sectors[rw], bio_sectors(rq->bio));
+	}
+
+	complete_buffers(rq->bio, ok);
+
+	add_disk_randomness(rq->rq_disk);
 
-        DBGPX(printk("Done with %p\n", cmd->rq););
-	end_that_request_last(cmd->rq, ok ? 1 : -EIO);
+	DBGPX(printk("Done with %p\n", rq););
+	end_that_request_last(rq, ok ? 1 : -EIO);
 }
 
 /*

Attachment: signature.asc
Description: Toto je =?iso-8859-2?Q?digit=E1ln=EC?= =?ISO-8859-1?Q?_podepsan=E1?= =?iso-8859-2?Q?_=E8=E1st?= =?ISO-8859-1?Q?_zpr=E1vy?=


[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux