SOURCES: patch-cryptoloop-jari-2.4.22-rc2.0 (NEW), jam-04-clone-de...
qboosh
qboosh at pld-linux.org
Thu Jul 20 14:28:25 CEST 2006
Author: qboosh Date: Thu Jul 20 12:28:25 2006 GMT
Module: SOURCES Tag: HEAD
---- Log message:
- argh, back (used by kernel24.spec at HEAD)
---- Files affected:
SOURCES:
patch-cryptoloop-jari-2.4.22-rc2.0 (1.5 -> 1.6) (NEW), jam-04-clone-detached.patch (1.2 -> 1.3) (NEW), jam-06-force-inline.patch (1.2 -> 1.3) (NEW), jam-07-scsi-error-tmout.patch (1.2 -> 1.3) (NEW), jam-10-highpage-init.patch (1.2 -> 1.3) (NEW), jam-11-self_exec_id.patch (1.2 -> 1.3) (NEW), jam-21-mem-barriers.patch (1.2 -> 1.3) (NEW), jam-30-smptimers-A0.patch (1.7 -> 1.8) (NEW), linux-2.4.20-lvm-updates.patch (1.3 -> 1.4) (NEW), linux-2.4.21-irda-ibm.patch (1.2 -> 1.3) (NEW), linux-scsi-debug-bug.patch (1.2 -> 1.3) (NEW), linux-sound_core.patch (1.2 -> 1.3) (NEW), kernel-pldfblogo.patch (1.8 -> 1.9) (NEW), kernel24-nls_default.patch (1.2 -> 1.3) (NEW)
---- Diffs:
================================================================
Index: SOURCES/patch-cryptoloop-jari-2.4.22-rc2.0
diff -u /dev/null SOURCES/patch-cryptoloop-jari-2.4.22-rc2.0:1.6
--- /dev/null Thu Jul 20 14:28:25 2006
+++ SOURCES/patch-cryptoloop-jari-2.4.22-rc2.0 Thu Jul 20 14:28:20 2006
@@ -0,0 +1,1546 @@
+diff -ruN linux-2.4/crypto/Config.in linux-2.4-cl/crypto/Config.in
+--- linux-2.4/crypto/Config.in 2003-08-16 19:11:38.783804504 +0200
++++ linux-2.4-cl/crypto/Config.in 2003-08-16 17:45:20.596330070 +0200
+@@ -4,7 +4,9 @@
+ mainmenu_option next_comment
+ comment 'Cryptographic options'
+
+-if [ "$CONFIG_INET_AH" = "y" -o \
++if [ "$CONFIG_BLK_DEV_CRYPTOLOOP" = "y" -o \
++ "$CONFIG_BLK_DEV_CRYPTOLOOP" = "m" -o \
++ "$CONFIG_INET_AH" = "y" -o \
+ "$CONFIG_INET_AH" = "m" -o \
+ "$CONFIG_INET_ESP" = "y" -o \
+ "$CONFIG_INET_ESP" = "m" -o \
+diff -ruN linux-2.4/drivers/block/Config.in linux-2.4-cl/drivers/block/Config.in
+--- linux-2.4/drivers/block/Config.in 2003-08-16 19:08:10.836128909 +0200
++++ linux-2.4-cl/drivers/block/Config.in 2003-08-16 19:28:45.732770341 +0200
+@@ -40,6 +40,7 @@
+ dep_tristate 'Micro Memory MM5415 Battery Backed RAM support (EXPERIMENTAL)' CONFIG_BLK_DEV_UMEM $CONFIG_PCI $CONFIG_EXPERIMENTAL
+
+ tristate 'Loopback device support' CONFIG_BLK_DEV_LOOP
++dep_tristate ' Cryptoloop support' CONFIG_BLK_DEV_CRYPTOLOOP $CONFIG_BLK_DEV_LOOP
+ dep_tristate 'Network block device support' CONFIG_BLK_DEV_NBD $CONFIG_NET
+
+ tristate 'RAM disk support' CONFIG_BLK_DEV_RAM
+diff -ruN linux-2.4/drivers/block/cryptoloop.c linux-2.4-cl/drivers/block/cryptoloop.c
+--- linux-2.4/drivers/block/cryptoloop.c 1970-01-01 01:00:00.000000000 +0100
++++ linux-2.4-cl/drivers/block/cryptoloop.c 2003-08-16 18:30:05.268601777 +0200
+@@ -0,0 +1,179 @@
++/*
++ Linux loop encryption enabling module
++
++ Copyright (C) 2002 Herbert Valerio Riedel <hvr at gnu.org>
++ Copyright (C) 2003 Fruhwirth Clemens <clemens at endorphin.org>
++
++ This module is free software; you can redistribute it and/or modify
++ it under the terms of the GNU General Public License as published by
++ the Free Software Foundation; either version 2 of the License, or
++ (at your option) any later version.
++
++ This module is distributed in the hope that it will be useful,
++ but WITHOUT ANY WARRANTY; without even the implied warranty of
++ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
++ GNU General Public License for more details.
++
++ You should have received a copy of the GNU General Public License
++ along with this module; if not, write to the Free Software
++ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
++ */
++
++#include <linux/module.h>
++
++#include <linux/init.h>
++#include <linux/string.h>
++#include <linux/crypto.h>
++#include <linux/blkdev.h>
++#include <linux/loop.h>
++#include <asm/semaphore.h>
++#include <asm/uaccess.h>
++#include <asm/scatterlist.h>
++
++MODULE_LICENSE("GPL");
++MODULE_DESCRIPTION("loop blockdevice transferfunction adaptor / CryptoAPI");
++MODULE_AUTHOR("Herbert Valerio Riedel <hvr at gnu.org>");
++
++static int
++cryptoloop_init(struct loop_device *lo, /* const */ struct loop_info *info)
++{
++ int err = -EINVAL;
++ char cms[LO_NAME_SIZE]; /* cipher-mode string */
++ char *cipher;
++ char *mode;
++ char *cmsp = cms; /* c-m string pointer */
++ struct crypto_tfm *tfm = NULL;
++
++ /* encryption breaks for non sector aligned offsets */
++
++ if (info->lo_offset % LOOP_IV_SECTOR_SIZE)
++ goto out;
++
++ strncpy(cms, info->lo_name, LO_NAME_SIZE);
++ cms[LO_NAME_SIZE - 1] = 0;
++ cipher = strsep(&cmsp, "-");
++ mode = strsep(&cmsp, "-");
++
++ if (mode == NULL || strcmp(mode, "cbc") == 0)
++ tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_CBC);
++ else if (strcmp(mode, "ecb") == 0)
++ tfm = crypto_alloc_tfm(cipher, CRYPTO_TFM_MODE_ECB);
++ if (tfm == NULL)
++ return -EINVAL;
++
++ err = tfm->crt_u.cipher.cit_setkey(tfm, info->lo_encrypt_key,
++ info->lo_encrypt_key_size);
++
++ if (err != 0)
++ goto out_free_tfm;
++
++ lo->key_data = tfm;
++ return 0;
++
++ out_free_tfm:
++ crypto_free_tfm(tfm);
++
++ out:
++ return err;
++}
++
++typedef int (*encdec_t)(struct crypto_tfm *tfm,
++ struct scatterlist *sg_out,
++ struct scatterlist *sg_in,
++ unsigned int nsg, u8 *iv);
++
++static int
++cryptoloop_transfer(struct loop_device *lo, int cmd, char *raw_buf,
++ char *loop_buf, int size, sector_t IV)
++{
++ struct crypto_tfm *tfm = (struct crypto_tfm *) lo->key_data;
++ struct scatterlist sg_out = { 0, };
++ struct scatterlist sg_in = { 0, };
++
++ encdec_t encdecfunc;
++ char const *in;
++ char *out;
++
++ if (cmd == READ) {
++ in = raw_buf;
++ out = loop_buf;
++ encdecfunc = tfm->crt_u.cipher.cit_decrypt_iv;
++ } else {
++ in = loop_buf;
++ out = raw_buf;
++ encdecfunc = tfm->crt_u.cipher.cit_encrypt_iv;
++ }
++
++ while (size > 0) {
++ const int sz = min(size, LOOP_IV_SECTOR_SIZE);
++ u32 iv[4] = { 0, };
++ iv[0] = cpu_to_le32(IV & 0xffffffff);
++
++ sg_in.page = virt_to_page(in);
++ sg_in.offset = (unsigned long)in & ~PAGE_MASK;
++ sg_in.length = sz;
++
++ sg_out.page = virt_to_page(out);
++ sg_out.offset = (unsigned long)out & ~PAGE_MASK;
++ sg_out.length = sz;
++
++ encdecfunc(tfm, &sg_out, &sg_in, sz, (u8 *)iv);
++
++ IV++;
++ size -= sz;
++ in += sz;
++ out += sz;
++ }
++
++ return 0;
++}
++
++
++static int
++cryptoloop_ioctl(struct loop_device *lo, int cmd, unsigned long arg)
++{
++ return -EINVAL;
++}
++
++static int
++cryptoloop_release(struct loop_device *lo)
++{
++ struct crypto_tfm *tfm = (struct crypto_tfm *) lo->key_data;
++ if (tfm != NULL) {
++ crypto_free_tfm(tfm);
++ lo->key_data = NULL;
++ return 0;
++ }
++ printk(KERN_ERR "cryptoloop_release(): tfm == NULL?\n");
++ return -EINVAL;
++}
++
++static struct loop_func_table cryptoloop_funcs = {
++ .number = LO_CRYPT_CRYPTOAPI,
++ .init = cryptoloop_init,
++ .ioctl = cryptoloop_ioctl,
++ .transfer = cryptoloop_transfer,
++ .release = cryptoloop_release,
++ /* .owner = THIS_MODULE */
++};
++
++static int __init
++init_cryptoloop(void)
++{
++ int rc = loop_register_transfer(&cryptoloop_funcs);
++
++ if (rc)
++ printk(KERN_ERR "cryptoloop: loop_register_transfer failed\n");
++ return rc;
++}
++
++static void __exit
++cleanup_cryptoloop(void)
++{
++ if (loop_unregister_transfer(LO_CRYPT_CRYPTOAPI))
++ printk(KERN_ERR
++ "cryptoloop: loop_unregister_transfer failed\n");
++}
++
++module_init(init_cryptoloop);
++module_exit(cleanup_cryptoloop);
+diff -ruN linux-2.4/drivers/block/loop.c linux-2.4-cl/drivers/block/loop.c
+--- linux-2.4/drivers/block/loop.c 2003-08-16 19:11:44.513638284 +0200
++++ linux-2.4-cl/drivers/block/loop.c 2003-08-16 19:38:49.487870443 +0200
+@@ -52,6 +52,18 @@
+ * problem above. Encryption modules that used to rely on the old scheme
+ * should just call ->i_mapping->bmap() to calculate the physical block
+ * number.
++ *
++ * IV is now passed as (512 byte) sector number.
++ * Jari Ruusu <jari.ruusu at pp.inet.fi>, May 18 2001
++ *
++ * External encryption module locking bug fixed.
++ * Ingo Rohloff <rohloff at in.tum.de>, June 21 2001
++ *
++ * Make device backed loop work with swap (pre-allocated buffers + queue rewrite).
++ * Jari Ruusu <jari.ruusu at pp.inet.fi>, September 2 2001
++ *
++ * File backed code now uses file->f_op->read/write. Based on Andrew Morton's idea.
++ * Jari Ruusu <jari.ruusu at pp.inet.fi>, May 23 2002
+ */
+
+ #include <linux/config.h>
+@@ -82,26 +94,25 @@
+ static struct loop_device *loop_dev;
+ static int *loop_sizes;
+ static int *loop_blksizes;
++static int *loop_hardsizes;
+ static devfs_handle_t devfs_handle; /* For the directory */
+
+ /*
+ * Transfer functions
+ */
+ static int transfer_none(struct loop_device *lo, int cmd, char *raw_buf,
+- char *loop_buf, int size, int real_block)
++ char *loop_buf, int size, sector_t real_block)
+ {
+- if (raw_buf != loop_buf) {
+- if (cmd == READ)
+- memcpy(loop_buf, raw_buf, size);
+- else
+- memcpy(raw_buf, loop_buf, size);
+- }
++ /* this code is only called from file backed loop */
++ /* and that code expects this function to be no-op */
+
++ if (current->need_resched)
++ schedule();
+ return 0;
+ }
+
+ static int transfer_xor(struct loop_device *lo, int cmd, char *raw_buf,
+- char *loop_buf, int size, int real_block)
++ char *loop_buf, int size, sector_t real_block)
+ {
+ char *in, *out, *key;
+ int i, keysize;
+@@ -118,12 +129,13 @@
+ keysize = lo->lo_encrypt_key_size;
+ for (i = 0; i < size; i++)
+ *out++ = *in++ ^ key[(i & 511) % keysize];
++ if (current->need_resched)
++ schedule();
+ return 0;
+ }
+
+ static int none_status(struct loop_device *lo, struct loop_info *info)
+ {
+- lo->lo_flags |= LO_FLAGS_BH_REMAP;
+ return 0;
+ }
+
+@@ -149,321 +161,367 @@
+ /* xfer_funcs[0] is special - its release function is never called */
+ struct loop_func_table *xfer_funcs[MAX_LO_CRYPT] = {
+ &none_funcs,
+- &xor_funcs
++ &xor_funcs,
+ };
+
+-#define MAX_DISK_SIZE 1024*1024*1024
+-
+-static int compute_loop_size(struct loop_device *lo, struct dentry * lo_dentry, kdev_t lodev)
+-{
+- if (S_ISREG(lo_dentry->d_inode->i_mode))
+- return (lo_dentry->d_inode->i_size - lo->lo_offset) >> BLOCK_SIZE_BITS;
+- if (blk_size[MAJOR(lodev)])
+- return blk_size[MAJOR(lodev)][MINOR(lodev)] -
+- (lo->lo_offset >> BLOCK_SIZE_BITS);
+- return MAX_DISK_SIZE;
++/*
++ * First number of 'lo_prealloc' is the default number of RAM pages
++ * to pre-allocate for each device backed loop. Every (configured)
++ * device backed loop pre-allocates this amount of RAM pages unless
++ * later 'lo_prealloc' numbers provide an override. 'lo_prealloc'
++ * overrides are defined in pairs: loop_index,number_of_pages
++ */
++static int lo_prealloc[9] = { 125, 999, 0, 999, 0, 999, 0, 999, 0 };
++#define LO_PREALLOC_MIN 4 /* minimum user defined pre-allocated RAM pages */
++#define LO_PREALLOC_MAX 512 /* maximum user defined pre-allocated RAM pages */
++
++#ifdef MODULE
++MODULE_PARM(lo_prealloc, "1-9i");
++MODULE_PARM_DESC(lo_prealloc, "Number of pre-allocated pages [,index,pages]...");
++#else
++static int __init lo_prealloc_setup(char *str)
++{
++ int x, y, z;
++
++ for (x = 0; x < (sizeof(lo_prealloc) / sizeof(int)); x++) {
++ z = get_option(&str, &y);
++ if (z > 0)
++ lo_prealloc[x] = y;
++ if (z < 2)
++ break;
++ }
++ return 1;
+ }
++__setup("lo_prealloc=", lo_prealloc_setup);
++#endif
+
+-static void figure_loop_size(struct loop_device *lo)
+-{
+- loop_sizes[lo->lo_number] = compute_loop_size(lo,
+- lo->lo_backing_file->f_dentry,
+- lo->lo_device);
+-}
++/*
++ * This is loop helper thread nice value in range
++ * from 0 (low priority) to -20 (high priority).
++ */
++#if defined(DEF_NICE) && defined(DEF_COUNTER)
++static int lo_nice = -20; /* old scheduler default */
++#else
++static int lo_nice = -1; /* O(1) scheduler default */
++#endif
+
+-static int lo_send(struct loop_device *lo, struct buffer_head *bh, int bsize,
+- loff_t pos)
++#ifdef MODULE
++MODULE_PARM(lo_nice, "1i");
++MODULE_PARM_DESC(lo_nice, "Loop thread scheduler nice (0 ... -20)");
++#else
++static int __init lo_nice_setup(char *str)
+ {
+- struct file *file = lo->lo_backing_file; /* kudos to NFsckingS */
+- struct address_space *mapping = file->f_dentry->d_inode->i_mapping;
+- struct address_space_operations *aops = mapping->a_ops;
+- struct page *page;
+- char *kaddr, *data;
+- unsigned long index;
+- unsigned size, offset;
+- int len;
+-
+- down(&mapping->host->i_sem);
+- index = pos >> PAGE_CACHE_SHIFT;
+- offset = pos & (PAGE_CACHE_SIZE - 1);
+- len = bh->b_size;
+- data = bh->b_data;
+- while (len > 0) {
+- int IV = index * (PAGE_CACHE_SIZE/bsize) + offset/bsize;
+- int transfer_result;
++ int y;
+
+- size = PAGE_CACHE_SIZE - offset;
+- if (size > len)
+- size = len;
+-
+- page = grab_cache_page(mapping, index);
+- if (!page)
+- goto fail;
+- kaddr = kmap(page);
+- if (aops->prepare_write(file, page, offset, offset+size))
+- goto unlock;
+- flush_dcache_page(page);
+- transfer_result = lo_do_transfer(lo, WRITE, kaddr + offset, data, size, IV);
+- if (transfer_result) {
+- /*
+- * The transfer failed, but we still write the data to
+- * keep prepare/commit calls balanced.
+- */
+- printk(KERN_ERR "loop: transfer error block %ld\n", index);
+- memset(kaddr + offset, 0, size);
+- }
+- if (aops->commit_write(file, page, offset, offset+size))
+- goto unlock;
+- if (transfer_result)
+- goto unlock;
+- kunmap(page);
+- data += size;
+- len -= size;
+- offset = 0;
+- index++;
+- pos += size;
+- UnlockPage(page);
+- page_cache_release(page);
+- }
+- up(&mapping->host->i_sem);
+- return 0;
+-
+-unlock:
+- kunmap(page);
+- UnlockPage(page);
+- page_cache_release(page);
+-fail:
+- up(&mapping->host->i_sem);
+- return -1;
++ if (get_option(&str, &y) == 1)
++ lo_nice = y;
++ return 1;
+ }
++__setup("lo_nice=", lo_nice_setup);
++#endif
+
+-struct lo_read_data {
+- struct loop_device *lo;
+- char *data;
+- int bsize;
+-};
++typedef struct {
++ struct buffer_head **q0;
++ struct buffer_head **q1;
++ struct buffer_head **q2;
++ int x0;
++ int x1;
++ int x2;
++} que_look_up_table;
+
+-static int lo_read_actor(read_descriptor_t * desc, struct page *page, unsigned long offset, unsigned long size)
++static void loop_prealloc_cleanup(struct loop_device *lo)
+ {
+- char *kaddr;
+- unsigned long count = desc->count;
+- struct lo_read_data *p = (struct lo_read_data*)desc->buf;
+- struct loop_device *lo = p->lo;
+- int IV = page->index * (PAGE_CACHE_SIZE/p->bsize) + offset/p->bsize;
+-
+- if (size > count)
+- size = count;
+-
+- kaddr = kmap(page);
+- if (lo_do_transfer(lo, READ, kaddr + offset, p->data, size, IV)) {
+- size = 0;
+- printk(KERN_ERR "loop: transfer error block %ld\n",page->index);
+- desc->error = -EINVAL;
+- }
+- kunmap(page);
+-
+- desc->count = count - size;
+- desc->written += size;
+- p->data += size;
+- return size;
+-}
+-
+-static int lo_receive(struct loop_device *lo, struct buffer_head *bh, int bsize,
+- loff_t pos)
+-{
+- struct lo_read_data cookie;
+- read_descriptor_t desc;
+- struct file *file;
+-
+- cookie.lo = lo;
+- cookie.data = bh->b_data;
+- cookie.bsize = bsize;
+- desc.written = 0;
+- desc.count = bh->b_size;
+- desc.buf = (char*)&cookie;
+- desc.error = 0;
+- spin_lock_irq(&lo->lo_lock);
+- file = lo->lo_backing_file;
+- spin_unlock_irq(&lo->lo_lock);
+- do_generic_file_read(file, &pos, &desc, lo_read_actor);
+- return desc.error;
++ struct buffer_head *bh;
++
++ while ((bh = lo->lo_bh_free)) {
++ __free_page(bh->b_page);
++ lo->lo_bh_free = bh->b_reqnext;
++ bh->b_reqnext = NULL;
++ kmem_cache_free(bh_cachep, bh);
++ }
+ }
+
+-static inline int loop_get_bs(struct loop_device *lo)
++static int loop_prealloc_init(struct loop_device *lo, int y)
+ {
+- int bs = 0;
++ struct buffer_head *bh;
++ int x;
+
+- if (blksize_size[MAJOR(lo->lo_device)])
+- bs = blksize_size[MAJOR(lo->lo_device)][MINOR(lo->lo_device)];
+- if (!bs)
+- bs = BLOCK_SIZE;
++ if(!y) {
++ y = lo_prealloc[0];
++ for (x = 1; x < (sizeof(lo_prealloc) / sizeof(int)); x += 2) {
++ if (lo_prealloc[x + 1] && (lo->lo_number == lo_prealloc[x])) {
++ y = lo_prealloc[x + 1];
++ break;
++ }
++ }
++ }
++ lo->lo_bh_flsh = (y * 3) / 4;
+
+- return bs;
++ for (x = 0; x < y; x++) {
++ bh = kmem_cache_alloc(bh_cachep, SLAB_KERNEL);
++ if (!bh) {
++ loop_prealloc_cleanup(lo);
++ return 1;
++ }
++ bh->b_page = alloc_page(GFP_KERNEL);
++ if (!bh->b_page) {
++ bh->b_reqnext = NULL;
++ kmem_cache_free(bh_cachep, bh);
++ loop_prealloc_cleanup(lo);
++ return 1;
++ }
++ bh->b_reqnext = lo->lo_bh_free;
++ lo->lo_bh_free = bh;
++ }
++ return 0;
+ }
+
+-static inline unsigned long loop_get_iv(struct loop_device *lo,
+- unsigned long sector)
++static void loop_add_queue_last(struct loop_device *lo, struct buffer_head *bh, struct buffer_head **q)
+ {
+- int bs = loop_get_bs(lo);
+- unsigned long offset, IV;
++ unsigned long flags;
+
+- IV = sector / (bs >> 9) + lo->lo_offset / bs;
+- offset = ((sector % (bs >> 9)) << 9) + lo->lo_offset % bs;
+- if (offset >= bs)
+- IV++;
++ spin_lock_irqsave(&lo->lo_lock, flags);
++ if (*q) {
++ bh->b_reqnext = (*q)->b_reqnext;
++ (*q)->b_reqnext = bh;
++ } else {
++ bh->b_reqnext = bh;
++ }
++ *q = bh;
++ spin_unlock_irqrestore(&lo->lo_lock, flags);
+
+- return IV;
++ if (waitqueue_active(&lo->lo_bh_wait))
++ wake_up_interruptible(&lo->lo_bh_wait);
+ }
+
+-static int do_bh_filebacked(struct loop_device *lo, struct buffer_head *bh, int rw)
++static void loop_add_queue_first(struct loop_device *lo, struct buffer_head *bh, struct buffer_head **q)
+ {
+- loff_t pos;
+- int ret;
+-
+- pos = ((loff_t) bh->b_rsector << 9) + lo->lo_offset;
+-
+- if (rw == WRITE)
+- ret = lo_send(lo, bh, loop_get_bs(lo), pos);
+- else
+- ret = lo_receive(lo, bh, loop_get_bs(lo), pos);
+-
+- return ret;
++ spin_lock_irq(&lo->lo_lock);
++ if (*q) {
++ bh->b_reqnext = (*q)->b_reqnext;
++ (*q)->b_reqnext = bh;
++ } else {
++ bh->b_reqnext = bh;
++ *q = bh;
++ }
++ spin_unlock_irq(&lo->lo_lock);
+ }
+
+-static void loop_end_io_transfer(struct buffer_head *bh, int uptodate);
+-static void loop_put_buffer(struct buffer_head *bh)
++static struct buffer_head *loop_get_bh(struct loop_device *lo, int *list_nr,
++ que_look_up_table *qt)
+ {
+- /*
+- * check b_end_io, may just be a remapped bh and not an allocated one
<<Diff was trimmed, longer than 597 lines>>
More information about the pld-cvs-commit
mailing list