xref: /linux/fs/xfs/scrub/xfile.h (revision e47e2e0ba9103df7b3d25356421e6832c4d0e7be)
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 /*
3  * Copyright (C) 2018-2023 Oracle.  All Rights Reserved.
4  * Author: Darrick J. Wong <djwong@kernel.org>
5  */
6 #ifndef __XFS_SCRUB_XFILE_H__
7 #define __XFS_SCRUB_XFILE_H__
8 
9 struct xfile_page {
10 	struct page		*page;
11 	void			*fsdata;
12 	loff_t			pos;
13 };
14 
15 static inline bool xfile_page_cached(const struct xfile_page *xfpage)
16 {
17 	return xfpage->page != NULL;
18 }
19 
20 static inline pgoff_t xfile_page_index(const struct xfile_page *xfpage)
21 {
22 	return xfpage->page->index;
23 }
24 
25 struct xfile {
26 	struct file		*file;
27 };
28 
29 int xfile_create(const char *description, loff_t isize, struct xfile **xfilep);
30 void xfile_destroy(struct xfile *xf);
31 
32 int xfile_load(struct xfile *xf, void *buf, size_t count, loff_t pos);
33 int xfile_store(struct xfile *xf, const void *buf, size_t count,
34 		loff_t pos);
35 
36 loff_t xfile_seek_data(struct xfile *xf, loff_t pos);
37 
38 int xfile_get_page(struct xfile *xf, loff_t offset, unsigned int len,
39 		struct xfile_page *xbuf);
40 int xfile_put_page(struct xfile *xf, struct xfile_page *xbuf);
41 
42 #endif /* __XFS_SCRUB_XFILE_H__ */
43