xfile.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435
  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. struct xfile {
  9. struct file *file;
  10. };
  11. int xfile_create(const char *description, loff_t isize, struct xfile **xfilep);
  12. void xfile_destroy(struct xfile *xf);
  13. int xfile_load(struct xfile *xf, void *buf, size_t count, loff_t pos);
  14. int xfile_store(struct xfile *xf, const void *buf, size_t count,
  15. loff_t pos);
  16. void xfile_discard(struct xfile *xf, loff_t pos, u64 count);
  17. loff_t xfile_seek_data(struct xfile *xf, loff_t pos);
  18. #define XFILE_MAX_FOLIO_SIZE (PAGE_SIZE << MAX_PAGECACHE_ORDER)
  19. #define XFILE_ALLOC (1 << 0) /* allocate folio if not present */
  20. struct folio *xfile_get_folio(struct xfile *xf, loff_t offset, size_t len,
  21. unsigned int flags);
  22. void xfile_put_folio(struct xfile *xf, struct folio *folio);
  23. static inline unsigned long long xfile_bytes(struct xfile *xf)
  24. {
  25. return file_inode(xf->file)->i_blocks << SECTOR_SHIFT;
  26. }
  27. #endif /* __XFS_SCRUB_XFILE_H__ */