Lines Matching +full:enable +full:- +full:remote +full:- +full:sense
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (c) 2000-2005 Silicon Graphics, Inc.
30 * Remote Attribute Values
33 * Remote extended attribute values are conceptually simple -- they're written
37 * However, on a v5 filesystem, maximally sized remote attr values require one
38 * block more than 64k worth of space to hold both the remote attribute value
42 * Therefore, we /must/ ensure that remote attribute value buffers never touch
46 /* How many bytes can be stored in a remote value buffer? */
51 unsigned int blocksize = mp->m_attr_geo->blksize; in xfs_attr3_rmt_buf_space()
54 return blocksize - sizeof(struct xfs_attr3_rmt_hdr); in xfs_attr3_rmt_buf_space()
59 /* Compute number of fsblocks needed to store a remote attr value */
76 * Checking of the remote attribute header is split into two parts. The verifier
90 if (bno != be64_to_cpu(rmt->rm_blkno)) in xfs_attr3_rmt_hdr_ok()
92 if (offset != be32_to_cpu(rmt->rm_offset)) in xfs_attr3_rmt_hdr_ok()
94 if (size != be32_to_cpu(rmt->rm_bytes)) in xfs_attr3_rmt_hdr_ok()
96 if (ino != be64_to_cpu(rmt->rm_owner)) in xfs_attr3_rmt_hdr_ok()
112 if (!xfs_verify_magic(bp, rmt->rm_magic)) in xfs_attr3_rmt_verify()
114 if (!uuid_equal(&rmt->rm_uuid, &mp->m_sb.sb_meta_uuid)) in xfs_attr3_rmt_verify()
116 if (be64_to_cpu(rmt->rm_blkno) != bno) in xfs_attr3_rmt_verify()
118 if (be32_to_cpu(rmt->rm_bytes) > mp->m_attr_geo->blksize - sizeof(*rmt)) in xfs_attr3_rmt_verify()
120 if (be32_to_cpu(rmt->rm_offset) + in xfs_attr3_rmt_verify()
121 be32_to_cpu(rmt->rm_bytes) > XFS_XATTR_SIZE_MAX) in xfs_attr3_rmt_verify()
123 if (rmt->rm_owner == 0) in xfs_attr3_rmt_verify()
135 struct xfs_mount *mp = bp->b_mount; in __xfs_attr3_rmt_read_verify()
139 unsigned int blksize = mp->m_attr_geo->blksize; in __xfs_attr3_rmt_read_verify()
141 /* no verification of non-crc buffers */ in __xfs_attr3_rmt_read_verify()
145 ptr = bp->b_addr; in __xfs_attr3_rmt_read_verify()
147 len = BBTOB(bp->b_length); in __xfs_attr3_rmt_read_verify()
154 return -EFSBADCRC; in __xfs_attr3_rmt_read_verify()
158 return -EFSCORRUPTED; in __xfs_attr3_rmt_read_verify()
159 len -= blksize; in __xfs_attr3_rmt_read_verify()
166 return -EFSCORRUPTED; in __xfs_attr3_rmt_read_verify()
199 struct xfs_mount *mp = bp->b_mount; in xfs_attr3_rmt_write_verify()
201 unsigned int blksize = mp->m_attr_geo->blksize; in xfs_attr3_rmt_write_verify()
206 /* no verification of non-crc buffers */ in xfs_attr3_rmt_write_verify()
210 ptr = bp->b_addr; in xfs_attr3_rmt_write_verify()
212 len = BBTOB(bp->b_length); in xfs_attr3_rmt_write_verify()
220 xfs_verifier_error(bp, -EFSCORRUPTED, fa); in xfs_attr3_rmt_write_verify()
228 if (rmt->rm_lsn != cpu_to_be64(NULLCOMMITLSN)) { in xfs_attr3_rmt_write_verify()
229 xfs_verifier_error(bp, -EFSCORRUPTED, __this_address); in xfs_attr3_rmt_write_verify()
234 len -= blksize; in xfs_attr3_rmt_write_verify()
240 xfs_verifier_error(bp, -EFSCORRUPTED, __this_address); in xfs_attr3_rmt_write_verify()
265 rmt->rm_magic = cpu_to_be32(XFS_ATTR3_RMT_MAGIC); in xfs_attr3_rmt_hdr_set()
266 rmt->rm_offset = cpu_to_be32(offset); in xfs_attr3_rmt_hdr_set()
267 rmt->rm_bytes = cpu_to_be32(size); in xfs_attr3_rmt_hdr_set()
268 uuid_copy(&rmt->rm_uuid, &mp->m_sb.sb_meta_uuid); in xfs_attr3_rmt_hdr_set()
269 rmt->rm_owner = cpu_to_be64(ino); in xfs_attr3_rmt_hdr_set()
270 rmt->rm_blkno = cpu_to_be64(bno); in xfs_attr3_rmt_hdr_set()
273 * Remote attribute blocks are written synchronously, so we don't in xfs_attr3_rmt_hdr_set()
274 * have an LSN that we can stamp in them that makes any sense to log in xfs_attr3_rmt_hdr_set()
282 rmt->rm_lsn = cpu_to_be64(NULLCOMMITLSN); in xfs_attr3_rmt_hdr_set()
300 char *src = bp->b_addr; in xfs_attr_rmtval_copyout()
302 unsigned int len = BBTOB(bp->b_length); in xfs_attr_rmtval_copyout()
303 unsigned int blksize = mp->m_attr_geo->blksize; in xfs_attr_rmtval_copyout()
317 "remote attribute header mismatch bno/off/len/owner (0x%llx/0x%x/Ox%x/0x%llx)", in xfs_attr_rmtval_copyout()
320 return -EFSCORRUPTED; in xfs_attr_rmtval_copyout()
328 len -= blksize; in xfs_attr_rmtval_copyout()
333 *valuelen -= byte_cnt; in xfs_attr_rmtval_copyout()
349 char *dst = bp->b_addr; in xfs_attr_rmtval_copyin()
351 unsigned int len = BBTOB(bp->b_length); in xfs_attr_rmtval_copyin()
352 unsigned int blksize = mp->m_attr_geo->blksize; in xfs_attr_rmtval_copyin()
371 ASSERT(*valuelen - byte_cnt == 0); in xfs_attr_rmtval_copyin()
374 blksize - hdr_size - byte_cnt); in xfs_attr_rmtval_copyin()
378 len -= blksize; in xfs_attr_rmtval_copyin()
383 *valuelen -= byte_cnt; in xfs_attr_rmtval_copyin()
390 * Read the value associated with an attribute from the out-of-line buffer
400 struct xfs_mount *mp = args->dp->i_mount; in xfs_attr_rmtval_get()
402 xfs_dablk_t lblkno = args->rmtblkno; in xfs_attr_rmtval_get()
403 uint8_t *dst = args->value; in xfs_attr_rmtval_get()
407 unsigned int blkcnt = args->rmtblkcnt; in xfs_attr_rmtval_get()
413 ASSERT(args->valuelen != 0); in xfs_attr_rmtval_get()
414 ASSERT(args->rmtvaluelen == args->valuelen); in xfs_attr_rmtval_get()
416 valuelen = args->rmtvaluelen; in xfs_attr_rmtval_get()
419 error = xfs_bmapi_read(args->dp, (xfs_fileoff_t)lblkno, in xfs_attr_rmtval_get()
434 error = xfs_buf_read(mp->m_ddev_targp, dblkno, dblkcnt, in xfs_attr_rmtval_get()
437 xfs_dirattr_mark_sick(args->dp, XFS_ATTR_FORK); in xfs_attr_rmtval_get()
443 if (error == -ENODATA) in xfs_attr_rmtval_get()
444 error = -EIO; in xfs_attr_rmtval_get()
448 error = xfs_attr_rmtval_copyout(mp, bp, args->dp, in xfs_attr_rmtval_get()
449 args->owner, &offset, &valuelen, &dst); in xfs_attr_rmtval_get()
456 blkcnt -= map[i].br_blockcount; in xfs_attr_rmtval_get()
471 struct xfs_inode *dp = args->dp; in xfs_attr_rmt_find_hole()
472 struct xfs_mount *mp = dp->i_mount; in xfs_attr_rmt_find_hole()
478 * Because CRC enable attributes have headers, we can't just do a in xfs_attr_rmt_find_hole()
482 blkcnt = xfs_attr3_rmt_blocks(mp, args->rmtvaluelen); in xfs_attr_rmt_find_hole()
483 error = xfs_bmap_first_unused(args->trans, args->dp, blkcnt, &lfileoff, in xfs_attr_rmt_find_hole()
488 args->rmtblkno = (xfs_dablk_t)lfileoff; in xfs_attr_rmt_find_hole()
489 args->rmtblkcnt = blkcnt; in xfs_attr_rmt_find_hole()
498 struct xfs_inode *dp = args->dp; in xfs_attr_rmtval_set_value()
499 struct xfs_mount *mp = dp->i_mount; in xfs_attr_rmtval_set_value()
502 uint8_t *src = args->value; in xfs_attr_rmtval_set_value()
511 * already-allocated blocks. Blocks are written synchronously in xfs_attr_rmtval_set_value()
515 lblkno = args->rmtblkno; in xfs_attr_rmtval_set_value()
516 blkcnt = args->rmtblkcnt; in xfs_attr_rmtval_set_value()
517 valuelen = args->rmtvaluelen; in xfs_attr_rmtval_set_value()
538 error = xfs_buf_get(mp->m_ddev_targp, dblkno, dblkcnt, &bp); in xfs_attr_rmtval_set_value()
541 bp->b_ops = &xfs_attr3_rmt_buf_ops; in xfs_attr_rmtval_set_value()
543 xfs_attr_rmtval_copyin(mp, bp, args->owner, &offset, &valuelen, in xfs_attr_rmtval_set_value()
554 blkcnt -= map.br_blockcount; in xfs_attr_rmtval_set_value()
560 /* Mark stale any incore buffers for the remote value. */
567 struct xfs_mount *mp = ip->i_mount; in xfs_attr_rmtval_stale()
573 if (XFS_IS_CORRUPT(mp, map->br_startblock == DELAYSTARTBLOCK) || in xfs_attr_rmtval_stale()
574 XFS_IS_CORRUPT(mp, map->br_startblock == HOLESTARTBLOCK)) { in xfs_attr_rmtval_stale()
576 return -EFSCORRUPTED; in xfs_attr_rmtval_stale()
579 error = xfs_buf_incore(mp->m_ddev_targp, in xfs_attr_rmtval_stale()
580 XFS_FSB_TO_DADDR(mp, map->br_startblock), in xfs_attr_rmtval_stale()
581 XFS_FSB_TO_BB(mp, map->br_blockcount), in xfs_attr_rmtval_stale()
584 if (error == -ENOENT) in xfs_attr_rmtval_stale()
603 struct xfs_da_args *args = attr->xattri_da_args; in xfs_attr_rmtval_find_space()
604 struct xfs_bmbt_irec *map = &attr->xattri_map; in xfs_attr_rmtval_find_space()
607 attr->xattri_lblkno = 0; in xfs_attr_rmtval_find_space()
608 attr->xattri_blkcnt = 0; in xfs_attr_rmtval_find_space()
609 args->rmtblkcnt = 0; in xfs_attr_rmtval_find_space()
610 args->rmtblkno = 0; in xfs_attr_rmtval_find_space()
617 attr->xattri_blkcnt = args->rmtblkcnt; in xfs_attr_rmtval_find_space()
618 attr->xattri_lblkno = args->rmtblkno; in xfs_attr_rmtval_find_space()
625 * out-of-line buffer that we have defined for it. This is similar to a subset
633 struct xfs_da_args *args = attr->xattri_da_args; in xfs_attr_rmtval_set_blk()
634 struct xfs_inode *dp = args->dp; in xfs_attr_rmtval_set_blk()
635 struct xfs_bmbt_irec *map = &attr->xattri_map; in xfs_attr_rmtval_set_blk()
640 error = xfs_bmapi_write(args->trans, dp, in xfs_attr_rmtval_set_blk()
641 (xfs_fileoff_t)attr->xattri_lblkno, in xfs_attr_rmtval_set_blk()
642 attr->xattri_blkcnt, XFS_BMAPI_ATTRFORK, args->total, in xfs_attr_rmtval_set_blk()
647 ASSERT((map->br_startblock != DELAYSTARTBLOCK) && in xfs_attr_rmtval_set_blk()
648 (map->br_startblock != HOLESTARTBLOCK)); in xfs_attr_rmtval_set_blk()
651 attr->xattri_lblkno += map->br_blockcount; in xfs_attr_rmtval_set_blk()
652 attr->xattri_blkcnt -= map->br_blockcount; in xfs_attr_rmtval_set_blk()
659 * out-of-line buffer that it is stored on.
672 lblkno = args->rmtblkno; in xfs_attr_rmtval_invalidate()
673 blkcnt = args->rmtblkcnt; in xfs_attr_rmtval_invalidate()
682 error = xfs_bmapi_read(args->dp, (xfs_fileoff_t)lblkno, in xfs_attr_rmtval_invalidate()
686 if (XFS_IS_CORRUPT(args->dp->i_mount, nmap != 1)) { in xfs_attr_rmtval_invalidate()
687 xfs_bmap_mark_sick(args->dp, XFS_ATTR_FORK); in xfs_attr_rmtval_invalidate()
688 return -EFSCORRUPTED; in xfs_attr_rmtval_invalidate()
690 error = xfs_attr_rmtval_stale(args->dp, &map, XBF_TRYLOCK); in xfs_attr_rmtval_invalidate()
695 blkcnt -= map.br_blockcount; in xfs_attr_rmtval_invalidate()
701 * Remove the value associated with an attribute by deleting the out-of-line
702 * buffer that it is stored on. Returns -EAGAIN for the caller to refresh the
703 * transaction and re-call the function. Callers should keep calling this
704 * routine until it returns something other than -EAGAIN.
710 struct xfs_da_args *args = attr->xattri_da_args; in xfs_attr_rmtval_remove()
716 error = xfs_bunmapi(args->trans, args->dp, args->rmtblkno, in xfs_attr_rmtval_remove()
717 args->rmtblkcnt, XFS_BMAPI_ATTRFORK, 1, &done); in xfs_attr_rmtval_remove()
724 * attr->xattri_dela_state may be some value reminiscent of the calling in xfs_attr_rmtval_remove()
730 trace_xfs_attr_rmtval_remove_return(attr->xattri_dela_state, in xfs_attr_rmtval_remove()
731 args->dp); in xfs_attr_rmtval_remove()
732 return -EAGAIN; in xfs_attr_rmtval_remove()
735 args->rmtblkno = 0; in xfs_attr_rmtval_remove()
736 args->rmtblkcnt = 0; in xfs_attr_rmtval_remove()