xref: /netbsd-src/sys/fs/nilfs/nilfs_subr.h (revision b17c955ea6f5039839b2e6402d7749c3419b4397)
1 /* $NetBSD: nilfs_subr.h,v 1.5 2023/01/29 16:07:14 reinoud Exp $ */
2 
3 /*
4  * Copyright (c) 2008, 2009 Reinoud Zandijk
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  */
28 
29 #ifndef _FS_NILFS_NILFS_SUBR_H_
30 #define _FS_NILFS_NILFS_SUBR_H_
31 
32 /* handies */
33 #define	VFSTONILFS(mp)	((struct nilfs_mount *)mp->mnt_data)
34 
35 /* basic calculators */
36 uint64_t nilfs_get_segnum_of_block(struct nilfs_device *nilfsdev, uint64_t blocknr);
37 void nilfs_get_segment_range(struct nilfs_device *nilfsdev, uint64_t segnum,
38 	uint64_t *seg_start, uint64_t *seg_end);
39 void nilfs_calc_mdt_consts(struct nilfs_device *nilfsdev,
40 	struct nilfs_mdt *mdt, int entry_size);
41 uint32_t crc32_le(uint32_t crc, const uint8_t *buf, size_t len);
42 
43 /* log reading / volume helpers */
44 int nilfs_get_segment_log(struct nilfs_device *nilfsdev, uint64_t *blocknr,
45 	uint64_t *offset, struct buf **bpp, int len, void *blob);
46 void nilfs_search_super_root(struct nilfs_device *nilfsdev);
47 
48 /* reading */
49 int nilfs_bread(struct nilfs_node *node, uint64_t blocknr,
50 	int flags, struct buf **bpp);
51 
52 /* btree operations */
53 int nilfs_btree_nlookup(struct nilfs_node *node, uint64_t from, uint64_t blks, uint64_t *l2vmap);
54 
55 /* vtop operations */
56 void nilfs_mdt_trans(struct nilfs_mdt *mdt, uint64_t index, uint64_t *blocknr, uint32_t *entry_in_block);
57 int nilfs_nvtop(struct nilfs_node *node, uint64_t blks, uint64_t *l2vmap, uint64_t *v2pmap);
58 
59 /* node action implementators */
60 int nilfs_get_node_raw(struct nilfs_device *nilfsdev, struct nilfs_mount *ump, uint64_t ino, struct nilfs_inode *inode, struct nilfs_node **nodep);
61 void nilfs_dispose_node(struct nilfs_node **node);
62 
63 int nilfs_grow_node(struct nilfs_node *node, uint64_t new_size);
64 int nilfs_shrink_node(struct nilfs_node *node, uint64_t new_size);
65 void nilfs_itimes(struct nilfs_node *nilfs_node, struct timespec *acc,
66 	struct timespec *mod, struct timespec *birth);
67 int  nilfs_update(struct vnode *node, struct timespec *acc,
68 	struct timespec *mod, struct timespec *birth, int updflags);
69 
70 /* return vpp? */
71 int nilfs_lookup_name_in_dir(struct vnode *dvp, const char *name, int namelen, uint64_t *ino, int *found);
72 int nilfs_create_node(struct vnode *dvp, struct vnode **vpp, struct vattr *vap, struct componentname *cnp);
73 void nilfs_delete_node(struct nilfs_node *nilfs_node);
74 
75 int nilfs_chsize(struct vnode *vp, u_quad_t newsize, kauth_cred_t cred);
76 int nilfs_dir_detach(struct nilfs_mount *ump, struct nilfs_node *dir_node, struct nilfs_node *nilfs_node, struct componentname *cnp);
77 int nilfs_dir_attach(struct nilfs_mount *ump, struct nilfs_node *dir_node, struct nilfs_node *nilfs_node, struct vattr *vap, struct componentname *cnp);
78 
79 
80 /* vnode operations */
81 int nilfs_inactive(void *v);
82 int nilfs_reclaim(void *v);
83 int nilfs_readdir(void *v);
84 int nilfs_getattr(void *v);
85 int nilfs_setattr(void *v);
86 int nilfs_pathconf(void *v);
87 int nilfs_open(void *v);
88 int nilfs_close(void *v);
89 int nilfs_access(void *v);
90 int nilfs_read(void *v);
91 int nilfs_write(void *v);
92 int nilfs_trivial_bmap(void *v);
93 int nilfs_vfsstrategy(void *v);
94 int nilfs_lookup(void *v);
95 int nilfs_create(void *v);
96 int nilfs_mknod(void *v);
97 int nilfs_link(void *);
98 int nilfs_symlink(void *v);
99 int nilfs_readlink(void *v);
100 int nilfs_rename(void *v);
101 int nilfs_remove(void *v);
102 int nilfs_mkdir(void *v);
103 int nilfs_rmdir(void *v);
104 int nilfs_fsync(void *v);
105 int nilfs_advlock(void *v);
106 
107 #endif	/* !_FS_NILFS_NILFS_SUBR_H_ */
108