Print this page
PSARC 2007/569 lofi(7D) compression support
6618343 lofi compression support

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/sys/lofi.h
          +++ new/usr/src/uts/common/sys/lofi.h
↓ open down ↓ 83 lines elided ↑ open up ↑
  84   84   *      li.li_minor = minor_number;
  85   85   *      ioctl(ld, LOFI_GET_FILENAME, &li);
  86   86   *
  87   87   *      strcpy(li.li_filename, "somefilename");
  88   88   *      ioctl(ld, LOFI_GET_MINOR, &li);
  89   89   *
  90   90   *      li.li_minor = 0;
  91   91   *      ioctl(ld, LOFI_GET_MAXMINOR, &li);
  92   92   *      maxminor = li.li_minor;
  93   93   *
       94 + *      strcpy(li.li_filename, "somefilename");
       95 + *      li.li_minor = 0;
       96 + *      ioctl(ld, LOFI_CHECK_COMPRESSED, &li);
       97 + *
  94   98   * If the 'li_force' flag is set for any of the LOFI_UNMAP_* commands, then if
  95   99   * the device is busy, the underlying vnode will be closed, and any subsequent
  96  100   * operations will fail.  It will behave as if the device had been forcibly
  97  101   * removed, so the DKIOCSTATE ioctl will return DKIO_DEV_GONE.  When the device
  98  102   * is last closed, it will be torn down.
  99  103   *
 100  104   * Oh, and last but not least: these ioctls are totally private and only
 101  105   * for use by lofiadm(1M).
 102  106   *
 103  107   */
 104  108  
 105  109  struct lofi_ioctl {
 106  110          uint32_t        li_minor;
 107  111          boolean_t       li_force;
 108      -        char    li_filename[MAXPATHLEN + 1];
      112 +        char    li_filename[MAXPATHLEN];
      113 +        char    li_algorithm[MAXPATHLEN];
 109  114  };
 110  115  
 111  116  #define LOFI_IOC_BASE           (('L' << 16) | ('F' << 8))
 112  117  
 113  118  #define LOFI_MAP_FILE           (LOFI_IOC_BASE | 0x01)
 114  119  #define LOFI_MAP_FILE_MINOR     (LOFI_IOC_BASE | 0x02)
 115  120  #define LOFI_UNMAP_FILE         (LOFI_IOC_BASE | 0x03)
 116  121  #define LOFI_UNMAP_FILE_MINOR   (LOFI_IOC_BASE | 0x04)
 117  122  #define LOFI_GET_FILENAME       (LOFI_IOC_BASE | 0x05)
 118  123  #define LOFI_GET_MINOR          (LOFI_IOC_BASE | 0x06)
 119  124  #define LOFI_GET_MAXMINOR       (LOFI_IOC_BASE | 0x07)
      125 +#define LOFI_CHECK_COMPRESSED   (LOFI_IOC_BASE | 0x08)
 120  126  
 121  127  /*
 122  128   * file types that might be usable with lofi, maybe. Only regular
 123  129   * files are documented though.
 124  130   */
 125  131  #define S_ISLOFIABLE(mode) \
 126  132          (S_ISREG(mode) || S_ISBLK(mode) || S_ISCHR(mode))
 127  133  
      134 +#define SEGHDR          1
      135 +#define COMPRESSED      1
      136 +#define UNCOMPRESSED    0
      137 +
 128  138  #if defined(_KERNEL)
 129  139  
 130  140  /*
 131  141   * We limit the maximum number of active lofi devices to 128, which seems very
 132  142   * large. You can tune this by changing lofi_max_files in /etc/system.
 133  143   * If you change it dynamically, which you probably shouldn't do, make sure
 134  144   * to only _increase_ it.
 135  145   */
 136  146  #define LOFI_MAX_FILES  128
 137  147  extern uint32_t lofi_max_files;
↓ open down ↓ 13 lines elided ↑ open up ↑
 151  161          uint32_t        ls_blk_open;
 152  162          uint32_t        ls_chr_open;
 153  163          uint32_t        ls_lyr_open_count;
 154  164          int             ls_openflag;
 155  165          taskq_t         *ls_taskq;
 156  166          kstat_t         *ls_kstat;
 157  167          kmutex_t        ls_kstat_lock;
 158  168          struct dk_geom  ls_dkg;
 159  169          struct vtoc     ls_vtoc;
 160  170          struct dk_cinfo ls_ci;
      171 +
      172 +        /* the following fields are required for compression support */
      173 +
      174 +        /*
      175 +         * index into lofi_compress_table for the compression algorithm
      176 +         * used
      177 +         */
      178 +        int             ls_comp_algorithm_index;
      179 +        uint32_t        ls_comp_algorithm_len;
      180 +        /* size of an uncompressed segment */
      181 +        uint32_t        ls_uncomp_seg_sz;
      182 +        /* number of index entries */
      183 +        uint32_t        ls_comp_index_sz;
      184 +        /* exponent for byte shift, power of 2 */
      185 +        uint32_t        ls_comp_seg_shift;
      186 +        /*
      187 +         * size of the last uncompressed segment (the file may
      188 +         * not be an exact multiple of the segment size ls_uncomp_seg_sz)
      189 +         */
      190 +        uint32_t        ls_uncomp_last_seg_sz;
      191 +        /*
      192 +         * the offset in the file where the header ends and the
      193 +         * actual compressed data begins. The segment offsets in
      194 +         * the index do not account for the header so this value must
      195 +         * be added
      196 +         */
      197 +        uint64_t        ls_comp_offbase;
      198 +        /*
      199 +         * the array holding the segment index. This is a pointer
      200 +         * into ls_comp_index_data
      201 +         */
      202 +        uint64_t        *ls_comp_seg_index;
      203 +        /*
      204 +         * holds the index pages loaded from the file. This is aligned
      205 +         * on a disk block boundary so lsecomp_seg_index above is used
      206 +         * to point to the actual array
      207 +         */
      208 +        caddr_t         ls_comp_index_data;
      209 +        /* size of ls_comp_index_data */
      210 +        uint32_t        ls_comp_index_data_sz;
      211 +        /*
      212 +         * incase of compressed files, ls_vp_size above is
      213 +         * tweaked to represent the actual uncompressed file
      214 +         * size so that fake_disk_geometry gives the correct
      215 +         * values. However we need the actual compressed file
      216 +         * size while faulting in pages from the compressed
      217 +         * file in lofi_mapped_rdwr
      218 +         */
      219 +        u_offset_t      ls_vp_comp_size;
 161  220  };
 162  221  
 163      -#endif
      222 +#endif  /* _KERNEL */
 164  223  
      224 +/*
      225 + * Common signature for all lofi compress functions
      226 + */
      227 +typedef int lofi_compress_func_t(void *src, size_t srclen, void *dst,
      228 +        size_t *destlen, int level);
      229 +
      230 +/*
      231 + * Information about each compression function
      232 + */
      233 +typedef struct lofi_compress_info {
      234 +        lofi_compress_func_t    *l_decompress;
      235 +        lofi_compress_func_t    *l_compress;
      236 +        int                     l_level;
      237 +        char                    *l_name;        /* algorithm name */
      238 +} lofi_compress_info_t;
      239 +
      240 +enum lofi_compress {
      241 +        LOFI_COMPRESS_GZIP = 0,
      242 +        LOFI_COMPRESS_GZIP_6 = 1,
      243 +        LOFI_COMPRESS_GZIP_9 = 2,
      244 +        LOFI_COMPRESS_FUNCTIONS
      245 +};
      246 +
 165  247  #ifdef  __cplusplus
 166  248  }
 167  249  #endif
 168  250  
 169  251  #endif  /* _SYS_LOFI_H */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX