diff options
Diffstat (limited to 'usr/src/uts/common/sys')
-rw-r--r-- | usr/src/uts/common/sys/cmlb.h | 18 | ||||
-rw-r--r-- | usr/src/uts/common/sys/cmlb_impl.h | 27 | ||||
-rw-r--r-- | usr/src/uts/common/sys/lofi.h | 41 | ||||
-rw-r--r-- | usr/src/uts/common/sys/vfs.h | 3 | ||||
-rw-r--r-- | usr/src/uts/common/sys/vtoc.h | 13 |
5 files changed, 70 insertions, 32 deletions
diff --git a/usr/src/uts/common/sys/cmlb.h b/usr/src/uts/common/sys/cmlb.h index 81e9c060f4..a1013c9fed 100644 --- a/usr/src/uts/common/sys/cmlb.h +++ b/usr/src/uts/common/sys/cmlb.h @@ -19,6 +19,7 @@ * CDDL HEADER END */ /* + * Copyright 2016 Toomas Soome <tsoome@me.com> * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -61,6 +62,7 @@ typedef struct tg_attribute { #define CMLB_OFF_BY_ONE 0x00000004 #define CMLB_FAKE_LABEL_ONE_PARTITION 0x00000008 #define CMLB_INTERNAL_MINOR_NODES 0x00000010 +#define CMLB_CREATE_P0_MINOR_NODE 0x00000020 /* bit definitions of flag passed to cmlb_validate */ #define CMLB_SILENT 0x00000001 @@ -80,6 +82,22 @@ typedef struct tg_attribute { #define TG_GETBLOCKSIZE 4 #define TG_GETATTR 5 +#if defined(_SUNOS_VTOC_8) + +#define CMLBUNIT_DFT_SHIFT 3 +/* This will support p0 node on sparc */ +#define CMLBUNIT_FORCE_P0_SHIFT (CMLBUNIT_DFT_SHIFT + 1) + +#elif defined(_SUNOS_VTOC_16) + +#define CMLBUNIT_DFT_SHIFT 6 +#define CMLBUNIT_FORCE_P0_SHIFT (CMLBUNIT_DFT_SHIFT) + +#else /* defined(_SUNOS_VTOC_16) */ + +#error "No VTOC format defined." + +#endif /* defined(_SUNOS_VTOC_8) */ /* * Ops vector including utility functions into target driver that cmlb uses. diff --git a/usr/src/uts/common/sys/cmlb_impl.h b/usr/src/uts/common/sys/cmlb_impl.h index 47ee3ab7bd..b64c4aa64b 100644 --- a/usr/src/uts/common/sys/cmlb_impl.h +++ b/usr/src/uts/common/sys/cmlb_impl.h @@ -20,6 +20,7 @@ */ /* + * Copyright 2016 Toomas Soome <tsoome@me.com> * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -42,7 +43,11 @@ extern "C" { #define FDISK_PARTS (FD_NUMPART + MAX_EXT_PARTS) #if defined(_SUNOS_VTOC_8) -#define NSDMAP NDKMAP +/* + * As lofi needs to support p0 on sparc in case of labeled virtual disks, + * define NDSMAP to support one extra entrie. + */ +#define NSDMAP (NDKMAP + 1) #elif defined(_SUNOS_VTOC_16) #define NSDMAP (NDKMAP + FDISK_PARTS + 1) #else @@ -51,11 +56,10 @@ extern "C" { #define MAXPART (NSDMAP + 1) #define WD_NODE 7 - +#define P0_RAW_DISK (NDKMAP) #if defined(__i386) || defined(__amd64) -#define P0_RAW_DISK (NDKMAP) #define FDISK_P1 (NDKMAP+1) #define FDISK_P2 (NDKMAP+2) #define FDISK_P3 (NDKMAP+3) @@ -82,21 +86,10 @@ extern "C" { #define ISCD(cl) (cl->cl_device_type == DTYPE_RODIRECT) #define ISHOTPLUGGABLE(cl) (cl->cl_is_hotpluggable) -#if defined(_SUNOS_VTOC_8) - -#define CMLBUNIT_SHIFT 3 -#define CMLBPART_MASK 7 - -#elif defined(_SUNOS_VTOC_16) - -#define CMLBUNIT_SHIFT 6 -#define CMLBPART_MASK 63 - -#else -#error "No VTOC format defined." -#endif +#define CMLBUNIT_SHIFT (CMLBUNIT_DFT_SHIFT) +#define CMLBPART_MASK ((1 << CMLBUNIT_SHIFT) - 1) -#define CMLBUNIT(dev) (getminor((dev)) >> CMLBUNIT_SHIFT) +#define CMLBUNIT(dev, shift) (getminor((dev)) >> (shift)) #define CMLBPART(dev) (getminor((dev)) & CMLBPART_MASK) /* diff --git a/usr/src/uts/common/sys/lofi.h b/usr/src/uts/common/sys/lofi.h index e4716c96af..f57388a098 100644 --- a/usr/src/uts/common/sys/lofi.h +++ b/usr/src/uts/common/sys/lofi.h @@ -23,6 +23,7 @@ * * Copyright 2013 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2016 Andrey Sokolov + * Copyright 2016 Toomas Soome <tsoome@me.com> */ #ifndef _SYS_LOFI_H @@ -31,12 +32,15 @@ #include <sys/types.h> #include <sys/time.h> #include <sys/taskq.h> -#include <sys/vtoc.h> #include <sys/dkio.h> #include <sys/vnode.h> #include <sys/list.h> #include <sys/crypto/api.h> #include <sys/zone.h> +#ifdef _KERNEL +#include <sys/cmlb.h> +#include <sys/open.h> +#endif /* _KERNEL */ #ifdef __cplusplus extern "C" { @@ -51,6 +55,8 @@ extern "C" { #define LOFI_DRIVER_NAME "lofi" #define LOFI_CTL_NODE "ctl" #define LOFI_CTL_NAME LOFI_DRIVER_NAME LOFI_CTL_NODE +#define LOFI_BLOCK_NODE "disk" +#define LOFI_CHAR_NODE LOFI_BLOCK_NODE ",raw" #define LOFI_BLOCK_NAME LOFI_DRIVER_NAME #define LOFI_CHAR_NAME "r" LOFI_DRIVER_NAME @@ -59,6 +65,20 @@ extern "C" { #define UNCOMPRESSED 0 #define MAXALGLEN 36 +#define LOFI_CMLB_SHIFT CMLBUNIT_FORCE_P0_SHIFT +#define LOFI_PART_MASK ((1 << LOFI_CMLB_SHIFT) - 1) +#define LOFI_PART_MAX (1 << LOFI_CMLB_SHIFT) +#define LOFI_PART(x) ((x) & LOFI_PART_MASK) + +/* + * The cmlb is using its own range of minor numbers for partitions, for + * unlabeled lofi devices, we need to use another range. + */ +/* unlabeled lofi device id to minor number. */ +#define LOFI_ID2MINOR(x) ((x) << LOFI_CMLB_SHIFT) +/* lofi id from minor number. */ +#define LOFI_MINOR2ID(x) ((x) >> LOFI_CMLB_SHIFT) + /* * * Use is: @@ -127,11 +147,13 @@ typedef enum iv_method { } iv_method_t; struct lofi_ioctl { - uint32_t li_minor; + uint32_t li_id; /* lofi ID */ boolean_t li_force; boolean_t li_cleanup; boolean_t li_readonly; + boolean_t li_labeled; char li_filename[MAXPATHLEN]; + char li_devpath[MAXPATHLEN]; /* the following fields are required for compression support */ char li_algorithm[MAXALGLEN]; @@ -230,10 +252,11 @@ struct lofi_state { kcondvar_t ls_vp_cv; /* signal changes to ls_vp */ uint32_t ls_vp_iocount; /* # pending I/O requests */ boolean_t ls_vp_closereq; /* force close requested */ + boolean_t ls_vp_ready; /* is vp ready for use? */ u_offset_t ls_vp_size; - uint32_t ls_blk_open; - uint32_t ls_chr_open; - uint32_t ls_lyr_open_count; + uint32_t ls_open_lyr[LOFI_PART_MAX]; /* open count */ + uint64_t ls_open_reg[OTYPCNT]; /* bitmask */ + uint64_t ls_open_excl; /* bitmask */ int ls_openflag; boolean_t ls_cleanup; /* cleanup on close */ boolean_t ls_readonly; @@ -241,12 +264,15 @@ struct lofi_state { kstat_t *ls_kstat; kmutex_t ls_kstat_lock; struct dk_geom ls_dkg; - struct vtoc ls_vtoc; - struct dk_cinfo ls_ci; zone_ref_t ls_zone; list_node_t ls_list; /* all lofis */ + dev_info_t *ls_dip; dev_t ls_dev; /* this node's dev_t */ + cmlb_handle_t ls_cmlbhandle; + uint32_t ls_lbshift; /* logical block shift */ + uint32_t ls_pbshift; /* physical block shift */ + /* the following fields are required for compression support */ int ls_comp_algorithm_index; /* idx into compress_table */ char ls_comp_algorithm[MAXALGLEN]; @@ -280,7 +306,6 @@ struct lofi_state { iv_method_t ls_iv_type; /* for iv derivation */ kmutex_t ls_crypto_lock; crypto_ctx_template_t ls_ctx_tmpl; - }; #endif /* _KERNEL */ diff --git a/usr/src/uts/common/sys/vfs.h b/usr/src/uts/common/sys/vfs.h index 38c1fded4a..fc6e22b3a2 100644 --- a/usr/src/uts/common/sys/vfs.h +++ b/usr/src/uts/common/sys/vfs.h @@ -21,6 +21,7 @@ /* * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * Copyright 2016 Toomas Soome <tsoome@me.com> */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ @@ -227,7 +228,7 @@ typedef struct vfs { struct vfs *vfs_zone_prev; /* prev VFS visible in zone */ struct fem_head *vfs_femhead; /* fs monitoring */ - minor_t vfs_lofi_minor; /* minor if lofi mount */ + uint32_t vfs_lofi_id; /* ID if lofi mount */ } vfs_t; #define vfs_featureset vfs_implp->vi_featureset diff --git a/usr/src/uts/common/sys/vtoc.h b/usr/src/uts/common/sys/vtoc.h index adaf7df5b9..2bfe68ba96 100644 --- a/usr/src/uts/common/sys/vtoc.h +++ b/usr/src/uts/common/sys/vtoc.h @@ -25,6 +25,7 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. * Copyright 2015 Nexenta Systems, Inc. All rights reserved. + * Copyright 2016 Toomas Soome <tsoome@me.com> */ @@ -272,15 +273,15 @@ struct vtoc32 { #define vtoctovtoc32(v, v32) \ { \ int i; \ - v32.v_bootinfo[0] = v.v_bootinfo[0]; \ - v32.v_bootinfo[1] = v.v_bootinfo[1]; \ - v32.v_bootinfo[2] = v.v_bootinfo[2]; \ - v32.v_sanity = v.v_sanity; \ - v32.v_version = v.v_version; \ + v32.v_bootinfo[0] = (uint32_t)v.v_bootinfo[0]; \ + v32.v_bootinfo[1] = (uint32_t)v.v_bootinfo[1]; \ + v32.v_bootinfo[2] = (uint32_t)v.v_bootinfo[2]; \ + v32.v_sanity = (uint32_t)v.v_sanity; \ + v32.v_version = (uint32_t)v.v_version; \ bcopy(v.v_volume, v32.v_volume, LEN_DKL_VVOL); \ v32.v_sectorsz = v.v_sectorsz; \ v32.v_nparts = v.v_nparts; \ - v32.v_version = v.v_version; \ + v32.v_version = (uint32_t)v.v_version; \ for (i = 0; i < 10; i++) \ v32.v_reserved[i] = v.v_reserved[i]; \ for (i = 0; i < V_NUMPAR; i++) { \ |