Author: avg
Date: Fri May 26 12:02:14 2017
New Revision: 318941
URL: https://svnweb.freebsd.org/changeset/base/318941

Log:
  7446 zpool create should support efi system partition
  
  illumos/illumos-gate@7855d95b30fd903e3918bad5a29b777e765db821
  
https://github.com/illumos/illumos-gate/commit/7855d95b30fd903e3918bad5a29b777e765db821
  
  https://www.illumos.org/issues/7446
    Since we support whole-disk configuration for boot pool, we also will need
    whole disk support with UEFI boot and for this, zpool create should create 
efi-
    system partition.
    I have borrowed the idea from oracle solaris, and introducing zpool create -
    B switch to provide an way to specify that boot partition should be created.
    However, there is still an question, how big should the system partition be.
    For time being, I have set default size 256MB (thats minimum size for FAT32
    with 4k blocks). To support custom size, the set on creation "bootsize"
    property is created and so the custom size can be set as: zpool create B -
    o bootsize=34MB rpool c0t0d0
    After pool is created, the "bootsize" property is read only. When -B switch 
is
    not used, the bootsize defaults to 0 and is shown in zpool get output with
    value ''. Older zfs/zpool implementations are ignoring this property.
    https://www.illumos.org/rb/r/219/
  
  Reviewed by: Andrew Stormont <[email protected]>
  Reviewed by: Yuri Pankov <[email protected]>
  Approved by: Dan McDonald <[email protected]>
  Author: Toomas Soome <[email protected]>

Modified:
  vendor-sys/illumos/dist/common/zfs/zpool_prop.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/metaslab.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/spa.c
  vendor-sys/illumos/dist/uts/common/fs/zfs/sys/spa_impl.h
  vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c
  vendor-sys/illumos/dist/uts/common/sys/fs/zfs.h

Changes in other areas also in this revision:
Modified:
  vendor/illumos/dist/cmd/zpool/zpool_main.c
  vendor/illumos/dist/cmd/zpool/zpool_util.h
  vendor/illumos/dist/cmd/zpool/zpool_vdev.c
  vendor/illumos/dist/lib/libzfs/common/libzfs.h
  vendor/illumos/dist/lib/libzfs/common/libzfs_pool.c
  vendor/illumos/dist/man/man1m/zpool.1m

Modified: vendor-sys/illumos/dist/common/zfs/zpool_prop.c
==============================================================================
--- vendor-sys/illumos/dist/common/zfs/zpool_prop.c     Fri May 26 12:00:31 
2017        (r318940)
+++ vendor-sys/illumos/dist/common/zfs/zpool_prop.c     Fri May 26 12:02:14 
2017        (r318941)
@@ -100,6 +100,10 @@ zpool_prop_init(void)
            PROP_READONLY, ZFS_TYPE_POOL, "<1.00x or higher if deduped>",
            "DEDUP");
 
+       /* system partition size */
+       zprop_register_number(ZPOOL_PROP_BOOTSIZE, "bootsize", 0, PROP_ONETIME,
+           ZFS_TYPE_POOL, "<size>", "BOOTSIZE");
+
        /* default number properties */
        zprop_register_number(ZPOOL_PROP_VERSION, "version", SPA_VERSION,
            PROP_DEFAULT, ZFS_TYPE_POOL, "<version>", "VERSION");

Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/metaslab.c
==============================================================================
--- vendor-sys/illumos/dist/uts/common/fs/zfs/metaslab.c        Fri May 26 
12:00:31 2017        (r318940)
+++ vendor-sys/illumos/dist/uts/common/fs/zfs/metaslab.c        Fri May 26 
12:02:14 2017        (r318941)
@@ -394,6 +394,7 @@ metaslab_class_expandable_space(metaslab
 
        spa_config_enter(mc->mc_spa, SCL_VDEV, FTAG, RW_READER);
        for (int c = 0; c < rvd->vdev_children; c++) {
+               uint64_t tspace;
                vdev_t *tvd = rvd->vdev_child[c];
                metaslab_group_t *mg = tvd->vdev_mg;
 
@@ -406,9 +407,13 @@ metaslab_class_expandable_space(metaslab
                 * Calculate if we have enough space to add additional
                 * metaslabs. We report the expandable space in terms
                 * of the metaslab size since that's the unit of expansion.
+                * Adjust by efi system partition size.
                 */
-               space += P2ALIGN(tvd->vdev_max_asize - tvd->vdev_asize,
-                   1ULL << tvd->vdev_ms_shift);
+               tspace = tvd->vdev_max_asize - tvd->vdev_asize;
+               if (tspace > mc->mc_spa->spa_bootsize) {
+                       tspace -= mc->mc_spa->spa_bootsize;
+               }
+               space += P2ALIGN(tspace, 1ULL << tvd->vdev_ms_shift);
        }
        spa_config_exit(mc->mc_spa, SCL_VDEV, FTAG);
        return (space);

Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/spa.c
==============================================================================
--- vendor-sys/illumos/dist/uts/common/fs/zfs/spa.c     Fri May 26 12:00:31 
2017        (r318940)
+++ vendor-sys/illumos/dist/uts/common/fs/zfs/spa.c     Fri May 26 12:02:14 
2017        (r318941)
@@ -2738,6 +2738,7 @@ spa_load_impl(spa_t *spa, uint64_t pool_
                spa_prop_find(spa, ZPOOL_PROP_DELEGATION, &spa->spa_delegation);
                spa_prop_find(spa, ZPOOL_PROP_FAILUREMODE, &spa->spa_failmode);
                spa_prop_find(spa, ZPOOL_PROP_AUTOEXPAND, &spa->spa_autoexpand);
+               spa_prop_find(spa, ZPOOL_PROP_BOOTSIZE, &spa->spa_bootsize);
                spa_prop_find(spa, ZPOOL_PROP_DEDUPDITTO,
                    &spa->spa_dedup_ditto);
 

Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/sys/spa_impl.h
==============================================================================
--- vendor-sys/illumos/dist/uts/common/fs/zfs/sys/spa_impl.h    Fri May 26 
12:00:31 2017        (r318940)
+++ vendor-sys/illumos/dist/uts/common/fs/zfs/sys/spa_impl.h    Fri May 26 
12:02:14 2017        (r318941)
@@ -237,6 +237,7 @@ struct spa {
        int             spa_mode;               /* FREAD | FWRITE */
        spa_log_state_t spa_log_state;          /* log state */
        uint64_t        spa_autoexpand;         /* lun expansion on/off */
+       uint64_t        spa_bootsize;           /* efi system partition size */
        ddt_t           *spa_ddt[ZIO_CHECKSUM_FUNCTIONS]; /* in-core DDTs */
        uint64_t        spa_ddt_stat_object;    /* DDT statistics */
        uint64_t        spa_dedup_ditto;        /* dedup ditto threshold */

Modified: vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c
==============================================================================
--- vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c    Fri May 26 12:00:31 
2017        (r318940)
+++ vendor-sys/illumos/dist/uts/common/fs/zfs/vdev.c    Fri May 26 12:02:14 
2017        (r318941)
@@ -2765,8 +2765,8 @@ vdev_get_stats(vdev_t *vd, vdev_stat_t *
         * since that determines how much space the pool can expand.
         */
        if (vd->vdev_aux == NULL && tvd != NULL) {
-               vs->vs_esize = P2ALIGN(vd->vdev_max_asize - vd->vdev_asize,
-                   1ULL << tvd->vdev_ms_shift);
+               vs->vs_esize = P2ALIGN(vd->vdev_max_asize - vd->vdev_asize -
+                   spa->spa_bootsize, 1ULL << tvd->vdev_ms_shift);
        }
        if (vd->vdev_aux == NULL && vd == vd->vdev_top && !vd->vdev_ishole) {
                vs->vs_fragmentation = vd->vdev_mg->mg_fragmentation;

Modified: vendor-sys/illumos/dist/uts/common/sys/fs/zfs.h
==============================================================================
--- vendor-sys/illumos/dist/uts/common/sys/fs/zfs.h     Fri May 26 12:00:31 
2017        (r318940)
+++ vendor-sys/illumos/dist/uts/common/sys/fs/zfs.h     Fri May 26 12:02:14 
2017        (r318941)
@@ -203,6 +203,7 @@ typedef enum {
        ZPOOL_PROP_FRAGMENTATION,
        ZPOOL_PROP_LEAKED,
        ZPOOL_PROP_MAXBLOCKSIZE,
+       ZPOOL_PROP_BOOTSIZE,
        ZPOOL_NUM_PROPS
 } zpool_prop_t;
 
_______________________________________________
[email protected] mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "[email protected]"

Reply via email to