<div dir="ltr"><div>Something like this should work, but code gets complicated (for what it's trying to do).</div><div><br></div><div>I really think this check should exist not only in userspace command runtime but also in kernel space,</div><div>given the assumption that the hammer's kernel code makes,</div><div>but I'll see if I can make it look any better.</div><div><br></div><div><br></div><div>diff --git a/sys/vfs/hammer/hammer_pfs.c b/sys/vfs/hammer/hammer_pfs.c</div><div>index 917a9c9..6bbe273 100644</div><div>--- a/sys/vfs/hammer/hammer_pfs.c</div><div>+++ b/sys/vfs/hammer/hammer_pfs.c</div><div>@@ -130,11 +130,19 @@ hammer_ioc_set_pseudofs(hammer_transaction_t trans, hammer_inode_t ip,</div><div> */</div><div> if (error == 0 &&</div><div> (pfsm->pfsd.mirror_flags & HAMMER_PFSD_SLAVE) == 0) {</div><div>+ if (lo_to_pfs(ip->obj_localization) != HAMMER_ROOT_PFSID) {</div><div>+ hmkprintf(trans->hmp,</div><div>+ "Creating a PFS from non-root PFS is "</div><div>+ "not allowed\n");</div><div>+ error = EINVAL;</div><div>+ goto end;</div><div>+ }</div><div> error = hammer_mkroot_pseudofs(trans, cred, pfsm);</div><div> }</div><div> if (error == 0)</div><div> error = hammer_save_pseudofs(trans, pfsm);</div><div><br></div><div>+end:</div><div> /*</div><div> * Wakeup anyone waiting for a TID update for this PFS</div><div> */</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-02-23 23:04 GMT+09:00 Tomohiro Kusumi <span dir="ltr"><<a href="mailto:kusumi.tomohiro@gmail.com" target="_blank">kusumi.tomohiro@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Sorry, I reverted</div><div><a href="https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/8a94c3ebc13420d2c3d35360eff649e2308b7d9c" target="_blank">https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/8a94c3ebc13420d2c3d35360eff649e2308b7d9c</a></div><div><br></div><div><br></div><div>There was one case where mirror write calls this ioctl (not to create a PFS),</div><div>and this sanity check I reverted wasn't appropriate for this particular case.</div><div><br></div><div>(I'm now wondering why no one has complained this for more than 2 months.</div><div>I will check some more details of this mirror write case that caused this issue)</div><div><br></div><div># grep SET_PSEUDOFS sbin/hammer -rI</div><div>sbin/hammer/cmd_pfs.c: if (ioctl(fd, HAMMERIOC_SET_PSEUDOFS, &pfs) < 0) {</div><div>sbin/hammer/cmd_pfs.c: if (ioctl(fd, HAMMERIOC_SET_PSEUDOFS, &pfs) < 0) {</div><div>sbin/hammer/cmd_pfs.c: if (ioctl(fd, HAMMERIOC_SET_PSEUDOFS, &pfs) < 0) {</div><div>sbin/hammer/cmd_pfs.c: if (ioctl(fd, HAMMERIOC_SET_PSEUDOFS, &pfs) == 0) {</div><div>sbin/hammer/cmd_mirror.c: if (ioctl(fd, HAMMERIOC_SET_PSEUDOFS, &pfs) != 0) {</div><div><br></div></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">2016-02-23 22:11 GMT+09:00 Sepherosa Ziehau <span dir="ltr"><<a href="mailto:sepherosa@gmail.com" target="_blank">sepherosa@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi all,<br>
<br>
I just noticed today, my hammer back mechanism seems stop working for a while.<br>
<br>
The output of mount on the backup machine:<br>
ROOT on / (hammer, local, noatime)<br>
devfs on /dev (devfs, local)<br>
/dev/serno/3PT023B3.s1a on /boot (ufs, local, noatime)<br>
REPOS on /repos (hammer, local, noatime)<br>
/repos/pfs/@@-1:00007 on /var (null, local)<br>
/repos/pfs/@@-1:00003 on /tmp (null, local)<br>
/repos/pfs/@@-1:00006 on /usr (null, local)<br>
/repos/pfs/@@-1:00001 on /usr/obj (null, local)<br>
/repos/pfs/@@-1:00005 on /var/crash (null, local)<br>
/repos/pfs/@@-1:00004 on /var/tmp (null, local)<br>
/repos/pfs/@@-1:00002 on /usr/src (null, local)<br>
/repos/pfs/@@0x00000004f3766630:00009 on /backup/sephe/home (null,<br>
local, read-only)<br>
/repos/pfs/@@0x00000004f3766630:00008 on /backup/sephe/opt (null,<br>
local, read-only)<br>
/repos/pfs/@@-1:00010 on /backup/cold (null, local)<br>
procfs on /proc (procfs, local)<br>
<br>
/backup/sephe/home and /backup/sephe/opt is the slave.<br>
<br>
On my laptop, I run:<br>
hammer mirror-stream /opt root@enigma:/backup/sephe/opt<br>
hammer mirror-stream /home root@enigma:/backup/sephe/home<br>
<br>
And on the backup machine, I got many:<br>
HAMMER(REPOS) Creating a PFS from non-root PFS is not allowed<br>
in dmesg<br>
<br>
It seems the above line is logged each time, the hammer mirror-stream<br>
runs on my laptop.<br>
<br>
I don't know when it started.<br>
<br>
Thanks,<br>
sephe<br>
<span><font color="#888888"><br>
--<br>
Tomorrow Will Never Die<br>
</font></span></blockquote></div><br></div>
</div></div></blockquote></div><br></div>