attr.h (1761B)
1/* SPDX-License-Identifier: GPL-2.0-or-later */ 2/* 3 * Copyright (C) 2019 Oracle. All Rights Reserved. 4 * Author: Darrick J. Wong <darrick.wong@oracle.com> 5 */ 6#ifndef __XFS_SCRUB_ATTR_H__ 7#define __XFS_SCRUB_ATTR_H__ 8 9/* 10 * Temporary storage for online scrub and repair of extended attributes. 11 */ 12struct xchk_xattr_buf { 13 /* Size of @buf, in bytes. */ 14 size_t sz; 15 16 /* 17 * Memory buffer -- either used for extracting attr values while 18 * walking the attributes; or for computing attr block bitmaps when 19 * checking the attribute tree. 20 * 21 * Each bitmap contains enough bits to track every byte in an attr 22 * block (rounded up to the size of an unsigned long). The attr block 23 * used space bitmap starts at the beginning of the buffer; the free 24 * space bitmap follows immediately after; and we have a third buffer 25 * for storing intermediate bitmap results. 26 */ 27 uint8_t buf[]; 28}; 29 30/* A place to store attribute values. */ 31static inline uint8_t * 32xchk_xattr_valuebuf( 33 struct xfs_scrub *sc) 34{ 35 struct xchk_xattr_buf *ab = sc->buf; 36 37 return ab->buf; 38} 39 40/* A bitmap of space usage computed by walking an attr leaf block. */ 41static inline unsigned long * 42xchk_xattr_usedmap( 43 struct xfs_scrub *sc) 44{ 45 struct xchk_xattr_buf *ab = sc->buf; 46 47 return (unsigned long *)ab->buf; 48} 49 50/* A bitmap of free space computed by walking attr leaf block free info. */ 51static inline unsigned long * 52xchk_xattr_freemap( 53 struct xfs_scrub *sc) 54{ 55 return xchk_xattr_usedmap(sc) + 56 BITS_TO_LONGS(sc->mp->m_attr_geo->blksize); 57} 58 59/* A bitmap used to hold temporary results. */ 60static inline unsigned long * 61xchk_xattr_dstmap( 62 struct xfs_scrub *sc) 63{ 64 return xchk_xattr_freemap(sc) + 65 BITS_TO_LONGS(sc->mp->m_attr_geo->blksize); 66} 67 68#endif /* __XFS_SCRUB_ATTR_H__ */