svn commit: r233985 - in projects/nand: lib/libnandfs sbin/nandfs
sbin/newfs_nandfs sys/conf sys/fs/nandfs usr.sbin/nandsim
Grzegorz Bernacki
gber at FreeBSD.org
Sat Apr 7 05:41:03 UTC 2012
Author: gber
Date: Sat Apr 7 05:41:02 2012
New Revision: 233985
URL: http://svn.freebsd.org/changeset/base/233985
Log:
nandfs: Various fixes and cleanups.
Obtained from: Semihalf
Supported by: FreeBSD Foundation, Juniper Networks
Modified:
projects/nand/lib/libnandfs/libnandfs.h
projects/nand/lib/libnandfs/nandfs.c
projects/nand/sbin/nandfs/Makefile
projects/nand/sbin/nandfs/lssnap.c
projects/nand/sbin/nandfs/nandfs.h
projects/nand/sbin/newfs_nandfs/Makefile
projects/nand/sbin/newfs_nandfs/newfs_nandfs.c
projects/nand/sys/conf/files
projects/nand/sys/fs/nandfs/nandfs_cleaner.c
projects/nand/sys/fs/nandfs/nandfs_segment.c
projects/nand/sys/fs/nandfs/nandfs_subr.c
projects/nand/sys/fs/nandfs/nandfs_subr.h
projects/nand/sys/fs/nandfs/nandfs_vfsops.c
projects/nand/usr.sbin/nandsim/sample.conf
Modified: projects/nand/lib/libnandfs/libnandfs.h
==============================================================================
--- projects/nand/lib/libnandfs/libnandfs.h Sat Apr 7 05:32:06 2012 (r233984)
+++ projects/nand/lib/libnandfs/libnandfs.h Sat Apr 7 05:41:02 2012 (r233985)
@@ -51,6 +51,8 @@ const char *nandfs_dev(struct nandfs *);
int nandfs_open(struct nandfs *);
void nandfs_close(struct nandfs *);
+int nandfs_get_cpstat(struct nandfs *, struct nandfs_cpstat *);
+
ssize_t nandfs_get_cp(struct nandfs *, uint64_t,
struct nandfs_cpinfo *, size_t);
Modified: projects/nand/lib/libnandfs/nandfs.c
==============================================================================
--- projects/nand/lib/libnandfs/nandfs.c Sat Apr 7 05:32:06 2012 (r233984)
+++ projects/nand/lib/libnandfs/nandfs.c Sat Apr 7 05:41:02 2012 (r233985)
@@ -163,6 +163,21 @@ nandfs_close(struct nandfs *fs)
fs->n_flags &= ~NANDFS_IS_OPENED;
}
+int
+nandfs_get_cpstat(struct nandfs *fs, struct nandfs_cpstat *cpstat)
+{
+
+ NANDFS_ASSERT_VALID(fs);
+
+ if (ioctl(fs->n_iocfd, NANDFS_IOCTL_GET_CPSTAT, cpstat) == -1) {
+ nandfs_seterr(fs, "ioctl NANDFS_IOCTL_GET_CPSTAT: %s",
+ strerror(errno));
+ return (-1);
+ }
+
+ return (0);
+}
+
static ssize_t
nandfs_get_cpinfo(struct nandfs *fs, uint64_t cno, int mode,
struct nandfs_cpinfo *cpinfo, size_t nci)
Modified: projects/nand/sbin/nandfs/Makefile
==============================================================================
--- projects/nand/sbin/nandfs/Makefile Sat Apr 7 05:32:06 2012 (r233984)
+++ projects/nand/sbin/nandfs/Makefile Sat Apr 7 05:41:02 2012 (r233985)
@@ -1,3 +1,5 @@
+# $FreeBSD$
+
PROG= nandfs
SRCS= nandfs.c lssnap.c mksnap.c rmsnap.c
MAN= nandfs.8
Modified: projects/nand/sbin/nandfs/lssnap.c
==============================================================================
--- projects/nand/sbin/nandfs/lssnap.c Sat Apr 7 05:32:06 2012 (r233984)
+++ projects/nand/sbin/nandfs/lssnap.c Sat Apr 7 05:41:02 2012 (r233985)
@@ -59,9 +59,6 @@ print_cpinfo(struct nandfs_cpinfo *cpinf
time_t t;
char timebuf[128];
- if (!(cpinfo->nci_nblk_inc) && !(cpinfo->nci_inodes_count))
- return;
-
t = (time_t)cpinfo->nci_create;
localtime_r(&t, &tm);
strftime(timebuf, sizeof(timebuf), "%F %T", &tm);
@@ -74,8 +71,8 @@ nandfs_lssnap(int argc, char **argv)
{
struct nandfs_cpinfo *cpinfos;
struct nandfs fs;
- int nsnap, i;
- int error;
+ uint64_t next;
+ int error, nsnap, i;
if (argc != 1) {
lssnap_usage();
@@ -95,14 +92,17 @@ nandfs_lssnap(int argc, char **argv)
goto out;
}
- nsnap = nandfs_get_snap(&fs, 1, cpinfos, NCPINFO);
- if (nsnap == -1) {
- fprintf(stderr, "nandfs_get_snap: %s\n", nandfs_errmsg(&fs));
- goto out;
+ for (next = 1; next != 0; next = cpinfos[nsnap - 1].nci_next) {
+ nsnap = nandfs_get_snap(&fs, next, cpinfos, NCPINFO);
+ if (nsnap < 1)
+ break;
+
+ for (i = 0; i < nsnap; i++)
+ print_cpinfo(&cpinfos[i]);
}
- for (i = 0; i < nsnap; i++)
- print_cpinfo(&cpinfos[i]);
+ if (nsnap == -1)
+ fprintf(stderr, "nandfs_get_snap: %s\n", nandfs_errmsg(&fs));
out:
nandfs_close(&fs);
Modified: projects/nand/sbin/nandfs/nandfs.h
==============================================================================
--- projects/nand/sbin/nandfs/nandfs.h Sat Apr 7 05:32:06 2012 (r233984)
+++ projects/nand/sbin/nandfs/nandfs.h Sat Apr 7 05:41:02 2012 (r233985)
@@ -31,6 +31,7 @@
*/
#ifndef NANDFS_H
+#define NANDFS_H
int nandfs_lssnap(int, char **);
int nandfs_mksnap(int, char **);
Modified: projects/nand/sbin/newfs_nandfs/Makefile
==============================================================================
--- projects/nand/sbin/newfs_nandfs/Makefile Sat Apr 7 05:32:06 2012 (r233984)
+++ projects/nand/sbin/newfs_nandfs/Makefile Sat Apr 7 05:41:02 2012 (r233985)
@@ -2,12 +2,8 @@
PROG= newfs_nandfs
MAN= newfs_nandfs.8
-.if ${MACHINE_ARCH} == "arm"
-WARNS?= 3
-.else
-WARNS?= 6
-.endif
LDADD+= -lgeom
+DPADD+= ${LIBGEOM}
.include <bsd.prog.mk>
Modified: projects/nand/sbin/newfs_nandfs/newfs_nandfs.c
==============================================================================
--- projects/nand/sbin/newfs_nandfs/newfs_nandfs.c Sat Apr 7 05:32:06 2012 (r233984)
+++ projects/nand/sbin/newfs_nandfs/newfs_nandfs.c Sat Apr 7 05:41:02 2012 (r233985)
@@ -93,7 +93,7 @@ struct nandfs_block {
LIST_ENTRY(nandfs_block) block_link;
uint32_t number;
uint64_t offset;
- char *data;
+ void *data;
};
static LIST_HEAD(, nandfs_block) block_head = LIST_HEAD_INITIALIZER(&block_head);
@@ -124,7 +124,6 @@ uint32_t crc_seed;
struct nandfs_super_root *sr;
uint32_t nuserfiles;
-uint32_t seg_nfinfo;
uint32_t seg_segsum_size;
uint32_t seg_nblocks;
uint32_t seg_endblock;
@@ -191,7 +190,7 @@ crc32_le(uint32_t crc, const uint8_t *bu
return (crc);
}
-static char *
+static void *
get_block(uint32_t block_nr, uint64_t offset)
{
struct nandfs_block *block, *new_block;
@@ -242,7 +241,6 @@ segment_size(void)
u_int size;
size = sizeof(struct nandfs_segment_summary );
- size += seg_nfinfo * sizeof(struct nandfs_finfo);
size += seg_nblocks * sizeof(struct nandfs_binfo_v);
if (size > blocksize)
@@ -256,13 +254,10 @@ static void
prepare_blockgrouped_file(uint32_t block)
{
struct nandfs_block_group_desc *desc;
- uint8_t *block_data;
uint32_t i, entries;
- block_data = get_block(block, 0);
+ desc = (struct nandfs_block_group_desc *)get_block(block, 0);
entries = blocksize / sizeof(struct nandfs_block_group_desc);
-
- desc = (struct nandfs_block_group_desc *) block_data;
for (i = 0; i < entries; i++)
desc[i].bg_nfrees = blocksize * 8;
}
@@ -274,8 +269,8 @@ alloc_blockgrouped_file(uint32_t block,
uint32_t desc_nr;
uint32_t *bitmap;
- desc = (struct nandfs_block_group_desc *) get_block(block, 0);
- bitmap = (uint32_t*)get_block(block + 1, 1);
+ desc = (struct nandfs_block_group_desc *)get_block(block, 0);
+ bitmap = (uint32_t *)get_block(block + 1, 1);
bitmap += (entry >> 5);
if (*bitmap & (1 << (entry % 32))) {
@@ -294,7 +289,7 @@ count_su_blocks(void)
{
uint64_t maxblk, blk, offset, i;
- maxblk = 0;
+ maxblk = blk = 0;
for (i = 0; i < bad_segments_count; i++) {
nandfs_seg_usage_blk_offset(bad_segments[i], &blk, &offset);
@@ -322,12 +317,8 @@ count_seg_blocks(void)
if (user_files[i].nblocks) {
seg_nblocks += user_files[i].nblocks;
user_files[i].blocks = malloc(user_files[i].nblocks * sizeof(uint32_t));
- seg_nfinfo++;
}
- /* and 4 finfos for cpfile, ifile, sufile and datfile */
- seg_nfinfo += 4;
-
ifile.nblocks = 2 +
SIZE_TO_BLOCK(sizeof(struct nandfs_inode) * (NANDFS_USER_INO + 1));
ifile.blocks = malloc(ifile.nblocks * sizeof(uint32_t));
@@ -428,45 +419,38 @@ update_datfile(uint64_t block)
return (allocated);
}
-static struct nandfs_finfo *
-update_block_info(struct nandfs_finfo *finfo, struct file_info *file)
+static union nandfs_binfo *
+update_block_info(union nandfs_binfo *binfo, struct file_info *file)
{
- union nandfs_binfo *binfo;
- uint64_t vblock;
+ nandfs_daddr_t vblock;
uint32_t i;
- finfo->fi_ino = file->ino;
- finfo->fi_ndatablk = file->nblocks;
- finfo->fi_nblocks = file->nblocks;
- finfo->fi_cno = 1;
- finfo++;
-
- binfo = (union nandfs_binfo *)finfo;
for (i = 0; i < file->nblocks; i++) {
debug("%s: blk %x", __func__, i);
if (file->ino != NANDFS_DAT_INO) {
vblock = update_datfile(file->blocks[i]);
binfo->bi_v.bi_vblocknr = vblock;
binfo->bi_v.bi_blkoff = i;
+ binfo->bi_v.bi_ino = file->ino;
file->inode->i_db[i] = vblock;
} else {
binfo->bi_dat.bi_blkoff = i;
+ binfo->bi_dat.bi_ino = file->ino;
file->inode->i_db[i] = datfile.blocks[i];
}
binfo++;
}
- finfo = (struct nandfs_finfo *)binfo;
- return (finfo);
+ return (binfo);
}
static void
save_segsum(struct nandfs_segment_summary *ss)
{
- struct nandfs_finfo *finfo;
+ union nandfs_binfo *binfo;
struct nandfs_block *block;
uint32_t sum_bytes, i;
- uint8_t *data, crc_data, crc_skip;
+ uint8_t crc_data, crc_skip;
sum_bytes = segment_size();
ss->ss_magic = NANDFS_SEGSUM_MAGIC;
@@ -478,7 +462,7 @@ save_segsum(struct nandfs_segment_summar
ss->ss_next = nandfs_first_block() + blocks_per_segment;
/* nblocks = segment blocks + segsum block + superroot */
ss->ss_nblocks = seg_nblocks + 2;
- ss->ss_nfinfo = seg_nfinfo;
+ ss->ss_nbinfos = seg_nblocks;
ss->ss_sumbytes = sum_bytes;
crc_skip = sizeof(ss->ss_datasum) + sizeof(ss->ss_sumsum);
@@ -486,18 +470,16 @@ save_segsum(struct nandfs_segment_summar
sum_bytes - crc_skip);
crc_data = 0;
- data = (uint8_t *)ss + sizeof(struct nandfs_segment_summary);
- finfo = (struct nandfs_finfo *)data;
-
+ binfo = (union nandfs_binfo *)(ss + 1);
for (i = 0; i < nuserfiles; i++) {
if (user_files[i].nblocks)
- finfo = update_block_info(finfo, &user_files[i]);
+ binfo = update_block_info(binfo, &user_files[i]);
}
- finfo = update_block_info(finfo, &ifile);
- finfo = update_block_info(finfo, &cpfile);
- finfo = update_block_info(finfo, &sufile);
- finfo = update_block_info(finfo, &datfile);
+ binfo = update_block_info(binfo, &ifile);
+ binfo = update_block_info(binfo, &cpfile);
+ binfo = update_block_info(binfo, &sufile);
+ update_block_info(binfo, &datfile);
/* save superroot crc */
crc_skip = sizeof(sr->sr_sum);
@@ -510,7 +492,8 @@ save_segsum(struct nandfs_segment_summar
if (block->number < NANDFS_FIRST_BLOCK)
continue;
if (block->number == NANDFS_FIRST_BLOCK)
- crc_data = crc32_le(crc_seed, block->data + crc_skip,
+ crc_data = crc32_le(crc_seed,
+ (uint8_t *)block->data + crc_skip,
blocksize - crc_skip);
else
crc_data = crc32_le(crc_data, block->data, blocksize);
@@ -546,7 +529,7 @@ create_fsdata(void)
fsdata.f_checkpoint_size = sizeof(struct nandfs_checkpoint);
fsdata.f_segment_usage_size = sizeof(struct nandfs_segment_usage);
- uuidgen((struct uuid *)fsdata.f_uuid, 1);
+ uuidgen(&fsdata.f_uuid, 1);
if (volumelabel)
memcpy(fsdata.f_volume_name, volumelabel, 16);
@@ -573,7 +556,7 @@ create_super_block(void)
super_block.s_last_pseg = NANDFS_FIRST_BLOCK;
super_block.s_last_seq = 1;
super_block.s_free_blocks_count =
- (nsegments - bad_segments_count - 1) * blocks_per_segment;
+ (nsegments - bad_segments_count) * blocks_per_segment;
super_block.s_mtime = 0;
super_block.s_wtime = nandfs_time;
super_block.s_mnt_count = 0;
@@ -604,14 +587,14 @@ save_super_root(void)
}
static struct nandfs_dir_entry *
-add_de(uint8_t *block, struct nandfs_dir_entry *de, uint64_t ino,
+add_de(void *block, struct nandfs_dir_entry *de, uint64_t ino,
const char *name, uint8_t type)
{
uint16_t reclen;
/* modify last de */
de->rec_len = NANDFS_DIR_REC_LEN(de->name_len);
- de = (struct nandfs_dir_entry *)((uint8_t *)de + de->rec_len);
+ de = (void *)((uint8_t *)de + de->rec_len);
reclen = blocksize - ((uintptr_t)de - (uintptr_t)block);
if (reclen < NANDFS_DIR_REC_LEN(strlen(name))) {
@@ -631,7 +614,7 @@ add_de(uint8_t *block, struct nandfs_dir
}
static struct nandfs_dir_entry *
-make_dir(uint8_t *block, uint64_t ino, uint64_t parent_ino)
+make_dir(void *block, uint64_t ino, uint64_t parent_ino)
{
struct nandfs_dir_entry *de = (struct nandfs_dir_entry *)block;
@@ -643,7 +626,7 @@ make_dir(uint8_t *block, uint64_t ino, u
memcpy(de->name, "..\0\0\0\0\0\0", 8);
/* create '.' entry */
- de = (struct nandfs_dir_entry *)(block + NANDFS_DIR_REC_LEN(2));
+ de = (void *)((uint8_t *)block + NANDFS_DIR_REC_LEN(2));
de->inode = ino;
de->rec_len = blocksize - NANDFS_DIR_REC_LEN(1) + NANDFS_DIR_REC_LEN(2);
de->name_len = 1;
@@ -660,7 +643,7 @@ save_root_dir(void)
struct file_info *root = &user_files[0];
struct nandfs_dir_entry *de;
uint32_t i;
- uint8_t *block;
+ void *block;
block = get_block(root->blocks[0], 0);
@@ -679,7 +662,7 @@ save_sufile(void)
struct nandfs_sufile_header *header;
struct nandfs_segment_usage *su;
uint64_t blk, i, off;
- char *block;
+ void *block;
int start;
/*
@@ -692,7 +675,7 @@ save_sufile(void)
block = get_block(sufile.blocks[start], 0);
header = (struct nandfs_sufile_header *)block;
- header->sh_ncleansegs = nsegments - 1;
+ header->sh_ncleansegs = nsegments - bad_segments_count - 1;
header->sh_ndirtysegs = 1;
header->sh_last_alloc = 1;
@@ -728,6 +711,7 @@ save_cpfile(void)
struct nandfs_checkpoint *cp, *initial_cp;
int i, entries = blocksize / sizeof(struct nandfs_checkpoint);
uint64_t cno;
+
header = (struct nandfs_cpfile_header *)get_block(cpfile.blocks[0], 0);
header->ch_ncheckpoints = 1;
header->ch_nsnapshots = 0;
@@ -741,7 +725,6 @@ save_cpfile(void)
initial_cp->cp_cno = NANDFS_FIRST_CNO;
initial_cp->cp_create = nandfs_time;
initial_cp->cp_nblk_inc = seg_endblock - 1;
- initial_cp->cp_inodes_count = nuserfiles;
initial_cp->cp_blocks_count = seg_nblocks;
memset(&initial_cp->cp_snapshot_list, 0,
sizeof(struct nandfs_snapshot_list));
@@ -854,8 +837,7 @@ create_fs(void)
}
/* Save segment summary and CRCs */
- data = get_block(NANDFS_FIRST_BLOCK, 0);
- save_segsum((struct nandfs_segment_summary *)data);
+ save_segsum(get_block(NANDFS_FIRST_BLOCK, 0));
return (0);
}
@@ -909,7 +891,9 @@ check_parameters(void)
/* check volume label */
i = 0;
if (volumelabel) {
- while (isalnum(volumelabel[++i]));
+ while (isalnum(volumelabel[++i]))
+ ;
+
if (volumelabel[i] != '\0') {
errx(1, "bad volume label. "
"Valid characters are alphanumerics.");
@@ -1092,8 +1076,10 @@ print_summary(void)
printf("filesystem created succesfully\n");
printf("total segments: %#jx valid segments: %#jx\n", nsegments,
- super_block.s_free_blocks_count);
- printf("total space: %ju MB\n",
+ nsegments - bad_segments_count);
+ printf("total space: %ju MB free: %ju MB\n",
+ (nsegments *
+ blocks_per_segment * blocksize) / (1024 * 1024),
((nsegments - bad_segments_count) *
blocks_per_segment * blocksize) / (1024 * 1024));
}
Modified: projects/nand/sys/conf/files
==============================================================================
--- projects/nand/sys/conf/files Sat Apr 7 05:32:06 2012 (r233984)
+++ projects/nand/sys/conf/files Sat Apr 7 05:41:02 2012 (r233985)
@@ -2269,6 +2269,7 @@ fs/nandfs/bmap.c optional nandfs
fs/nandfs/nandfs_alloc.c optional nandfs
fs/nandfs/nandfs_bmap.c optional nandfs
fs/nandfs/nandfs_buffer.c optional nandfs
+fs/nandfs/nandfs_cleaner.c optional nandfs
fs/nandfs/nandfs_cpfile.c optional nandfs
fs/nandfs/nandfs_dat.c optional nandfs
fs/nandfs/nandfs_dir.c optional nandfs
Modified: projects/nand/sys/fs/nandfs/nandfs_cleaner.c
==============================================================================
--- projects/nand/sys/fs/nandfs/nandfs_cleaner.c Sat Apr 7 05:32:06 2012 (r233984)
+++ projects/nand/sys/fs/nandfs/nandfs_cleaner.c Sat Apr 7 05:41:02 2012 (r233985)
@@ -255,6 +255,12 @@ nandfs_cleaner_iterate_segment(struct na
segsum = (struct nandfs_segment_summary *)bp->b_data;
binfo = (union nandfs_binfo *)(bp->b_data + segsum->ss_bytes);
+ if (!nandfs_segsum_valid(segsum)) {
+ nandfs_error("nandfs: invalid summary of segment %jx\n", segno);
+ brelse(bp);
+ return (error);
+ }
+
DPRINTF(CLEAN, ("%s: %jx magic %x bytes %x nblocks %x nbinfos "
"%x\n", __func__, segno, segsum->ss_magic, segsum->ss_bytes,
segsum->ss_nblocks, segsum->ss_nbinfos));
Modified: projects/nand/sys/fs/nandfs/nandfs_segment.c
==============================================================================
--- projects/nand/sys/fs/nandfs/nandfs_segment.c Sat Apr 7 05:32:06 2012 (r233984)
+++ projects/nand/sys/fs/nandfs/nandfs_segment.c Sat Apr 7 05:41:02 2012 (r233985)
@@ -1099,6 +1099,7 @@ nandfs_segment_constructor(struct nandfs
fsdev = nmp->nm_nandfsdev;
lockmgr(&fsdev->nd_seg_const, LK_EXCLUSIVE, NULL);
+again:
create_seginfo(fsdev, &seginfo);
dat = fsdev->nd_dat_node;
@@ -1191,6 +1192,22 @@ reiterate:
VOP_UNLOCK(NTOV(su), 0);
delete_seginfo(seginfo);
+
+ /*
+ * XXX: a hack, will go away soon
+ */
+ if ((NTOV(dat)->v_bufobj.bo_dirty.bv_cnt != 0 ||
+ NTOV(cp)->v_bufobj.bo_dirty.bv_cnt != 0 ||
+ NTOV(gc)->v_bufobj.bo_dirty.bv_cnt != 0 ||
+ NTOV(ifile)->v_bufobj.bo_dirty.bv_cnt != 0 ||
+ NTOV(su)->v_bufobj.bo_dirty.bv_cnt != 0) &&
+ (flags & NANDFS_UMOUNT)) {
+ DPRINTF(SYNC, ("%s: RERUN\n", __func__));
+ goto again;
+ }
+
+ MPASS(fsdev->nd_free_base == NULL);
+
lockmgr(&fsdev->nd_seg_const, LK_RELEASE, NULL);
if (cno_changed) {
Modified: projects/nand/sys/fs/nandfs/nandfs_subr.c
==============================================================================
--- projects/nand/sys/fs/nandfs/nandfs_subr.c Sat Apr 7 05:32:06 2012 (r233984)
+++ projects/nand/sys/fs/nandfs/nandfs_subr.c Sat Apr 7 05:41:02 2012 (r233985)
@@ -513,6 +513,13 @@ struct nandfs_recover_info {
};
int
+nandfs_segsum_valid(struct nandfs_segment_summary *segsum)
+{
+
+ return (segsum->ss_magic == NANDFS_SEGSUM_MAGIC);
+}
+
+int
nandfs_load_segsum(struct nandfs_device *fsdev, nandfs_daddr_t blocknr,
struct nandfs_segment_summary *segsum)
{
@@ -529,7 +536,7 @@ nandfs_load_segsum(struct nandfs_device
memcpy(segsum, bp->b_data, sizeof(struct nandfs_segment_summary));
brelse(bp);
- if (segsum->ss_magic != NANDFS_SEGSUM_MAGIC) {
+ if (!nandfs_segsum_valid(segsum)) {
DPRINTF(VOLUMES, ("%s: bad magic pseg:%jx\n", __func__,
blocknr));
return (EINVAL);
Modified: projects/nand/sys/fs/nandfs/nandfs_subr.h
==============================================================================
--- projects/nand/sys/fs/nandfs/nandfs_subr.h Sat Apr 7 05:32:06 2012 (r233984)
+++ projects/nand/sys/fs/nandfs/nandfs_subr.h Sat Apr 7 05:41:02 2012 (r233985)
@@ -203,6 +203,7 @@ void nandfs_dirty_bufs_decrement(struct
int nandfs_start_cleaner(struct nandfs_device *);
int nandfs_stop_cleaner(struct nandfs_device *);
+int nandfs_segsum_valid(struct nandfs_segment_summary *);
int nandfs_load_segsum(struct nandfs_device *, nandfs_daddr_t,
struct nandfs_segment_summary *);
int nandfs_get_segment_info(struct nandfs_device *, struct nandfs_suinfo *,
Modified: projects/nand/sys/fs/nandfs/nandfs_vfsops.c
==============================================================================
--- projects/nand/sys/fs/nandfs/nandfs_vfsops.c Sat Apr 7 05:32:06 2012 (r233984)
+++ projects/nand/sys/fs/nandfs/nandfs_vfsops.c Sat Apr 7 05:41:02 2012 (r233985)
@@ -95,23 +95,23 @@ int nandfs_max_dirty_segs = NANDFS_MAX_D
SYSCTL_UINT(_vfs_nandfs, OID_AUTO, max_dirty_segs, CTLFLAG_RW,
&nandfs_max_dirty_segs, 0, "");
-#define NANFS_CPS_BETWEEN_SBLOCKS 5
-int nandfs_cps_between_sblocks = NANFS_CPS_BETWEEN_SBLOCKS; /* write superblock every 5 checkpoints */
+#define NANDFS_CPS_BETWEEN_SBLOCKS 5
+int nandfs_cps_between_sblocks = NANDFS_CPS_BETWEEN_SBLOCKS; /* write superblock every 5 checkpoints */
SYSCTL_UINT(_vfs_nandfs, OID_AUTO, cps_between_sblocks, CTLFLAG_RW,
&nandfs_cps_between_sblocks, 0, "");
-#define NANFS_CLEANER_ENABLE 0
-int nandfs_cleaner_enable = NANFS_CLEANER_ENABLE;
+#define NANDFS_CLEANER_ENABLE 0
+int nandfs_cleaner_enable = NANDFS_CLEANER_ENABLE;
SYSCTL_UINT(_vfs_nandfs, OID_AUTO, cleaner_enable, CTLFLAG_RW,
&nandfs_cleaner_enable, 0, "");
-#define NANFS_CLEANER_INTERVAL 5
-int nandfs_cleaner_interval = NANFS_CLEANER_INTERVAL;
+#define NANDFS_CLEANER_INTERVAL 5
+int nandfs_cleaner_interval = NANDFS_CLEANER_INTERVAL;
SYSCTL_UINT(_vfs_nandfs, OID_AUTO, cleaner_interval, CTLFLAG_RW,
&nandfs_cleaner_interval, 0, "");
-#define NANFS_CLEANER_SEGMENTS 5
-int nandfs_cleaner_segments = NANFS_CLEANER_SEGMENTS;
+#define NANDFS_CLEANER_SEGMENTS 5
+int nandfs_cleaner_segments = NANDFS_CLEANER_SEGMENTS;
SYSCTL_UINT(_vfs_nandfs, OID_AUTO, cleaner_segments, CTLFLAG_RW,
&nandfs_cleaner_segments, 0, "");
@@ -746,6 +746,10 @@ nandfs_unmount_device(struct nandfs_devi
if (nandfsdev->nd_refcnt >= 1)
return;
+ MPASS(nandfsdev->nd_syncer == NULL);
+ MPASS(nandfsdev->nd_cleaner == NULL);
+ MPASS(nandfsdev->nd_free_base == NULL);
+
/* Unmount our base */
nandfs_unmount_base(nandfsdev);
@@ -1124,8 +1128,11 @@ nandfs_procbody(struct nandfsmount *nmp)
nandfs_gc_finished(nffsdev, 0);
}
nmp->nm_flags &= ~NANDFS_KILL_SYNCER;
+ MPASS(nffsdev->nd_free_base == NULL);
+
nandfs_gc_finished(nffsdev, 1);
nffsdev->nd_syncer = NULL;
+ MPASS(nffsdev->nd_free_base == NULL);
/*
* A bit of explanation:
@@ -1215,14 +1222,13 @@ nandfs_mount(struct mount *mp)
if (mp->mnt_flag & MNT_FORCE)
flags |= FORCECLOSE;
- nandfs_stop_cleaner(nmp->nm_nandfsdev);
-
nandfs_wakeup_wait_sync(nmp->nm_nandfsdev,
SYNCER_ROUPD);
error = vflush(mp, 0, flags, td);
if (error)
return (error);
+ nandfs_stop_cleaner(nmp->nm_nandfsdev);
stop_syncer(nmp);
DROP_GIANT();
g_topology_lock();
@@ -1446,7 +1452,6 @@ nandfs_unmount(struct mount *mp, int mnt
/* Umount already stopped writing */
if (!(nmp->nm_ronly)) {
- nandfs_stop_cleaner(nandfsdev);
nmp->nm_flags |= NANDFS_UMOUNT;
/*
* XXX This is a hack soon to be removed
@@ -1459,8 +1464,10 @@ nandfs_unmount(struct mount *mp, int mnt
if (error)
return (error);
- if (!(nmp->nm_ronly))
+ if (!(nmp->nm_ronly)) {
+ nandfs_stop_cleaner(nandfsdev);
stop_syncer(nmp);
+ }
if (nmp->nm_ifile_node)
NANDFS_UNSET_SYSTEMFILE(NTOV(nmp->nm_ifile_node));
Modified: projects/nand/usr.sbin/nandsim/sample.conf
==============================================================================
--- projects/nand/usr.sbin/nandsim/sample.conf Sat Apr 7 05:32:06 2012 (r233984)
+++ projects/nand/usr.sbin/nandsim/sample.conf Sat Apr 7 05:41:02 2012 (r233985)
@@ -122,7 +122,7 @@ pages_per_block=64
# blocks_per_lun=[>0]
blocks_per_lun=4096
# luns=1..N
-luns=2
+luns=1
# column_addr_cycle=[1,2]
column_addr_cycle=2
# row_addr_cycle=[1,2,3]
More information about the svn-src-projects
mailing list