PERFORCE change 107581 for review
John Birrell
jb at FreeBSD.org
Mon Oct 9 14:13:54 PDT 2006
http://perforce.freebsd.org/chv.cgi?CH=107581
Change 107581 by jb at jb_freebsd7 on 2006/10/09 21:13:32
Reset this file to match current, removing the T1 simulator
code for sun4v.
Affected files ...
.. //depot/projects/dtrace/src/lib/libstand/ufs.c#6 edit
Differences ...
==== //depot/projects/dtrace/src/lib/libstand/ufs.c#6 (text+ko) ====
@@ -81,7 +81,6 @@
#include <sys/param.h>
#include <sys/disklabel.h>
#include <sys/time.h>
-#include <sys/stddef.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ufs/dir.h>
#include <ufs/ffs/fs.h>
@@ -111,136 +110,6 @@
ufs_readdir
};
-#if defined(__sparc64__) && defined(T1_SIMULATOR)
-typedef int32_t daddr32_t;
-typedef int32_t time32_t;
-typedef unsigned char uchar_t;
-#define MAXCSBUFS 32
-typedef struct _quad { int val[2]; } squad_t;
-struct solaris_fs {
- uint32_t fs_link; /* linked list of file systems */
- uint32_t fs_rolled; /* logging only: fs fully rolled */
- daddr32_t fs_sblkno; /* addr of super-block in filesys */
- daddr32_t fs_cblkno; /* offset of cyl-block in filesys */
- daddr32_t fs_iblkno; /* offset of inode-blocks in filesys */
- daddr32_t fs_dblkno; /* offset of first data after cg */
- int32_t fs_cgoffset; /* cylinder group offset in cylinder */
- int32_t fs_cgmask; /* used to calc mod fs_ntrak */
- time32_t fs_time; /* last time written */
- int32_t fs_size; /* number of blocks in fs */
- int32_t fs_dsize; /* number of data blocks in fs */
- int32_t fs_ncg; /* number of cylinder groups */
- int32_t fs_bsize; /* size of basic blocks in fs */
- int32_t fs_fsize; /* size of frag blocks in fs */
- int32_t fs_frag; /* number of frags in a block in fs */
-/* these are configuration parameters */
- int32_t fs_minfree; /* minimum percentage of free blocks */
- int32_t fs_rotdelay; /* num of ms for optimal next block */
- int32_t fs_rps; /* disk revolutions per second */
-/* these fields can be computed from the others */
- int32_t fs_bmask; /* ``blkoff'' calc of blk offsets */
- int32_t fs_fmask; /* ``fragoff'' calc of frag offsets */
- int32_t fs_bshift; /* ``lblkno'' calc of logical blkno */
- int32_t fs_fshift; /* ``numfrags'' calc number of frags */
-/* these are configuration parameters */
- int32_t fs_maxcontig; /* max number of contiguous blks */
- int32_t fs_maxbpg; /* max number of blks per cyl group */
-/* these fields can be computed from the others */
- int32_t fs_fragshift; /* block to frag shift */
- int32_t fs_fsbtodb; /* fsbtodb and dbtofsb shift constant */
- int32_t fs_sbsize; /* actual size of super block */
- int32_t fs_csmask; /* csum block offset */
- int32_t fs_csshift; /* csum block number */
- int32_t fs_nindir; /* value of NINDIR */
- int32_t fs_inopb; /* value of INOPB */
- int32_t fs_nspf; /* value of NSPF */
-/* yet another configuration parameter */
- int32_t fs_optim; /* optimization preference, see below */
-/* these fields are derived from the hardware */
- /* USL SVR4 compatibility */
-#ifdef _LITTLE_ENDIAN
- /*
- * USL SVR4 compatibility
- *
- * There was a significant divergence here between Solaris and
- * SVR4 for x86. By swapping these two members in the superblock,
- * we get read-only compatibility of SVR4 filesystems. Otherwise
- * there would be no compatibility. This change was introduced
- * during bootstrapping of Solaris on x86. By making this ifdef'ed
- * on byte order, we provide ongoing compatibility across all
- * platforms with the same byte order, the highest compatibility
- * that can be achieved.
- */
- int32_t fs_state; /* file system state time stamp */
-#else
- int32_t fs_npsect; /* # sectors/track including spares */
-#endif
- int32_t fs_si; /* summary info state - lufs only */
- int32_t fs_trackskew; /* sector 0 skew, per track */
-/* a unique id for this filesystem (currently unused and unmaintained) */
-/* In 4.3 Tahoe this space is used by fs_headswitch and fs_trkseek */
-/* Neither of those fields is used in the Tahoe code right now but */
-/* there could be problems if they are. */
- int32_t fs_id[2]; /* file system id */
-/* sizes determined by number of cylinder groups and their sizes */
- daddr32_t fs_csaddr; /* blk addr of cyl grp summary area */
- int32_t fs_cssize; /* size of cyl grp summary area */
- int32_t fs_cgsize; /* cylinder group size */
-/* these fields are derived from the hardware */
- int32_t fs_ntrak; /* tracks per cylinder */
- int32_t fs_nsect; /* sectors per track */
- int32_t fs_spc; /* sectors per cylinder */
-/* this comes from the disk driver partitioning */
- int32_t fs_ncyl; /* cylinders in file system */
-/* these fields can be computed from the others */
- int32_t fs_cpg; /* cylinders per group */
- int32_t fs_ipg; /* inodes per group */
- int32_t fs_fpg; /* blocks per group * fs_frag */
-/* this data must be re-computed after crashes */
- struct csum fs_cstotal; /* cylinder summary information */
-/* these fields are cleared at mount time */
- char fs_fmod; /* super block modified flag */
- char fs_clean; /* file system state flag */
- char fs_ronly; /* mounted read-only flag */
- char fs_flags; /* largefiles flag, etc. */
- char fs_fsmnt[512]; /* name mounted on */
-/* these fields retain the current block allocation info */
- int32_t fs_cgrotor; /* last cg searched */
- /*
- * The following used to be fs_csp[MAXCSBUFS]. It was not
- * used anywhere except in old utilities. We removed this
- * in 5.6 and expect fs_u.fs_csp to be used instead.
- * We no longer limit fs_cssize based on MAXCSBUFS.
- */
- union { /* fs_cs (csum) info */
- uint32_t fs_csp_pad[MAXCSBUFS];
- struct csum *fs_csp;
- } fs_u;
- int32_t fs_cpc; /* cyl per cycle in postbl */
- short fs_opostbl[16*8]; /* old rotation block list head */
- int32_t fs_sparecon[51]; /* reserved for future constants */
- int32_t fs_version; /* minor version of MTB ufs */
- int32_t fs_logbno; /* block # of embedded log */
- int32_t fs_reclaim; /* reclaim open, deleted files */
- int32_t fs_sparecon2; /* reserved for future constant */
-#ifdef _LITTLE_ENDIAN
- /* USL SVR4 compatibility */
- int32_t fs_npsect; /* # sectors/track including spares */
-#else
- int32_t fs_state; /* file system state time stamp */
-#endif
- squad_t fs_qbmask; /* ~fs_bmask - for use with quad size */
- squad_t fs_qfmask; /* ~fs_fmask - for use with quad size */
- int32_t fs_postblformat; /* format of positional layout tables */
- int32_t fs_nrpos; /* number of rotaional positions */
- int32_t fs_postbloff; /* (short) rotation block list head */
- int32_t fs_rotbloff; /* (uchar_t) blocks for each rotation */
- int32_t fs_magic; /* magic number */
- uchar_t fs_space[1]; /* list of blocks for each rotation */
-/* actually longer */
-};
-#endif
-
/*
* In-core open file.
*/
@@ -273,51 +142,7 @@
static int buf_write_file(struct open_file *, char *, size_t *);
static int search_directory(char *, struct open_file *, ino_t *);
-
/*
- * Search a directory for a name and return its
- * i_number.
- */
-
-#ifdef DEBUG
-static void hdump(uint8_t *bp, int size)
-{
- int i;
- int f = 1;
- uint8_t tmp[17];
-
- tmp[16] = '\0';
-
- for (i=0; i<size; i++) {
- uint8_t c;
-
- c = bp[i];
- if (f) {
- printf("%04x : ", i);
- f=0;
- }
- printf(" 0x%02x", c);
-
- if (c<32 || c>126) c='.';
- tmp[i&15] = c;
-
- if ((i&15)==15) {
- printf(" : %s\n", tmp);
- f=1;
- }
- }
- if (!f) {
- for (i=(i&15); i<16; i++) {
- printf(" --");
- tmp[i]=' ';
- }
- printf(" : %s\n", tmp);
- }
-}
-#endif
-
-
-/*
* Read a new inode into a file structure.
*/
static int
@@ -334,13 +159,6 @@
if (fs == NULL)
panic("fs == NULL");
-#ifdef DEBUG
- printf("read_inode : inumber=0x%llx fsba=0x%llx dba=0x%llx\n",
- (uint64_t)inumber,
- (uint64_t)ino_to_fsba(fs, inumber),
- (uint64_t)fsbtodb(fs, ino_to_fsba(fs, inumber)) );
-#endif
-
/*
* Read inode and save it.
*/
@@ -509,7 +327,6 @@
file_block = lblkno(fs, fp->f_seekp);
block_size = sblksize(fs, DIP(fp, di_size), file_block);
-
rc = block_map(f, file_block, &disk_block);
if (rc)
return (rc);
@@ -576,7 +393,6 @@
struct file *fp = (struct file *)f->f_fsdata;
struct fs *fs = fp->f_fs;
long off;
- size_t file_size;
ufs_lbn_t file_block;
ufs2_daddr_t disk_block;
size_t block_size;
@@ -584,26 +400,8 @@
off = blkoff(fs, fp->f_seekp);
file_block = lblkno(fs, fp->f_seekp);
- file_size = DIP(fp, di_size);
- block_size = sblksize(fs, file_size, file_block);
-#ifdef DEBUG
- printf("buf_read_file: fs->f_seekp=0x%llx : off=0x%lx : file_block=0x%lx : block_size=0x%llx\n",
- (uint64_t)fp->f_seekp, off, file_block, (uint64_t)block_size);
- printf("\tfile_size=0x%llx : fs_bsize=0x%llx\n", (uint64_t)file_size, (uint64_t)fs->fs_bsize);
- printf("fragroundup[blkoff[%lld]=%lld]=%lld\n", file_size, blkoff(fs, file_size),
- fragroundup(fs, blkoff(fs, file_size)));
- printf("fs->fs_qbmask=%llx fs->fs_qfmask=%llx fs->fs_fmask=%lx\n", fs->fs_qbmask, fs->fs_qfmask, fs->fs_fmask);
-#endif
+ block_size = sblksize(fs, DIP(fp, di_size), file_block);
-#if defined(__sparc64__) && defined(T1_SIMULATOR)
- if (block_size > 8192) {
- block_size=8192;
- printf("FORCE ROUND block_size\n");
- }
-#endif
-#ifdef DEBUG
- printf("\tfp->f_buf_blkno = 0x%lx\n", fp->f_buf_blkno);
-#endif
if (file_block != fp->f_buf_blkno) {
if (fp->f_buf == (char *)0)
fp->f_buf = malloc(fs->fs_bsize);
@@ -611,27 +409,17 @@
rc = block_map(f, file_block, &disk_block);
if (rc)
return (rc);
-#ifdef DEBUG
- printf("\tblock_map : disk_block = 0x%lx\n", disk_block);
-#endif
+
if (disk_block == 0) {
bzero(fp->f_buf, block_size);
fp->f_buf_size = block_size;
} else {
twiddle();
-#ifdef DEBUG
- printf("\tcalling dev_strategy for block read fsbtodb[0x%lx]=0x%lx\n",
- disk_block, fsbtodb(fs, disk_block));
-#endif
rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
fsbtodb(fs, disk_block),
block_size, fp->f_buf, &fp->f_buf_size);
if (rc)
return (rc);
-#ifdef DEBUG
- printf("\treturned from block read with 0x%lx bytes\n", fp->f_buf_size);
- hdump(fp->f_buf, fp->f_buf_size);
-#endif
}
fp->f_buf_blkno = file_block;
@@ -654,37 +442,10 @@
return (0);
}
-#if defined(__sparc64__) && defined(T1_SIMULATOR)
-static void
-test_disk(struct open_file *f)
-{
- int i, rc;
- char *buf;
- uint64_t read_size;
-
- struct file *fp = (struct file *)f->f_fsdata;
- struct fs *fs = fp->f_fs;
-
- buf = (char *)malloc(512);
-
- for (i = 0; i < 10; i++) {
- rc = (f->f_dev->dv_strategy)(f->f_devdata, F_READ,
- fsbtodb(fs, i),
- 512, buf, &read_size);
-
-
- if (rc || read_size != 512)
- printf("strategy failed\n");
-#ifdef DEBUG
- printf("%04d\n", i);
- hdump(buf, 512);
-#endif
-
- }
-
-}
-#endif
-
+/*
+ * Search a directory for a name and return its
+ * i_number.
+ */
static int
search_directory(name, f, inumber_p)
char *name;
@@ -698,34 +459,18 @@
size_t buf_size;
int namlen, length;
int rc;
-#if defined(__sparc64__) && defined(T1_SIMULATOR)
- test_disk(f);
-#endif
+
length = strlen(name);
-#ifdef DEBUG
- printf("search_directory: name=%s\n", name);
-#endif
+
fp->f_seekp = 0;
while (fp->f_seekp < DIP(fp, di_size)) {
- int i;
rc = buf_read_file(f, &buf, &buf_size);
if (rc)
return (rc);
-#ifdef DEBUG
- printf("scan directory entries: @ 0x%llx (size=0x%llx)\n",
- (uint64_t)buf, (uint64_t)buf_size);
-#endif
+
dp = (struct direct *)buf;
edp = (struct direct *)(buf + buf_size);
- i = 0;
-#ifdef DEBUG
- hdump(buf, buf_size);
-#endif
while (dp < edp) {
-#ifdef DEBUG
- printf("\tdirent# %d (dp=0x%llx edp=0x%llx\n", i,
- (uint64_t)dp, (uint64_t)edp);
-#endif
if (dp->d_ino == (ino_t)0)
goto next;
#if BYTE_ORDER == LITTLE_ENDIAN
@@ -734,9 +479,6 @@
else
#endif
namlen = dp->d_namlen;
-#ifdef DEBUG
- printf("namlen: %d dp->d_name: %s\n", namlen, dp->d_name);
-#endif
if (namlen == length &&
!strcmp(name, dp->d_name)) {
/* found entry */
@@ -745,7 +487,6 @@
}
next:
dp = (struct direct *)((char *)dp + dp->d_reclen);
- i++;
}
fp->f_seekp += buf_size;
}
@@ -753,33 +494,7 @@
}
static int sblock_try[] = SBLOCKSEARCH;
-#if defined(__sparc64__) && defined(T1_SIMULATOR)
-#define SOLARIS_SBLOCK_CONVERT 1
-void map_sblock(struct fs *fsp)
-{
- struct solaris_fs sfs = *(struct solaris_fs *)fsp;
-#ifdef DEBUG
- printf("fbsd fs_qfmask offset %lx solaris fs_qfmask offset %lx\n",
- offsetof(struct fs, fs_qfmask), offsetof(struct solaris_fs, fs_qfmask));
- printf("fbsd fs_qbmask offset %lx solaris fs_qbmask offset %lx\n",
- offsetof(struct fs, fs_qbmask), offsetof(struct solaris_fs, fs_qbmask));
-
- printf(" fsp->fs_qbmask: %llx = sfs.fs_qbmask %08lx%08lx;\n",
- fsp->fs_qbmask, sfs.fs_qbmask.val[0], sfs.fs_qbmask.val[1]);
- printf(" fsp->fs_qfmask: %llx = sfs.fs_qfmask %08lx%08lx;\n",
- fsp->fs_qfmask, sfs.fs_qfmask.val[0], sfs.fs_qfmask.val[1]);
-#endif
- fsp->fs_qbmask = ((uint64_t)sfs.fs_qbmask.val[0]) << 32 | sfs.fs_qbmask.val[1];
- fsp->fs_qfmask = ((uint64_t)sfs.fs_qfmask.val[0]) << 32 | sfs.fs_qfmask.val[1];
-
-}
-#endif
-
-
-
-
-
/*
* Open a file.
*/
@@ -818,16 +533,6 @@
(char *)fs, &buf_size);
if (rc)
goto out;
-
-
-
-
-#ifdef DEBUG
- printf("fs->fs_magic: %x fs->fs_bsize: %x fs->fs_sblockloc: %lx\n",
- fs->fs_magic, fs->fs_bsize, fs->fs_sblockloc);
- printf("sblock_try[i]: %x buf_size %lx\n",
- sblock_try[i], buf_size);
-#endif
if ((fs->fs_magic == FS_UFS1_MAGIC ||
(fs->fs_magic == FS_UFS2_MAGIC &&
fs->fs_sblockloc == sblock_try[i])) &&
@@ -840,9 +545,6 @@
rc = EINVAL;
goto out;
}
-#if defined(__sparc64__) && defined(T1_SIMULATOR)
- map_sblock(fs);
-#endif
/*
* Calculate indirect block levels.
*/
@@ -858,14 +560,9 @@
}
inumber = ROOTINO;
- if ((rc = read_inode(inumber, f)) != 0) {
- printf("failed to read root inode \n");
- goto out;
+ if ((rc = read_inode(inumber, f)) != 0)
+ goto out;
- }
-#ifdef DEBUG
- printf("read root inode \n");
-#endif
cp = path = strdup(upath);
if (path == NULL) {
rc = ENOMEM;
@@ -912,10 +609,6 @@
* symbolic link.
*/
parent_inumber = inumber;
-#ifdef DEBUG
- printf("-- searching %s @ inode = 0x%x - found @ 0x%x\n",
- ncp, parent_inumber, inumber);
-#endif
rc = search_directory(ncp, f, &inumber);
*cp = c;
if (rc)
More information about the p4-projects
mailing list