blob: 3ec5ec0b86789004428591b824d982a16262a829 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7b718762005-11-02 14:58:39 +11002 * Copyright (c) 2000,2002-2003,2005 Silicon Graphics, Inc.
Dave Chinner517c2222013-04-24 18:58:55 +10003 * Copyright (c) 2013 Red Hat, Inc.
Nathan Scottaa82daa2005-11-02 10:33:33 +11004 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 *
Nathan Scott7b718762005-11-02 14:58:39 +11006 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
Linus Torvalds1da177e2005-04-16 15:20:36 -07008 * published by the Free Software Foundation.
9 *
Nathan Scott7b718762005-11-02 14:58:39 +110010 * This program is distributed in the hope that it would be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
Linus Torvalds1da177e2005-04-16 15:20:36 -070014 *
Nathan Scott7b718762005-11-02 14:58:39 +110015 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Linus Torvalds1da177e2005-04-16 15:20:36 -070018 */
19#ifndef __XFS_ATTR_LEAF_H__
20#define __XFS_ATTR_LEAF_H__
21
Linus Torvalds1da177e2005-04-16 15:20:36 -070022struct attrlist;
23struct attrlist_cursor_kern;
Christoph Hellwigad9b4632008-06-23 13:23:48 +100024struct xfs_attr_list_context;
Linus Torvalds1da177e2005-04-16 15:20:36 -070025struct xfs_da_args;
26struct xfs_da_state;
27struct xfs_da_state_blk;
28struct xfs_inode;
29struct xfs_trans;
30
Linus Torvalds1da177e2005-04-16 15:20:36 -070031/*
32 * Used to keep a list of "remote value" extents when unlinking an inode.
33 */
34typedef struct xfs_attr_inactive_list {
35 xfs_dablk_t valueblk; /* block number of value bytes */
36 int valuelen; /* number of bytes in value */
37} xfs_attr_inactive_list_t;
38
39
40/*========================================================================
41 * Function prototypes for the kernel.
42 *========================================================================*/
43
44/*
Nathan Scottd8cc8902005-11-02 10:34:53 +110045 * Internal routines when attribute fork size < XFS_LITINO(mp).
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 */
Nathan Scottd8cc8902005-11-02 10:34:53 +110047void xfs_attr_shortform_create(struct xfs_da_args *args);
48void xfs_attr_shortform_add(struct xfs_da_args *args, int forkoff);
Linus Torvalds1da177e2005-04-16 15:20:36 -070049int xfs_attr_shortform_lookup(struct xfs_da_args *args);
50int xfs_attr_shortform_getvalue(struct xfs_da_args *args);
51int xfs_attr_shortform_to_leaf(struct xfs_da_args *args);
Nathan Scottd8cc8902005-11-02 10:34:53 +110052int xfs_attr_shortform_remove(struct xfs_da_args *args);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053int xfs_attr_shortform_list(struct xfs_attr_list_context *context);
Dave Chinner1d9025e2012-06-22 18:50:14 +100054int xfs_attr_shortform_allfit(struct xfs_buf *bp, struct xfs_inode *dp);
Nathan Scottd8cc8902005-11-02 10:34:53 +110055int xfs_attr_shortform_bytesfit(xfs_inode_t *dp, int bytes);
56
Linus Torvalds1da177e2005-04-16 15:20:36 -070057
58/*
Nathan Scottd8cc8902005-11-02 10:34:53 +110059 * Internal routines when attribute fork size == XFS_LBSIZE(mp).
Linus Torvalds1da177e2005-04-16 15:20:36 -070060 */
Dave Chinner517c2222013-04-24 18:58:55 +100061int xfs_attr3_leaf_to_node(struct xfs_da_args *args);
62int xfs_attr3_leaf_to_shortform(struct xfs_buf *bp,
Nathan Scottd8cc8902005-11-02 10:34:53 +110063 struct xfs_da_args *args, int forkoff);
Dave Chinner517c2222013-04-24 18:58:55 +100064int xfs_attr3_leaf_clearflag(struct xfs_da_args *args);
65int xfs_attr3_leaf_setflag(struct xfs_da_args *args);
66int xfs_attr3_leaf_flipflags(struct xfs_da_args *args);
Linus Torvalds1da177e2005-04-16 15:20:36 -070067
68/*
69 * Routines used for growing the Btree.
70 */
Dave Chinner517c2222013-04-24 18:58:55 +100071int xfs_attr3_leaf_split(struct xfs_da_state *state,
Linus Torvalds1da177e2005-04-16 15:20:36 -070072 struct xfs_da_state_blk *oldblk,
73 struct xfs_da_state_blk *newblk);
Dave Chinner517c2222013-04-24 18:58:55 +100074int xfs_attr3_leaf_lookup_int(struct xfs_buf *leaf,
Linus Torvalds1da177e2005-04-16 15:20:36 -070075 struct xfs_da_args *args);
Dave Chinner517c2222013-04-24 18:58:55 +100076int xfs_attr3_leaf_getvalue(struct xfs_buf *bp, struct xfs_da_args *args);
77int xfs_attr3_leaf_add(struct xfs_buf *leaf_buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -070078 struct xfs_da_args *args);
Dave Chinner517c2222013-04-24 18:58:55 +100079int xfs_attr3_leaf_remove(struct xfs_buf *leaf_buffer,
Linus Torvalds1da177e2005-04-16 15:20:36 -070080 struct xfs_da_args *args);
Dave Chinner517c2222013-04-24 18:58:55 +100081int xfs_attr3_leaf_list_int(struct xfs_buf *bp,
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 struct xfs_attr_list_context *context);
83
84/*
85 * Routines used for shrinking the Btree.
86 */
Dave Chinner517c2222013-04-24 18:58:55 +100087int xfs_attr3_leaf_toosmall(struct xfs_da_state *state, int *retval);
88void xfs_attr3_leaf_unbalance(struct xfs_da_state *state,
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 struct xfs_da_state_blk *drop_blk,
90 struct xfs_da_state_blk *save_blk);
Dave Chinner517c2222013-04-24 18:58:55 +100091int xfs_attr3_root_inactive(struct xfs_trans **trans, struct xfs_inode *dp);
Linus Torvalds1da177e2005-04-16 15:20:36 -070092
93/*
94 * Utility routines.
95 */
Dave Chinner1d9025e2012-06-22 18:50:14 +100096xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_buf *bp, int *count);
97int xfs_attr_leaf_order(struct xfs_buf *leaf1_bp,
98 struct xfs_buf *leaf2_bp);
Nathan Scottaa82daa2005-11-02 10:33:33 +110099int xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700100 int *local);
Dave Chinner517c2222013-04-24 18:58:55 +1000101int xfs_attr3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp,
Dave Chinnerd9392a42012-11-12 22:54:17 +1100102 xfs_dablk_t bno, xfs_daddr_t mappedbno,
103 struct xfs_buf **bpp);
Dave Chinner517c2222013-04-24 18:58:55 +1000104void xfs_attr3_leaf_hdr_from_disk(struct xfs_attr3_icleaf_hdr *to,
105 struct xfs_attr_leafblock *from);
Dave Chinnerd386b322013-08-12 20:49:31 +1000106void xfs_attr3_leaf_hdr_to_disk(struct xfs_attr_leafblock *to,
107 struct xfs_attr3_icleaf_hdr *from);
Dave Chinner1813dd62012-11-14 17:54:40 +1100108
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109#endif /* __XFS_ATTR_LEAF_H__ */