Skip to contentSkip to conversation

ufs: make solaris fsck happy

PATCH In review Evgeniy Dushistov 2 participants 2 messages Feb 25, 2010 – Mar 2, 2010

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ufs: make solaris fsck happy

Alex Viskovatoff let me know that after copying data to solaris's ufs from linux, solaris's fsck sees some errors in cylinder summary information. This is because of solaris expects find some data on another places, then curernt implementation save it.
This patch fixes this issue. It is tested by me, and also Alex reported that it works for him.

---
 fs/ufs/ufs_fs.h |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)
fs/ufs/ufs_fs.h +7 -2
index 54bde18..f221c5e 100644
@@ -227,11 +227,16 @@ typedef __u16 __bitwise __fs16;
  */
 #define ufs_cbtocylno(bno) \
 	((bno) * uspi->s_nspf / uspi->s_spc)
-#define ufs_cbtorpos(bno) \
+#define ufs_cbtorpos(bno)				      \
+	((UFS_SB(sb)->s_flags & UFS_CG_SUN) ?		      \
+	 (((((bno) * uspi->s_nspf % uspi->s_spc) %	      \
+	    uspi->s_nsect) *				      \
+	   uspi->s_nrpos) / uspi->s_nsect)		      \
+	 :						      \
 	((((bno) * uspi->s_nspf % uspi->s_spc / uspi->s_nsect \
 	* uspi->s_trackskew + (bno) * uspi->s_nspf % uspi->s_spc \
 	% uspi->s_nsect * uspi->s_interleave) % uspi->s_nsect \
-	* uspi->s_nrpos) / uspi->s_npsect)
+	  * uspi->s_nrpos) / uspi->s_npsect))
 
 /*
  * The following macros optimize certain frequently calculated
Signature · 4 lines
1.6.5.6

-- 
/Evgeniy
#1 lore raw
Quoted 8 lines · On Thu, 25 Feb 2010 21:47:43 +0300 Evgeniy Dushistov <[email protected]> wrote:
fs/ufs/ufs_fs.h +1 -1
@@ -227,11 +227,16 @@ typedef __u16 __bitwise __fs16;
  */
 #define ufs_cbtocylno(bno) \
 	((bno) * uspi->s_nspf / uspi->s_spc)
-#define ufs_cbtorpos(bno) \
+#define ufs_cbtorpos(bno)				      \

fs/ufs/ufs_fs.h typedef __u16 __bitwise __fs16; · line 239

Quoted 10 lines
fs/ufs/ufs_fs.h +6 -1
+	((UFS_SB(sb)->s_flags & UFS_CG_SUN) ?		      \
+	 (((((bno) * uspi->s_nspf % uspi->s_spc) %	      \
+	    uspi->s_nsect) *				      \
+	   uspi->s_nrpos) / uspi->s_nsect)		      \
+	 :						      \
 	((((bno) * uspi->s_nspf % uspi->s_spc / uspi->s_nsect \
 	* uspi->s_trackskew + (bno) * uspi->s_nspf % uspi->s_spc \
 	% uspi->s_nsect * uspi->s_interleave) % uspi->s_nsect \
-	* uspi->s_nrpos) / uspi->s_npsect)
+	  * uspi->s_nrpos) / uspi->s_npsect))

yikes, that macro should be killed with a stick before it becomes self-aware and starts breeding.

Or converted into a C function which humans have a chance of understanding and maintaining.