18c2ecf20Sopenharmony_ci/*
28c2ecf20Sopenharmony_ci * Copyright (c) 2000-2001 Christoph Hellwig.
38c2ecf20Sopenharmony_ci * All rights reserved.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or without
68c2ecf20Sopenharmony_ci * modification, are permitted provided that the following conditions
78c2ecf20Sopenharmony_ci * are met:
88c2ecf20Sopenharmony_ci * 1. Redistributions of source code must retain the above copyright
98c2ecf20Sopenharmony_ci *    notice, this list of conditions, and the following disclaimer,
108c2ecf20Sopenharmony_ci *    without modification.
118c2ecf20Sopenharmony_ci * 2. The name of the author may not be used to endorse or promote products
128c2ecf20Sopenharmony_ci *    derived from this software without specific prior written permission.
138c2ecf20Sopenharmony_ci *
148c2ecf20Sopenharmony_ci * Alternatively, this software may be distributed under the terms of the
158c2ecf20Sopenharmony_ci * GNU General Public License ("GPL").
168c2ecf20Sopenharmony_ci *
178c2ecf20Sopenharmony_ci * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
188c2ecf20Sopenharmony_ci * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
198c2ecf20Sopenharmony_ci * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
208c2ecf20Sopenharmony_ci * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR
218c2ecf20Sopenharmony_ci * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
228c2ecf20Sopenharmony_ci * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
238c2ecf20Sopenharmony_ci * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
248c2ecf20Sopenharmony_ci * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
258c2ecf20Sopenharmony_ci * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
268c2ecf20Sopenharmony_ci * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
278c2ecf20Sopenharmony_ci * SUCH DAMAGE.
288c2ecf20Sopenharmony_ci */
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci/*
318c2ecf20Sopenharmony_ci * Veritas filesystem driver - support for 'immed' inodes.
328c2ecf20Sopenharmony_ci */
338c2ecf20Sopenharmony_ci#include <linux/fs.h>
348c2ecf20Sopenharmony_ci#include <linux/pagemap.h>
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#include "vxfs.h"
378c2ecf20Sopenharmony_ci#include "vxfs_extern.h"
388c2ecf20Sopenharmony_ci#include "vxfs_inode.h"
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_cistatic int	vxfs_immed_readpage(struct file *, struct page *);
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci/*
448c2ecf20Sopenharmony_ci * Address space operations for immed files and directories.
458c2ecf20Sopenharmony_ci */
468c2ecf20Sopenharmony_ciconst struct address_space_operations vxfs_immed_aops = {
478c2ecf20Sopenharmony_ci	.readpage =		vxfs_immed_readpage,
488c2ecf20Sopenharmony_ci};
498c2ecf20Sopenharmony_ci
508c2ecf20Sopenharmony_ci/**
518c2ecf20Sopenharmony_ci * vxfs_immed_readpage - read part of an immed inode into pagecache
528c2ecf20Sopenharmony_ci * @file:	file context (unused)
538c2ecf20Sopenharmony_ci * @page:	page frame to fill in.
548c2ecf20Sopenharmony_ci *
558c2ecf20Sopenharmony_ci * Description:
568c2ecf20Sopenharmony_ci *   vxfs_immed_readpage reads a part of the immed area of the
578c2ecf20Sopenharmony_ci *   file that hosts @pp into the pagecache.
588c2ecf20Sopenharmony_ci *
598c2ecf20Sopenharmony_ci * Returns:
608c2ecf20Sopenharmony_ci *   Zero on success, else a negative error code.
618c2ecf20Sopenharmony_ci *
628c2ecf20Sopenharmony_ci * Locking status:
638c2ecf20Sopenharmony_ci *   @page is locked and will be unlocked.
648c2ecf20Sopenharmony_ci */
658c2ecf20Sopenharmony_cistatic int
668c2ecf20Sopenharmony_civxfs_immed_readpage(struct file *fp, struct page *pp)
678c2ecf20Sopenharmony_ci{
688c2ecf20Sopenharmony_ci	struct vxfs_inode_info	*vip = VXFS_INO(pp->mapping->host);
698c2ecf20Sopenharmony_ci	u_int64_t	offset = (u_int64_t)pp->index << PAGE_SHIFT;
708c2ecf20Sopenharmony_ci	caddr_t		kaddr;
718c2ecf20Sopenharmony_ci
728c2ecf20Sopenharmony_ci	kaddr = kmap(pp);
738c2ecf20Sopenharmony_ci	memcpy(kaddr, vip->vii_immed.vi_immed + offset, PAGE_SIZE);
748c2ecf20Sopenharmony_ci	kunmap(pp);
758c2ecf20Sopenharmony_ci
768c2ecf20Sopenharmony_ci	flush_dcache_page(pp);
778c2ecf20Sopenharmony_ci	SetPageUptodate(pp);
788c2ecf20Sopenharmony_ci        unlock_page(pp);
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ci	return 0;
818c2ecf20Sopenharmony_ci}
82