Commit Graph

4 Commits

Author SHA1 Message Date
Auke Kok c0fb1ef641 Add sysfs default_groups usage
Since v5.1-rc3-29-gaa30f47cf666, and in el9, there are changes to reduce
the amount of boilerplate code needed to hook up lots of attribute files
using a .default_groups member. In el10, this is the required method as
.default_attrs has been removed. This touches every sysfs part that we
have.

Signed-off-by: Auke Kok <auke.kok@versity.com>
2026-06-01 17:09:05 +00:00
Zach Brown e354fd18b1 scoutfs: add sysfs.c, fsid file
I wanted to add a sysfs file that exports the fsid for the mount of a
given device.  But our use of sysfs was confusing and spread through
super.c and counters.c.

This moves the core of our sysfs use to sysfs.c.  Instead of defining
the per-mount dir as a kset we define it as an object with attributes
which gives us a place to add an fsid attribute.

counters still have their own whack of sysfs implementation.  We'll let
it keep it for now but we could move it into sysfs.c.  It's just counter
interation around the insane sysfs obj/attr/type nonsense.  For now it
just needs to know to add its counters dir as a child of the per-mount
dir instead of adding it to the kset.

Signed-off-by: Zach Brown <zab@versity.com>
2017-12-20 12:21:13 -08:00
Zach Brown e15eb13ec9 scoutfs: centralize teardown in put_super
We were trying to tear down our mounted file system resources in the
->kill_sb() callback.  This happens relatively early in the unmount
process.  We call kill_block_super() in our teardown which syncs the
mount and tears down the vfs structures.  By tearing down in ->kill_sb()
we were forced to juggle tearing down before and after the call to
kill_block_super().

When we got that wrong we'd tear down too many resources and crash in
kill_block_super() or we wouldn't tear down enough and leave work still
pending that'd explode as we tried to shut down after
kill_block_super().

It turns out the vfs has a callback specifcally to solve this ordering
problem.  The put_super callback is called after having synced the mount
but before its totally torn down.  By putting all our shutdown in there
we no longer have to worry about racing with active use.

Auditing the shutdown dependencies also found some bad cases where we
were tearding down subsystems that were still in use.  The biggest
problem was shutting down locking and networking before shutting down
the transaction processing which relies on both.   Now we first shut
down all the client processing, then all the server processing, then the
lowest level common infrastructure.

The trickiest part in understanding this is knowing that
kill_block_super() only calls put_super during mount failure if mount
got far enough to assign the root dentry to s_root.  We call put_super
manually ourselves in mount failure if it didn't get far enough so that
all teardown goes through put_super.  (You'll see this s_root test in
other upstream file system error paths.)

Finally while auding the setup and shutdown paths I noticed a few, trans
and counters, that needed simple fixes to properly cleanup errors and
only shutdown if they've been setup.

This all was stressed with an xfstests that races mount and unmount
across the cluster.  Before this change it'd crash/hang almost instantly
and with this change it runs to completion.

Signed-off-by: Zach Brown <zab@versity.com>
2017-12-08 13:22:11 -06:00
Zach Brown 7a565a69df scoutfs: add percpu coutners with sysfs files
Add percpu counters that will let us track all manner of things.

To report them we add a sysfs directory full of attribute files in a
sysfs dir for each mount:

    # (cd /sys/fs/scoutfs/loop0/counters && grep . *)
    skip_delete:0
    skip_insert:3218
    skip_lookup:8439
    skip_next:1190
    skip_search:156

The implementation is careful to define each counter in only one place.
We don't have to make sure that a bunch of defintions and arrays are in
sync.

This builds off of Ben's initial patches that added sysfs dirs.

Signed-off-by: Zach Brown <zab@versity.com>
Signed-off-by: Ben McClelland <ben.mcclelland@versity.com>
2016-03-31 16:44:37 -07:00