Re: [PATCH 5/6] Squashfs: restructure squashfs_readpage()

2013-11-07 Thread Minchan Kim
On Thu, Nov 07, 2013 at 08:24:24PM +, Phillip Lougher wrote:
> Restructure squashfs_readpage() splitting it into separate
> functions for datablocks, fragments and sparse blocks.
> 
> Move the memcpying (from squashfs cache entry) implementation of
> squashfs_readpage_block into file_cache.c
> 
> This allows different implementations to be supported.
> 
> Signed-off-by: Phillip Lougher 
> ---
>  fs/squashfs/Makefile |2 +-
>  fs/squashfs/file.c   |  142 
> +++---
>  fs/squashfs/file_cache.c |   38 +
>  fs/squashfs/squashfs.h   |7 +++
>  4 files changed, 118 insertions(+), 71 deletions(-)
>  create mode 100644 fs/squashfs/file_cache.c
> 
> diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile
> index 5833b96..908c0d9 100644
> --- a/fs/squashfs/Makefile
> +++ b/fs/squashfs/Makefile
> @@ -4,7 +4,7 @@
>  
>  obj-$(CONFIG_SQUASHFS) += squashfs.o
>  squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o
> -squashfs-y += namei.o super.o symlink.o decompressor.o
> +squashfs-y += namei.o super.o symlink.o decompressor.o file_cache.c

  file_cache.o

-- 
Kind regards,
Minchan Kim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 5/6] Squashfs: restructure squashfs_readpage()

2013-11-07 Thread Minchan Kim
On Thu, Nov 07, 2013 at 08:24:24PM +, Phillip Lougher wrote:
> Restructure squashfs_readpage() splitting it into separate
> functions for datablocks, fragments and sparse blocks.
> 
> Move the memcpying (from squashfs cache entry) implementation of
> squashfs_readpage_block into file_cache.c
> 
> This allows different implementations to be supported.
> 
> Signed-off-by: Phillip Lougher 
Reviewed-by: Minchan Kim 

-- 
Kind regards,
Minchan Kim
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


[PATCH 5/6] Squashfs: restructure squashfs_readpage()

2013-11-07 Thread Phillip Lougher
Restructure squashfs_readpage() splitting it into separate
functions for datablocks, fragments and sparse blocks.

Move the memcpying (from squashfs cache entry) implementation of
squashfs_readpage_block into file_cache.c

This allows different implementations to be supported.

Signed-off-by: Phillip Lougher 
---
 fs/squashfs/Makefile |2 +-
 fs/squashfs/file.c   |  142 +++---
 fs/squashfs/file_cache.c |   38 +
 fs/squashfs/squashfs.h   |7 +++
 4 files changed, 118 insertions(+), 71 deletions(-)
 create mode 100644 fs/squashfs/file_cache.c

diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile
index 5833b96..908c0d9 100644
--- a/fs/squashfs/Makefile
+++ b/fs/squashfs/Makefile
@@ -4,7 +4,7 @@
 
 obj-$(CONFIG_SQUASHFS) += squashfs.o
 squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o
-squashfs-y += namei.o super.o symlink.o decompressor.o
+squashfs-y += namei.o super.o symlink.o decompressor.o file_cache.c
 squashfs-$(CONFIG_SQUASHFS_DECOMP_SINGLE) += decompressor_single.o
 squashfs-$(CONFIG_SQUASHFS_DECOMP_MULTI) += decompressor_multi.o
 squashfs-$(CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU) += decompressor_multi_percpu.o
diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
index 8ca62c2..e5c9689 100644
--- a/fs/squashfs/file.c
+++ b/fs/squashfs/file.c
@@ -370,77 +370,15 @@ static int read_blocklist(struct inode *inode, int index, 
u64 *block)
return le32_to_cpu(size);
 }
 
-
-static int squashfs_readpage(struct file *file, struct page *page)
+/* Copy data into page cache  */
+void squashfs_copy_cache(struct page *page, struct squashfs_cache_entry 
*buffer,
+   int bytes, int offset)
 {
struct inode *inode = page->mapping->host;
struct squashfs_sb_info *msblk = inode->i_sb->s_fs_info;
-   int bytes, i, offset = 0, sparse = 0;
-   struct squashfs_cache_entry *buffer = NULL;
void *pageaddr;
-
-   int mask = (1 << (msblk->block_log - PAGE_CACHE_SHIFT)) - 1;
-   int index = page->index >> (msblk->block_log - PAGE_CACHE_SHIFT);
-   int start_index = page->index & ~mask;
-   int end_index = start_index | mask;
-   int file_end = i_size_read(inode) >> msblk->block_log;
-
-   TRACE("Entered squashfs_readpage, page index %lx, start block %llx\n",
-   page->index, squashfs_i(inode)->start);
-
-   if (page->index >= ((i_size_read(inode) + PAGE_CACHE_SIZE - 1) >>
-   PAGE_CACHE_SHIFT))
-   goto out;
-
-   if (index < file_end || squashfs_i(inode)->fragment_block ==
-   SQUASHFS_INVALID_BLK) {
-   /*
-* Reading a datablock from disk.  Need to read block list
-* to get location and block size.
-*/
-   u64 block = 0;
-   int bsize = read_blocklist(inode, index, );
-   if (bsize < 0)
-   goto error_out;
-
-   if (bsize == 0) { /* hole */
-   bytes = index == file_end ?
-   (i_size_read(inode) & (msblk->block_size - 1)) :
-msblk->block_size;
-   sparse = 1;
-   } else {
-   /*
-* Read and decompress datablock.
-*/
-   buffer = squashfs_get_datablock(inode->i_sb,
-   block, bsize);
-   if (buffer->error) {
-   ERROR("Unable to read page, block %llx, size %x"
-   "\n", block, bsize);
-   squashfs_cache_put(buffer);
-   goto error_out;
-   }
-   bytes = buffer->length;
-   }
-   } else {
-   /*
-* Datablock is stored inside a fragment (tail-end packed
-* block).
-*/
-   buffer = squashfs_get_fragment(inode->i_sb,
-   squashfs_i(inode)->fragment_block,
-   squashfs_i(inode)->fragment_size);
-
-   if (buffer->error) {
-   ERROR("Unable to read page, block %llx, size %x\n",
-   squashfs_i(inode)->fragment_block,
-   squashfs_i(inode)->fragment_size);
-   squashfs_cache_put(buffer);
-   goto error_out;
-   }
-   bytes = i_size_read(inode) & (msblk->block_size - 1);
-   offset = squashfs_i(inode)->fragment_offset;
-   }
+   int i, mask = (1 << (msblk->block_log - PAGE_CACHE_SHIFT)) - 1;
+   int start_index = page->index & ~mask, end_index = start_index | mask;
 
/*
 * Loop 

[PATCH 5/6] Squashfs: restructure squashfs_readpage()

2013-11-07 Thread Phillip Lougher
Restructure squashfs_readpage() splitting it into separate
functions for datablocks, fragments and sparse blocks.

Move the memcpying (from squashfs cache entry) implementation of
squashfs_readpage_block into file_cache.c

This allows different implementations to be supported.

Signed-off-by: Phillip Lougher phil...@squashfs.org.uk
---
 fs/squashfs/Makefile |2 +-
 fs/squashfs/file.c   |  142 +++---
 fs/squashfs/file_cache.c |   38 +
 fs/squashfs/squashfs.h   |7 +++
 4 files changed, 118 insertions(+), 71 deletions(-)
 create mode 100644 fs/squashfs/file_cache.c

diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile
index 5833b96..908c0d9 100644
--- a/fs/squashfs/Makefile
+++ b/fs/squashfs/Makefile
@@ -4,7 +4,7 @@
 
 obj-$(CONFIG_SQUASHFS) += squashfs.o
 squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o
-squashfs-y += namei.o super.o symlink.o decompressor.o
+squashfs-y += namei.o super.o symlink.o decompressor.o file_cache.c
 squashfs-$(CONFIG_SQUASHFS_DECOMP_SINGLE) += decompressor_single.o
 squashfs-$(CONFIG_SQUASHFS_DECOMP_MULTI) += decompressor_multi.o
 squashfs-$(CONFIG_SQUASHFS_DECOMP_MULTI_PERCPU) += decompressor_multi_percpu.o
diff --git a/fs/squashfs/file.c b/fs/squashfs/file.c
index 8ca62c2..e5c9689 100644
--- a/fs/squashfs/file.c
+++ b/fs/squashfs/file.c
@@ -370,77 +370,15 @@ static int read_blocklist(struct inode *inode, int index, 
u64 *block)
return le32_to_cpu(size);
 }
 
-
-static int squashfs_readpage(struct file *file, struct page *page)
+/* Copy data into page cache  */
+void squashfs_copy_cache(struct page *page, struct squashfs_cache_entry 
*buffer,
+   int bytes, int offset)
 {
struct inode *inode = page-mapping-host;
struct squashfs_sb_info *msblk = inode-i_sb-s_fs_info;
-   int bytes, i, offset = 0, sparse = 0;
-   struct squashfs_cache_entry *buffer = NULL;
void *pageaddr;
-
-   int mask = (1  (msblk-block_log - PAGE_CACHE_SHIFT)) - 1;
-   int index = page-index  (msblk-block_log - PAGE_CACHE_SHIFT);
-   int start_index = page-index  ~mask;
-   int end_index = start_index | mask;
-   int file_end = i_size_read(inode)  msblk-block_log;
-
-   TRACE(Entered squashfs_readpage, page index %lx, start block %llx\n,
-   page-index, squashfs_i(inode)-start);
-
-   if (page-index = ((i_size_read(inode) + PAGE_CACHE_SIZE - 1) 
-   PAGE_CACHE_SHIFT))
-   goto out;
-
-   if (index  file_end || squashfs_i(inode)-fragment_block ==
-   SQUASHFS_INVALID_BLK) {
-   /*
-* Reading a datablock from disk.  Need to read block list
-* to get location and block size.
-*/
-   u64 block = 0;
-   int bsize = read_blocklist(inode, index, block);
-   if (bsize  0)
-   goto error_out;
-
-   if (bsize == 0) { /* hole */
-   bytes = index == file_end ?
-   (i_size_read(inode)  (msblk-block_size - 1)) :
-msblk-block_size;
-   sparse = 1;
-   } else {
-   /*
-* Read and decompress datablock.
-*/
-   buffer = squashfs_get_datablock(inode-i_sb,
-   block, bsize);
-   if (buffer-error) {
-   ERROR(Unable to read page, block %llx, size %x
-   \n, block, bsize);
-   squashfs_cache_put(buffer);
-   goto error_out;
-   }
-   bytes = buffer-length;
-   }
-   } else {
-   /*
-* Datablock is stored inside a fragment (tail-end packed
-* block).
-*/
-   buffer = squashfs_get_fragment(inode-i_sb,
-   squashfs_i(inode)-fragment_block,
-   squashfs_i(inode)-fragment_size);
-
-   if (buffer-error) {
-   ERROR(Unable to read page, block %llx, size %x\n,
-   squashfs_i(inode)-fragment_block,
-   squashfs_i(inode)-fragment_size);
-   squashfs_cache_put(buffer);
-   goto error_out;
-   }
-   bytes = i_size_read(inode)  (msblk-block_size - 1);
-   offset = squashfs_i(inode)-fragment_offset;
-   }
+   int i, mask = (1  (msblk-block_log - PAGE_CACHE_SHIFT)) - 1;
+   int start_index = page-index  ~mask, end_index = start_index | mask;
 
/*
 * Loop copying datablock into 

Re: [PATCH 5/6] Squashfs: restructure squashfs_readpage()

2013-11-07 Thread Minchan Kim
On Thu, Nov 07, 2013 at 08:24:24PM +, Phillip Lougher wrote:
 Restructure squashfs_readpage() splitting it into separate
 functions for datablocks, fragments and sparse blocks.
 
 Move the memcpying (from squashfs cache entry) implementation of
 squashfs_readpage_block into file_cache.c
 
 This allows different implementations to be supported.
 
 Signed-off-by: Phillip Lougher phil...@squashfs.org.uk
Reviewed-by: Minchan Kim minc...@kernel.org

-- 
Kind regards,
Minchan Kim
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/


Re: [PATCH 5/6] Squashfs: restructure squashfs_readpage()

2013-11-07 Thread Minchan Kim
On Thu, Nov 07, 2013 at 08:24:24PM +, Phillip Lougher wrote:
 Restructure squashfs_readpage() splitting it into separate
 functions for datablocks, fragments and sparse blocks.
 
 Move the memcpying (from squashfs cache entry) implementation of
 squashfs_readpage_block into file_cache.c
 
 This allows different implementations to be supported.
 
 Signed-off-by: Phillip Lougher phil...@squashfs.org.uk
 ---
  fs/squashfs/Makefile |2 +-
  fs/squashfs/file.c   |  142 
 +++---
  fs/squashfs/file_cache.c |   38 +
  fs/squashfs/squashfs.h   |7 +++
  4 files changed, 118 insertions(+), 71 deletions(-)
  create mode 100644 fs/squashfs/file_cache.c
 
 diff --git a/fs/squashfs/Makefile b/fs/squashfs/Makefile
 index 5833b96..908c0d9 100644
 --- a/fs/squashfs/Makefile
 +++ b/fs/squashfs/Makefile
 @@ -4,7 +4,7 @@
  
  obj-$(CONFIG_SQUASHFS) += squashfs.o
  squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o
 -squashfs-y += namei.o super.o symlink.o decompressor.o
 +squashfs-y += namei.o super.o symlink.o decompressor.o file_cache.c

  file_cache.o

-- 
Kind regards,
Minchan Kim
--
To unsubscribe from this list: send the line unsubscribe linux-kernel in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/