public inbox for linux-mtd@lists.infradead.org
 help / color / mirror / Atom feed
From: Peter Kundrat <kundrat@pkx.sk>
To: mtd@infradead.org
Subject: small nftl fix
Date: Wed, 4 Oct 2000 04:26:29 +0200	[thread overview]
Message-ID: <20001004042629.A2152@napri.sk> (raw)
In-Reply-To: <6998.970054171@passion.cygnus.co.uk>; from dwmw2@infradead.org on Wed, Sep 27, 2000 at 12:29:31PM +0100

[-- Attachment #1: Type: text/plain, Size: 1164 bytes --]

Greetings,

When writing to an empty fs on nftl, I always got garbled partition table.
Looking at the nftl.c, there seems to be a problem with overwriting media header
(which seems to be at the FirstPhysicalEUN). 

So the patch simply skips first two units (i'd like to know if magic constant 2 
is fine (i got it from nftl_format.c)).

Except for that there is a smal fix for LEVEL3 debug eliminating the dump of
"unrecognised partitions" (it was not very syslog friendly anyways).

Last part is about setting LastFreeEUN after the scanning loop .. which didnt
make sense to me .. (it is not correct before the loop either - for the
case of no empty blocks, but seems better :).
Anyways its quite late now, so i may have missed something.

Another problem is the fact, that VirtualUnitTable and ReplUnitTable are
allocated for NumEraseUnits, but are indexed with absolute EUN numbers .. 

Also WriteInh seems to be set to 0x1 on all my units (formatted by m-sys utils),
but the code checks for 0xffffffff .. is that value in specification ?


	Thats for tonight, more later,

		pkx

PS: is it possible to obtain specifications for DOC devices resp. nftl layout ?

[-- Attachment #2: first-eun-pkx.patch --]
[-- Type: text/plain, Size: 2804 bytes --]

--- nftl.c.orig	Sun Oct  1 11:52:19 2000
+++ nftl.c	Wed Oct  4 03:46:17 2000
@@ -237,10 +237,11 @@
 	nftl->lastEUN = le16_to_cpu(nftl->MediaHdr.NumEraseUnits) +
 		le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN) - 1;
 	nftl->numfreeEUNs = 0;
+	nftl->LastFreeEUN = le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN)+2;
 
 	/* Scan each physical Erase Unit for validity and to find the 
 	   Virtual Erase Unit Chain to which it belongs */
-	for (i = le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN); i <= nftl->lastEUN; i++) {
+	for (i = le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN)+2; i <= nftl->lastEUN; i++) {
 		union nftl_uci uci;
 		unsigned long ofs;
 		size_t retlen;
@@ -277,6 +278,10 @@
 		nftl->VirtualUnitTable[i] = le16_to_cpu(uci.a.VirtUnitNum);
 		nftl->ReplUnitTable[i] = le16_to_cpu(uci.a.ReplUnitNum);
 
+		if (nftl->ReplUnitTable[i] < le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN)+2) 
+			printk(KERN_WARNING "EUN %d: is replaced by HDR EUN (%x)\n", i,
+			       le16_to_cpu(uci.a.ReplUnitNum));
+
 		/* if (!(VUN & 0x8000) && VUN < (arraybounds)).. optimises to: */
 		if (le16_to_cpu(uci.a.VirtUnitNum) < nftl->numvunits) 
 			nftl->EUNtable[le16_to_cpu(uci.a.VirtUnitNum) & 0x7fff] = i;
@@ -288,7 +293,6 @@
 		}
 	} 
 	NFTLs[firstfree] = nftl;
-	nftl->LastFreeEUN = le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN);
 
 #ifdef PSYCHO_DEBUG
 	for (i=0; i < 10/* nftl->numvunits*/; i++) {
@@ -377,17 +381,24 @@
 			}
 			if (!strncmp(hdr.DataOrgID, "ANAND", 6)) {
 				DEBUG(MTD_DEBUG_LEVEL2, "Valid NFTL partition at ofs 0x%lx\n", ofs);	
+				DEBUG(MTD_DEBUG_LEVEL2,"Erase Units: %d, FirstPhysicalEUN: %d, FormattedSize: %d, UnitSizeFactor: 0x%0x\n",
+				      hdr.NumEraseUnits, hdr.FirstPhysicalEUN,
+				      hdr.FormattedSize, hdr.UnitSizeFactor);
 				NFTL_setup(mtd, ofs, &hdr);
-			} else {
-				DEBUG(MTD_DEBUG_LEVEL3,"No valid NFTL Partition at ofs 0x%lx\n", ofs);
-				for (i = 0; i < 6; i++) {
-				    DEBUG(MTD_DEBUG_LEVEL3,"%x, ", hdr.DataOrgID[i]);
-				}
+			} /* else {
+				DEBUG(MTD_DEBUG_LEVEL3,
+				      "No valid NFTL Partition at ofs 0x%lx"
+				      ", DataOrgId %02.2x,%02.2x,%02.2x,%02.2x,%02.2x,%02.2x (%6.6s)\n",
+				      ofs, hdr.DataOrgID[0], hdr.DataOrgID[1], hdr.DataOrgID[2], 
+				           hdr.DataOrgID[4], hdr.DataOrgID[5], hdr.DataOrgID[6],
+					   hdr.DataOrgID);
+
 				DEBUG(MTD_DEBUG_LEVEL3," = %s\n", hdr.DataOrgID);
 				DEBUG(MTD_DEBUG_LEVEL3,"%d, %d, %d, %d\n",
 				      hdr.NumEraseUnits, hdr.FirstPhysicalEUN,
 				      hdr.FormattedSize, hdr.UnitSizeFactor);
 			}
+				*/
 		}
 		return;
 	}
@@ -430,7 +441,7 @@
 		}
 
 		if (++pot > nftl->lastEUN)
-			pot = le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN);
+			pot = le16_to_cpu(nftl->MediaHdr.FirstPhysicalEUN)+2;
 
 		if (!silly--) {
 			printk("Tell Dave he fucked up. LastFreeEUN = %d, "

  reply	other threads:[~2000-10-04  2:48 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <E13dhnU-0007fK-00@infradead.org>
2000-09-27  6:05 ` journalled fs on partitioned flash Peter Kundrat
2000-09-27  9:17   ` David Woodhouse
2000-09-27 11:22     ` David Given
2000-09-27 11:29       ` David Woodhouse
2000-10-04  2:26         ` Peter Kundrat [this message]
2000-10-18 16:45           ` small nftl fix David Woodhouse
2000-09-27 22:35     ` journalled fs on partitioned flash Peter Kundrat

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20001004042629.A2152@napri.sk \
    --to=kundrat@pkx.sk \
    --cc=mtd@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox