SOURCES: linux-2.4-squashfs.patch - original squashfs3.1 patch for...

hawk hawk at pld-linux.org
Wed Aug 30 14:17:03 CEST 2006


Author: hawk                         Date: Wed Aug 30 12:17:03 2006 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- original squashfs3.1 patch for 2.4.33

---- Files affected:
SOURCES:
   linux-2.4-squashfs.patch (1.2 -> 1.3) 

---- Diffs:

================================================================
Index: SOURCES/linux-2.4-squashfs.patch
diff -u SOURCES/linux-2.4-squashfs.patch:1.2 SOURCES/linux-2.4-squashfs.patch:1.3
--- SOURCES/linux-2.4-squashfs.patch:1.2	Fri Feb 11 10:19:25 2005
+++ SOURCES/linux-2.4-squashfs.patch	Wed Aug 30 14:16:58 2006
@@ -1,18 +1,25 @@
-diff --new-file -ur linux-2.4.28/fs/Config.in linux-2.4.28-squashfs2.1-r2/fs/Config.in
---- linux-2.4.28/fs/Config.in	2004-11-17 11:54:21.000000000 +0000
-+++ linux-2.4.28-squashfs2.1-r2/fs/Config.in	2004-12-02 02:14:05.000000000 +0000
-@@ -51,6 +51,7 @@
+diff --new-file -urp linux-2.4.33/fs/Config.in linux-2.4.33-squashfs3.1/fs/Config.in
+--- linux-2.4.33/fs/Config.in	2004-11-17 11:54:21.000000000 +0000
++++ linux-2.4.33-squashfs3.1/fs/Config.in	2006-08-13 00:12:59.000000000 +0100
+@@ -51,6 +51,14 @@ if [ "$CONFIG_JFFS2_FS" = "y" -o "$CONFI
     int 'JFFS2 debugging verbosity (0 = quiet, 2 = noisy)' CONFIG_JFFS2_FS_DEBUG 0
  fi
  tristate 'Compressed ROM file system support' CONFIG_CRAMFS
 +tristate 'Squashed file system support' CONFIG_SQUASHFS
++if [ "$CONFIG_SQUASHFS" = "y" -o "$CONFIG_SQUASHFS" = "m" ] ; then
++bool 'Additional options for memory constrained systems ' CONFIG_SQUASHFS_EMBEDDED
++fi
++if [ "$CONFIG_SQUASHFS_EMBEDDED" = "y" ] ; then
++int 'Number of fragments cached' CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE 3
++bool 'Use Vmalloc rather than Kmalloc'  CONFIG_SQUASHFS_VMALLOC
++fi
  bool 'Virtual memory file system support (former shm fs)' CONFIG_TMPFS
  define_bool CONFIG_RAMFS y
  
-diff --new-file -ur linux-2.4.28/fs/Makefile linux-2.4.28-squashfs2.1-r2/fs/Makefile
---- linux-2.4.28/fs/Makefile	2004-02-18 13:36:31.000000000 +0000
-+++ linux-2.4.28-squashfs2.1-r2/fs/Makefile	2004-12-02 02:14:05.000000000 +0000
-@@ -65,6 +65,7 @@
+diff --new-file -urp linux-2.4.33/fs/Makefile linux-2.4.33-squashfs3.1/fs/Makefile
+--- linux-2.4.33/fs/Makefile	2004-02-18 13:36:31.000000000 +0000
++++ linux-2.4.33-squashfs3.1/fs/Makefile	2006-08-13 00:12:59.000000000 +0100
+@@ -65,6 +65,7 @@ subdir-$(CONFIG_REISERFS_FS)	+= reiserfs
  subdir-$(CONFIG_DEVPTS_FS)	+= devpts
  subdir-$(CONFIG_SUN_OPENPROMFS)	+= openpromfs
  subdir-$(CONFIG_BEFS_FS)	+= befs
@@ -20,14 +27,15 @@
  subdir-$(CONFIG_JFS_FS)		+= jfs
  subdir-$(CONFIG_XFS_FS)		+= xfs
  
-diff --new-file -ur linux-2.4.28/fs/squashfs/inode.c linux-2.4.28-squashfs2.1-r2/fs/squashfs/inode.c
---- linux-2.4.28/fs/squashfs/inode.c	1970-01-01 01:00:00.000000000 +0100
-+++ linux-2.4.28-squashfs2.1-r2/fs/squashfs/inode.c	2004-12-15 10:13:06.000000000 +0000
-@@ -0,0 +1,1677 @@
+diff --new-file -urp linux-2.4.33/fs/squashfs/inode.c linux-2.4.33-squashfs3.1/fs/squashfs/inode.c
+--- linux-2.4.33/fs/squashfs/inode.c	1970-01-01 01:00:00.000000000 +0100
++++ linux-2.4.33-squashfs3.1/fs/squashfs/inode.c	2006-08-20 01:08:52.000000000 +0100
+@@ -0,0 +1,2029 @@
 +/*
 + * Squashfs - a compressed read only filesystem for Linux
 + *
-+ * Copyright (c) 2002, 2003, 2004 Phillip Lougher <plougher at users.sourceforge.net>
++ * Copyright (c) 2002, 2003, 2004, 2005, 2006
++ * Phillip Lougher <phillip at lougher.org.uk>
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
@@ -42,39 +50,28 @@
 + * You should have received a copy of the GNU General Public License
 + * along with this program; if not, write to the Free Software
 + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-+ * Squashfs - a compressed read only filesystem for Linux
 + *
 + * inode.c
 + */
 +
-+#define SQUASHFS_1_0_COMPATIBILITY
-+
 +#include <linux/types.h>
 +#include <linux/squashfs_fs.h>
 +#include <linux/module.h>
 +#include <linux/errno.h>
 +#include <linux/slab.h>
++#include <linux/zlib.h>
 +#include <linux/fs.h>
++#include <linux/smp_lock.h>
 +#include <linux/locks.h>
 +#include <linux/init.h>
 +#include <linux/dcache.h>
-+#include <asm/uaccess.h>
 +#include <linux/wait.h>
-+#include <asm/semaphore.h>
-+#include <linux/zlib.h>
 +#include <linux/blkdev.h>
 +#include <linux/vmalloc.h>
++#include <asm/uaccess.h>
++#include <asm/semaphore.h>
 +
-+#ifdef SQUASHFS_TRACE
-+#define TRACE(s, args...)				printk(KERN_NOTICE "SQUASHFS: "s, ## args)
-+#else
-+#define TRACE(s, args...)				{}
-+#endif
-+
-+#define ERROR(s, args...)				printk(KERN_ERR "SQUASHFS error: "s, ## args)
-+
-+#define SERROR(s, args...)				if(!silent) printk(KERN_ERR "SQUASHFS error: "s, ## args)
-+#define WARNING(s, args...)				printk(KERN_WARNING "SQUASHFS: "s, ## args)
++#include "squashfs.h"
 +
 +static struct super_block *squashfs_read_super(struct super_block *, void *, int);
 +static void squashfs_put_super(struct super_block *);
@@ -84,26 +81,10 @@
 +static int squashfs_readpage4K(struct file *file, struct page *page);
 +static int squashfs_readdir(struct file *, void *, filldir_t);
 +static struct dentry *squashfs_lookup(struct inode *, struct dentry *);
-+static unsigned int read_data(struct super_block *s, char *buffer,
-+		unsigned int index, unsigned int length, unsigned int *next_index);
-+static int squashfs_get_cached_block(struct super_block *s, char *buffer,
-+		unsigned int block, unsigned int offset, int length,
-+		unsigned int *next_block, unsigned int *next_offset);
-+static struct inode *squashfs_iget(struct super_block *s, squashfs_inode inode);
-+static unsigned int read_blocklist(struct inode *inode, int index, int readahead_blks,
-+		char *block_list, unsigned short **block_p, unsigned int *bsize);
-+static void squashfs_put_super(struct super_block *s);
-+
-+#ifdef SQUASHFS_1_0_COMPATIBILITY
-+static int squashfs_readpage_lessthan4K(struct file *file, struct page *page);
-+static struct inode *squashfs_iget_1(struct super_block *s, squashfs_inode inode);
-+static unsigned int read_blocklist_1(struct inode *inode, int index, int readahead_blks,
-+		char *block_list, unsigned short **block_p, unsigned int *bsize);
-+#endif
-+
-+DECLARE_MUTEX(read_data_mutex);
-+
-+static z_stream stream;
++static struct inode *squashfs_iget(struct super_block *s, squashfs_inode_t inode);
++static long long read_blocklist(struct inode *inode, int index,
++				int readahead_blks, char *block_list,
++				unsigned short **block_p, unsigned int *bsize);
 +
 +static DECLARE_FSTYPE_DEV(squashfs_fs_type, "squashfs", squashfs_read_super);
 +
@@ -112,144 +93,161 @@
 +};
 +
 +static struct super_operations squashfs_ops = {
-+	statfs: squashfs_statfs,
-+	put_super: squashfs_put_super,
++	.statfs = squashfs_statfs,
++	.put_super = squashfs_put_super,
 +};
 +
-+static struct address_space_operations squashfs_symlink_aops = {
-+	readpage: squashfs_symlink_readpage
++SQSH_EXTERN struct address_space_operations squashfs_symlink_aops = {
++	.readpage = squashfs_symlink_readpage
 +};
 +
-+static struct address_space_operations squashfs_aops = {
-+	readpage: squashfs_readpage
++SQSH_EXTERN struct address_space_operations squashfs_aops = {
++	.readpage = squashfs_readpage
 +};
 +
-+static struct address_space_operations squashfs_aops_4K = {
-+	readpage: squashfs_readpage4K
++SQSH_EXTERN struct address_space_operations squashfs_aops_4K = {
++	.readpage = squashfs_readpage4K
 +};
 +
-+#ifdef SQUASHFS_1_0_COMPATIBILITY
-+static struct address_space_operations squashfs_aops_lessthan4K = {
-+	readpage: squashfs_readpage_lessthan4K
-+};
-+#endif
-+
 +static struct file_operations squashfs_dir_ops = {
-+	read: generic_read_dir,
-+	readdir: squashfs_readdir
++	.read = generic_read_dir,
++	.readdir = squashfs_readdir
 +};
 +
 +static struct inode_operations squashfs_dir_inode_ops = {
-+	lookup: squashfs_lookup
++	.lookup = squashfs_lookup
 +};
 +
-+
-+static struct buffer_head *get_block_length(struct super_block *s, int *cur_index, int *offset, int *c_byte)
++static struct buffer_head *get_block_length(struct super_block *s,
++				int *cur_index, int *offset, int *c_byte)
 +{
-+	squashfs_sb_info *msBlk = &s->u.squashfs_sb;
++	struct squashfs_sb_info *msblk = &s->u.squashfs_sb;
 +	unsigned short temp;
 +	struct buffer_head *bh;
 +
-+	if(!(bh = sb_bread(s, *cur_index)))
-+		return NULL;
++	if (!(bh = sb_bread(s, *cur_index)))
++		goto out;
 +
-+	if(msBlk->devblksize - *offset == 1) {
-+		if(msBlk->swap)
-+			((unsigned char *) &temp)[1] = *((unsigned char *) (bh->b_data + *offset));
++	if (msblk->devblksize - *offset == 1) {
++		if (msblk->swap)
++			((unsigned char *) &temp)[1] = *((unsigned char *)
++				(bh->b_data + *offset));
 +		else
-+			((unsigned char *) &temp)[0] = *((unsigned char *) (bh->b_data + *offset));
++			((unsigned char *) &temp)[0] = *((unsigned char *)
++				(bh->b_data + *offset));
 +		brelse(bh);
-+		if(!(bh = sb_bread(s, ++(*cur_index))))
-+			return NULL;
-+		if(msBlk->swap)
-+			((unsigned char *) &temp)[0] = *((unsigned char *) bh->b_data); 
++		if (!(bh = sb_bread(s, ++(*cur_index))))
++			goto out;
++		if (msblk->swap)
++			((unsigned char *) &temp)[0] = *((unsigned char *)
++				bh->b_data); 
 +		else
-+			((unsigned char *) &temp)[1] = *((unsigned char *) bh->b_data); 
++			((unsigned char *) &temp)[1] = *((unsigned char *)
++				bh->b_data); 
 +		*c_byte = temp;
 +		*offset = 1;
-+	}
-+	else {
-+		if(msBlk->swap) {
-+			unsigned short temp;
-+			((unsigned char *) &temp)[1] = *((unsigned char *) (bh->b_data + *offset));
-+			((unsigned char *) &temp)[0] = *((unsigned char *) (bh->b_data + *offset + 1)); 
-+			*c_byte = temp;
-+		} else
-+			*c_byte = *((unsigned short *) (bh->b_data + *offset));
++	} else {
++		if (msblk->swap) {
++			((unsigned char *) &temp)[1] = *((unsigned char *)
++				(bh->b_data + *offset));
++			((unsigned char *) &temp)[0] = *((unsigned char *)
++				(bh->b_data + *offset + 1)); 
++		} else {
++			((unsigned char *) &temp)[0] = *((unsigned char *)
++				(bh->b_data + *offset));
++			((unsigned char *) &temp)[1] = *((unsigned char *)
++				(bh->b_data + *offset + 1)); 
++		}
++		*c_byte = temp;
 +		*offset += 2;
 +	}
-+	if(SQUASHFS_CHECK_DATA(msBlk->sBlk.flags)) {
-+		if(*offset == msBlk->devblksize) {
++
++	if (SQUASHFS_CHECK_DATA(msblk->sblk.flags)) {
++		if (*offset == msblk->devblksize) {
 +			brelse(bh);
-+			if(!(bh = sb_bread(s, ++(*cur_index))))
-+				return NULL;
-+			offset = 0;
-+		}
-+		if(*((unsigned char *) (bh->b_data + *offset)) != SQUASHFS_MARKER_BYTE) {
-+			ERROR("Metadata block marker corrupt @ %x\n", *cur_index);
++			if (!(bh = sb_bread(s, ++(*cur_index))))
++				goto out;
++			*offset = 0;
++		}
++		if (*((unsigned char *) (bh->b_data + *offset)) !=
++						SQUASHFS_MARKER_BYTE) {
++			ERROR("Metadata block marker corrupt @ %x\n",
++						*cur_index);
 +			brelse(bh);
-+			return NULL;
++			goto out;
 +		}
-+		*offset ++;
++		(*offset)++;
 +	}
-+
 +	return bh;
++
++out:
++	return NULL;
 +}
 +
 +
-+static unsigned int read_data(struct super_block *s, char *buffer,
-+		unsigned int index, unsigned int length, unsigned int *next_index)
-+{
-+	squashfs_sb_info *msBlk = &s->u.squashfs_sb;
-+	struct buffer_head *bh[((SQUASHFS_FILE_MAX_SIZE - 1) >> msBlk->devblksize_log2) + 2];
-+	unsigned int offset = index & ((1 << msBlk->devblksize_log2) - 1);
-+	unsigned int cur_index = index >> msBlk->devblksize_log2;
++SQSH_EXTERN unsigned int squashfs_read_data(struct super_block *s, char *buffer,
++			long long index, unsigned int length,
++			long long *next_index)
++{
++	struct squashfs_sb_info *msblk = &s->u.squashfs_sb;
++	struct buffer_head *bh[((SQUASHFS_FILE_MAX_SIZE - 1) >>
++			msblk->devblksize_log2) + 2];
++	unsigned int offset = index & ((1 << msblk->devblksize_log2) - 1);
++	unsigned int cur_index = index >> msblk->devblksize_log2;
 +	int bytes, avail_bytes, b = 0, k;
 +	char *c_buffer;
 +	unsigned int compressed;
 +	unsigned int c_byte = length;
 +
-+	if(c_byte) {
-+		bytes = msBlk->devblksize - offset;
++	if (c_byte) {
++		bytes = msblk->devblksize - offset;
 +		compressed = SQUASHFS_COMPRESSED_BLOCK(c_byte);
-+		c_buffer = compressed ? msBlk->read_data : buffer;
++		c_buffer = compressed ? msblk->read_data : buffer;
 +		c_byte = SQUASHFS_COMPRESSED_SIZE_BLOCK(c_byte);
 +
-+		TRACE("Block @ 0x%x, %scompressed size %d\n", index, compressed ? "" : "un", (unsigned int) c_byte);
++		TRACE("Block @ 0x%llx, %scompressed size %d\n", index, compressed
++					? "" : "un", (unsigned int) c_byte);
 +
-+		if(!(bh[0] = sb_getblk(s, cur_index)))
++		if (!(bh[0] = sb_getblk(s, cur_index)))
 +			goto block_release;
-+		for(b = 1; bytes < c_byte; b++) {
-+			if(!(bh[b] = sb_getblk(s, ++cur_index)))
++
++		for (b = 1; bytes < c_byte; b++) {
++			if (!(bh[b] = sb_getblk(s, ++cur_index)))
 +				goto block_release;
-+			bytes += msBlk->devblksize;
++			bytes += msblk->devblksize;
 +		}
 +		ll_rw_block(READ, b, bh);
 +	} else {
-+		if(!(bh[0] = get_block_length(s, &cur_index, &offset, &c_byte)))
++		if (!(bh[0] = get_block_length(s, &cur_index, &offset,
++								&c_byte)))
 +			goto read_failure;
 +
-+		bytes = msBlk->devblksize - offset;
++		bytes = msblk->devblksize - offset;
 +		compressed = SQUASHFS_COMPRESSED(c_byte);
-+		c_buffer = compressed ? msBlk->read_data : buffer;
++		c_buffer = compressed ? msblk->read_data : buffer;
 +		c_byte = SQUASHFS_COMPRESSED_SIZE(c_byte);
 +
-+		TRACE("Block @ 0x%x, %scompressed size %d\n", index, compressed ? "" : "un", (unsigned int) c_byte);
++		TRACE("Block @ 0x%llx, %scompressed size %d\n", index, compressed
++					? "" : "un", (unsigned int) c_byte);
 +
-+		for(b = 1; bytes < c_byte; b++) {
-+			if(!(bh[b] = sb_getblk(s, ++cur_index)))
++		for (b = 1; bytes < c_byte; b++) {
++			if (!(bh[b] = sb_getblk(s, ++cur_index)))
 +				goto block_release;
-+			bytes += msBlk->devblksize;
++			bytes += msblk->devblksize;
 +		}
 +		ll_rw_block(READ, b - 1, bh + 1);
 +	}
 +
-+	if(compressed)
-+		down(&read_data_mutex);
++	if (compressed)
++		down(&msblk->read_data_mutex);
 +
-+	for(bytes = 0, k = 0; k < b; k++) {
-+		avail_bytes = (c_byte - bytes) > (msBlk->devblksize - offset) ? msBlk->devblksize - offset : c_byte - bytes;
++	for (bytes = 0, k = 0; k < b; k++) {
++		avail_bytes = (c_byte - bytes) > (msblk->devblksize - offset) ?
++					msblk->devblksize - offset :
++					c_byte - bytes;
 +		wait_on_buffer(bh[k]);
++		if (!buffer_uptodate(bh[k]))
++			goto block_release;
 +		memcpy(c_buffer + bytes, bh[k]->b_data + offset, avail_bytes);
 +		bytes += avail_bytes;
 +		offset = 0;
@@ -259,831 +257,916 @@
 +	/*
 +	 * uncompress block
 +	 */
-+	if(compressed) {
++	if (compressed) {
 +		int zlib_err;
 +
-+		stream.next_in = c_buffer;
-+		stream.avail_in = c_byte;
-+		stream.next_out = buffer;
-+		stream.avail_out = msBlk->read_size;
-+		if(((zlib_err = zlib_inflateInit(&stream)) != Z_OK) ||
-+				((zlib_err = zlib_inflate(&stream, Z_FINISH)) != Z_STREAM_END) ||
-+				((zlib_err = zlib_inflateEnd(&stream)) != Z_OK)) {
-+			ERROR("zlib_fs returned unexpected result 0x%x\n", zlib_err);
++		msblk->stream.next_in = c_buffer;
++		msblk->stream.avail_in = c_byte;
++		msblk->stream.next_out = buffer;
++		msblk->stream.avail_out = msblk->read_size;
++
++		if (((zlib_err = zlib_inflateInit(&msblk->stream)) != Z_OK) ||
++				((zlib_err = zlib_inflate(&msblk->stream, Z_FINISH))
++				 != Z_STREAM_END) || ((zlib_err =
++				zlib_inflateEnd(&msblk->stream)) != Z_OK)) {
++			ERROR("zlib_fs returned unexpected result 0x%x\n",
++				zlib_err);
 +			bytes = 0;
 +		} else
-+			bytes = stream.total_out;
-+		up(&read_data_mutex);
++			bytes = msblk->stream.total_out;
++		
++		up(&msblk->read_data_mutex);
 +	}
 +
-+	if(next_index)
-+		*next_index = index + c_byte + (length ? 0 : (SQUASHFS_CHECK_DATA(msBlk->sBlk.flags) ? 3 : 2));
-+
++	if (next_index)
++		*next_index = index + c_byte + (length ? 0 :
++				(SQUASHFS_CHECK_DATA(msblk->sblk.flags)
++				 ? 3 : 2));
 +	return bytes;
 +
 +block_release:
-+	while(--b >= 0) brelse(bh[b]);
++	while (--b >= 0)
++		brelse(bh[b]);
 +
 +read_failure:
 +	ERROR("sb_bread failed reading block 0x%x\n", cur_index);
 +	return 0;
 +}
-+static int squashfs_get_cached_block(struct super_block *s, char *buffer,
-+		unsigned int block, unsigned int offset, int length,
-+		unsigned int *next_block, unsigned int *next_offset)
++
++
++SQSH_EXTERN int squashfs_get_cached_block(struct super_block *s, char *buffer,
++				long long block, unsigned int offset,
++				int length, long long *next_block,
++				unsigned int *next_offset)
 +{
-+	squashfs_sb_info *msBlk = &s->u.squashfs_sb;
++	struct squashfs_sb_info *msblk = &s->u.squashfs_sb;
 +	int n, i, bytes, return_length = length;
-+	unsigned int next_index;
++	long long next_index;
 +
-+	TRACE("Entered squashfs_get_cached_block [%x:%x]\n", block, offset);
++	TRACE("Entered squashfs_get_cached_block [%llx:%x]\n", block, offset);
 +
-+	for(;;) {
-+		for(i = 0; i < SQUASHFS_CACHED_BLKS; i++) 
-+			if(msBlk->block_cache[i].block == block)
++	while ( 1 ) {
++		for (i = 0; i < SQUASHFS_CACHED_BLKS; i++) 
++			if (msblk->block_cache[i].block == block)
 +				break; 
 +		
-+		down(&msBlk->block_cache_mutex);
-+		if(i == SQUASHFS_CACHED_BLKS) {
++		down(&msblk->block_cache_mutex);
++
++		if (i == SQUASHFS_CACHED_BLKS) {
 +			/* read inode header block */
-+			for(i = msBlk->next_cache, n = SQUASHFS_CACHED_BLKS; n ; n --, i = (i + 1) % SQUASHFS_CACHED_BLKS)
-+				if(msBlk->block_cache[i].block != SQUASHFS_USED_BLK)
++			for (i = msblk->next_cache, n = SQUASHFS_CACHED_BLKS;
++					n ; n --, i = (i + 1) %
++					SQUASHFS_CACHED_BLKS)
++				if (msblk->block_cache[i].block !=
++							SQUASHFS_USED_BLK)
 +					break;
-+			if(n == 0) {
-+				up(&msBlk->block_cache_mutex);
-+				sleep_on(&msBlk->waitq);
++
++			if (n == 0) {
++				wait_queue_t wait;
++
++				init_waitqueue_entry(&wait, current);
++				add_wait_queue(&msblk->waitq, &wait);
++				set_current_state(TASK_UNINTERRUPTIBLE);
++ 				up(&msblk->block_cache_mutex);
++				schedule();
++				set_current_state(TASK_RUNNING);
++				remove_wait_queue(&msblk->waitq, &wait);
 +				continue;
 +			}
-+			msBlk->next_cache = (i + 1) % SQUASHFS_CACHED_BLKS;
++			msblk->next_cache = (i + 1) % SQUASHFS_CACHED_BLKS;
 +
-+			if(msBlk->block_cache[i].block == SQUASHFS_INVALID_BLK) {
-+				if(!(msBlk->block_cache[i].data = (unsigned char *)
-+							kmalloc(SQUASHFS_METADATA_SIZE, GFP_KERNEL))) {
-+					ERROR("Failed to allocate cache block\n");
-+					up(&msBlk->block_cache_mutex);
-+					return 0;
++			if (msblk->block_cache[i].block ==
++							SQUASHFS_INVALID_BLK) {
++				if (!(msblk->block_cache[i].data =
++						kmalloc(SQUASHFS_METADATA_SIZE,
++						GFP_KERNEL))) {
++					ERROR("Failed to allocate cache"
++							"block\n");
++					up(&msblk->block_cache_mutex);
++					goto out;
 +				}
 +			}
 +	
-+			msBlk->block_cache[i].block = SQUASHFS_USED_BLK;
-+			up(&msBlk->block_cache_mutex);
-+			if(!(msBlk->block_cache[i].length = read_data(s, msBlk->block_cache[i].data, block, 0,
-+							&next_index))) {
-+				ERROR("Unable to read cache block [%x:%x]\n", block, offset);
-+				return 0;
++			msblk->block_cache[i].block = SQUASHFS_USED_BLK;
++			up(&msblk->block_cache_mutex);
++
++			if (!(msblk->block_cache[i].length =
++						squashfs_read_data(s,
++						msblk->block_cache[i].data,
++						block, 0, &next_index))) {
++				ERROR("Unable to read cache block [%llx:%x]\n",
++						block, offset);
++				goto out;
 +			}
-+			down(&msBlk->block_cache_mutex);
-+			wake_up(&msBlk->waitq);
-+			msBlk->block_cache[i].block = block;
-+			msBlk->block_cache[i].next_index = next_index;
-+			TRACE("Read cache block [%x:%x]\n", block, offset);
++
++			down(&msblk->block_cache_mutex);
++			wake_up(&msblk->waitq);
++			msblk->block_cache[i].block = block;
++			msblk->block_cache[i].next_index = next_index;
++			TRACE("Read cache block [%llx:%x]\n", block, offset);
 +		}
 +
-+		if(msBlk->block_cache[i].block != block) {
-+			up(&msBlk->block_cache_mutex);
++		if (msblk->block_cache[i].block != block) {
++			up(&msblk->block_cache_mutex);
 +			continue;
 +		}
 +
-+		if((bytes = msBlk->block_cache[i].length - offset) >= length) {
-+			if(buffer)
-+				memcpy(buffer, msBlk->block_cache[i].data + offset, length);
-+			if(msBlk->block_cache[i].length - offset == length) {
-+				*next_block = msBlk->block_cache[i].next_index;
++		if ((bytes = msblk->block_cache[i].length - offset) >= length) {
++			if (buffer)
++				memcpy(buffer, msblk->block_cache[i].data +
++						offset, length);
++			if (msblk->block_cache[i].length - offset == length) {
++				*next_block = msblk->block_cache[i].next_index;
 +				*next_offset = 0;
 +			} else {
 +				*next_block = block;
 +				*next_offset = offset + length;
 +			}
-+	
-+			up(&msBlk->block_cache_mutex);
-+			return return_length;
++			up(&msblk->block_cache_mutex);
++			goto finish;
 +		} else {
-+			if(buffer) {
-+				memcpy(buffer, msBlk->block_cache[i].data + offset, bytes);
++			if (buffer) {
++				memcpy(buffer, msblk->block_cache[i].data +
++						offset, bytes);
 +				buffer += bytes;
 +			}
-+			block = msBlk->block_cache[i].next_index;
-+			up(&msBlk->block_cache_mutex);
++			block = msblk->block_cache[i].next_index;
++			up(&msblk->block_cache_mutex);
 +			length -= bytes;
 +			offset = 0;
 +		}
 +	}
++
++finish:
++	return return_length;
++out:
++	return 0;
 +}
 +
 +
-+static int get_fragment_location(struct super_block *s, unsigned int fragment, unsigned int *fragment_start_block, unsigned int *fragment_size)
-+{
-+	squashfs_sb_info *msBlk = &s->u.squashfs_sb;
-+	unsigned int start_block = msBlk->fragment_index[SQUASHFS_FRAGMENT_INDEX(fragment)];
++static int get_fragment_location(struct super_block *s, unsigned int fragment,
++				long long *fragment_start_block,
++				unsigned int *fragment_size)
++{
<<Diff was trimmed, longer than 597 lines>>

---- CVS-web:
    http://cvs.pld-linux.org/SOURCES/linux-2.4-squashfs.patch?r1=1.2&r2=1.3&f=u



More information about the pld-cvs-commit mailing list