mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-12-04 10:19:26 +00:00
Implements gjournal support. If file system has gjournal support enabled
and -p flag was given perform fast file system checking (bascially only garbage collecting of orphaned objects). Rename bread() to blread() and bwrite() to blwrite() as we now link to the libufs library, which also implement functions with that names. Sponsored by: home.pl
This commit is contained in:
parent
5a9dc069e0
commit
aef8d2449b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=163845
@ -7,7 +7,9 @@ LINKS+= ${BINDIR}/fsck_ffs ${BINDIR}/fsck_4.2bsd
|
||||
MAN= fsck_ffs.8
|
||||
MLINKS= fsck_ffs.8 fsck_ufs.8 fsck_ffs.8 fsck_4.2bsd.8
|
||||
SRCS= dir.c ea.c fsutil.c inode.c main.c pass1.c pass1b.c pass2.c pass3.c \
|
||||
pass4.c pass5.c setup.c utilities.c ffs_subr.c ffs_tables.c
|
||||
pass4.c pass5.c setup.c utilities.c ffs_subr.c ffs_tables.c gjournal.c
|
||||
DPADD= ${LIBUFS}
|
||||
LDADD= -lufs
|
||||
WARNS?= 2
|
||||
CFLAGS+= -I${.CURDIR}
|
||||
|
||||
|
@ -328,9 +328,9 @@ ino_t allocdir(ino_t parent, ino_t request, int mode);
|
||||
ino_t allocino(ino_t request, int type);
|
||||
void blkerror(ino_t ino, const char *type, ufs2_daddr_t blk);
|
||||
char *blockcheck(char *name);
|
||||
int bread(int fd, char *buf, ufs2_daddr_t blk, long size);
|
||||
int blread(int fd, char *buf, ufs2_daddr_t blk, long size);
|
||||
void bufinit(void);
|
||||
void bwrite(int fd, char *buf, ufs2_daddr_t blk, long size);
|
||||
void blwrite(int fd, char *buf, ufs2_daddr_t blk, long size);
|
||||
void cacheino(union dinode *dp, ino_t inumber);
|
||||
void catch(int);
|
||||
void catchquit(int);
|
||||
@ -388,3 +388,4 @@ void rwerror(const char *mesg, ufs2_daddr_t blk);
|
||||
void sblock_init(void);
|
||||
void setinodebuf(ino_t);
|
||||
int setup(char *dev);
|
||||
void gjournal_check(const char *filesys);
|
||||
|
@ -221,7 +221,7 @@ getblk(struct bufarea *bp, ufs2_daddr_t blk, long size)
|
||||
if (bp->b_bno != dblk) {
|
||||
flush(fswritefd, bp);
|
||||
diskreads++;
|
||||
bp->b_errs = bread(fsreadfd, bp->b_un.b_buf, dblk, size);
|
||||
bp->b_errs = blread(fsreadfd, bp->b_un.b_buf, dblk, size);
|
||||
bp->b_bno = dblk;
|
||||
bp->b_size = size;
|
||||
}
|
||||
@ -244,11 +244,11 @@ flush(int fd, struct bufarea *bp)
|
||||
(bp->b_errs == bp->b_size / dev_bsize) ? "" : "PARTIALLY ",
|
||||
(long long)bp->b_bno);
|
||||
bp->b_errs = 0;
|
||||
bwrite(fd, bp->b_un.b_buf, bp->b_bno, (long)bp->b_size);
|
||||
blwrite(fd, bp->b_un.b_buf, bp->b_bno, (long)bp->b_size);
|
||||
if (bp != &sblk)
|
||||
return;
|
||||
for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize, j++) {
|
||||
bwrite(fswritefd, (char *)sblock.fs_csp + i,
|
||||
blwrite(fswritefd, (char *)sblock.fs_csp + i,
|
||||
fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag),
|
||||
sblock.fs_cssize - i < sblock.fs_bsize ?
|
||||
sblock.fs_cssize - i : sblock.fs_bsize);
|
||||
@ -345,7 +345,7 @@ ckfini(int markclean)
|
||||
}
|
||||
|
||||
int
|
||||
bread(int fd, char *buf, ufs2_daddr_t blk, long size)
|
||||
blread(int fd, char *buf, ufs2_daddr_t blk, long size)
|
||||
{
|
||||
char *cp;
|
||||
int i, errs;
|
||||
@ -387,7 +387,7 @@ bread(int fd, char *buf, ufs2_daddr_t blk, long size)
|
||||
}
|
||||
|
||||
void
|
||||
bwrite(int fd, char *buf, ufs2_daddr_t blk, long size)
|
||||
blwrite(int fd, char *buf, ufs2_daddr_t blk, long size)
|
||||
{
|
||||
int i;
|
||||
char *cp;
|
||||
|
@ -329,10 +329,10 @@ getnextinode(ino_t inumber)
|
||||
lastinum += fullcnt;
|
||||
}
|
||||
/*
|
||||
* If bread returns an error, it will already have zeroed
|
||||
* If blread returns an error, it will already have zeroed
|
||||
* out the buffer, so we do not need to do so here.
|
||||
*/
|
||||
(void)bread(fsreadfd, inodebuf, dblk, size);
|
||||
(void)blread(fsreadfd, inodebuf, dblk, size);
|
||||
nextinop = inodebuf;
|
||||
}
|
||||
dp = (union dinode *)nextinop;
|
||||
|
@ -237,6 +237,29 @@ checkfilesys(char *filesys)
|
||||
exit(7); /* Filesystem clean, report it now */
|
||||
exit(0);
|
||||
}
|
||||
if (preen && skipclean) {
|
||||
/*
|
||||
* If file system is gjournaled, check it here.
|
||||
*/
|
||||
if ((fsreadfd = open(filesys, O_RDONLY)) < 0 || readsb(0) == 0)
|
||||
exit(3); /* Cannot read superblock */
|
||||
close(fsreadfd);
|
||||
if ((sblock.fs_flags & FS_GJOURNAL) != 0) {
|
||||
//printf("GJournaled file system detected on %s.\n",
|
||||
// filesys);
|
||||
if (sblock.fs_clean == 1) {
|
||||
pwarn("FILE SYSTEM CLEAN; SKIPPING CHECKS\n");
|
||||
exit(0);
|
||||
}
|
||||
if ((sblock.fs_flags & (FS_UNCLEAN | FS_NEEDSFSCK)) == 0) {
|
||||
gjournal_check(filesys);
|
||||
exit(0);
|
||||
} else {
|
||||
pfatal("UNEXPECTED INCONSISTENCY, %s\n",
|
||||
"CANNOT RUN FAST FSCK\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* If we are to do a background check:
|
||||
* Get the mount point information of the file system
|
||||
@ -437,7 +460,7 @@ checkfilesys(char *filesys)
|
||||
* Write out the duplicate super blocks
|
||||
*/
|
||||
for (cylno = 0; cylno < sblock.fs_ncg; cylno++)
|
||||
bwrite(fswritefd, (char *)&sblock,
|
||||
blwrite(fswritefd, (char *)&sblock,
|
||||
fsbtodb(&sblock, cgsblock(&sblock, cylno)),
|
||||
SBLOCKSIZE);
|
||||
}
|
||||
|
@ -164,6 +164,7 @@ pass5(void)
|
||||
pfatal("CG %d: BAD MAGIC NUMBER\n", c);
|
||||
newcg->cg_time = cg->cg_time;
|
||||
newcg->cg_old_time = cg->cg_old_time;
|
||||
newcg->cg_unrefs = cg->cg_unrefs;
|
||||
newcg->cg_cgx = c;
|
||||
dbase = cgbase(fs, c);
|
||||
dmax = dbase + fs->fs_fpg;
|
||||
|
@ -249,7 +249,7 @@ setup(char *dev)
|
||||
for (i = 0, j = 0; i < sblock.fs_cssize; i += sblock.fs_bsize, j++) {
|
||||
size = sblock.fs_cssize - i < sblock.fs_bsize ?
|
||||
sblock.fs_cssize - i : sblock.fs_bsize;
|
||||
if (bread(fsreadfd, (char *)sblock.fs_csp + i,
|
||||
if (blread(fsreadfd, (char *)sblock.fs_csp + i,
|
||||
fsbtodb(&sblock, sblock.fs_csaddr + j * sblock.fs_frag),
|
||||
size) != 0 && !asked) {
|
||||
pfatal("BAD SUMMARY INFORMATION");
|
||||
@ -322,7 +322,7 @@ readsb(int listerr)
|
||||
|
||||
if (bflag) {
|
||||
super = bflag;
|
||||
if ((bread(fsreadfd, (char *)&sblock, super, (long)SBLOCKSIZE)))
|
||||
if ((blread(fsreadfd, (char *)&sblock, super, (long)SBLOCKSIZE)))
|
||||
return (0);
|
||||
if (sblock.fs_magic == FS_BAD_MAGIC) {
|
||||
fprintf(stderr, BAD_MAGIC_MSG);
|
||||
@ -337,7 +337,7 @@ readsb(int listerr)
|
||||
} else {
|
||||
for (i = 0; sblock_try[i] != -1; i++) {
|
||||
super = sblock_try[i] / dev_bsize;
|
||||
if ((bread(fsreadfd, (char *)&sblock, super,
|
||||
if ((blread(fsreadfd, (char *)&sblock, super,
|
||||
(long)SBLOCKSIZE)))
|
||||
return (0);
|
||||
if (sblock.fs_magic == FS_BAD_MAGIC) {
|
||||
|
Loading…
Reference in New Issue
Block a user