1328970deSThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-or-later */
2*fa60ce2cSMasahiro Yamada /*
3ccd979bdSMark Fasheh * dir.h
4ccd979bdSMark Fasheh *
5ccd979bdSMark Fasheh * Function prototypes
6ccd979bdSMark Fasheh *
7ccd979bdSMark Fasheh * Copyright (C) 2002, 2004 Oracle. All rights reserved.
8ccd979bdSMark Fasheh */
9ccd979bdSMark Fasheh
10ccd979bdSMark Fasheh #ifndef OCFS2_DIR_H
11ccd979bdSMark Fasheh #define OCFS2_DIR_H
12ccd979bdSMark Fasheh
139b7895efSMark Fasheh struct ocfs2_dx_hinfo {
149b7895efSMark Fasheh u32 major_hash;
159b7895efSMark Fasheh u32 minor_hash;
169b7895efSMark Fasheh };
179b7895efSMark Fasheh
184a12ca3aSMark Fasheh struct ocfs2_dir_lookup_result {
199b7895efSMark Fasheh struct buffer_head *dl_leaf_bh; /* Unindexed leaf
209b7895efSMark Fasheh * block */
219b7895efSMark Fasheh struct ocfs2_dir_entry *dl_entry; /* Target dirent in
229b7895efSMark Fasheh * unindexed leaf */
239b7895efSMark Fasheh
244ed8a6bbSMark Fasheh struct buffer_head *dl_dx_root_bh; /* Root of indexed
254ed8a6bbSMark Fasheh * tree */
26e7c17e43SMark Fasheh
279b7895efSMark Fasheh struct buffer_head *dl_dx_leaf_bh; /* Indexed leaf block */
289b7895efSMark Fasheh struct ocfs2_dx_entry *dl_dx_entry; /* Target dx_entry in
299b7895efSMark Fasheh * indexed leaf */
309b7895efSMark Fasheh struct ocfs2_dx_hinfo dl_hinfo; /* Name hash results */
31e7c17e43SMark Fasheh
32e7c17e43SMark Fasheh struct buffer_head *dl_prev_leaf_bh;/* Previous entry in
33e7c17e43SMark Fasheh * dir free space
34e7c17e43SMark Fasheh * list. NULL if
35e7c17e43SMark Fasheh * previous entry is
36e7c17e43SMark Fasheh * dx root block. */
374a12ca3aSMark Fasheh };
38e7c17e43SMark Fasheh
394a12ca3aSMark Fasheh void ocfs2_free_dir_lookup_result(struct ocfs2_dir_lookup_result *res);
404a12ca3aSMark Fasheh
414a12ca3aSMark Fasheh int ocfs2_find_entry(const char *name, int namelen,
42316f4b9fSMark Fasheh struct inode *dir,
434a12ca3aSMark Fasheh struct ocfs2_dir_lookup_result *lookup);
44316f4b9fSMark Fasheh int ocfs2_delete_entry(handle_t *handle,
45316f4b9fSMark Fasheh struct inode *dir,
464a12ca3aSMark Fasheh struct ocfs2_dir_lookup_result *res);
47316f4b9fSMark Fasheh int __ocfs2_add_entry(handle_t *handle,
48316f4b9fSMark Fasheh struct inode *dir,
49316f4b9fSMark Fasheh const char *name, int namelen,
50316f4b9fSMark Fasheh struct inode *inode, u64 blkno,
51316f4b9fSMark Fasheh struct buffer_head *parent_fe_bh,
524a12ca3aSMark Fasheh 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)53316f4b9fSMark Fasheh static inline int ocfs2_add_entry(handle_t *handle,
54316f4b9fSMark Fasheh struct dentry *dentry,
55316f4b9fSMark Fasheh struct inode *inode, u64 blkno,
56316f4b9fSMark Fasheh struct buffer_head *parent_fe_bh,
574a12ca3aSMark Fasheh struct ocfs2_dir_lookup_result *lookup)
58316f4b9fSMark Fasheh {
592b0143b5SDavid Howells return __ocfs2_add_entry(handle, d_inode(dentry->d_parent),
60316f4b9fSMark Fasheh dentry->d_name.name, dentry->d_name.len,
614a12ca3aSMark Fasheh inode, blkno, parent_fe_bh, lookup);
62316f4b9fSMark Fasheh }
6338760e24SMark Fasheh int ocfs2_update_entry(struct inode *dir, handle_t *handle,
644a12ca3aSMark Fasheh struct ocfs2_dir_lookup_result *res,
6538760e24SMark Fasheh struct inode *new_entry_inode);
66316f4b9fSMark Fasheh
67ccd979bdSMark Fasheh int ocfs2_check_dir_for_entry(struct inode *dir,
68ccd979bdSMark Fasheh const char *name,
69ccd979bdSMark Fasheh int namelen);
700bfbbf62SMark Fasheh int ocfs2_empty_dir(struct inode *inode);
714a12ca3aSMark Fasheh
72ccd979bdSMark Fasheh int ocfs2_find_files_on_disk(const char *name,
73ccd979bdSMark Fasheh int namelen,
74ccd979bdSMark Fasheh u64 *blkno,
75ccd979bdSMark Fasheh struct inode *inode,
764a12ca3aSMark Fasheh struct ocfs2_dir_lookup_result *res);
77be94d117SMark Fasheh int ocfs2_lookup_ino_from_name(struct inode *dir, const char *name,
78be94d117SMark Fasheh int namelen, u64 *blkno);
793704412bSAl Viro int ocfs2_readdir(struct file *file, struct dir_context *ctx);
803704412bSAl Viro int ocfs2_dir_foreach(struct inode *inode, struct dir_context *ctx);
81ccd979bdSMark Fasheh int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb,
82ccd979bdSMark Fasheh struct inode *dir,
83ccd979bdSMark Fasheh struct buffer_head *parent_fe_bh,
84ccd979bdSMark Fasheh const char *name,
85ccd979bdSMark Fasheh int namelen,
864a12ca3aSMark Fasheh struct ocfs2_dir_lookup_result *lookup);
87ccd979bdSMark Fasheh struct ocfs2_alloc_context;
88316f4b9fSMark Fasheh int ocfs2_fill_new_dir(struct ocfs2_super *osb,
891fabe148SMark Fasheh handle_t *handle,
90316f4b9fSMark Fasheh struct inode *parent,
91316f4b9fSMark Fasheh struct inode *inode,
92316f4b9fSMark Fasheh struct buffer_head *fe_bh,
939b7895efSMark Fasheh struct ocfs2_alloc_context *data_ac,
949b7895efSMark Fasheh struct ocfs2_alloc_context *meta_ac);
959b7895efSMark Fasheh
969b7895efSMark Fasheh int ocfs2_dx_dir_truncate(struct inode *dir, struct buffer_head *di_bh);
97316f4b9fSMark Fasheh
98c175a518SJoel Becker struct ocfs2_dir_block_trailer *ocfs2_dir_trailer_from_size(int blocksize,
99c175a518SJoel Becker void *data);
100ccd979bdSMark Fasheh #endif /* OCFS2_DIR_H */
101