mirror of
https://github.com/FEX-Emu/linux.git
synced 2024-12-22 17:33:01 +00:00
09cbfeaf1a
PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} macros were introduced *long* time ago with promise that one day it will be possible to implement page cache with bigger chunks than PAGE_SIZE. This promise never materialized. And unlikely will. We have many places where PAGE_CACHE_SIZE assumed to be equal to PAGE_SIZE. And it's constant source of confusion on whether PAGE_CACHE_* or PAGE_* constant should be used in a particular case, especially on the border between fs and mm. Global switching to PAGE_CACHE_SIZE != PAGE_SIZE would cause to much breakage to be doable. Let's stop pretending that pages in page cache are special. They are not. The changes are pretty straight-forward: - <foo> << (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>; - <foo> >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) -> <foo>; - PAGE_CACHE_{SIZE,SHIFT,MASK,ALIGN} -> PAGE_{SIZE,SHIFT,MASK,ALIGN}; - page_cache_get() -> get_page(); - page_cache_release() -> put_page(); This patch contains automated changes generated with coccinelle using script below. For some reason, coccinelle doesn't patch header files. I've called spatch for them manually. The only adjustment after coccinelle is revert of changes to PAGE_CAHCE_ALIGN definition: we are going to drop it later. There are few places in the code where coccinelle didn't reach. I'll fix them manually in a separate patch. Comments and documentation also will be addressed with the separate patch. virtual patch @@ expression E; @@ - E << (PAGE_CACHE_SHIFT - PAGE_SHIFT) + E @@ expression E; @@ - E >> (PAGE_CACHE_SHIFT - PAGE_SHIFT) + E @@ @@ - PAGE_CACHE_SHIFT + PAGE_SHIFT @@ @@ - PAGE_CACHE_SIZE + PAGE_SIZE @@ @@ - PAGE_CACHE_MASK + PAGE_MASK @@ expression E; @@ - PAGE_CACHE_ALIGN(E) + PAGE_ALIGN(E) @@ expression E; @@ - page_cache_get(E) + get_page(E) @@ expression E; @@ - page_cache_release(E) + put_page(E) Signed-off-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com> Acked-by: Michal Hocko <mhocko@suse.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
127 lines
3.7 KiB
C
127 lines
3.7 KiB
C
/*
|
|
* Squashfs - a compressed read only filesystem for Linux
|
|
*
|
|
* Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008
|
|
* Phillip Lougher <phillip@squashfs.org.uk>
|
|
*
|
|
* This program 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,
|
|
* or (at your option) any later version.
|
|
*
|
|
* This program 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 program; if not, write to the Free Software
|
|
* Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
*
|
|
* symlink.c
|
|
*/
|
|
|
|
/*
|
|
* This file implements code to handle symbolic links.
|
|
*
|
|
* The data contents of symbolic links are stored inside the symbolic
|
|
* link inode within the inode table. This allows the normally small symbolic
|
|
* link to be compressed as part of the inode table, achieving much greater
|
|
* compression than if the symbolic link was compressed individually.
|
|
*/
|
|
|
|
#include <linux/fs.h>
|
|
#include <linux/vfs.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/string.h>
|
|
#include <linux/pagemap.h>
|
|
#include <linux/xattr.h>
|
|
|
|
#include "squashfs_fs.h"
|
|
#include "squashfs_fs_sb.h"
|
|
#include "squashfs_fs_i.h"
|
|
#include "squashfs.h"
|
|
#include "xattr.h"
|
|
|
|
static int squashfs_symlink_readpage(struct file *file, struct page *page)
|
|
{
|
|
struct inode *inode = page->mapping->host;
|
|
struct super_block *sb = inode->i_sb;
|
|
struct squashfs_sb_info *msblk = sb->s_fs_info;
|
|
int index = page->index << PAGE_SHIFT;
|
|
u64 block = squashfs_i(inode)->start;
|
|
int offset = squashfs_i(inode)->offset;
|
|
int length = min_t(int, i_size_read(inode) - index, PAGE_SIZE);
|
|
int bytes, copied;
|
|
void *pageaddr;
|
|
struct squashfs_cache_entry *entry;
|
|
|
|
TRACE("Entered squashfs_symlink_readpage, page index %ld, start block "
|
|
"%llx, offset %x\n", page->index, block, offset);
|
|
|
|
/*
|
|
* Skip index bytes into symlink metadata.
|
|
*/
|
|
if (index) {
|
|
bytes = squashfs_read_metadata(sb, NULL, &block, &offset,
|
|
index);
|
|
if (bytes < 0) {
|
|
ERROR("Unable to read symlink [%llx:%x]\n",
|
|
squashfs_i(inode)->start,
|
|
squashfs_i(inode)->offset);
|
|
goto error_out;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Read length bytes from symlink metadata. Squashfs_read_metadata
|
|
* is not used here because it can sleep and we want to use
|
|
* kmap_atomic to map the page. Instead call the underlying
|
|
* squashfs_cache_get routine. As length bytes may overlap metadata
|
|
* blocks, we may need to call squashfs_cache_get multiple times.
|
|
*/
|
|
for (bytes = 0; bytes < length; offset = 0, bytes += copied) {
|
|
entry = squashfs_cache_get(sb, msblk->block_cache, block, 0);
|
|
if (entry->error) {
|
|
ERROR("Unable to read symlink [%llx:%x]\n",
|
|
squashfs_i(inode)->start,
|
|
squashfs_i(inode)->offset);
|
|
squashfs_cache_put(entry);
|
|
goto error_out;
|
|
}
|
|
|
|
pageaddr = kmap_atomic(page);
|
|
copied = squashfs_copy_data(pageaddr + bytes, entry, offset,
|
|
length - bytes);
|
|
if (copied == length - bytes)
|
|
memset(pageaddr + length, 0, PAGE_SIZE - length);
|
|
else
|
|
block = entry->next_index;
|
|
kunmap_atomic(pageaddr);
|
|
squashfs_cache_put(entry);
|
|
}
|
|
|
|
flush_dcache_page(page);
|
|
SetPageUptodate(page);
|
|
unlock_page(page);
|
|
return 0;
|
|
|
|
error_out:
|
|
SetPageError(page);
|
|
unlock_page(page);
|
|
return 0;
|
|
}
|
|
|
|
|
|
const struct address_space_operations squashfs_symlink_aops = {
|
|
.readpage = squashfs_symlink_readpage
|
|
};
|
|
|
|
const struct inode_operations squashfs_symlink_inode_ops = {
|
|
.readlink = generic_readlink,
|
|
.get_link = page_get_link,
|
|
.getxattr = generic_getxattr,
|
|
.listxattr = squashfs_listxattr
|
|
};
|
|
|