Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge Illumos 4445fff (Illumos feature #2882, issue #2883, feature #2900) #1496

Closed
wants to merge 1 commit into from

Conversation

dweeezil
Copy link
Contributor

@dweeezil dweeezil commented Jun 3, 2013

Notes from the Illumos commit:

2882 implement libzfs_core
2883 changing "canmount" property to "on" should not always remount dataset
2900 "zfs snapshot" should be able to create multiple, arbitrary snapshots at once
Reviewed by: George Wilson <[email protected]>
Reviewed by: Chris Siden <[email protected]>
Reviewed by: Garrett D'Amore <[email protected]>
Reviewed by: Bill Pijewski <[email protected]>
Reviewed by: Dan Kruchinin <[email protected]>
Approved by: Eric Schrock <[email protected]>

From feature #2882:

We should implement libzfs_core, under the principles proposed here:
http://blog.delphix.com/matt/2012/01/17/the-future-of-libzfs/

This feature request will cover the first phase of this project,
specifically the following tasks:

- create libzfs_core library with functions for snapshot, create,
  clone, destroy snapshots, send & receive (simple cases), send space
  estimation
- revamp the way zfs ioctls are handled: ioctl-specific arguments
  are passed in nvlist, not random zfs_cmd_t fields
- new-style ioctls are logged to the zpool history
- new method of history logging (separate ioctl)
- "zfs snapshot" can create multiple arbitrary snapshots at once
- revamp the way internal history events are handled (stored on disk
  as names rather than event ID)

From issue #2883:

If a dataset has the "canmount" property set to "noauto" it may be mounted.
Changing this property to "on" on a mounted dataset should not result
in a umount+mount of this dataset.

From feature #2900:

The "zfs snapshot" command can create a single snapshot, or with
the -r flag, a snapshot for every filesystem under a certain
point. But it may be desired to create only some snapshots, and
to specify a different name for each of them. The "zfs snapshot"
command should allow you to specify multiple snapshots, e.g. "zfs
snapshot pool/fs@a pool/fs2@b".

ZoL-specific changes:

Add "nosleep" versions of the fnvlist_dup, fnvlist_merge,
fnvlist_alloc and fnvlist_pack functions with a suffix of "_nosleep".
They simply perform their allocations with the KM_NOSLEEP flag.

Add zvol minor device creation to the new zfs_snapshot_nvl function.

Misc generic fixes:

Remove the logging of the "release" operation in
dsl_dataset_user_release_sync().  The logging caused a null dereference
because ds->ds_dir is zeroed in dsl_dataset_destroy_sync() and the
logging functions try to get the ds name via the dsl_dataset_name()
function. I've got no idea why this particular code would have worked
in Illumos.  This code has subsequently been completely reworked in
Illumos commit 3b2aab1 (3464 zfs synctask code needs restructuring).

Squash some "may be used uninitialized" warning/erorrs.

Fix some printf format warnings for %lld and %llu.

@@ -563,9 +562,11 @@ extern int zfs_create(libzfs_handle_t *, const char *, zfs_type_t,
extern int zfs_create_ancestors(libzfs_handle_t *, const char *);
extern int zfs_destroy(zfs_handle_t *, boolean_t);
extern int zfs_destroy_snaps(zfs_handle_t *, char *, boolean_t);
extern int zfs_destroy_snaps_nvl(zfs_handle_t *, nvlist_t *, boolean_t);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The parameter change to zfs_destroy_snaps_nvl was accidentally picked up from illumos 3b2aab1. There should be no problem with it in this commit, but it doesn't totally track the history of changes to Illumos.

@dweeezil
Copy link
Contributor Author

dweeezil commented Jun 4, 2013

#1495 Port Illumos #3464 (3b2aab1) - zfs synctask code needs restructuring a day ago

While working on issue #1495, I noticed I included a few changes from that commit (Illumos 3b2aab1) in this one. In particular, the zfs_destroy_snaps_nvl() function was updated to use a libzfs_handle_t * argument rather than a zfs_handle_t * argument. There should be no problem with this change being in this commit.

@dweeezil
Copy link
Contributor Author

Note: Commit 8592f00 is an amend of 9bdf8c to use the original author attribution.

@dweeezil
Copy link
Contributor Author

I have a feeling part of this commit may be causing the problem reported in #1518. See my comments there.

@behlendorf
Copy link
Contributor

@dweeezil Thanks for starting this port. These are changes we absolutely want to bring in but they're so extensive it's going to be a challenge to review and test them, I won't have a chance to carefully review these for a little but I wanted to ask how difficult was this to port? Were there a large number of conflicts?

@dweeezil
Copy link
Contributor Author

@behlendorf Yes, there were a lot of conflicts. In some cases, I took parts wholesale from Illumos and modified them after-the-fact as necessary (dmu_objset.c dweeezil/zfs@f0379f4). I'd also like to refer you to my "illumos-4445fff" branch (dweeezil/zfs@357fa8e) which is my "working branch" (the pull request is a roll-up branch) for a bit more of a blow-by-blow commentary on the porting effort.

Testing this all for correctness will, indeed, be a bear. I've got reason to believe that parts of it may not be playing nice with your changes from 3558fd7 and, among other things, think that some interaction between 3558fd7 and mine may be causing the problem indicated in #1518. While trying to track that one down, I came across #1536 which occurs even in master. There seems to be some underlying problem that can be triggered as part of the various operations that need to remount a file system such as the post-receive part of a zfs receive and also rollbacks.

In any case, this patch does currently pass all the tests in "zconfig.sh" and can run ztest for long stretches of time without errors. I'm going to continue to try to track down the cause of some of these recent issues and also stress it on a few personal systems of mine.

@behlendorf
Copy link
Contributor

@dweeezil OK, well I'll queue it up for automated testing and additional review. Beyond that I'm going to need a significant amount of run time with this patch before I'm comfortable merging it.

@imp
Copy link
Contributor

imp commented Jul 3, 2013

@dweeezil I am building this on centos 6.4 and make pkg fails with include/libzfs_core.h

the patch that fixes it for me is

diff --git a/include/Makefile.am b/include/Makefile.am
index 64141d9..2e1c31a 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -18,6 +18,7 @@ USER_H = \
        $(top_srcdir)/include/libuutil.h \
        $(top_srcdir)/include/libuutil_impl.h \
        $(top_srcdir)/include/libzfs.h \
+       $(top_srcdir)/include/libzfs_core.h \
        $(top_srcdir)/include/libzfs_impl.h

 EXTRA_DIST = $(COMMON_H) $(KERNEL_H) $(USER_H)

@dweeezil
Copy link
Contributor Author

dweeezil commented Jul 3, 2013

@imp Thanks. I guess I'm not too familiar with all the various make targets. All I've ever done are plain makes and installs. One of my test systems is actually CentOS 6.4 so I suppose I should try some of the other building options there. I'll put this into my work-in-progress branch (illumos-4445fff). NOTE: my WIP branch has already been rebased against against a newer master (but not tested).

I'm planning on testing a rebase against a current master over the long weekend and then I'll push a new unified commit into the pull-2 branch.

@behlendorf
Copy link
Contributor

@dweeezil I needed to make the following change to build:

diff --git a/module/zfs/dsl_dataset.c b/module/zfs/dsl_dataset.c
index a98d003..e289931 100644
--- a/module/zfs/dsl_dataset.c
+++ b/module/zfs/dsl_dataset.c
@@ -1109,7 +1109,7 @@ dsl_dataset_destroy(dsl_dataset_t *ds, void *tag, boolean_
         */
        if (ds->ds_phys->ds_bp.blk_fill == 0 &&
            dmu_objset_userused_enabled(os)) {
-               uint64_t count;
+               ASSERTV(uint64_t count);

                ASSERT(zap_count(os, DMU_USERUSED_OBJECT, &count) != 0 ||
                    count == 0);

@dweeezil
Copy link
Contributor Author

dweeezil commented Jul 3, 2013

@behlendorf I did actually notice the unused variable warnings the last time I compiled it. I had thought that warnings were promoted to errors but apparently, at least on my current systems, they aren't.

I just cherry-picked this and a Makefile fix found by @imp into the illumos-4445fff-pull-2 branch (from my WIP illumos-4445fff branch). As previously mentioned, I'd like to get this rebased to a newer master and then I'll roll it all into a single commit at that time.

@behlendorf
Copy link
Contributor

BUG: unable to handle kernel paging request at ffffffffa035e810
IP: [<ffffffffa035e810>] 0xffffffffa035e80f
PGD 1c0d067 PUD 1c11063 PMD 36b60067 PTE 0 
Oops: 0010 [#1] SMP  
RIP: 0010:[<ffffffffa035e810>]  [<ffffffffa035e810>] 0xffffffffa035e80f
Process rmmod (pid: 5101, threadinfo ffff880118866000, task ffff8800c1e55c80)
Stack:
 ffffffffa01a5bc2 ffff8801155dfff0 ffff880036a1be78 ffff8801152974c0
 0000000000000000 ffff880118867eb8 ffffffffa01a7a4c fffffffffffffff5
 0000000000000000 ffff880118867e58 ffff880118867e58 000000000000002b
Call Trace:
 [<ffffffffa01a5bc2>] ? tsd_hash_dtor+0xb2/0x120 [spl]
 [<ffffffffa01a7a4c>] spl_tsd_fini+0x12c/0x2e0 [spl]
 [<ffffffffa01a23ac>] spl_fini+0x4c/0xc0 [spl]
 [<ffffffff81617cc9>] ? mutex_unlock+0x9/0x20
 [<ffffffff810bde06>] sys_delete_module+0x1a6/0x2b0
 [<ffffffff810d863c>] ? __audit_syscall_entry+0xcc/0x310
 [<ffffffff810d8c56>] ? __audit_syscall_exit+0x3d6/0x410
 [<ffffffff81622429>] system_call_fastpath+0x16/0x1b
Code:  Bad RIP value.
RIP  [<ffffffffa035e810>] 0xffffffffa035e80f
 RSP <ffff880118867e10>
CR2: ffffffffa035e810
---[ end trace 18df537cf648cc88 ]--- 

Observed while testing with the zconfig.sh script. It appears that during module remove when we're cleaning up the tsd_hash we find some remaining entries. Those entries now have a destructor registered which we try to call but that symbol was in the zfs module which has been removed from the system. zfs should make sure it destroys the zfs_allow_log_key in _fini().

@dweeezil
Copy link
Contributor Author

dweeezil commented Jul 3, 2013

@behlendorf I thought I had fixed that in dweeezil/zfs@944351e (commit from my WIP branch). I wonder if the tsd_destroy isn't in the right place.

@dweeezil
Copy link
Contributor Author

dweeezil commented Jul 3, 2013

@behlendorf Hmm, somehow that didn't make it into my all-in-one commit in the illumos-4445fff-pull-2 branch. Now I wonder what else might be missing. I either didn't squash all the commits correctly or I snuck in a few fixes after making the unified commit.

@dweeezil
Copy link
Contributor Author

dweeezil commented Jul 3, 2013

@behlendorf OK, I'm really sorry. Somehow I totally screwed up the commit for the pull request. I'll have to re-do it. In the mean time, the equivalent is supposed to be on my illumos-4445fff-orig branch. That branch is my original work and is based on master from early May. The illumos-4445fff branch is based on a much newer master. I'm going to re-make the pull request commit one more time.

@dweeezil
Copy link
Contributor Author

dweeezil commented Jul 3, 2013

@behlendorf and @imp and anyone else trying this, I just re-did this pull request and now, hopefully, it represents what I really wanted to have here. It's based on master as of 0377189 and includes all my work-in-progress as well as the 2 cherry-picked commits to deal with the Makefile and the unused count variable.

@behlendorf
Copy link
Contributor

@dweeezil I haven't verify using the refreshed branch but I'm also seeing zconfig tests 3,4 failing because the ZoL specific snapdev properly isn't being honored properly. Is this something you addressed in you latest version?

@dweeezil
Copy link
Contributor Author

dweeezil commented Jul 3, 2013

@behlendorf In all honesty, I don't remember there being any issues specific to the snapdev property, however, I've run all of the zconfig tests plenty of times and they all passed. I just looked again at the stuff that was missing from the earlier pull request and it looks to me like the other big missing chunk is the zvol minor handling code from dweeezil/zfs@6ed1435 and dweeezil/zfs@357fa8e.

@behlendorf
Copy link
Contributor

@dweeezil OK, I'll refresh to your latest patch and give it a spin again. The failure I saw was related to minor creation.

@dweeezil
Copy link
Contributor Author

dweeezil commented Jul 3, 2013

@behlendorf I just tried the new illumos-4445fff-pull-2 branch (dweeezil/zfs@751c7d0) on a test Ubuntu 12.04 system and it does seem to, at least, pass the zconfig.sh tests.

root@ubu12-zfstest:~# /usr/share/zfs/zconfig.sh 
1    persistent zpool.cache             Pass
2    scan disks for pools to import     Pass
3    zpool import/export device         Pass
4    zpool insmod/rmmod device          Pass
5    zvol+ext2 volume                   Pass
6    zvol+ext2 snapshot                 Pass
7    zvol+ext2 clone                    Pass
8    zfs send/receive                   Pass
9    zpool events                       Pass
10   zpool add/remove vdev              Pass
root@ubu12-zfstest:~# uname -r
3.8.0-22-generic
tim@ubu12-zfstest:~/zfs$ dmesg | grep ZFS | tail -1
[   94.481691] ZFS: Unloaded module v0.6.1-37_g751c7d0 (DEBUG mode)

@behlendorf
Copy link
Contributor

@dweeezil I'm unable to reproduce this issue with the refreshed code. Currently I'm running xfstests and filebench against it I'll let you know if they turn up anything.

@dweeezil
Copy link
Contributor Author

I just refreshed the illumos-4445fff-pull-2 (and also the underlying illumos-4445fff) branch with a rebase on this evening's master and consolidated the 2 extra commits into it.

@dweeezil
Copy link
Contributor Author

I just refreshed to today's master and also included a few other fixes from dweeezil/zfs@aa2bc8c. I discovered a couple of missing spa_writeable() changes and an fnvlist_free() call that I missed because when its illumos patch (illumos/illumos-gate@347eec8) was ported to ZoL (9e11c7e), ZoL hadn't quite "caught up" yet and the call wasn't needed.

@dweeezil
Copy link
Contributor Author

My patch caused a regression in dsl_dataset_destroy() due to an improper patch. See dweeezil/zfs@bbb374a for details. I just pushed dweeezil/zfs@84d8e54 to fix it.

@dweeezil
Copy link
Contributor Author

Just pushed dweeezil/zfs@a0dc667 to rebase on a current master. I'm trying to keep this patch current because my work on Illumos 3464 (ZoL issue #1495) must be based on it.

@edillmann edillmann mentioned this pull request Jul 31, 2013
@behlendorf
Copy link
Contributor

@dweeezil Expect fairly little churn is master over the next week or so while we finalize the code for the 0.6.2 tag. It would be great if this branch was in a state ready to merge after we cut that tag.

@ryao ryao mentioned this pull request Aug 12, 2013
@ryao
Copy link
Contributor

ryao commented Aug 12, 2013

@behlendorf This branch appears to be ready to merge.

@dweeezil
Copy link
Contributor Author

@ryao Just got back from vacation. I'm getting this rebased and tested right now. It seems to apply to a current master pretty well.

@dweeezil
Copy link
Contributor Author

I just pushed dweeezil/zfs@1726a6b based on today's master. It seems to work, however, there are a number of stack size warnings generated when I run ztest.sh. Also, I applied this little patch to suppress a pointer type warning:

diff --git a/include/sys/zpl.h b/include/sys/zpl.h
index 61a57ef..f01d359 100644
--- a/include/sys/zpl.h
+++ b/include/sys/zpl.h
@@ -72,7 +72,7 @@ extern ssize_t zpl_xattr_list(struct dentry *dentry, char *buf, size_t size);
 extern int zpl_xattr_security_init(struct inode *ip, struct inode *dip,
     const struct qstr *qstr);

-extern xattr_handler_t *zpl_xattr_handlers[];
+extern const xattr_handler_t *zpl_xattr_handlers[];

 /* zpl_ctldir.c */
 extern const struct file_operations zpl_fops_root;
diff --git a/module/zfs/zpl_xattr.c b/module/zfs/zpl_xattr.c
index eb2c00d..134e547 100644
--- a/module/zfs/zpl_xattr.c
+++ b/module/zfs/zpl_xattr.c
@@ -674,7 +674,7 @@ xattr_handler_t zpl_xattr_security_handler = {
        .set    = zpl_xattr_security_set,
 };

-xattr_handler_t *zpl_xattr_handlers[] = {
+const xattr_handler_t *zpl_xattr_handlers[] = {
        &zpl_xattr_security_handler,
        &zpl_xattr_trusted_handler,
        &zpl_xattr_user_handler,

I'm going to install this on a semi-production server now.

@ryao
Copy link
Contributor

ryao commented Aug 14, 2013

This commit contains code from Illumos 3464. ryao/zfs@bd06e62 removes it.

@dweeezil
Copy link
Contributor Author

@ryao Ugh, while working on this one, the illumos 3464 came on to my radar which I realized was another major patch we needed. Unfortunately, you're totally correct in that a couple of chunks from that one leaked into this patch and I tried to back them out appropriately. As you likely realize, I've also got that one mostly ported and working (see #1495) but I guess I really should clean this up.

Update... I've just read (finally) your comments in #1495. My Illumos 3464 branch does mostly work but there are some PUSHPAGE fixes necessary in the nvlist code, IIRC. Obviously, the 3464 patch totally relies on the "4445fff" branch and is based on same. That makes it a pain in the butt when I've got to fix something in the 4445fff branch because I've then got to repair the 3464 patch. Unfortunately, I just got off vacation and haven't had much quality time to spend working on this yet but I do feel I could get it cleaned up pretty quickly. How do you think we should proceed with this?

@dweeezil
Copy link
Contributor Author

@ryao I just pushed dweeezil/zfs@d138d88 which incorporates your illumos 3464 back-out. Now I've got to put that back into my issue-1495-illumos-3464-synctask branch.

@dweeezil dweeezil mentioned this pull request Aug 16, 2013
@dweeezil
Copy link
Contributor Author

@behlendorf I just pushed dweeezil/zfs@1826f91 which should hopefully be the final change to this patch. I removed the various fnvlist*nosleep() functions I had added and replaced them with calls using the existing infrastructure. It is also now based on the most current master. When I originally did this patch, I wasn't aware of the "allocation handler" feature built in to the nvlist library. I'll be rebasing the commit in #1658 to this commit shortly.

2882 implement libzfs_core
2883 changing "canmount" property to "on" should not always remount dataset
2900 "zfs snapshot" should be able to create multiple, arbitrary snapshots at once

Reviewed by: George Wilson <[email protected]>
Reviewed by: Chris Siden <[email protected]>
Reviewed by: Garrett D'Amore <[email protected]>
Reviewed by: Bill Pijewski <[email protected]>
Reviewed by: Dan Kruchinin <[email protected]>
Approved by: Eric Schrock <[email protected]>

References:
  illumos/illumos-gate@4445fff

Ported-by: Tim Chase <[email protected]>
Closes openzfs#1293

Porting notes:

Add zvol minor device creation to the new zfs_snapshot_nvl function.

Remove the logging of the "release" operation in
dsl_dataset_user_release_sync().  The logging caused a null dereference
because ds->ds_dir is zeroed in dsl_dataset_destroy_sync() and the
logging functions try to get the ds name via the dsl_dataset_name()
function. I've got no idea why this particular code would have worked
in Illumos.  This code has subsequently been completely reworked in
Illumos commit 3b2aab1 (3464 zfs synctask code needs restructuring).

Squash some "may be used uninitialized" warning/erorrs.

Fix some printf format warnings for %lld and %llu.

Apply a few spa_writeable() changes that were made to Illumos in
illumos/illumos-gate.git@cd1c8b8 as part of the 3112, 3113, 3114 and
3115 fixes.

Add a missing call to fnvlist_free(nvl) in log_internal() that was added
in Illumos to fix issue 3085 but couldn't be ported to ZoL at the time
(openzfs/zfs@9e11c73) because it depended on future work.
@dweeezil
Copy link
Contributor Author

Pushed dweeezil/zfs@ac02a59 to refresh to current zfsonlinux/zfs master (0.6.2).

@behlendorf
Copy link
Contributor

@dweeezil Your latest patch passes all the automated testing cleanly and I had a chance to review it. It looks good. So if you don't have any last minute concerns I'm going to merge it in to master. Thank you for for working on this and keeping it up to date while we got 0.6.2 out the door. Once it's in master lots of systems are going to pick it up rather quickly so let's keep any eye out for regressions.

@behlendorf
Copy link
Contributor

Merged. The patch passed all of the automated testing and it's been in Illumos for some time. However since it so large I expect that we missed something so let's keep an eye out for new regressions. At a minimum people should be aware that this change breaks the user/kernel ABI so the zfs/zpool utilities from master no longer inter-operate with the 0.6.2 modules.

6f1ffb0 Illumos #2882, #2883, #2900

@behlendorf behlendorf closed this Sep 4, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants