summaryrefslogtreecommitdiffstats
path: root/fs/squashfs/file_cache.c
diff options
context:
space:
mode:
authorPhillip Lougher <phillip@squashfs.org.uk>2013-10-31 19:24:27 +0000
committerPhillip Lougher <phillip@squashfs.org.uk>2013-11-20 03:59:07 +0000
commit5f55dbc0c5c466a9cdfa4da7ac1bfe351c7fc52a (patch)
treedccfe66c090bfd05c75f5d6a1cc31bf138bd76b1 /fs/squashfs/file_cache.c
parent846b730e99518a1c9945afcb2afbe4d08a02ed80 (diff)
downloadlinux-5f55dbc0c5c466a9cdfa4da7ac1bfe351c7fc52a.tar.gz
linux-5f55dbc0c5c466a9cdfa4da7ac1bfe351c7fc52a.tar.bz2
linux-5f55dbc0c5c466a9cdfa4da7ac1bfe351c7fc52a.zip
Squashfs: Restructure squashfs_readpage()
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 <phillip@squashfs.org.uk> Reviewed-by: Minchan Kim <minchan@kernel.org>
Diffstat (limited to 'fs/squashfs/file_cache.c')
-rw-r--r--fs/squashfs/file_cache.c38
1 files changed, 38 insertions, 0 deletions
diff --git a/fs/squashfs/file_cache.c b/fs/squashfs/file_cache.c
new file mode 100644
index 000000000000..f2310d2a2019
--- /dev/null
+++ b/fs/squashfs/file_cache.c
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2013
+ * Phillip Lougher <phillip@squashfs.org.uk>
+ *
+ * This work is licensed under the terms of the GNU GPL, version 2. See
+ * the COPYING file in the top-level directory.
+ */
+
+#include <linux/fs.h>
+#include <linux/vfs.h>
+#include <linux/kernel.h>
+#include <linux/slab.h>
+#include <linux/string.h>
+#include <linux/pagemap.h>
+#include <linux/mutex.h>
+
+#include "squashfs_fs.h"
+#include "squashfs_fs_sb.h"
+#include "squashfs_fs_i.h"
+#include "squashfs.h"
+
+/* Read separately compressed datablock and memcopy into page cache */
+int squashfs_readpage_block(struct page *page, u64 block, int bsize)
+{
+ struct inode *i = page->mapping->host;
+ struct squashfs_cache_entry *buffer = squashfs_get_datablock(i->i_sb,
+ block, bsize);
+ int res = buffer->error;
+
+ if (res)
+ ERROR("Unable to read page, block %llx, size %x\n", block,
+ bsize);
+ else
+ squashfs_copy_cache(page, buffer, buffer->length, 0);
+
+ squashfs_cache_put(buffer);
+ return res;
+}