git: sbin/hammer: Allow pfs commands directly handle pfs
Tomohiro Kusumi
tkusumi at crater.dragonflybsd.org
Sun Apr 12 04:36:23 PDT 2015
commit a42b6da657e45b10986036aef9ed7b737b4909ee
Author: Tomohiro Kusumi <kusumi.tomohiro at gmail.com>
Date: Sat Apr 11 05:32:18 2015 +0900
sbin/hammer: Allow pfs commands directly handle pfs
- pfs commands can handle a link to pfs, but not the pfs itself.
This commit allows pfs commands to directly handle pfs node,
in addition to doing it via link. Being able to execute them
only via link is strange behavior and should be able to do via
both ways.
- This commit basically makes both link and non-link path go through
scanpfsid() which scans pfs id and returns fd of its parent dir.
In the existing code only link path goes through pfs id scan code,
so pfs commands are unable to directly handle non-link pfs node
itself (even if one wants to do so).
==========
example1 - using existing /sbin/hammer
# ls -l ./test1
lrwxr-xr-x 1 root wheel 10 Apr 8 05:52 ./test1 -> @@-1:00001
# hammer pfs-downgrade @@-1:00001
pfs-downgrade of PFS#1 () failed: Directory not empty
# hammer pfs-destroy ./@@-1:00001
You have requested that PFS#1 () be destroyed
<snip>
Destroying PFS #1 () in 5 4 3 2 1.. starting destruction pass
pfs-destroy of PFS#1 failed: Directory not empty
==========
example2 - using this commit to directly destroy pfs
# hammer pfs-destroy ./@@-1:00001
You have requested that PFS#1 () be destroyed
<snip>
Destroying PFS #1 () in 5 4 3 2 1.. starting destruction pass
pfs-destroy of PFS#1 succeeded!
# hammer pfs-status ./test1
Cannot access PFS ./test1: No such file or directory
The only case that breaks current behavior is when there is a
regular directory whose format matches (not existing) pfs name,
although this is not likely to happen in the real world. This
is inevitable since stat(2) also recognizes pfs as a directory
(also see hammer_mkroot_pseudofs()).
# mkdir ./@@-1:00005
# hammer pfs-status ./@@-1:00005
Cannot access PFS ./@@-1:00005: No such file or directory
==========
example3 - another example using this commit.
Actually location of the pfs link doesn't matter as the pfs node
represents the root inode of pfs, but not a subdirectory of where
the pfs link is made in the root filesystem. This is confusing
though when there are more than 1 HAMMER filesystems in a single
system as "@@-1:00001" could indicate different pfs-es depending
on where/how commands are executed. Having access to pfs-es via
symlinks (created by pfs-master|slave) is usually a clearer way.
# mkdir -p a/b/c/d/e
# cd a/b/c/d/e
# hammer pfs-master test2 > /dev/null
# ls -l ./test2
lrwxr-xr-x 1 root wheel 10 Apr 10 04:12 ./test2 -> @@-1:00001
# cd ../../../../..
# hammer pfs-destroy @@-1:00001
You have requested that PFS#1 () be destroyed
<snip>
Destroying PFS #1 () in 5 4 3 2 1.. starting destruction pass
pfs-destroy of PFS#1 succeeded!
# hammer pfs-slave test3 > /dev/null
# ls -l ./test3
lrwxr-xr-x 1 root wheel 10 Apr 12 16:30 ./test3 -> @@0x0000000000000001:00001
# hammer pfs-destroy a/b/c/d/e/@@0x0000000000000001:00001
You have requested that PFS#1 () be destroyed
<snip>
Destroying PFS #1 () in 5 4 3 2 1.. starting destruction pass
pfs-destroy of PFS#1 succeeded!
Summary of changes:
sbin/hammer/cmd_pseudofs.c | 142 +++++++++++++++++++++++++++------------------
1 file changed, 86 insertions(+), 56 deletions(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/a42b6da657e45b10986036aef9ed7b737b4909ee
--
DragonFly BSD source repository
More information about the Commits
mailing list