Commit Graph
1457 Commits
Author SHA1 Message Date
Auke Kok cebe465443 Abort pending net requests when a mount fails
A failed mount tears down with scoutfs_put_super(), which calls
scoutfs_srch_destroy() first.  srch_destroy() does cancel_work_sync() on
the srch compact worker, but that worker can be parked in an
uninterruptible scoutfs_net_sync_request() to a server that will never
respond (e.g. the server is stuck in recovery).  Nothing completes the
request: the forced-unmount drain in the net shutdown path only runs for
umount -f, and a failed mount never calls ->umount_begin, so the request
sits on the resend queue and cancel_work_sync() waits forever.

The result is an unkillable D-state mount that survives the SIGKILL a
mount timeout sends, and only clears on reboot:

  systemd[1]: data-archive.mount: Killing process 15740 (mount) with signal SIGKILL.
  systemd[1]: data-archive.mount: Mount process still around after SIGKILL. Ignoring.

  cat /proc/26717/stack
  [<0>] __flush_work+0x16f/0x240
  [<0>] __cancel_work_sync+0x135/0x1a0
  [<0>] scoutfs_srch_destroy+0x33/0x70 [scoutfs]
  [<0>] scoutfs_put_super+0x4f/0x1a0 [scoutfs]
  [<0>] scoutfs_fill_super+0x260/0x520 [scoutfs]
  [<0>] mount_bdev+0xf9/0x150
  [<0>] do_new_mount+0x17a/0x310
  [<0>] __x64_sys_mount+0x107/0x140

The worker it waits on, blocked in the sync request that never returns:

  task:kworker/u269:1  state:D
  Workqueue: scoutfs_srch_compact scoutfs_srch_compact_worker [scoutfs]
  Call Trace:
   __wait_for_common+0x90/0x1d0
   scoutfs_net_sync_request+0xdb/0xf0 [scoutfs]
   scoutfs_client_srch_get_compact+0x2e/0x40 [scoutfs]
   scoutfs_srch_compact_worker+0x64/0x3d0 [scoutfs]

On the fill_super error path, mark forced_unmount and shut the client
connection down before teardown.  That drains pending requests with
-ECONNABORTED so the worker returns and srch_destroy()'s cancel_work_sync
completes.  It is done for any failure, before the direct put_super call
and before returning to generic_shutdown_super (which calls put_super
when s_root was set), so both teardown paths are covered.  sbi is
allocated before any goto out, and scoutfs_client_net_shutdown() is a
no-op when the client or connection was never set up, so early failures
are safe.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-07-23 09:17:39 -07:00
Auke Kok 205cfbdf4a Don't shut down the server when fencing a rid twice
A node only needs to be fenced once, but scoutfs_fence_start() can be
called for the same rid more than once. When a new leader starts it
fences the previous leader as it removes it from the quorum
(quorum_block_leader), and that same rid can also be a mounted client
that then fails to recover within the timeout (client_recovery).

The second fence call collides on that name, sysfs returns -EEXIST,
and the error is propagated to fence_pending_recov_worker() which
treats any error as fatal and shuts the server down. On the next
mount a new leader hits the same stale set and the same collision,
so the filesystem can never finish recovery.

  Jun 15 09:22:35 kernel: scoutfs f.000000.r.222222: fencing previous leader f.000000.r.111111 at term 183942 in slot 3 with address x.x.x.x:6000
  Jun 15 09:22:36 scoutfs-fenced[9194]: [2026-06-15 09:22:36.588037842] server f.000000.r.222222 fencing rid 1111111111111111 at IP x.x.x.x for quorum_block_leader
  Jun 15 09:23:09 kernel: scoutfs f.000000.r.222222 error: 30000 ms recovery timeout expired for client rid 1111111111111111, fencing
  Jun 15 09:23:09 kernel: sysfs: cannot create duplicate filename '/fs/scoutfs/f.000000.r.222222/fence/1111111111111111'
  Jun 15 09:23:09 kernel: scoutfs f.000000.r.222222 error: fence returned err -17, shutting down server

Check the list for the rid and skip the duplicate before creating
sysfs. A pending fence can be freed once it is on the list, so a new
fi->mutex serializes creation against the freeing path: the duplicate
check, sysfs create, and list insert run as a unit, and a fence becomes
visible on the list only once it is fully built. scoutfs_fence_free()
and scoutfs_fence_stop() take the same mutex around removing a fence
and tearing it down, and scoutfs_fence_destroy() drains through
fence_stop() rather than walking the list unlocked.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-07-23 09:14:59 -07:00
Auke Kok fd1df67efa Shorten the default TCP_KEEPALIVE_TIMEOUT_MS to 24s
In v1.25-49-gf6746275, we adjusted the default TCP keepalive
value for clients from 10s to 60s. The motivation for doing so
was to allow the system to withstand an - at that time - unknown
networking issue that caused intermittent fencing/disconnects.

It was later determined that lock recovery stalls were the culprit,
and those were largely addressed by ca. v1.26-21-gf0c79966 which
fixes the issue at the root of the problem. The increase from
10s to 60s however was not reverted.

We are now seeing issues when scoutfs is deployed as multiple
filesystem mounts on a cluster where e.g. the server is dropped
for a fencing test - causing a non-leader node to take over from
the fenced server. It will issue new fence requests for clients
that were previously connected in 30 seconds. But with a 60sec
TCP timeout value, any client that is still up will wait silently
for the fenced server, until the new leader fences them. This leaves
the cluster degraded in case of a 3-node quorum.

The precise timeline:
  -  0sec: nmcli down on node0
  - 10sec: new election issued, node1 wins, node2 remains follower
  - 15sec: node0 fenced (quorum old leader fence)
  - 45sec: node1 fences clients that failed to recover
  never reached:
  - 60sec: node2 client reconnect due to TCP timeout

In our scoutfs testing we never see this because we just call umount
in our testing script unconditionally. In a multi-fs scenario with
real fencing this is never done, and so the cluster degrades almost
entirely consistently.

Drop the value to 24sec. The new value is well below the highest
acceptable value: 45sec. We don't want to lower it too much, and we
also don't want it to be a multiple of 15/10 to avoid concurrent
intervals causing "flapping" or waves of events excluding. 24s fits
well between the minimum of 15 and maximum of 45 and isn't a straight
factor or multiple of 10, 15, or 30.

Test results: on my 3-node 3-fs setup, this 100% recovered all 3
fs's without degrading the cluster. In 1/20 tests I had to re-start
2 nodes (a "flap") in succession to recover. In the rest of the tests,
the cluster recovered as expected.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-23 15:13:37 -07:00
Auke Kok 99b87371c6 Drop KC_HAS_SET_ACL
RHEL7 was the only conditional user of this define, but since
support for that is removed, these can be dropped.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-08 11:53:16 -07:00
Auke Kok d929b06292 Collapse scoutfs_rename2 into scoutfs_rename_common.
scoutfs_rename2 was a thin shim that validated flags and forwarded
to scoutfs_rename_common. It existed because the old el7
RHEL_IOPS_WRAPPER path used a non-flag-taking .rename op alongside
.rename2; with that path gone there is only one rename method,
and the wrapper has no purpose.

Move the RENAME_NOREPLACE flag validation into scoutfs_rename_common
and point the directory inode_operations .rename slot at it directly.
The symlink inode_operations already used scoutfs_rename_common, so
this also makes symlink rename consistently reject unknown flags
instead of silently accepting them.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-08 11:27:46 -07:00
Auke Kok f4a28f1f04 Remove KC_STACK_TRACE_SAVE compat for el7.
el8 already provides stack_trace_save() and stack_trace_print()
in linux/stacktrace.h, so the legacy save_stack_trace/print_stack_trace
fallback inlines are dead. Drop the detection stanza and the inlines.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-08 11:27:33 -07:00
Auke Kok 56526e617f Remove KC_MM_VM_FAULT_T compat for el7.
el8 already provides vm_fault_t and vmf_error(), so the fallback
typedef and inline are dead. Drop the detection stanza and the
two function-signature ifdefs in data.c that switched between the
pre-v4.11 and modern fault handler prototypes.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 77156d695f Remove list_lru_walk_* el7 compat.
The original patch added compat for both el7 and higher kernels,
so this just drops the el7 parts.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 9f6d46ab66 Remove list_lru_shrink_count() and list_lru_shrink_walk() compat for el7
Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 0b669980d0 Remove .remap_pages method for el7
Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 99eb9c2c45 Remove kc_inode_dio_end compat for el7.
Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 2ce496167c Remove __kernel_old_timeval compat for el7.
Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok e7c8881ca4 Remove KC_XATTR_HANDLER_NAME compat for el7
Every kernel now supports .name instead of .prefix.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 505d7f8198 Remove el7 RHEL_IOPS_WRAPPER and KC_LINUX_AIO_KI_LEFT
These were kind of globbed together. This removes a large
amount of duplicate method definitions.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 32845f85c3 Remove .aio_read and .aio_write methods.
This removes two large duplicate code blocks.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 1af1040631 Remove KC_FILE_AOPS_READAHEAD compat for el7
Thanks to RH backporting this 5.x kernel feature, we can drop
a large chunk of code here.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok c81832a2c6 Remove MS_* (mount) flags for el7
These are obsolete, we won't need their backwards compatible
versions anymore.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 986efe1ce1 All workqueues are non-reentrant since el8
Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 2944ea6424 remove generic_file_buffered_write backport for el7
We still need to keep KC_GENERIC_PERFORM_WRITE_KIOCB_IOV_ITER for
el8. So kc_generic_perform_write remains in place for now.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 16af2fe5ff Remove KC_CPU_NOTIFIER compat for el7
Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 99415423ae Remove timespec64 compat for el7
Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok c83e37c1c7 Remove kc_sock_create_kern compat for el7
Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok d611cf1368 Remove kc_get_sock/peername compat for el7
Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok a3b77c224f Remove KC_XATTR_STRUCT_XATTR_HANDLER compat for el7
This includes removal of a lot of double function definitions.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 1824980d29 Remove KC_BIO_BI_STATUS compat for el7
Unwrap the remaining stubs.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 166238abc7 Remove KC_BIO_BI_OPF compat for el7
Unwrap the remaining stubs everywhere used.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 84a3e73086 Remove memalloc_noio_save/_restore compath for el7
Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 7c0c1e6f38 Remove __percpu_counter_add compat for el7
Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 276034f89d Remove iversion.h compat for el7
For simplicity we just include the header here now that we
don't need it in the kernelcompat anymore.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 9102dc0136 Remove setattr_prepare() compat for el7
Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 94d06e65bc Remove KC_RB_TREE_AUGMENTED_COMPUTE_MAX compat for el7
Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok fcf94498fb Remove kc_posix_acl_valid compat.
This is a pre-el7 remnant, possibly from a really old rhel9
version, and was already effectively a stub.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 3d9a7918c4 Remove KC_FMODE_KABI_ITERATE compat for el7
Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 64587c505a Remove backing_dev_info compat for el7
Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 31c9ea40ce Remove shinker compat for el7
Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok e1a8b17e0c Remove posix_acl_create
We're now using __posix_acl_create instead.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Auke Kok 845b43d29c Remove use of d_materialise_unique
This is no longer used. We always d_splice_alias.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-05 09:49:45 -07:00
Zach BrownandGitHub 24aeb0175f Merge pull request #319 from versity/auke/nfs_setfacl
nfs setfacl + test (needs nfs-utils)
2026-06-03 10:06:17 -07:00
Zach BrownandGitHub 07e90422ee Merge pull request #293 from versity/auke/data_prealloc_min
scaling prealloc.
2026-05-28 09:40:31 -07:00
Auke Kok fa560016d4 Register .set_acl unconditionally to fix POSIX ACL writes over NFS
Scoutfs has supported posix ACLs through the xattr handler table,
which allowed NFS to fetch them through this sideband, which worked
for older kernels.

With recent changes we've pulled in .get_acl because the mainline
kernel is changing how ACL ops are called. But we still left .set_acl
unreachable. This meant that on el9.7 nfs clients could now reach
.get_acl, but still not set them.

With this change, we're finally exposing .set_acl consistently
across all el releases and allowing nfs clients to both get and set
posix ACLs.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-05-28 09:02:47 -07:00
Auke Kok 1f1e3e9c6a Use timer_container_of with fallback for from_timer
El9.8 backported the upstream v6.15.* rename of from_timer to
timer_container_of.  Switch the two callers in fence.c and recov.c
to the new style and add a simple kcompat define for older kernels.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-05-26 17:45:53 -04:00
Auke Kok 5a6523ecf4 Ramping up data preallocation
Ramps up data preallocation based on the number of online
blocks. This results in a simple 2<<n block allocation pattern
until n=11 (2048) - the default value of data_prealloc_blocks.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-05-19 19:18:53 -07:00
Zach BrownandGitHub ceebadd139 Merge pull request #308 from versity/auke/totl-delta-repair
totl key repair
2026-05-05 13:05:57 -07:00
Zach BrownandGitHub 4b4ddc9ded Merge pull request #298 from versity/auke/double_unlock_dw_truncate
Fix double unlock in scoutfs_setattr data_wait error path
2026-05-04 09:52:29 -07:00
Zach BrownandGitHub 94d3ece590 Merge pull request #299 from versity/auke/cond_resched_block_free
Add cond_resched in block_free_work
2026-05-04 09:49:43 -07:00
Auke Kok 6d5517614b Fix double unlock in scoutfs_setattr data_wait error path
When scoutfs_setattr truncates a file with offline extents, it unlocks
the inode lock before calling scoutfs_data_wait to wait for the data
to be staged. If data_wait returns any error, the code jumps to 'goto
out' which calls scoutfs_unlock again, thus double-unlocking the lock.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-05-04 09:48:54 -07:00
Zach BrownandGitHub 443c34309f Merge pull request #303 from versity/auke/clang_build_werr
3 minor clang things
2026-05-04 09:42:43 -07:00
Auke Kok 5c81a979d5 Add SCOUTFS_IOC_INJECT_TOTL_DELTA ioctl.
Inject a signed (total, count) delta at a totl key.  No validity
checking.  Requires CAP_SYS_ADMIN.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-05-04 09:42:42 -07:00
Zach BrownandGitHub ec38b6e1c8 Merge pull request #305 from versity/auke/block_submit_bio_err
Set BLOCK_BIT_ERROR on bio submit failure during forced unmount
2026-05-04 09:35:43 -07:00
Zach BrownandGitHub 8e0066b231 Merge pull request #309 from versity/auke/quota_invalidate_race
fix and test - quota invalidate race
2026-05-04 09:34:26 -07:00