1/*-
2 * Copyright 2009, 2010 Jeffrey W. Roberson <jeff@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 11 unchanged lines hidden (view full) ---
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: stable/10/sbin/fsck_ffs/suj.c 248658 2013-03-23 20:00:02Z mckusick $");
29
30#include <sys/param.h>
31#include <sys/disk.h>
32#include <sys/disklabel.h>
33#include <sys/mount.h>
34#include <sys/stat.h>
35
36#include <ufs/ufs/ufsmount.h>
--- 83 unchanged lines hidden (view full) ---
120 struct suj_ino *sc_lastino;
121 struct suj_blk *sc_lastblk;
122 uint8_t *sc_cgbuf;
123 struct cg *sc_cgp;
124 int sc_dirty;
125 int sc_cgx;
126};
127
128LIST_HEAD(cghd, suj_cg) cghash[SUJ_HASHSIZE];
129LIST_HEAD(dblkhd, data_blk) dbhash[SUJ_HASHSIZE];
130struct suj_cg *lastcg;
131struct data_blk *lastblk;
132
133TAILQ_HEAD(seghd, suj_seg) allsegs;
134uint64_t oldseq;
135static struct uufsd *disk = NULL;
136static struct fs *fs = NULL;
137ino_t sujino;
138
139/*
140 * Summary statistics.
141 */
142uint64_t freefrags;
143uint64_t freeblocks;
144uint64_t freeinos;
145uint64_t freedir;
146uint64_t jbytes;
147uint64_t jrecs;
148
149static jmp_buf jmpbuf;
150
151typedef void (*ino_visitor)(ino_t, ufs_lbn_t, ufs2_daddr_t, int);
152static void err_suj(const char *, ...) __dead2;
153static void ino_trunc(ino_t, off_t);
154static void ino_decr(ino_t);
155static void ino_adjust(struct suj_ino *);
156static void ino_build(struct suj_ino *);
157static int blk_isfree(ufs2_daddr_t);
158
159static void *
160errmalloc(size_t n)
161{
162 void *a;
163
164 a = Malloc(n);
165 if (a == NULL)
--- 2242 unchanged lines hidden (view full) ---
2408 int jb_head; /* Allocator head. */
2409 int jb_off; /* Allocator extent offset. */
2410};
2411struct jextent {
2412 ufs2_daddr_t je_daddr; /* Disk block address. */
2413 int je_blocks; /* Disk block count. */
2414};
2415
2416struct jblocks *suj_jblocks;
2417
2418static struct jblocks *
2419jblocks_create(void)
2420{
2421 struct jblocks *jblocks;
2422 int size;
2423
2424 jblocks = errmalloc(sizeof(*jblocks));
--- 243 unchanged lines hidden (view full) ---
2668{
2669 union dinode *jip;
2670 union dinode *ip;
2671 uint64_t blocks;
2672 int retval;
2673 struct suj_seg *seg;
2674 struct suj_seg *segn;
2675
2676 opendisk(filesys);
2677 TAILQ_INIT(&allsegs);
2678
2679 /*
2680 * Set an exit point when SUJ check failed
2681 */
2682 retval = setjmp(jmpbuf);
2683 if (retval != 0) {
2684 pwarn("UNEXPECTED SU+J INCONSISTENCY\n");
2685 TAILQ_FOREACH_SAFE(seg, &allsegs, ss_next, segn) {
--- 72 unchanged lines hidden (view full) ---
2758 printf("** %jd journal records in %jd bytes for %.2f%% utilization\n",
2759 jrecs, jbytes, ((float)jrecs / (float)(jbytes / JREC_SIZE)) * 100);
2760 printf("** Freed %jd inodes (%jd dirs) %jd blocks, and %jd frags.\n",
2761 freeinos, freedir, freeblocks, freefrags);
2762 }
2763
2764 return (0);
2765}
2 * Copyright 2009, 2010 Jeffrey W. Roberson <jeff@FreeBSD.org>
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright
--- 11 unchanged lines hidden (view full) ---
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 * SUCH DAMAGE.
25 */
26
27#include <sys/cdefs.h>
28__FBSDID("$FreeBSD: stable/10/sbin/fsck_ffs/suj.c 248658 2013-03-23 20:00:02Z mckusick $");
29
30#include <sys/param.h>
31#include <sys/disk.h>
32#include <sys/disklabel.h>
33#include <sys/mount.h>
34#include <sys/stat.h>
35
36#include <ufs/ufs/ufsmount.h>
--- 83 unchanged lines hidden (view full) ---
120 struct suj_ino *sc_lastino;
121 struct suj_blk *sc_lastblk;
122 uint8_t *sc_cgbuf;
123 struct cg *sc_cgp;
124 int sc_dirty;
125 int sc_cgx;
126};
127
128LIST_HEAD(cghd, suj_cg) cghash[SUJ_HASHSIZE];
129LIST_HEAD(dblkhd, data_blk) dbhash[SUJ_HASHSIZE];
130struct suj_cg *lastcg;
131struct data_blk *lastblk;
132
133TAILQ_HEAD(seghd, suj_seg) allsegs;
134uint64_t oldseq;
135static struct uufsd *disk = NULL;
136static struct fs *fs = NULL;
137ino_t sujino;
138
139/*
140 * Summary statistics.
141 */
142uint64_t freefrags;
143uint64_t freeblocks;
144uint64_t freeinos;
145uint64_t freedir;
146uint64_t jbytes;
147uint64_t jrecs;
148
149static jmp_buf jmpbuf;
150
151typedef void (*ino_visitor)(ino_t, ufs_lbn_t, ufs2_daddr_t, int);
152static void err_suj(const char *, ...) __dead2;
153static void ino_trunc(ino_t, off_t);
154static void ino_decr(ino_t);
155static void ino_adjust(struct suj_ino *);
156static void ino_build(struct suj_ino *);
157static int blk_isfree(ufs2_daddr_t);
158
159static void *
160errmalloc(size_t n)
161{
162 void *a;
163
164 a = Malloc(n);
165 if (a == NULL)
--- 2242 unchanged lines hidden (view full) ---
2408 int jb_head; /* Allocator head. */
2409 int jb_off; /* Allocator extent offset. */
2410};
2411struct jextent {
2412 ufs2_daddr_t je_daddr; /* Disk block address. */
2413 int je_blocks; /* Disk block count. */
2414};
2415
2416struct jblocks *suj_jblocks;
2417
2418static struct jblocks *
2419jblocks_create(void)
2420{
2421 struct jblocks *jblocks;
2422 int size;
2423
2424 jblocks = errmalloc(sizeof(*jblocks));
--- 243 unchanged lines hidden (view full) ---
2668{
2669 union dinode *jip;
2670 union dinode *ip;
2671 uint64_t blocks;
2672 int retval;
2673 struct suj_seg *seg;
2674 struct suj_seg *segn;
2675
2676 opendisk(filesys);
2677 TAILQ_INIT(&allsegs);
2678
2679 /*
2680 * Set an exit point when SUJ check failed
2681 */
2682 retval = setjmp(jmpbuf);
2683 if (retval != 0) {
2684 pwarn("UNEXPECTED SU+J INCONSISTENCY\n");
2685 TAILQ_FOREACH_SAFE(seg, &allsegs, ss_next, segn) {
--- 72 unchanged lines hidden (view full) ---
2758 printf("** %jd journal records in %jd bytes for %.2f%% utilization\n",
2759 jrecs, jbytes, ((float)jrecs / (float)(jbytes / JREC_SIZE)) * 100);
2760 printf("** Freed %jd inodes (%jd dirs) %jd blocks, and %jd frags.\n",
2761 freeinos, freedir, freeblocks, freefrags);
2762 }
2763
2764 return (0);
2765}