zio_compress.c (249195) | zio_compress.c (254591) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 63 unchanged lines hidden (view full) --- 72 73 if (child == ZIO_COMPRESS_ON) 74 return (ZIO_COMPRESS_ON_VALUE); 75 76 return (child); 77} 78 79size_t | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 63 unchanged lines hidden (view full) --- 72 73 if (child == ZIO_COMPRESS_ON) 74 return (ZIO_COMPRESS_ON_VALUE); 75 76 return (child); 77} 78 79size_t |
80zio_compress_data(enum zio_compress c, void *src, void *dst, size_t s_len) | 80zio_compress_data(enum zio_compress c, void *src, void *dst, size_t s_len, 81 size_t minblocksize) |
81{ 82 uint64_t *word, *word_end; 83 size_t c_len, d_len, r_len; 84 zio_compress_info_t *ci = &zio_compress_table[c]; 85 86 ASSERT((uint_t)c < ZIO_COMPRESS_FUNCTIONS); 87 ASSERT((uint_t)c == ZIO_COMPRESS_EMPTY || ci->ci_compress != NULL); 88 --- 8 unchanged lines hidden (view full) --- 97 98 if (word == word_end) 99 return (0); 100 101 if (c == ZIO_COMPRESS_EMPTY) 102 return (s_len); 103 104 /* Compress at least 12.5% */ | 82{ 83 uint64_t *word, *word_end; 84 size_t c_len, d_len, r_len; 85 zio_compress_info_t *ci = &zio_compress_table[c]; 86 87 ASSERT((uint_t)c < ZIO_COMPRESS_FUNCTIONS); 88 ASSERT((uint_t)c == ZIO_COMPRESS_EMPTY || ci->ci_compress != NULL); 89 --- 8 unchanged lines hidden (view full) --- 98 99 if (word == word_end) 100 return (0); 101 102 if (c == ZIO_COMPRESS_EMPTY) 103 return (s_len); 104 105 /* Compress at least 12.5% */ |
105 d_len = P2ALIGN(s_len - (s_len >> 3), (size_t)SPA_MINBLOCKSIZE); | 106 d_len = P2ALIGN(s_len - (s_len >> 3), minblocksize); |
106 if (d_len == 0) 107 return (s_len); 108 109 c_len = ci->ci_compress(src, dst, s_len, d_len, ci->ci_level); 110 111 if (c_len > d_len) 112 return (s_len); 113 114 /* 115 * Cool. We compressed at least as much as we were hoping to. 116 * For both security and repeatability, pad out the last sector. 117 */ | 107 if (d_len == 0) 108 return (s_len); 109 110 c_len = ci->ci_compress(src, dst, s_len, d_len, ci->ci_level); 111 112 if (c_len > d_len) 113 return (s_len); 114 115 /* 116 * Cool. We compressed at least as much as we were hoping to. 117 * For both security and repeatability, pad out the last sector. 118 */ |
118 r_len = P2ROUNDUP(c_len, (size_t)SPA_MINBLOCKSIZE); | 119 r_len = P2ROUNDUP(c_len, minblocksize); |
119 if (r_len > c_len) { 120 bzero((char *)dst + c_len, r_len - c_len); 121 c_len = r_len; 122 } 123 124 ASSERT3U(c_len, <=, d_len); | 120 if (r_len > c_len) { 121 bzero((char *)dst + c_len, r_len - c_len); 122 c_len = r_len; 123 } 124 125 ASSERT3U(c_len, <=, d_len); |
125 ASSERT(P2PHASE(c_len, (size_t)SPA_MINBLOCKSIZE) == 0); | 126 ASSERT(P2PHASE(c_len, minblocksize) == 0); |
126 127 return (c_len); 128} 129 130int 131zio_decompress_data(enum zio_compress c, void *src, void *dst, 132 size_t s_len, size_t d_len) 133{ 134 zio_compress_info_t *ci = &zio_compress_table[c]; 135 136 if ((uint_t)c >= ZIO_COMPRESS_FUNCTIONS || ci->ci_decompress == NULL) 137 return (SET_ERROR(EINVAL)); 138 139 return (ci->ci_decompress(src, dst, s_len, d_len, ci->ci_level)); 140} | 127 128 return (c_len); 129} 130 131int 132zio_decompress_data(enum zio_compress c, void *src, void *dst, 133 size_t s_len, size_t d_len) 134{ 135 zio_compress_info_t *ci = &zio_compress_table[c]; 136 137 if ((uint_t)c >= ZIO_COMPRESS_FUNCTIONS || ci->ci_decompress == NULL) 138 return (SET_ERROR(EINVAL)); 139 140 return (ci->ci_decompress(src, dst, s_len, d_len, ci->ci_level)); 141} |