config_attach_pseudo/config_attach_pseudo: assert kernel lock
as commented in the code, whese functions are inherently
mp-unsafe and only usable with the kernel lock held.
sw_reg_strategy: stop panicking on hole
after the recent change to uvm_aio_aiodone_pages,
it should be ok to report errors here. the swap slots
will be marked bad as expected.
tested with a swap file with 50% holes:
```
Device Size Used Bad Avail Capacity Priority
/dev/dk1 2.0G 1.8G 0B 190M 91% 0
/swapfile_with_half_holes 2.0G 2.0G 1.0G 5.6M 100% 0
Total 4.0G 3.8G 1.0G 196M 95%
```
uvm_aio_aiodone_pages: do not discard user data on swap out failure
if swap out i/o failed, maybe the swap device is broken. it's
reasonable to mark it bad. however, there is no point to discard
the user data on the page being swapped out. unlike file pages,
the association to the particular swap slot is not permanent.
next time the page is picked as a victim by the page daemon, a
different swap slot, which is hopefully good, will be allocated.
swapctl: report npgbad
the current layout of swapent is like the following on amd64:
```
(gdb) ptype /o struct swapent
/* offset | size */ type = struct swapent {
/* 0 | 8 */ dev_t se_dev;
/* 8 | 4 */ int se_flags;
/* 12 | 4 */ int se_nblks;
/* 16 | 4 */ int se_inuse;
/* 20 | 4 */ int se_priority;
/* 24 | 1025 */ char se_path[1025];
/* XXX 7-byte padding */
/* total size (bytes): 1056 */
}
```
while it's tempting to use the padding for the new member
to avoid versioning, i guess we can't because, on some
architectures, 64-bit value only has 32-bit alignment. (eg. i386)
zfs: fix "slow rm" issue (cont.)
commit a change which was lost during a porting from
my local git repo to cvs.
fortunately, it was harmless to miss this change though.
Fix sh tests failing after the PR 60099 fix to /bin/sh
After the fix for PR 60099 was applied to /bin/sh, 2 of the
sh ATF tests no longer give the same output as they used to:
In t_expand:dollar_at_empty_and_conditional
set -- "a+a" "" "b " " c"; IFS=+; delim_argv $*"$@"
That creates 4 positional params, (as shown), so $*"$@"
should be the same as
$1 $2 $3 $4"$1" "$2" "$3" "$4"
'a+a' '' 'b ' ' c'"a+a" "" "b " " c"
where the single quotes are just so the values can be detected,
double quotes indicate quoted values.
The unquoted $* values are then field split, using IFS=+ (which only
[55 lines not shown]
Use the new M68K_EC_VAC and M68K_EC_PAC options, based on configured
model.
As a transitional step, ensure that the new options are consistent with
the legacy CACHE_HAVE_{PAC,VAC} defines.
Add 3 new arch options:
- M68K_EC -- platform has an external cache
- M68K_EC_PAC -- platform has an external cache that's physically addressed
- M68K_EC_VAC -- platform has an external cache that's virtually addressed
M68K_EC_PAC and M68K_EC_VAC are to be used by individual platforms to
indicate their cache configuration options, M68K_EC is inferred by either.
uvmpd_scan_queue: remove ENABLE_UNRELIABLE_CHECK_PR_56764 block
while this condition is true in most of times, we can't
assert it here because these counters are not always
updated in-sync.
for example, consider a removal of a large tmpfs file which is
mostly swapped out. because uao_dropswap_range() batches swpgonly
updates, swpgonly can be temporarily larger than swpginuse.
the original symptom reported in PR/56764 ("uvmexp.swpgonly > 0")
looks like a different issue though.
https://gnats.netbsd.org/56764
zfs_putapage: don't try to write to zfs in the page daemon context
basically zfs is not prepared to be called safely for page daemon.
for now, if we found the page dirty, (thus we need to push it into zfs)
just punt with ENOMEM. hopefully the page daemon will find some other
pages to reclaim.
if the system is already full of dirty pages backed by zfs, i suppose
there is no good way to recover. for a longer term, we probably need
some dirty-page throttling mechanism to avoid the situation in the
first place.
zfs: don't commit the zil for FSYNC_LAZY
FSYNC_LAZY is meant for periodic syncer activity.
unlike fsync() system call, it doesn't give any promises
about data integrity to users.
zfs: flush mmap pages on fsync
it seems the logic to flush page cache in fsync has been removed
during the initial port to netbsd. at that point it was probably ok
because we simply didn't support mmap. since then, mmap support has
been added. but the fsync logic has not been restored. it means that
mmap-modified pages are left dirty basically forever, unless the
application explicitly performs msync on them or page daemon tries
to reclaim them on system memory shortage. it's bad especially for
a file system like zfs because writing data to zfs involves complex
locking and memory allocations, and thus not safe in the context of
the page daemon.
this commit fixes (well, at least improves the situation a bit) by
putting back the page flushing logic.
ideally netbsd needs to have some throttling mechanism on
page-dirtying activities. i suppose such a mechanism can be
implemented in a mostly filesystem-independent manner.
(it was one of my motivations of yamt-pagecache branch.)
Use the fake exception frame created by pmap_bootstrap2() by
capturing its return value and passing it along as the return
value from start_c_finish().
Move initialization of %dfc and %sfc into _bootstrap() (which will
eventually itself be re-factored to reduce duplication). Also, catch
up with the others: no need to initialize %usp before calling main().
For many many years now, it has been unnecessary to initialize the user
stack pointer before calling main(). TL;DR - %usp comes from the exception
frame and is restored in the syscall stub (always) or rei (if an AST is
pending). For newly-forked processes, those take the non-AST path through
rei, but lwp_trampoline() takes care of it in that case.
PR bin/60099 - Fix unquoted $* ($@) expansion
Make unquoted $* (or $@) when used in a context where field
splitting happens (which requires unquoted of course) generate
the same result, always, as would have been obtained had the
number of params been known, and
$1 $2 $3 ... ${n} (n is the value of $#)
been used instead of $* - so for x$*y, for any strings x & y
(including empty), the equivalent would be
x$1 $2 $3 ... ${n}y
This must hold, whatever the setting of IFS (which affects
how the fields generated are field split after they appear,
but should not affect the generation of those fields).
The bug this fixes is (in practice) never encountered, which is
how it has persisted for so long, and in so many different shells.
The method that was previously used to expand $* in this situation
would work perfectly, if the first character of ${IFS} was an IFS
[28 lines not shown]