From b088aaf58853da73527f42716ef91a8ecf4635ac Mon Sep 17 00:00:00 2001 From: Waldemar Kozaczuk Date: Tue, 9 Jun 2020 15:18:25 -0400 Subject: [PATCH] ZFS out --- Makefile | 4 ++-- bsd/porting/shrinker.cc | 16 +++++++-------- core/pagecache.cc | 45 +++++++++++++++++++++-------------------- fs/vfs/vfs_conf.cc | 5 ++--- loader.cc | 4 ++-- 5 files changed, 37 insertions(+), 37 deletions(-) diff --git a/Makefile b/Makefile index 32589d8641..302de29f42 100644 --- a/Makefile +++ b/Makefile @@ -737,7 +737,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 \ @@ -778,7 +778,7 @@ drivers += drivers/clock-common.o drivers += drivers/clockevent.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 diff --git a/bsd/porting/shrinker.cc b/bsd/porting/shrinker.cc index 3fb7aff10f..9a624d60c3 100644 --- a/bsd/porting/shrinker.cc +++ b/bsd/porting/shrinker.cc @@ -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) @@ -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") { @@ -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) { @@ -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); diff --git a/core/pagecache.cc b/core/pagecache.cc index b58a97fb27..fcc7af03b5 100644 --- a/core/pagecache.cc +++ b/core/pagecache.cc @@ -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(), false); } }; - +/* class cached_page_arc; static unsigned drop_arc_read_cached_page(cached_page_arc* cp, bool flush = true); @@ -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 cached_page_arc::arc_cache_map; +//std::unordered_multimap cached_page_arc::arc_cache_map; //Map used to store read cache pages for ZFS filesystem interacting with ARC -static std::unordered_map arc_read_cache; +//static std::unordered_map arc_read_cache; //Map used to store read cache pages for non-ZFS filesystems static std::unordered_map read_cache; static std::unordered_map write_cache; static std::deque 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 @@ -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 static void remove_read_mapping(std::unordered_map& cache, cached_page* cp, mmu::hw_ptep<0> ptep) @@ -339,13 +339,13 @@ static void remove_read_mapping(std::unordered_map& 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) { @@ -374,7 +374,7 @@ 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); @@ -382,7 +382,7 @@ void remove_arc_read_mapping(hashkey& key, mmu::hw_ptep<0> ptep) if (cp) { remove_arc_read_mapping(cp, ptep); } -} +}*/ template static unsigned drop_read_cached_page(std::unordered_map& cache, cached_page* cp, bool flush) @@ -398,11 +398,11 @@ static unsigned drop_read_cached_page(std::unordered_map& 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) { @@ -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) { @@ -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) { @@ -508,7 +508,7 @@ 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); @@ -516,7 +516,7 @@ bool get(vfs_file* fp, off_t offset, mmu::hw_ptep<0> ptep, mmu::pt_element<0> pt } 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); @@ -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) @@ -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) { @@ -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; @@ -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;*/ } diff --git a/fs/vfs/vfs_conf.cc b/fs/vfs/vfs_conf.cc index a042d6d196..1d1059f9d0 100644 --- a/fs/vfs/vfs_conf.cc +++ b/fs/vfs/vfs_conf.cc @@ -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); @@ -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 @@ -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}, diff --git a/loader.cc b/loader.cc index 6ce4db1971..475ea271d6 100644 --- a/loader.cc +++ b/loader.cc @@ -401,8 +401,8 @@ void* do_main_thread(void *_main_args) if(mount_rofs_rootfs(opt_pivot) != 0) { // // Failed -> try to mount zfs - zfsdev::zfsdev_init(); - mount_zfs_rootfs(opt_pivot, opt_extra_zfs_pools); + //zfsdev::zfsdev_init(); + //mount_zfs_rootfs(opt_pivot, opt_extra_zfs_pools); bsd_shrinker_init(); boot_time.event("ZFS mounted");