On Sun, Aug 12, 2001 at 08:34:13PM +0200, g-skjold wrote: > Hi. I got a Promise Fasttrak66 RAID controller. Almost everything seems to > work fine. When I 'cfdisk /dev/ataraid/d0', it looks like its working. BUT, > after I have made a partition, and do a 'mke2fs /dev/ataraid/d0', it looks > like its making a fs om one of the disks... The partition is half the size of > what I made. But cfdisk still says its a 6,4GB. > > What I also did by accident, was to make an ext2 fs directly on the HD: > 'mke2fs /dev/ataraid/d0'. THEN, it was 6,4GB like it is supposed to be. So I > guess the partition dev's are kinda fucked, while the main dev works. > > It would be nice to have partiotions... =) If you know what I mean...;) Ok this is the second such report in two days ;( Could you please post the partition info as fdisk sees it in expert mode ? And also mail me the output of the attached program (off-list as it's rather huge) ? Greetings, Arjan van de Ven
#define __LARGEFILE64_SOURCE #define __USE_GNU */ #include <unistd.h> #include <sys/ioctl.h> #include <stdio.h> #include <fcntl.h> #include <linux/hdreg.h> #include <linux/fs.h> #include <string.h> #include <assert.h> typedef unsigned int uint32_t; struct promise_raid_conf { char promise_id[24]; #define PR_MAGIC "Promise Technology, Inc." int32_t dummy_0; int32_t magic_0; int32_t dummy_1; int32_t magic_1; int16_t dummy_2; int8_t filler1[470]; struct { int32_t flags; /* 0x200 */ #define PR_F_CONFED 0x00000080 int8_t dummy_0; int8_t disk_number; int8_t channel; int8_t device; int32_t magic_0; int32_t dummy_1; int32_t dummy_2; /* 0x210 */ int32_t disk_secs; int32_t dummy_3; int16_t dummy_4; int8_t status; #define PR_S_DEFINED 0x01 #define PR_S_ONLINE 0x02 #define PR_S_OFFLINE 0x10 int8_t type; #define PR_T_STRIPE 0x00 #define PR_T_MIRROR 0x01 #define PR_T_STRIPE_MIRROR 0x04 #define PR_T_SPAN 0x08 u_int8_t total_disks; /* 0x220 */ u_int8_t raid0_shift; u_int8_t raid0_disks; u_int8_t array_number; u_int32_t total_secs; u_int16_t cylinders; u_int8_t heads; u_int8_t sectors; int32_t magic_1; int32_t dummy_5; /* 0x230 */ struct { int16_t dummy_0; int8_t channel; int8_t device; int32_t magic_0; int32_t disk_number; } disk[8]; } raid; int32_t filler2[346]; uint32_t checksum; }; struct raidlist { int fd; int max_sector; int current_sector; }; struct raidlist raidlist[8]; int sectors; static unsigned long calc_pdcblock_offset (int fd) { unsigned long lba = 0; struct hd_big_geometry g; long sectors; int sector_size = 1; if (ioctl(fd, HDIO_GETGEO_BIG_RAW, &g)) return -1; if (ioctl(fd, BLKGETSIZE, §ors)) return -1; if (ioctl(fd, BLKSSZGET, §or_size)) return -1; if (!sector_size || !sectors || !g.cylinders || !g.heads || !g.sectors) return -1; sector_size /= 512; g.cylinders = (sectors / (g.heads * g.sectors)) / sector_size; lba = g.cylinders * (g.heads*g.sectors); lba = lba - g.sectors; return lba; } static int read_disk_sb (int fd, unsigned char *buffer,int bufsize) { int ret = -1; char bh[4096]; unsigned long long sb_offset; /* * Calculate the position of the superblock, * it's at first sector of the last cylinder */ sb_offset = calc_pdcblock_offset(fd) * 512; if (sb_offset == -1) return -1; lseek64(fd, sb_offset, SEEK_SET); read (fd, buffer, bufsize); ret = 0; return ret; } static unsigned int calc_sb_csum (unsigned int* ptr) { unsigned int sum; int count; sum = 0; for (count=0;count<511;count++) sum += *ptr++; return sum; } static int check_disk_sb (void) { return 0; } int pdc_dev_running_raid(int fd) { int i; struct promise_raid_conf *prom; unsigned char block[4096]; if (read_disk_sb(fd,(unsigned char*)&block,sizeof(block))) return -1; prom = (struct promise_raid_conf*)&block[0]; printf("Disk number : %i \n",prom->raid.disk_number); printf("Channel : %i \n",prom->raid.channel); printf("Device : %i \n",prom->raid.device); printf("Sectors : %i \n",prom->raid.disk_secs); printf("Status : %i \n",prom->raid.status); printf("Type : %i \n",prom->raid.type); printf("Total disks : %i \n",prom->raid.total_disks); printf("RAID0 shift : %i (%i)\n",prom->raid.raid0_shift,(1<<prom->raid.raid0_shift)); sectors = (1<<prom->raid.raid0_shift); printf("RAID0 disks : %i \n",prom->raid.raid0_disks); printf("Array number : %i \n",prom->raid.array_number); printf("Total secs : %i \n",prom->raid.total_secs); printf("Cylinders : %i \n",prom->raid.cylinders); printf("Heads : %i \n",prom->raid.heads); printf("Dummy 1 : %x \n",prom->raid.dummy_1); printf("Dummy 2 : %x \n",prom->raid.dummy_2); printf("Dummy 3 : %x \n",prom->raid.dummy_3); printf("Dummy 4 : %x \n",prom->raid.dummy_4); printf("Dummy 5 : %x \n",prom->raid.dummy_5); for (i=0;i<prom->raid.total_disks;i++) { printf("%i -> channel %i \n",i,prom->raid.disk[i].channel); printf("%i -> device %i \n",i,prom->raid.disk[i].device); printf("%i -> disk_number %i \n",i,prom->raid.disk[i].disk_number); } if (!strcmp(prom->promise_id, "Promise Technology, Inc.") && (prom->checksum == calc_sb_csum((unsigned int*)prom))) { raidlist[prom->raid.disk_number].fd = fd; raidlist[prom->raid.disk_number].max_sector = prom->raid.disk_secs; printf("FOO"); return 1; } return 0; } int main() { int fd1,fd2; FILE *file1,*file2,*out; int done=0,total_sectors = 0; unsigned char *buffer; file1 = fopen("/dev/hde","r"); fd1 = fileno(file1); if (pdc_dev_running_raid(fd1)) printf("RAID\n"); else printf("noraid\n"); file2 = fopen("/dev/hdg","r"); fd2 = fileno(file2); if (pdc_dev_running_raid(fd2)) printf("RAID\n"); else printf("noraid\n"); out = fopen64("/tmp/out","w"); buffer = (unsigned char*)malloc(512*sectors); assert(buffer!=NULL); while (!done) { int i; done = 1; for (i=0;i<8;i++) { if (raidlist[i].max_sector <= raidlist[i].current_sector) continue; lseek64(raidlist[i].fd, raidlist[i].current_sector*512, SEEK_SET); read(raidlist[i].fd,buffer,sectors*512); fwrite(buffer,512*sectors,1,out); raidlist[i].current_sector += sectors; done = 0; total_sectors += sectors; } } fclose(file1); fclose(file2); fclose(out); }