1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (c) 2000-2001 Christoph Hellwig.
7 * Veritas filesystem driver - shared subroutines.
10 #include <linux/buffer_head.h>
11 #include <linux/kernel.h>
12 #include <linux/pagemap.h>
14 #include "vxfs_extern.h"
17 static int vxfs_read_folio(struct file *, struct folio *);
18 static sector_t vxfs_bmap(struct address_space *, sector_t);
20 const struct address_space_operations vxfs_aops = {
21 .read_folio = vxfs_read_folio,
26 vxfs_put_page(struct page *pp)
33 * vxfs_get_page - read a page into memory.
34 * @mapping: mapping to read from
38 * vxfs_get_page reads the @n th page of @ip into the pagecache.
41 * The wanted page on success, else a NULL pointer.
44 vxfs_get_page(struct address_space *mapping, u_long n)
48 pp = read_mapping_page(mapping, n, NULL);
52 /** if (!PageChecked(pp)) **/
53 /** vxfs_check_page(pp); **/
60 * vxfs_bread - read buffer for a give inode,block tuple
62 * @block: logical block
65 * The vxfs_bread function reads block no @block of
66 * @ip into the buffercache.
69 * The resulting &struct buffer_head.
72 vxfs_bread(struct inode *ip, int block)
74 struct buffer_head *bp;
77 pblock = vxfs_bmap1(ip, block);
78 bp = sb_bread(ip->i_sb, pblock);
84 * vxfs_getblk - locate buffer for given inode,block tuple
86 * @iblock: logical block
87 * @bp: buffer skeleton
88 * @create: %TRUE if blocks may be newly allocated.
91 * The vxfs_getblk function fills @bp with the right physical
92 * block and device number to perform a lowlevel read/write on
96 * Zero on success, else a negativ error code (-EIO).
99 vxfs_getblk(struct inode *ip, sector_t iblock,
100 struct buffer_head *bp, int create)
104 pblock = vxfs_bmap1(ip, iblock);
106 map_bh(bp, ip->i_sb, pblock);
114 * vxfs_read_folio - read one page synchronously into the pagecache
115 * @file: file context (unused)
116 * @folio: folio to fill in.
119 * The vxfs_read_folio routine reads @folio synchronously into the
123 * Zero on success, else a negative error code.
126 * @folio is locked and will be unlocked.
128 static int vxfs_read_folio(struct file *file, struct folio *folio)
130 return block_read_full_folio(folio, vxfs_getblk);
134 * vxfs_bmap - perform logical to physical block mapping
135 * @mapping: logical to physical mapping to use
136 * @block: logical block (relative to @mapping).
139 * Vxfs_bmap find out the corresponding phsical block to the
140 * @mapping, @block pair.
143 * Physical block number on success, else Zero.
146 * We are under the bkl.
149 vxfs_bmap(struct address_space *mapping, sector_t block)
151 return generic_block_bmap(mapping, block, vxfs_getblk);