xref: /OK3568_Linux_fs/kernel/fs/ocfs2/dir.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun /* SPDX-License-Identifier: GPL-2.0-or-later */
2*4882a593Smuzhiyun /* -*- mode: c; c-basic-offset: 8; -*-
3*4882a593Smuzhiyun  * vim: noexpandtab sw=8 ts=8 sts=0:
4*4882a593Smuzhiyun  *
5*4882a593Smuzhiyun  * dir.h
6*4882a593Smuzhiyun  *
7*4882a593Smuzhiyun  * Function prototypes
8*4882a593Smuzhiyun  *
9*4882a593Smuzhiyun  * Copyright (C) 2002, 2004 Oracle.  All rights reserved.
10*4882a593Smuzhiyun  */
11*4882a593Smuzhiyun 
12*4882a593Smuzhiyun #ifndef OCFS2_DIR_H
13*4882a593Smuzhiyun #define OCFS2_DIR_H
14*4882a593Smuzhiyun 
15*4882a593Smuzhiyun struct ocfs2_dx_hinfo {
16*4882a593Smuzhiyun 	u32	major_hash;
17*4882a593Smuzhiyun 	u32	minor_hash;
18*4882a593Smuzhiyun };
19*4882a593Smuzhiyun 
20*4882a593Smuzhiyun struct ocfs2_dir_lookup_result {
21*4882a593Smuzhiyun 	struct buffer_head		*dl_leaf_bh;	/* Unindexed leaf
22*4882a593Smuzhiyun 							 * block */
23*4882a593Smuzhiyun 	struct ocfs2_dir_entry		*dl_entry;	/* Target dirent in
24*4882a593Smuzhiyun 							 * unindexed leaf */
25*4882a593Smuzhiyun 
26*4882a593Smuzhiyun 	struct buffer_head		*dl_dx_root_bh;	/* Root of indexed
27*4882a593Smuzhiyun 							 * tree */
28*4882a593Smuzhiyun 
29*4882a593Smuzhiyun 	struct buffer_head		*dl_dx_leaf_bh;	/* Indexed leaf block */
30*4882a593Smuzhiyun 	struct ocfs2_dx_entry		*dl_dx_entry;	/* Target dx_entry in
31*4882a593Smuzhiyun 							 * indexed leaf */
32*4882a593Smuzhiyun 	struct ocfs2_dx_hinfo		dl_hinfo;	/* Name hash results */
33*4882a593Smuzhiyun 
34*4882a593Smuzhiyun 	struct buffer_head		*dl_prev_leaf_bh;/* Previous entry in
35*4882a593Smuzhiyun 							  * dir free space
36*4882a593Smuzhiyun 							  * list. NULL if
37*4882a593Smuzhiyun 							  * previous entry is
38*4882a593Smuzhiyun 							  * dx root block. */
39*4882a593Smuzhiyun };
40*4882a593Smuzhiyun 
41*4882a593Smuzhiyun void ocfs2_free_dir_lookup_result(struct ocfs2_dir_lookup_result *res);
42*4882a593Smuzhiyun 
43*4882a593Smuzhiyun int ocfs2_find_entry(const char *name, int namelen,
44*4882a593Smuzhiyun 		     struct inode *dir,
45*4882a593Smuzhiyun 		     struct ocfs2_dir_lookup_result *lookup);
46*4882a593Smuzhiyun int ocfs2_delete_entry(handle_t *handle,
47*4882a593Smuzhiyun 		       struct inode *dir,
48*4882a593Smuzhiyun 		       struct ocfs2_dir_lookup_result *res);
49*4882a593Smuzhiyun int __ocfs2_add_entry(handle_t *handle,
50*4882a593Smuzhiyun 		      struct inode *dir,
51*4882a593Smuzhiyun 		      const char *name, int namelen,
52*4882a593Smuzhiyun 		      struct inode *inode, u64 blkno,
53*4882a593Smuzhiyun 		      struct buffer_head *parent_fe_bh,
54*4882a593Smuzhiyun 		      struct ocfs2_dir_lookup_result *lookup);
ocfs2_add_entry(handle_t * handle,struct dentry * dentry,struct inode * inode,u64 blkno,struct buffer_head * parent_fe_bh,struct ocfs2_dir_lookup_result * lookup)55*4882a593Smuzhiyun static inline int ocfs2_add_entry(handle_t *handle,
56*4882a593Smuzhiyun 				  struct dentry *dentry,
57*4882a593Smuzhiyun 				  struct inode *inode, u64 blkno,
58*4882a593Smuzhiyun 				  struct buffer_head *parent_fe_bh,
59*4882a593Smuzhiyun 				  struct ocfs2_dir_lookup_result *lookup)
60*4882a593Smuzhiyun {
61*4882a593Smuzhiyun 	return __ocfs2_add_entry(handle, d_inode(dentry->d_parent),
62*4882a593Smuzhiyun 				 dentry->d_name.name, dentry->d_name.len,
63*4882a593Smuzhiyun 				 inode, blkno, parent_fe_bh, lookup);
64*4882a593Smuzhiyun }
65*4882a593Smuzhiyun int ocfs2_update_entry(struct inode *dir, handle_t *handle,
66*4882a593Smuzhiyun 		       struct ocfs2_dir_lookup_result *res,
67*4882a593Smuzhiyun 		       struct inode *new_entry_inode);
68*4882a593Smuzhiyun 
69*4882a593Smuzhiyun int ocfs2_check_dir_for_entry(struct inode *dir,
70*4882a593Smuzhiyun 			      const char *name,
71*4882a593Smuzhiyun 			      int namelen);
72*4882a593Smuzhiyun int ocfs2_empty_dir(struct inode *inode);
73*4882a593Smuzhiyun 
74*4882a593Smuzhiyun int ocfs2_find_files_on_disk(const char *name,
75*4882a593Smuzhiyun 			     int namelen,
76*4882a593Smuzhiyun 			     u64 *blkno,
77*4882a593Smuzhiyun 			     struct inode *inode,
78*4882a593Smuzhiyun 			     struct ocfs2_dir_lookup_result *res);
79*4882a593Smuzhiyun int ocfs2_lookup_ino_from_name(struct inode *dir, const char *name,
80*4882a593Smuzhiyun 			       int namelen, u64 *blkno);
81*4882a593Smuzhiyun int ocfs2_readdir(struct file *file, struct dir_context *ctx);
82*4882a593Smuzhiyun int ocfs2_dir_foreach(struct inode *inode, struct dir_context *ctx);
83*4882a593Smuzhiyun int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb,
84*4882a593Smuzhiyun 				 struct inode *dir,
85*4882a593Smuzhiyun 				 struct buffer_head *parent_fe_bh,
86*4882a593Smuzhiyun 				 const char *name,
87*4882a593Smuzhiyun 				 int namelen,
88*4882a593Smuzhiyun 				 struct ocfs2_dir_lookup_result *lookup);
89*4882a593Smuzhiyun struct ocfs2_alloc_context;
90*4882a593Smuzhiyun int ocfs2_fill_new_dir(struct ocfs2_super *osb,
91*4882a593Smuzhiyun 		       handle_t *handle,
92*4882a593Smuzhiyun 		       struct inode *parent,
93*4882a593Smuzhiyun 		       struct inode *inode,
94*4882a593Smuzhiyun 		       struct buffer_head *fe_bh,
95*4882a593Smuzhiyun 		       struct ocfs2_alloc_context *data_ac,
96*4882a593Smuzhiyun 		       struct ocfs2_alloc_context *meta_ac);
97*4882a593Smuzhiyun 
98*4882a593Smuzhiyun int ocfs2_dx_dir_truncate(struct inode *dir, struct buffer_head *di_bh);
99*4882a593Smuzhiyun 
100*4882a593Smuzhiyun struct ocfs2_dir_block_trailer *ocfs2_dir_trailer_from_size(int blocksize,
101*4882a593Smuzhiyun 							    void *data);
102*4882a593Smuzhiyun #endif /* OCFS2_DIR_H */
103