Skip to content

Commit

Permalink
reduce kernel: 3.1M, remove ZFS
Browse files Browse the repository at this point in the history
  • Loading branch information
wkozaczuk committed Jul 22, 2021
1 parent 2c36ef6 commit df98287
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 56 deletions.
24 changes: 12 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -650,16 +650,16 @@ solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/os/callb.o
solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/os/fm.o
solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/os/list.o
solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/os/nvpair_alloc_system.o
solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/adler32.o
solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/deflate.o
solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/inffast.o
solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/inflate.o
solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/inftrees.o
solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/opensolaris_crc32.o
solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/trees.o
solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod.o
solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod_subr.o
solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/zutil.o
#solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/adler32.o
#solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/deflate.o
#solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/inffast.o
#solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/inflate.o
#solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/inftrees.o
#solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/opensolaris_crc32.o
#solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/trees.o
#solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod.o
#solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/zmod_subr.o
#solaris += bsd/sys/cddl/contrib/opensolaris/uts/common/zmod/zutil.o

zfs += bsd/sys/cddl/contrib/opensolaris/common/zfs/zfeature_common.o
zfs += bsd/sys/cddl/contrib/opensolaris/common/zfs/zfs_comutil.o
Expand Down Expand Up @@ -753,7 +753,7 @@ zfs += bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zrlock.o
zfs += bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zvol.o
zfs += bsd/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/lz4.o

solaris += $(zfs)
#solaris += $(zfs)

$(zfs:%=$(out)/%): CFLAGS+= \
-DBUILDING_ZFS \
Expand Down Expand Up @@ -795,7 +795,7 @@ drivers += drivers/clockevent.o
drivers += drivers/isa-serial-base.o
drivers += core/elf.o
drivers += drivers/random.o
drivers += drivers/zfs.o
#drivers += drivers/zfs.o
drivers += drivers/null.o
drivers += drivers/device.o
#drivers += drivers/pci-generic.o
Expand Down
16 changes: 8 additions & 8 deletions bsd/porting/shrinker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ class bsd_shrinker : public memory::shrinker {
private:
struct eventhandler_entry_generic *_ee;
};

/*
class arc_shrinker : public memory::shrinker {
public:
explicit arc_shrinker();
size_t request_memory(size_t s, bool hard);
};
};*/

bsd_shrinker::bsd_shrinker(struct eventhandler_entry_generic *ee)
: shrinker("BSD"), _ee(ee)
Expand All @@ -39,7 +39,7 @@ size_t bsd_shrinker::request_memory(size_t s, bool hard)
// Return the amount of released memory.
return _ee->func(_ee->ee.ee_arg);
}

/*
arc_shrinker::arc_shrinker()
: shrinker("ARC")
{
Expand Down Expand Up @@ -74,7 +74,7 @@ size_t arc_shrinker::request_memory(size_t s, bool hard)
ret += r;
} while (ret < s);
return ret;
}
}*/

void bsd_shrinker_init(void)
{
Expand All @@ -89,11 +89,11 @@ void bsd_shrinker_init(void)

auto *_ee = (struct eventhandler_entry_generic *)ep;

if ((void *)_ee->func == (void *)arc_lowmem) {
new arc_shrinker();
} else {
//if ((void *)_ee->func == (void *)arc_lowmem) {
// new arc_shrinker();
//} else {
new bsd_shrinker(_ee);
}
//}
}
EHL_UNLOCK(list);

Expand Down
45 changes: 23 additions & 22 deletions core/pagecache.cc
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ class cached_page_write : public cached_page {
return for_each_pte([] (mmu::hw_ptep<0> pte) { return mmu::clear_pte(pte).dirty(); }, std::logical_or<bool>(), false);
}
};

/*
class cached_page_arc;
static unsigned drop_arc_read_cached_page(cached_page_arc* cp, bool flush = true);
Expand Down Expand Up @@ -294,16 +294,16 @@ class cached_page_arc : public cached_page {
static bool operator==(const cached_page_arc::arc_map::value_type& l, const cached_page_arc* r) {
return l.second == r;
}
}*/

std::unordered_multimap<arc_buf_t*, cached_page_arc*> cached_page_arc::arc_cache_map;
//std::unordered_multimap<arc_buf_t*, cached_page_arc*> cached_page_arc::arc_cache_map;
//Map used to store read cache pages for ZFS filesystem interacting with ARC
static std::unordered_map<hashkey, cached_page_arc*> arc_read_cache;
//static std::unordered_map<hashkey, cached_page_arc*> arc_read_cache;
//Map used to store read cache pages for non-ZFS filesystems
static std::unordered_map<hashkey, cached_page*> read_cache;
static std::unordered_map<hashkey, cached_page_write*> write_cache;
static std::deque<cached_page_write*> write_lru;
static mutex arc_read_lock; // protects against parallel access to the ARC read cache
//static mutex arc_read_lock; // protects against parallel access to the ARC read cache
static mutex read_lock; // protects against parallel access to the read cache
static mutex write_lock; // protect against parallel access to the write cache

Expand All @@ -323,13 +323,13 @@ static void add_read_mapping(cached_page *cp, mmu::hw_ptep<0> ptep)
{
cp->map(ptep);
}

/*
TRACEPOINT(trace_add_read_mapping, "buf=%p, addr=%p, ptep=%p", void*, void*, void*);
static void add_arc_read_mapping(cached_page_arc *cp, mmu::hw_ptep<0> ptep)
{
trace_add_read_mapping(cp->arcbuf(), cp->addr(), ptep.release());
add_read_mapping(cp, ptep);
}
}*/

template<typename T>
static void remove_read_mapping(std::unordered_map<hashkey, T>& cache, cached_page* cp, mmu::hw_ptep<0> ptep)
Expand All @@ -339,13 +339,13 @@ static void remove_read_mapping(std::unordered_map<hashkey, T>& cache, cached_pa
delete cp;
}
}

/*
TRACEPOINT(trace_remove_mapping, "buf=%p, addr=%p, ptep=%p", void*, void*, void*);
static void remove_arc_read_mapping(cached_page_arc* cp, mmu::hw_ptep<0> ptep)
{
trace_remove_mapping(cp->arcbuf(), cp->addr(), ptep.release());
remove_read_mapping(arc_read_cache, cp, ptep);
}
}*/

void remove_read_mapping(hashkey& key, mmu::hw_ptep<0> ptep)
{
Expand Down Expand Up @@ -374,15 +374,15 @@ void remove_read_mapping(hashkey& key, mmu::hw_ptep<0> ptep)
mmu::flush_tlb_all();
}
}

/*
void remove_arc_read_mapping(hashkey& key, mmu::hw_ptep<0> ptep)
{
SCOPE_LOCK(arc_read_lock);
cached_page_arc* cp = find_in_cache(arc_read_cache, key);
if (cp) {
remove_arc_read_mapping(cp, ptep);
}
}
}*/

template<typename T>
static unsigned drop_read_cached_page(std::unordered_map<hashkey, T>& cache, cached_page* cp, bool flush)
Expand All @@ -398,11 +398,11 @@ static unsigned drop_read_cached_page(std::unordered_map<hashkey, T>& cache, cac

return flushed;
}

/*
static unsigned drop_arc_read_cached_page(cached_page_arc* cp, bool flush)
{
return drop_read_cached_page(arc_read_cache, cp, flush);
}
}*/

static void drop_read_cached_page(hashkey& key)
{
Expand All @@ -412,7 +412,7 @@ static void drop_read_cached_page(hashkey& key)
drop_read_cached_page(read_cache, cp, true);
}
}

/*
TRACEPOINT(trace_drop_read_cached_page, "buf=%p, addr=%p", void*, void*);
static void drop_arc_read_cached_page(hashkey& key)
{
Expand Down Expand Up @@ -440,7 +440,7 @@ void map_arc_buf(hashkey *key, arc_buf_t* ab, void *page)
cached_page_arc* pc = new cached_page_arc(*key, page, ab);
arc_read_cache.emplace(*key, pc);
arc_share_buf(ab);
}
}*/

void map_read_cached_page(hashkey *key, void *page)
{
Expand Down Expand Up @@ -508,15 +508,15 @@ bool get(vfs_file* fp, off_t offset, mmu::hw_ptep<0> ptep, mmu::pt_element<0> pt
// page is moved from read cache to write cache
// drop read page if exists, removing all mappings
if (IS_ZFS(st.st_dev)) {
drop_arc_read_cached_page(key);
// drop_arc_read_cached_page(key);
} else {
// ROFS (at least for now)
drop_read_cached_page(key);
}
} else {
// remove mapping to read cache page if exists
if (IS_ZFS(st.st_dev)) {
remove_arc_read_mapping(key, ptep);
// remove_arc_read_mapping(key, ptep);
} else {
// ROFS (at least for now)
remove_read_mapping(key, ptep);
Expand All @@ -535,13 +535,14 @@ bool get(vfs_file* fp, off_t offset, mmu::hw_ptep<0> ptep, mmu::pt_element<0> pt
// read fault and page is not in write cache yet, return one from ARC, mark it cow
do {
if (IS_ZFS(st.st_dev)) {
/*
WITH_LOCK(arc_read_lock) {
cached_page_arc* cp = find_in_cache(arc_read_cache, key);
if (cp) {
add_arc_read_mapping(cp, ptep);
return mmu::write_pte(cp->addr(), ptep, mmu::pte_mark_cow(pte, true));
}
}
}*/
}
else {
// ROFS (at least for now)
Expand Down Expand Up @@ -604,14 +605,14 @@ bool release(vfs_file* fp, void *addr, off_t offset, mmu::hw_ptep<0> ptep)
}

if (IS_ZFS(st.st_dev)) {
WITH_LOCK(arc_read_lock) {
/*WITH_LOCK(arc_read_lock) {
cached_page_arc* rcp = find_in_cache(arc_read_cache, key);
if (rcp && mmu::virt_to_phys(rcp->addr()) == old.addr()) {
// page is in ARC read cache
remove_arc_read_mapping(rcp, ptep);
return false;
}
}
}*/
} else {
// ROFS (at least for now)
WITH_LOCK(read_lock) {
Expand Down Expand Up @@ -654,7 +655,7 @@ void sync(vfs_file* fp, off_t start, off_t end)
dirty.pop();
}
}

/*
TRACEPOINT(trace_access_scanner, "scanned=%u, cleared=%u, %%cpu=%g", unsigned, unsigned, double);
static class access_scanner {
static constexpr double _max_cpu = 20;
Expand Down Expand Up @@ -749,7 +750,7 @@ static class access_scanner {
} s_access_scanner;
constexpr double access_scanner::_max_cpu;
constexpr double access_scanner::_min_cpu;
constexpr double access_scanner::_min_cpu;*/


}
5 changes: 2 additions & 3 deletions fs/vfs/vfs_conf.cc
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ extern struct vfsops devfs_vfsops;
extern struct vfsops nfs_vfsops;
extern struct vfsops procfs_vfsops;
extern struct vfsops sysfs_vfsops;
extern struct vfsops zfs_vfsops;
//extern struct vfsops zfs_vfsops;
//extern struct vfsops virtiofs_vfsops;

extern int ramfs_init(void);
Expand All @@ -61,7 +61,7 @@ extern int devfs_init(void);
extern int nfs_init(void);
extern int procfs_init(void);
extern int sysfs_init(void);
extern "C" int zfs_init(void);
//extern "C" int zfs_init(void);

/*
* VFS switch table
Expand All @@ -72,7 +72,6 @@ const struct vfssw vfssw[] = {
{"nfs", nfs_init, &nfs_vfsops},
{"procfs", procfs_init, &procfs_vfsops},
{"sysfs", sysfs_init, &sysfs_vfsops},
{"zfs", zfs_init, &zfs_vfsops},
{"rofs", rofs_init, &rofs_vfsops},
// {"virtiofs", virtiofs_init, &virtiofs_vfsops},
{nullptr, fs_noop, nullptr},
Expand Down
22 changes: 11 additions & 11 deletions loader.cc
Original file line number Diff line number Diff line change
Expand Up @@ -420,15 +420,15 @@ void* do_main_thread(void *_main_args)
rofs_disable_cache();
}
boot_time.event("ROFS mounted");
} else if (opt_rootfs.compare("zfs") == 0) {
/*} else if (opt_rootfs.compare("zfs") == 0) {
zfsdev::zfsdev_init();
auto error = mount_zfs_rootfs(opt_pivot, opt_extra_zfs_pools);
if (error) {
debug("Could not mount zfs root filesystem.\n");
}
bsd_shrinker_init();
boot_time.event("ZFS mounted");
boot_time.event("ZFS mounted");*/
} else if (opt_rootfs.compare("ramfs") == 0) {
// NOTE: The ramfs is already mounted, we just need to mount fstab
// entries. That's the only difference between this and --nomount.
Expand All @@ -454,19 +454,19 @@ void* do_main_thread(void *_main_args)
} else if (mount_virtiofs_rootfs(opt_pivot) == 0) {
boot_time.event("Virtio-fs mounted");
} else {
zfsdev::zfsdev_init();
auto error = mount_zfs_rootfs(opt_pivot, opt_extra_zfs_pools);
if (error) {
debug("Could not mount zfs root filesystem (while "
"auto-discovering).\n");
//zfsdev::zfsdev_init();
//auto error = mount_zfs_rootfs(opt_pivot, opt_extra_zfs_pools);
//if (error) {
// debug("Could not mount zfs root filesystem (while "
// "auto-discovering).\n");
// Continue with ramfs (already mounted)
// TODO: Avoid the hack of using pivot_rootfs() just for
// mounting the fstab entries.
pivot_rootfs("/");
} else {
bsd_shrinker_init();
boot_time.event("ZFS mounted");
}
//} else {
// bsd_shrinker_init();
// boot_time.event("ZFS mounted");
//}
}
}
}
Expand Down

0 comments on commit df98287

Please sign in to comment.