Patch?: linux-2.5.33/drivers/block/loop.c update
Here is an update to my loop.c changes.
Herbert Riedel reported memory corruption typically of single
bytes when using a loop device backed by a file on an XFS filesystem on a multiprocessor. I believe was due to lo_aops_send doing its call to flush_dcache_page before writing to the effected memory rather than after, which is what my new patch does. Herbert says that he may not have time to retest for a little while, so I thought I ought to post this update in case anyone else wants to comment or test.
Also in this version, <linux/loop.h> exports loop_iv_t, which
Herbert requested to simplify cryptoapi maintenance.
Signature · 4 lines
Adam J. Richter __ ______________ 575 Oroville Road [email protected] \ / Milpitas, California 95035 +1 408 309-6081 | g g d r a s i l United States of America "Free Software For The Rest Of Us."
include/linux/loop.h +37 -20
@@ -1,8 +1,3 @@ -#ifndef _LINUX_LOOP_H -#define _LINUX_LOOP_H - -#include <linux/kdev_t.h> -/* * include/linux/loop.h *
@@ -12,11 +7,20 @@* permitted under the GNU General Public License. */ +#ifndef _LINUX_LOOP_H +#define _LINUX_LOOP_H + +#include <linux/kdev_t.h> +#define LO_NAME_SIZE 64#define LO_KEY_SIZE 32#ifdef __KERNEL__ +#include <linux/bio.h> +#include <linux/blkdev.h> +#include <linux/completion.h> +/* Possible states of device */ enum { Lo_unbound,
@@ -24,16 +28,32 @@ Lo_rundown, }; +/* IV calculation related constants */ +#define LO_IV_MODE_DEFAULT 0/* old logical block size based mode */ +#define LO_IV_MODE_SECTOR 1/* calculate IV based on relative +512 byte sectors */ +#define LO_IV_SECTOR_BITS 9 +#define LO_IV_SECTOR_SIZE (1 << LO_IV_SECTOR_BITS) + +struct loop_device ; + +typedef int (*loop_file_xfer_t )(struct loop_device *lo,int rw, +void *data,int len,loff_t pos); + +typedef int loop_iv_t ; +struct loop_device { +request_queue_t lo_queue;int lo_number; -int lo_refcnt; -int lo_offset; +loff_t lo_offset; +sector_t lo_sector_offset;/* lo_offset / 512 */ int lo_encrypt_type;int lo_encrypt_key_size; -int lo_flags; +void (*thread_handle_bio)(struct loop_device *lo, +struct bio *bio);int (*transfer)(struct loop_device *,int cmd,char *raw_buf,char *loop_buf,int size, -int real_block); +loop_iv_t real_block);char lo_name[LO_NAME_SIZE ];char lo_encrypt_key[LO_KEY_SIZE ];__u32 lo_init[2 ];
@@ -51,11 +71,14 @@spinlock_t lo_lock;struct bio *lo_bio;struct bio *lo_biotail; -int lo_state; -struct semaphore lo_sem; -struct semaphore lo_ctl_mutex; +struct completion lo_thread_exited;struct semaphore lo_bh_mutex;atomic_t lo_pending; +int lo_iv_mode; +struct list_head lo_list; +loop_file_xfer_t lo_file_io[2 ];/* [0]=read and [1]=write */ +struct semaphore lo_backup_sem; +struct bio lo_backup_bio; }; typedef int (* transfer_proc_t)(struct loop_device *, int cmd,
@@ -64,13 +87,6 @@#endif /* __KERNEL__ */ -/* -* Loop flags -*/ -#define LO_FLAGS_DO_BMAP 1 -#define LO_FLAGS_READ_ONLY 2 -#define LO_FLAGS_BH_REMAP 4 -/* * Note that this structure gets the wrong offsets when directly used * from a glibc program, because glibc has a 32bit dev_t.
@@ -94,7 +110,7 @@int lo_offset;int lo_encrypt_type;int lo_encrypt_key_size;/* ioctl w/o */ -int lo_flags;/* ioctl r/o */ +int lo_flags;/* no longer used, formerly r/o */ char lo_name[LO_NAME_SIZE ];unsigned char lo_encrypt_key[LO_KEY_SIZE ];/* ioctl w/o */ unsigned long lo_init[2 ];
@@ -114,6 +130,7 @@#define LO_CRYPT_IDEA 6#define LO_CRYPT_DUMMY 9#define LO_CRYPT_SKIPJACK 10 +#define LO_CRYPT_CRYPTOAPI 18/* international crypto patch */ #define MAX_LO_CRYPT 20#ifdef __KERNEL__
drivers/block/loop.c +745 -561
1,744 lines not on this page · raw message
Quoted 2 lines · Adam J. Richter
have time to retest for a little while, so I thought I ought to post this update in case anyone else wants to comment or test.
I've integrated adam's loop.diff into
http://www.kernel.org/pub/linux/kernel/crypto/v2.5/patch-int-2.5.33.2.bz2
in case anyone wants an all-in-one patch...
regards,
Signature · 4 lines
Herbert Valerio Riedel / Phone: (EUROPE) +43-1-58801-18840 Email: [email protected] / Finger [email protected] for GnuPG Public Key GnuPG Key Fingerprint: 7BB9 2D6C D485 CE64 4748 5F65 4981 E064 883F 4142