wok-next rev 20252
Up linux-cloop (4.12)
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Tue Nov 07 13:45:24 2017 +0100 (2017-11-07) |
parents | d247e85339a4 |
children | 65128f750fc5 |
files | linux-cloop/receipt linux-cloop/stuff/cloop.u linux-cloop/stuff/patches/4.3-to-4.12.patch |
line diff
1.1 --- a/linux-cloop/receipt Tue Nov 07 14:03:40 2017 +0200 1.2 +++ b/linux-cloop/receipt Tue Nov 07 13:45:24 2017 +0100 1.3 @@ -2,7 +2,7 @@ 1.4 1.5 PACKAGE="linux-cloop" 1.6 SOURCE="cloop" 1.7 -GITHASH="9acc0fcad420b5ff7062fdd1c90d27ada5278b97" # 3.14 1.8 +GITHASH="897009b4b2fe70433a1e8aea8a024aeebc32b209" # 3.4 1.9 VERSION="${GITHASH:0:7}" 1.10 EXTRAVERSION="_$kvers" 1.11 CATEGORY="base-system" 1.12 @@ -11,8 +11,9 @@ 1.13 SHORT_DESC="The read-only compressed loop device kernel module." 1.14 WEB_SITE="http://knoppix.net/wiki/Cloop" 1.15 TARBALL="$SOURCE-$VERSION.zip" 1.16 -WGET_URL="http://debian-knoppix.alioth.debian.org/packages/$SOURCE/$TARBALL" 1.17 -WGET_URL="https://github.com/KlausKnopper/cloop/archive/$GITHASH.zip" 1.18 +#WGET_URL="http://debian-knoppix.alioth.debian.org/packages/$SOURCE/$TARBALL" 1.19 +#WGET_URL="https://github.com/KlausKnopper/cloop/archive/$GITHASH.zip" 1.20 +WGET_URL="https://github.com/Outernet-Project/cloop/archive/$GITHASH.zip 1.21 1.22 DEPENDS="linux" 1.23 BUILD_DEPENDS="linux-module-headers xz" 1.24 @@ -22,12 +23,6 @@ 1.25 1.26 compile_rules() 1.27 { 1.28 - patch -p0 < $stuff/cloop.u 1.29 - # use f_inode with linux > 3.19 1.30 - sed -i -e 's|f_dentry->d_inode|f_inode|' \ 1.31 - -e 's|&& rw != READA|\n#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0)\n&\n#endif\n|' \ 1.32 - -e 's|.*blk_queue_merge_bvec.*|#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)\n&\n#endif|' \ 1.33 - cloop.c 1.34 make cloop_suspend && 1.35 make KERNEL_DIR="/usr/src/linux" cloop.ko && xz cloop.ko 1.36 }
2.1 --- a/linux-cloop/stuff/cloop.u Tue Nov 07 14:03:40 2017 +0200 2.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 2.3 @@ -1,289 +0,0 @@ 2.4 ---- cloop.h 2.5 -+++ cloop.h 2.6 -@@ -20,6 +20,81 @@ 2.7 - /* data_index (num_blocks 64bit pointers, network order)... */ 2.8 - /* compressed data (gzip block compressed format)... */ 2.9 - 2.10 -+struct cloop_tail 2.11 -+{ 2.12 -+ u_int32_t table_size; 2.13 -+ u_int32_t index_size; 2.14 -+ u_int32_t num_blocks; 2.15 -+}; 2.16 -+ 2.17 -+struct block_info 2.18 -+{ 2.19 -+ loff_t offset; /* 64-bit offsets of compressed block */ 2.20 -+ u_int32_t size; /* 32-bit compressed block size */ 2.21 -+ u_int32_t optidx; /* 32-bit index number */ 2.22 -+}; 2.23 -+ 2.24 -+#define ntohl be32_to_cpu 2.25 -+static inline char *build_index(struct block_info *offsets, unsigned long n) 2.26 -+{ 2.27 -+ u_int32_t *ofs32 = (u_int32_t *) offsets; 2.28 -+ loff_t *ofs64 = (loff_t *) offsets; 2.29 -+ 2.30 -+ if (ofs32[0] == 0) { 2.31 -+ if (ofs32[2]) { /* ACCELERATED KNOPPIX V1.0 */ 2.32 -+ while (n--) { 2.33 -+ offsets[n].offset = be64_to_cpu(offsets[n].offset); 2.34 -+ offsets[n].size = ntohl(offsets[n].size); 2.35 -+ } 2.36 -+ return (char *) "128BE accelerated knoppix 1.0"; 2.37 -+ } 2.38 -+ else { /* V2.0 */ 2.39 -+ loff_t last = be64_to_cpu(ofs64[n - 1]); 2.40 -+ while (n--) { 2.41 -+ offsets[n].size = last - 2.42 -+ (offsets[n].offset = be64_to_cpu(ofs64[n])); 2.43 -+ last = offsets[n].offset; 2.44 -+ } 2.45 -+ return (char *) "64BE v2.0"; 2.46 -+ } 2.47 -+ } 2.48 -+ else if (ofs32[1] == 0) { /* V1.0 */ 2.49 -+ loff_t last = le64_to_cpu(ofs64[n - 1]); 2.50 -+ while (n--) { 2.51 -+ offsets[n].size = last - 2.52 -+ (offsets[n].offset = le64_to_cpu(ofs64[n])); 2.53 -+ last = offsets[n].offset; 2.54 -+ } 2.55 -+ return (char *) "64LE v1.0"; 2.56 -+ } 2.57 -+ else if (ntohl(ofs32[0]) == (4*n) + 0x8C) { /* V0.68 */ 2.58 -+ loff_t last = ntohl(ofs32[n - 1]); 2.59 -+ while (n--) { 2.60 -+ offsets[n].size = last - 2.61 -+ (offsets[n].offset = ntohl(ofs32[n])); 2.62 -+ last = offsets[n].offset; 2.63 -+ } 2.64 -+ return (char *) "32BE v0.68"; 2.65 -+ } 2.66 -+ else { /* V3.0 */ 2.67 -+ unsigned long i; 2.68 -+ loff_t j; 2.69 -+ 2.70 -+ for (i = n; i-- != 0; ) 2.71 -+ offsets[i].size = ntohl(ofs32[i]); 2.72 -+ for (i = 0, j = sizeof(struct cloop_head); i < n; i++) { 2.73 -+ offsets[i].offset = j; 2.74 -+ if (offsets[i].size & 0x80000000) { 2.75 -+ unsigned long k = offsets[i].size & 0x7FFFFFFF; 2.76 -+ offsets[i].offset = offsets[k].offset; 2.77 -+ offsets[i].size = offsets[k].size; 2.78 -+ } 2.79 -+ else j += offsets[i].size; 2.80 -+ } 2.81 -+ return (char *) "32BE v3.0"; 2.82 -+ } 2.83 -+} 2.84 -+ 2.85 - /* Cloop suspend IOCTL */ 2.86 - #define CLOOP_SUSPEND 0x4C07 2.87 - 2.88 ---- cloop.c 2.89 -+++ cloop.c 2.90 -@@ -5,11 +5,18 @@ 2.91 - * A cloop file looks like this: 2.92 - * [32-bit uncompressed block size: network order] 2.93 - * [32-bit number of blocks (n_blocks): network order] 2.94 -- * [64-bit file offsets of start of blocks: network order] 2.95 -+ * [for version < 3] 2.96 -+ * [32-bit, 64-bit or 128-bit file offsets of start of blocks] 2.97 - * ... 2.98 - * (n_blocks + 1). 2.99 - * n_blocks consisting of: 2.100 - * [compressed block] 2.101 -+ * ... 2.102 -+ * [for version >= 3] 2.103 -+ * [compressed list of 32-bit block sizes] 2.104 -+ * [32-bit compressed index size: network order] 2.105 -+ * [32-bit index size = 4: network order] 2.106 -+ * [32-bit number of blocks (n_blocks): network order] 2.107 - * 2.108 - * Every version greatly inspired by code seen in loop.c 2.109 - * by Theodore Ts'o, 3/29/93. 2.110 -@@ -115,7 +122,7 @@ 2.111 - struct cloop_head head; 2.112 - 2.113 - /* An array of offsets of compressed blocks within the file */ 2.114 -- loff_t *offsets; 2.115 -+ struct block_info *offsets; 2.116 - 2.117 - /* We buffer some uncompressed blocks for performance */ 2.118 - int buffered_blocknum[BUFFERED_BLOCKS]; 2.119 -@@ -260,11 +267,11 @@ 2.120 - return i; 2.121 - } 2.122 - 2.123 -- buf_length = be64_to_cpu(clo->offsets[blocknum+1]) - be64_to_cpu(clo->offsets[blocknum]); 2.124 -+ buf_length = clo->offsets[blocknum].size; 2.125 - 2.126 - /* Load one compressed block from the file. */ 2.127 - cloop_read_from_file(clo, clo->backing_file, (char *)clo->compressed_buffer, 2.128 -- be64_to_cpu(clo->offsets[blocknum]), buf_length); 2.129 -+ clo->offsets[blocknum].offset, buf_length); 2.130 - 2.131 - buflen = ntohl(clo->head.block_size); 2.132 - 2.133 -@@ -279,9 +286,9 @@ 2.134 - if (ret != 0) 2.135 - { 2.136 - printk(KERN_ERR "%s: zlib decompression error %i uncompressing block %u %u/%lu/%u/%u " 2.137 -- "%Lu-%Lu\n", cloop_name, ret, blocknum, 2.138 -+ "%Lu:%u\n", cloop_name, ret, blocknum, 2.139 - ntohl(clo->head.block_size), buflen, buf_length, buf_done, 2.140 -- be64_to_cpu(clo->offsets[blocknum]), be64_to_cpu(clo->offsets[blocknum+1])); 2.141 -+ clo->offsets[blocknum].offset, clo->offsets[blocknum].size); 2.142 - clo->buffered_blocknum[clo->current_bufnum] = -1; 2.143 - return -1; 2.144 - } 2.145 -@@ -493,30 +500,73 @@ 2.146 - cloop_name, ntohl(clo->head.block_size)); 2.147 - error=-EBADF; goto error_release; 2.148 - } 2.149 -- if (clo->head.preamble[0x0B]!='V'||clo->head.preamble[0x0C]<'1') 2.150 -- { 2.151 -- printk(KERN_ERR "%s: Cannot read old 32-bit (version 0.68) images, " 2.152 -- "please use an older version of %s for this file.\n", 2.153 -- cloop_name, cloop_name); 2.154 -- error=-EBADF; goto error_release; 2.155 -- } 2.156 -- if (clo->head.preamble[0x0C]<'2') 2.157 -- { 2.158 -- printk(KERN_ERR "%s: Cannot read old architecture-dependent " 2.159 -- "(format <= 1.0) images, please use an older " 2.160 -- "version of %s for this file.\n", 2.161 -- cloop_name, cloop_name); 2.162 -- error=-EBADF; goto error_release; 2.163 -- } 2.164 -- total_offsets=ntohl(clo->head.num_blocks)+1; 2.165 -- if (!isblkdev && (sizeof(struct cloop_head)+sizeof(loff_t)* 2.166 -+ total_offsets=ntohl(clo->head.num_blocks); 2.167 -+ if (!isblkdev && (sizeof(struct cloop_head)+sizeof(struct block_info)* 2.168 - total_offsets > inode->i_size)) 2.169 - { 2.170 - printk(KERN_ERR "%s: file too small for %u blocks\n", 2.171 - cloop_name, ntohl(clo->head.num_blocks)); 2.172 - error=-EBADF; goto error_release; 2.173 - } 2.174 -- clo->offsets = cloop_malloc(sizeof(loff_t) * total_offsets); 2.175 -+ if (total_offsets + 1 == 0) /* Version >= 3.0 */ 2.176 -+ { 2.177 -+ struct cloop_tail tail; 2.178 -+ if(isblkdev) 2.179 -+ { 2.180 -+ /* No end of file: can't find index */ 2.181 -+ printk(KERN_ERR "%s: no V3 support for block device\n", 2.182 -+ cloop_name); 2.183 -+ error=-EBADF; goto error_release; 2.184 -+ } 2.185 -+ bytes_read = cloop_read_from_file(clo, file, (void *) &tail, 2.186 -+ inode->i_size - sizeof(struct cloop_tail), 2.187 -+ sizeof(struct cloop_tail)); 2.188 -+ if(bytes_read == sizeof(struct cloop_tail)) 2.189 -+ { 2.190 -+ unsigned long len, zlen; 2.191 -+ void *zbuf; 2.192 -+ clo->head.num_blocks = tail.num_blocks; 2.193 -+ total_offsets = ntohl(clo->head.num_blocks); 2.194 -+ clo->offsets = cloop_malloc(sizeof(struct block_info) * total_offsets); 2.195 -+ if (!clo->offsets) 2.196 -+ { 2.197 -+ printk(KERN_ERR "%s: can't alloc index\n", 2.198 -+ cloop_name); 2.199 -+ error=-EBADF; goto error_release; 2.200 -+ } 2.201 -+ zbuf = &clo->offsets[total_offsets/2]; 2.202 -+ zlen = ntohl(tail.table_size); 2.203 -+ len = ntohl(tail.index_size) * total_offsets; 2.204 -+ bytes_read = cloop_read_from_file(clo, file, zbuf, 2.205 -+ inode->i_size - zlen - sizeof(struct cloop_tail), 2.206 -+ zlen); 2.207 -+ if (bytes_read != zlen) 2.208 -+ { 2.209 -+ printk(KERN_ERR "%s: can't read index\n", 2.210 -+ cloop_name); 2.211 -+ error=-EBADF; goto error_release; 2.212 -+ } 2.213 -+ clo->zstream.workspace = cloop_malloc(zlib_inflate_workspacesize()); 2.214 -+ if(!clo->zstream.workspace) 2.215 -+ { 2.216 -+ printk(KERN_ERR "%s: can't alloc index workspace\n", 2.217 -+ cloop_name); 2.218 -+ error=-EBADF; goto error_release; 2.219 -+ } 2.220 -+ zlib_inflateInit(&clo->zstream); 2.221 -+ uncompress(clo, (void *) clo->offsets, &len, zbuf, zlen); 2.222 -+ cloop_free(clo->zstream.workspace, zlib_inflate_workspacesize()); 2.223 -+ clo->zstream.workspace = NULL; 2.224 -+ break; 2.225 -+ } 2.226 -+ else 2.227 -+ { 2.228 -+ printk(KERN_ERR "%s: can't find index\n", 2.229 -+ cloop_name); 2.230 -+ error=-EBADF; goto error_release; 2.231 -+ } 2.232 -+ } 2.233 -+ clo->offsets = cloop_malloc(sizeof(struct block_info) * total_offsets); 2.234 - if (!clo->offsets) 2.235 - { 2.236 - printk(KERN_ERR "%s: out of kernel mem for offsets\n", cloop_name); 2.237 -@@ -525,19 +575,22 @@ 2.238 - } 2.239 - num_readable = MIN(total_offsets - offsets_read, 2.240 - (clo->underlying_blksize - offset) 2.241 -- / sizeof(loff_t)); 2.242 -- memcpy(&clo->offsets[offsets_read], bbuf+offset, num_readable * sizeof(loff_t)); 2.243 -+ / sizeof(struct block_info)); 2.244 -+ memcpy(&clo->offsets[offsets_read], bbuf+offset, num_readable * sizeof(struct block_info)); 2.245 - offsets_read += num_readable; 2.246 - } 2.247 - { /* Search for largest block rather than estimate. KK. */ 2.248 - int i; 2.249 -- for(i=0;i<total_offsets-1;i++) 2.250 -+ char *version = build_index(clo->offsets, ntohl(clo->head.num_blocks)); 2.251 -+ for(i=0,clo->largest_block=0;i<total_offsets;i++) 2.252 - { 2.253 -- loff_t d=be64_to_cpu(clo->offsets[i+1]) - be64_to_cpu(clo->offsets[i]); 2.254 -- clo->largest_block=MAX(clo->largest_block,d); 2.255 -+ clo->largest_block=MAX(clo->largest_block,clo->offsets[i].size); 2.256 - } 2.257 -- printk(KERN_INFO "%s: %s: %u blocks, %u bytes/block, largest block is %lu bytes.\n", 2.258 -- cloop_name, filename, ntohl(clo->head.num_blocks), 2.259 -+ i = ntohl(clo->head.block_size); 2.260 -+ i += i/1000 + 12 + 4; /* max gzip block size */ 2.261 -+ if (clo->largest_block > i) clo->largest_block = i; /* broken index ? */ 2.262 -+ printk(KERN_INFO "%s: %s: %s, %u blocks, %u bytes/block, largest block is %lu bytes.\n", 2.263 -+ cloop_name, filename, version, ntohl(clo->head.num_blocks), 2.264 - ntohl(clo->head.block_size), clo->largest_block); 2.265 - } 2.266 - /* Combo kmalloc used too large chunks (>130000). */ 2.267 -@@ -569,16 +622,6 @@ 2.268 - error=-ENOMEM; goto error_release_free_all; 2.269 - } 2.270 - zlib_inflateInit(&clo->zstream); 2.271 -- if(!isblkdev && 2.272 -- be64_to_cpu(clo->offsets[ntohl(clo->head.num_blocks)]) != inode->i_size) 2.273 -- { 2.274 -- printk(KERN_ERR "%s: final offset wrong (%Lu not %Lu)\n", 2.275 -- cloop_name, 2.276 -- be64_to_cpu(clo->offsets[ntohl(clo->head.num_blocks)]), 2.277 -- inode->i_size); 2.278 -- cloop_free(clo->zstream.workspace, zlib_inflate_workspacesize()); clo->zstream.workspace=NULL; 2.279 -- goto error_release_free_all; 2.280 -- } 2.281 - { 2.282 - int i; 2.283 - for(i=0; i<BUFFERED_BLOCKS; i++) clo->buffered_blocknum[i] = -1; 2.284 -@@ -657,7 +700,7 @@ 2.285 - } 2.286 - } 2.287 - error_release_free: 2.288 -- cloop_free(clo->offsets, sizeof(loff_t) * total_offsets); 2.289 -+ cloop_free(clo->offsets, sizeof(struct block_info) * total_offsets); 2.290 - clo->offsets=NULL; 2.291 - error_release: 2.292 - if(bbuf) cloop_free(bbuf, clo->underlying_blksize);
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/linux-cloop/stuff/patches/4.3-to-4.12.patch Tue Nov 07 13:45:24 2017 +0100 3.3 @@ -0,0 +1,99 @@ 3.4 +--- cloop.c 3.5 ++++ cloop.c 3.6 +@@ -17,7 +17,7 @@ 3.7 + \************************************************************************/ 3.8 + 3.9 + #define CLOOP_NAME "cloop" 3.10 +-#define CLOOP_VERSION "4.3" 3.11 ++#define CLOOP_VERSION "4.12" 3.12 + #define CLOOP_MAX 8 3.13 + 3.14 + #ifndef KBUILD_MODNAME 3.15 +@@ -257,8 +257,14 @@ 3.16 + { 3.17 + size_t outputSize = clo->head.block_size; 3.18 + /* We should adjust outputSize here, in case the last block is smaller than block_size */ 3.19 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) /* field removed */ 3.20 + err = lz4_decompress(clo->compressed_buffer, (size_t *) &compressed_length, 3.21 + clo->buffer[clo->current_bufnum], outputSize); 3.22 ++#else 3.23 ++ err = LZ4_decompress_safe(clo->compressed_buffer, 3.24 ++ clo->buffer[clo->current_bufnum], 3.25 ++ compressed_length, outputSize); 3.26 ++#endif 3.27 + if (err >= 0) 3.28 + { 3.29 + err = 0; 3.30 +@@ -438,6 +444,7 @@ 3.31 + offset += length_in_buffer; 3.32 + } /* while inner loop */ 3.33 + kunmap(bvec.bv_page); 3.34 ++ cond_resched(); 3.35 + } /* end rq_for_each_segment*/ 3.36 + return ((buffered_blocknum!=-1) || preloaded); 3.37 + } 3.38 +@@ -490,10 +497,18 @@ 3.39 + int rw; 3.40 + /* quick sanity checks */ 3.41 + /* blk_fs_request() was removed in 2.6.36 */ 3.42 +- if (unlikely(req == NULL || (req->cmd_type != REQ_TYPE_FS))) 3.43 ++ if (unlikely(req == NULL 3.44 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) /* field removed */ 3.45 ++ || (req->cmd_type != REQ_TYPE_FS) 3.46 ++#endif 3.47 ++ )) 3.48 + goto error_continue; 3.49 + rw = rq_data_dir(req); 3.50 +- if (unlikely(rw != READ && rw != READA)) 3.51 ++ if (unlikely(rw != READ 3.52 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 8, 0) 3.53 ++ && rw != READA 3.54 ++#endif 3.55 ++ )) 3.56 + { 3.57 + DEBUGP("cloop_do_request: bad command\n"); 3.58 + goto error_continue; 3.59 +@@ -509,7 +524,11 @@ 3.60 + continue; /* next request */ 3.61 + error_continue: 3.62 + DEBUGP(KERN_ERR "cloop_do_request: Discarding request %p.\n", req); 3.63 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) 3.64 + req->errors++; 3.65 ++#else 3.66 ++ req->error_count++; 3.67 ++#endif 3.68 + __blk_end_request_all(req, -EIO); 3.69 + } 3.70 + } 3.71 +@@ -926,7 +945,11 @@ 3.72 + struct kstat stat; 3.73 + int err; 3.74 + if (!file) return -ENXIO; 3.75 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0) 3.76 + err = vfs_getattr(&file->f_path, &stat); 3.77 ++#else 3.78 ++ err = vfs_getattr(&file->f_path, &stat, STATX_INO, AT_STATX_SYNC_AS_STAT); 3.79 ++#endif 3.80 + if (err) return err; 3.81 + memset(info, 0, sizeof(*info)); 3.82 + info->lo_number = clo->clo_number; 3.83 +@@ -1096,7 +1119,7 @@ 3.84 + /* losetup uses write-open and flags=0x8002 to set a new file */ 3.85 + if(mode & FMODE_WRITE) 3.86 + { 3.87 +- printk(KERN_WARNING "%s: Can't open device read-write in mode 0x%x\n", cloop_name, mode); 3.88 ++ printk(KERN_INFO "%s: Open in read-write mode 0x%x requested, ignored.\n", cloop_name, mode); 3.89 + return -EROFS; 3.90 + } 3.91 + cloop_dev[cloop_num]->refcnt+=1; 3.92 +@@ -1154,6 +1177,10 @@ 3.93 + goto error_out; 3.94 + } 3.95 + clo->clo_queue->queuedata = clo; 3.96 ++#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 12, 0) 3.97 ++ queue_flag_set_unlocked(QUEUE_FLAG_NONROT, clo->clo_queue); 3.98 ++ queue_flag_set_unlocked(QUEUE_FLAG_NOMERGES, clo->clo_queue); 3.99 ++#endif 3.100 + clo->clo_disk = alloc_disk(1); 3.101 + if(!clo->clo_disk) 3.102 + {