Bug 45911 - GEOM-related problem sysutils/diskcheckd does not work
Summary: GEOM-related problem sysutils/diskcheckd does not work
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-12-02 10:10 UTC by Vladimir B.Grebenschikov
Modified: 2004-10-28 07:15 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Vladimir B.Grebenschikov 2002-12-02 10:10:00 UTC
It seem there are some problems with accessing HDD through GEOM:

# egrep -v \^# /usr/local/etc/diskcheckd.conf
/dev/ad0        *       28      *
# diskcheckd 
# tail /var/log/messages
...
Dec  2 12:46:50 vbook diskcheckd[1444]: DIOCGDINFO on /dev/ad0 failed: Operation not supported by device
# strace /usr/local/sbin/diskcheckd -d
...
open("/dev/ad0", O_RDONLY)              = 3
ioctl(3, DIOCGDINFO, 0xbfbff250)        = -1 ENODEV (Operation not supported by device)
...

When I have change /dev/ad0 in config file to /dev/ad0s2c it work. But I
want to check integrity of all drive, not only FreeBSD part.

How-To-Repeat: Just run diskcheckd on post-GEOM CURRENT.
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2003-09-29 14:45:11 UTC
Hello Ben,

Could you please have a look at this PR? Right now sysutils/diskcheckd
is pretty much dead in the water.

Edwin

-- 
Edwin Groothuis
edwin@freebsd.org
http://www.mavetju.org
Comment 2 ben freebsd_committer freebsd_triage 2003-09-29 15:06:05 UTC
Edwin Groothuis wrote:

> Could you please have a look at this PR? Right now sysutils/diskcheckd
> is pretty much dead in the water.


I'll look, but I really don't have much time for FreeBSD at the moment,
unfortunately. :-( I didn't realize I was the maintainer of that port
actually ... could you set it back to ports@ please?

thanks,
-ben

-- 
Ben Smithurst / ben@FreeBSD.org                 FreeBSD: The Power To Serve
                                                    http://www.FreeBSD.org/
Comment 3 edwin 2003-09-29 15:36:19 UTC
On Mon, Sep 29, 2003 at 07:10:12AM -0700, Ben Smithurst wrote:
> Cc: freebsd-gnats-submit@FreeBSD.org
> Subject: Re: ports/45911 - sysutils/diskcheckd
> Date: Mon, 29 Sep 2003 15:06:05 +0100
> 
>  Edwin Groothuis wrote:
>  
>  > Could you please have a look at this PR? Right now sysutils/diskcheckd
>  > is pretty much dead in the water.
>  
>  I'll look, but I really don't have much time for FreeBSD at the moment,
>  unfortunately. :-( I didn't realize I was the maintainer of that port
>  actually ... could you set it back to ports@ please?

You aren't the maintainer, you are the author of the original code.
That's why I thought you might have a better chance of understanding
what it is doing or what is going wrong.

Edwin

-- 
Edwin Groothuis      |            Personal website: http://www.mavetju.org
edwin@mavetju.org    |    Weblog: http://www.mavetju.org/weblog/weblog.php
Comment 4 ben freebsd_committer freebsd_triage 2003-09-29 15:49:28 UTC
Edwin Groothuis wrote:

>>  I'll look, but I really don't have much time for FreeBSD at the moment,
>>  unfortunately. :-( I didn't realize I was the maintainer of that port
>>  actually ... could you set it back to ports@ please?
> 
> You aren't the maintainer, you are the author of the original code.
>
> That's why I thought you might have a better chance of understanding
> what it is doing or what is going wrong.


It just looks to me like the rules for opening raw devices has changed
in -current?  I don't use -current so I can't easily play with this.

sorry.

-- 
Ben Smithurst / ben@FreeBSD.org                 FreeBSD: The Power To Serve
                                                    http://www.FreeBSD.org/
Comment 5 Mark Linimon freebsd_committer freebsd_triage 2004-03-14 00:28:36 UTC
State Changed
From-To: open->suspended

Mark suspended until someone submits patches, or volunteers to take 
over this port, or both.  Note that since the port doesn't work on 
5.X, it's in pretty bad shape.  If no one steps forward, it should 
probably be marked as DEPRECATED and phased out.
Comment 6 Valentin Nechayev 2004-09-21 17:06:53 UTC
Following patch makes it at least starting and successfully testing.
I can't provide now bad disk to check error reporting;), but here only
logging problem can appear, not functioning problem.

diff -rNu 0/ports/sysutils/diskcheckd/files/diskcheckd.c 1/ports/sysutils/diskcheckd/files/diskcheckd.c
--- 0/ports/sysutils/diskcheckd/files/diskcheckd.c	Mon Oct 21 03:34:31 2002
+++ 1/ports/sysutils/diskcheckd/files/diskcheckd.c	Tue Sep 21 18:59:13 2004
@@ -27,7 +27,7 @@
 static const char rcsid[] =
 	"$FreeBSD: ports/sysutils/diskcheckd/files/diskcheckd.c,v 1.6 2002/10/21 00:34:31 kris Exp $";
 
-#include <sys/types.h>
+#include <sys/param.h>
 #include <sys/sysctl.h>
 
 #include <ctype.h>
@@ -46,6 +46,7 @@
 
 #define DKTYPENAMES
 #define FSTYPENAMES
+#include <sys/disk.h>
 #include <sys/disklabel.h>
 #include <sys/diskmbr.h>
 
@@ -757,7 +758,23 @@
 void
 getdisksize(struct disk *dp) {
 	struct disklabel label;
+#if __FreeBSD_version >= 500040
+	off_t mediasize;
+	u_int sectorsize;
 
+	if (ioctl(dp->fd, DIOCGSECTORSIZE, &sectorsize) < 0) {
+		syslog(LOG_NOTICE, "DIOCGSECTORSIZE on %s failed: %m",
+		    dp->device);
+		exit(EXIT_FAILURE);
+	}
+	if (ioctl(dp->fd, DIOCGMEDIASIZE, &mediasize) < 0) {
+		syslog(LOG_NOTICE, "DIOCGMEDIASIZE on %s failed: %m",
+		    dp->device);
+		exit(EXIT_FAILURE);
+	}
+	dp->secsize = sectorsize;
+	dp->size = mediasize;
+#else
 	if (ioctl(dp->fd, DIOCGDINFO, &label) < 0) {
 		syslog(LOG_NOTICE, "DIOCGDINFO on %s failed: %m",
 		    dp->device);
@@ -766,6 +783,7 @@
 
 	dp->secsize = label.d_secsize;
 	dp->size = (off_t)label.d_secperunit * label.d_secsize;
+#endif
 
 	if (label.d_secsize != 512)
 		syslog(LOG_NOTICE,
Comment 7 Valentin Nechayev 2004-09-21 20:00:23 UTC
Resend previous patch with minor fix. This seems to be working and correctly
reporting. Previous erroneosuly warned for incorrect sector size.

(Note that code in logreaderror() is strictly bounded to DOS partitioning
scheme and BSD labels in primary slices. This isn't too bad for now, but
may confuse when using another schemes, e.g. GPT.)

--- 0/ports/sysutils/diskcheckd/files/diskcheckd.c	Mon Oct 21 03:34:31 2002
+++ 1/ports/sysutils/diskcheckd/files/diskcheckd.c	Tue Sep 21 21:48:13 2004
@@ -27,7 +27,7 @@
 static const char rcsid[] =
 	"$FreeBSD: ports/sysutils/diskcheckd/files/diskcheckd.c,v 1.6 2002/10/21 00:34:31 kris Exp $";
 
-#include <sys/types.h>
+#include <sys/param.h>
 #include <sys/sysctl.h>
 
 #include <ctype.h>
@@ -46,6 +46,7 @@
 
 #define DKTYPENAMES
 #define FSTYPENAMES
+#include <sys/disk.h>
 #include <sys/disklabel.h>
 #include <sys/diskmbr.h>
 
@@ -757,7 +758,23 @@
 void
 getdisksize(struct disk *dp) {
 	struct disklabel label;
+#if __FreeBSD_version >= 500040
+	off_t mediasize;
+	unsigned sectorsize;
 
+	if (ioctl(dp->fd, DIOCGSECTORSIZE, &sectorsize) < 0) {
+		syslog(LOG_NOTICE, "DIOCGSECTORSIZE on %s failed: %m",
+		    dp->device);
+		exit(EXIT_FAILURE);
+	}
+	if (ioctl(dp->fd, DIOCGMEDIASIZE, &mediasize) < 0) {
+		syslog(LOG_NOTICE, "DIOCGMEDIASIZE on %s failed: %m",
+		    dp->device);
+		exit(EXIT_FAILURE);
+	}
+	dp->secsize = label.d_secsize = sectorsize;
+	dp->size = mediasize;
+#else
 	if (ioctl(dp->fd, DIOCGDINFO, &label) < 0) {
 		syslog(LOG_NOTICE, "DIOCGDINFO on %s failed: %m",
 		    dp->device);
@@ -766,6 +783,7 @@
 
 	dp->secsize = label.d_secsize;
 	dp->size = (off_t)label.d_secperunit * label.d_secsize;
+#endif
 
 	if (label.d_secsize != 512)
 		syslog(LOG_NOTICE,
Comment 8 FUJISHIMA Satsuki freebsd_committer freebsd_triage 2004-10-28 06:41:39 UTC
$ ls -l /usr/local/sbin/diskcheckd 
-r-xr-xr-x  1 root  wheel  14860 Sep 28 02:13 /usr/local/sbin/diskcheckd*

I'm running this on -CURRENT with your fix for a month.
And finally I got an event we wanted to see(?):

Oct 27 02:20:05 souffle kernel: ad0: TIMEOUT - READ_DMA retrying (2 retries left) LBA=738048
Oct 27 02:20:05 souffle kernel: ad0: FAILURE - READ_DMA timed out
Oct 27 02:20:04 souffle diskcheckd[591]: error reading 65536 bytes from sector 738176 on /dev/ad0
Oct 27 02:20:05 souffle diskcheckd[591]: DIOCGDINFO on /dev/ad0s1 failed: Inappropriate ioctl for device

Now the time for commit!
Comment 9 FUJISHIMA Satsuki freebsd_committer freebsd_triage 2004-10-28 07:13:39 UTC
State Changed
From-To: suspended->closed

fixed by Valentin Nechayev.