Author: mm
Date: Wed Sep 26 09:37:58 2012
New Revision: 240955
URL: http://svn.freebsd.org/changeset/base/240955

Log:
  Merge recent vendor changes in ZFS.
  
  Illumos issued covered:
  2811 missing implementation: zfs send -r
  3139 zdb dies when it tries to determine path of unlinked file
  3189 kernel panic in ZFS test suite during hotspare_onoffline_004_neg
  3208 moving zpool cross-endian results in incorrect user/group accounting
  
  References:
    https://www.illumos.org/issues/ + [issue_id]
  
  Obtained from:        illumos (vendor/illumos, vendor/illumos-sys)
  MFC after:    2 weeks

Modified:
  head/cddl/contrib/opensolaris/cmd/zfs/zfs.8
  head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/sa_impl.h
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
  head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
Directory Properties:
  head/cddl/contrib/opensolaris/   (props changed)
  head/cddl/contrib/opensolaris/cmd/zfs/   (props changed)
  head/sys/cddl/contrib/opensolaris/   (props changed)

Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs.8
==============================================================================
--- head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Wed Sep 26 09:29:48 2012        
(r240954)
+++ head/cddl/contrib/opensolaris/cmd/zfs/zfs.8 Wed Sep 26 09:37:58 2012        
(r240955)
@@ -174,7 +174,7 @@
 .Fl a | Ar filesystem Ns | Ns Ar mountpoint
 .Nm
 .Cm send
-.Op Fl DnPpRrv
+.Op Fl DnPpRv
 .Op Fl i Ar snapshot | Fl I Ar snapshot
 .Ar snapshot
 .Nm
@@ -2196,7 +2196,7 @@ file system shared on the system.
 .It Xo
 .Nm
 .Cm send
-.Op Fl DnPpRrv
+.Op Fl DnPpRv
 .Op Fl i Ar snapshot | Fl I Ar snapshot
 .Ar snapshot
 .Xc
@@ -2269,13 +2269,6 @@ be used regardless of the dataset's
 property, but performance will be much better if the filesystem uses a
 dedup-capable checksum (eg.
 .Sy sha256 ) .
-.It Fl r
-Recursively send all descendant snapshots.  This is similar to the
-.Fl R
-flag, but information about deleted and renamed datasets is not included, and
-property information is only included if the
-.Fl p
-flag is specified.
 .It Fl p
 Include the dataset's properties in the stream. This flag is implicit when
 .Fl R

Modified: head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c
==============================================================================
--- head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c    Wed Sep 26 09:29:48 
2012        (r240954)
+++ head/cddl/contrib/opensolaris/cmd/zfs/zfs_main.c    Wed Sep 26 09:37:58 
2012        (r240955)
@@ -267,7 +267,7 @@ get_usage(zfs_help_t idx)
        case HELP_ROLLBACK:
                return (gettext("\trollback [-rRf] <snapshot>\n"));
        case HELP_SEND:
-               return (gettext("\tsend [-DnPpRrv] "
+               return (gettext("\tsend [-DnPpRv] "
                    "[-i snapshot | -I snapshot] <snapshot>\n"));
        case HELP_SET:
                return (gettext("\tset <property=value> "

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c        Wed Sep 
26 09:29:48 2012        (r240954)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/dmu_tx.c        Wed Sep 
26 09:37:58 2012        (r240955)
@@ -572,7 +572,7 @@ dmu_tx_count_free(dmu_tx_hold_t *txh, ui
                    (dn->dn_indblkshift - SPA_BLKPTRSHIFT);
 
                while (level++ < maxlevel) {
-                       txh->txh_memory_tohold += MIN(blkcnt, (nl1blks >> epbs))
+                       txh->txh_memory_tohold += MAX(MIN(blkcnt, nl1blks), 1)
                            << dn->dn_indblkshift;
                        blkcnt = 1 + (blkcnt >> epbs);
                }

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/sa_impl.h
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/sa_impl.h   Wed Sep 
26 09:29:48 2012        (r240954)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/sys/sa_impl.h   Wed Sep 
26 09:37:58 2012        (r240955)
@@ -20,6 +20,7 @@
  */
 /*
  * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
  */
 
 #ifndef        _SYS_SA_IMPL_H
@@ -181,7 +182,7 @@ typedef struct sa_hdr_phys {
  */
 
 #define        SA_HDR_LAYOUT_NUM(hdr) BF32_GET(hdr->sa_layout_info, 0, 10)
-#define        SA_HDR_SIZE(hdr) BF32_GET_SB(hdr->sa_layout_info, 10, 16, 3, 0)
+#define        SA_HDR_SIZE(hdr) BF32_GET_SB(hdr->sa_layout_info, 10, 6, 3, 0)
 #define        SA_HDR_LAYOUT_INFO_ENCODE(x, num, size) \
 { \
        BF32_SET_SB(x, 10, 6, 3, 0, size); \

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c    Wed Sep 
26 09:29:48 2012        (r240954)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_vfsops.c    Wed Sep 
26 09:37:58 2012        (r240955)
@@ -49,6 +49,7 @@
 #include <sys/spa.h>
 #include <sys/zap.h>
 #include <sys/sa.h>
+#include <sys/sa_impl.h>
 #include <sys/varargs.h>
 #include <sys/policy.h>
 #include <sys/atomic.h>
@@ -59,7 +60,6 @@
 #include <sys/dnlc.h>
 #include <sys/dmu_objset.h>
 #include <sys/spa_boot.h>
-#include <sys/sa.h>
 #include <sys/jail.h>
 #include "zfs_comutil.h"
 
@@ -550,7 +550,6 @@ static int
 zfs_space_delta_cb(dmu_object_type_t bonustype, void *data,
     uint64_t *userp, uint64_t *groupp)
 {
-       znode_phys_t *znp = data;
        int error = 0;
 
        /*
@@ -569,20 +568,18 @@ zfs_space_delta_cb(dmu_object_type_t bon
                return (EEXIST);
 
        if (bonustype == DMU_OT_ZNODE) {
+               znode_phys_t *znp = data;
                *userp = znp->zp_uid;
                *groupp = znp->zp_gid;
        } else {
                int hdrsize;
+               sa_hdr_phys_t *sap = data;
+               sa_hdr_phys_t sa = *sap;
+               boolean_t swap = B_FALSE;
 
                ASSERT(bonustype == DMU_OT_SA);
-               hdrsize = sa_hdrsize(data);
 
-               if (hdrsize != 0) {
-                       *userp = *((uint64_t *)((uintptr_t)data + hdrsize +
-                           SA_UID_OFFSET));
-                       *groupp = *((uint64_t *)((uintptr_t)data + hdrsize +
-                           SA_GID_OFFSET));
-               } else {
+               if (sa.sa_magic == 0) {
                        /*
                         * This should only happen for newly created
                         * files that haven't had the znode data filled
@@ -590,6 +587,25 @@ zfs_space_delta_cb(dmu_object_type_t bon
                         */
                        *userp = 0;
                        *groupp = 0;
+                       return (0);
+               }
+               if (sa.sa_magic == BSWAP_32(SA_MAGIC)) {
+                       sa.sa_magic = SA_MAGIC;
+                       sa.sa_layout_info = BSWAP_16(sa.sa_layout_info);
+                       swap = B_TRUE;
+               } else {
+                       VERIFY3U(sa.sa_magic, ==, SA_MAGIC);
+               }
+
+               hdrsize = sa_hdrsize(&sa);
+               VERIFY3U(hdrsize, >=, sizeof (sa_hdr_phys_t));
+               *userp = *((uint64_t *)((uintptr_t)data + hdrsize +
+                   SA_UID_OFFSET));
+               *groupp = *((uint64_t *)((uintptr_t)data + hdrsize +
+                   SA_GID_OFFSET));
+               if (swap) {
+                       *userp = BSWAP_64(*userp);
+                       *groupp = BSWAP_64(*groupp);
                }
        }
        return (error);

Modified: head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c
==============================================================================
--- head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c     Wed Sep 
26 09:29:48 2012        (r240954)
+++ head/sys/cddl/contrib/opensolaris/uts/common/fs/zfs/zfs_znode.c     Wed Sep 
26 09:37:58 2012        (r240955)
@@ -2050,13 +2050,16 @@ zfs_release_sa_handle(sa_handle_t *hdl, 
  * or not the object is an extended attribute directory.
  */
 static int
-zfs_obj_to_pobj(sa_handle_t *hdl, sa_attr_type_t *sa_table, uint64_t *pobjp,
-    int *is_xattrdir)
+zfs_obj_to_pobj(objset_t *osp, sa_handle_t *hdl, sa_attr_type_t *sa_table,
+    uint64_t *pobjp, int *is_xattrdir)
 {
        uint64_t parent;
        uint64_t pflags;
        uint64_t mode;
+       uint64_t parent_mode;
        sa_bulk_attr_t bulk[3];
+       sa_handle_t *sa_hdl;
+       dmu_buf_t *sa_db;
        int count = 0;
        int error;
 
@@ -2070,9 +2073,32 @@ zfs_obj_to_pobj(sa_handle_t *hdl, sa_att
        if ((error = sa_bulk_lookup(hdl, bulk, count)) != 0)
                return (error);
 
-       *pobjp = parent;
+       /*
+        * When a link is removed its parent pointer is not changed and will
+        * be invalid.  There are two cases where a link is removed but the
+        * file stays around, when it goes to the delete queue and when there
+        * are additional links.
+        */
+       error = zfs_grab_sa_handle(osp, parent, &sa_hdl, &sa_db, FTAG);
+       if (error != 0)
+               return (error);
+
+       error = sa_lookup(sa_hdl, ZPL_MODE, &parent_mode, sizeof (parent_mode));
+       zfs_release_sa_handle(sa_hdl, sa_db, FTAG);
+       if (error != 0)
+               return (error);
+
        *is_xattrdir = ((pflags & ZFS_XATTR) != 0) && S_ISDIR(mode);
 
+       /*
+        * Extended attributes can be applied to files, directories, etc.
+        * Otherwise the parent must be a directory.
+        */
+       if (!*is_xattrdir && !S_ISDIR(parent_mode))
+               return (EINVAL);
+
+       *pobjp = parent;
+
        return (0);
 }
 
@@ -2121,7 +2147,7 @@ zfs_obj_to_path_impl(objset_t *osp, uint
                if (prevdb)
                        zfs_release_sa_handle(prevhdl, prevdb, FTAG);
 
-               if ((error = zfs_obj_to_pobj(sa_hdl, sa_table, &pobj,
+               if ((error = zfs_obj_to_pobj(osp, sa_hdl, sa_table, &pobj,
                    &is_xattrdir)) != 0)
                        break;
 
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to