xref: /openbmc/linux/fs/freevxfs/vxfs_immed.c (revision 2bc7d3e0)
1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (c) 2000-2001 Christoph Hellwig.
4  */
5 
6 /*
7  * Veritas filesystem driver - support for 'immed' inodes.
8  */
9 #include <linux/fs.h>
10 #include <linux/pagemap.h>
11 
12 #include "vxfs.h"
13 #include "vxfs_extern.h"
14 #include "vxfs_inode.h"
15 
16 
17 static int	vxfs_immed_read_folio(struct file *, struct folio *);
18 
19 /*
20  * Address space operations for immed files and directories.
21  */
22 const struct address_space_operations vxfs_immed_aops = {
23 	.read_folio =		vxfs_immed_read_folio,
24 };
25 
26 /**
27  * vxfs_immed_read_folio - read part of an immed inode into pagecache
28  * @file:	file context (unused)
29  * @folio:	folio to fill in.
30  *
31  * Description:
32  *   vxfs_immed_read_folio reads a part of the immed area of the
33  *   file that hosts @pp into the pagecache.
34  *
35  * Returns:
36  *   Zero on success, else a negative error code.
37  *
38  * Locking status:
39  *   @folio is locked and will be unlocked.
40  */
41 static int
42 vxfs_immed_read_folio(struct file *fp, struct folio *folio)
43 {
44 	struct page *pp = &folio->page;
45 	struct vxfs_inode_info	*vip = VXFS_INO(pp->mapping->host);
46 	u_int64_t	offset = (u_int64_t)pp->index << PAGE_SHIFT;
47 	caddr_t		kaddr;
48 
49 	kaddr = kmap(pp);
50 	memcpy(kaddr, vip->vii_immed.vi_immed + offset, PAGE_SIZE);
51 	kunmap(pp);
52 
53 	flush_dcache_page(pp);
54 	SetPageUptodate(pp);
55         unlock_page(pp);
56 
57 	return 0;
58 }
59