blob: 4b9f5a12c7d25d54f56914f50058d0348c8dbe2c [file] [log] [blame]
Thomas Gleixner328970d2019-05-24 12:04:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Masahiro Yamadafa60ce22021-05-06 18:06:44 -07002/*
Mark Fashehccd979b2005-12-15 14:31:24 -08003 * dir.h
4 *
5 * Function prototypes
6 *
7 * Copyright (C) 2002, 2004 Oracle. All rights reserved.
Mark Fashehccd979b2005-12-15 14:31:24 -08008 */
9
10#ifndef OCFS2_DIR_H
11#define OCFS2_DIR_H
12
Mark Fasheh9b7895e2008-11-12 16:27:44 -080013struct ocfs2_dx_hinfo {
14 u32 major_hash;
15 u32 minor_hash;
16};
17
Mark Fasheh4a12ca32008-11-12 15:43:34 -080018struct ocfs2_dir_lookup_result {
Mark Fasheh9b7895e2008-11-12 16:27:44 -080019 struct buffer_head *dl_leaf_bh; /* Unindexed leaf
20 * block */
21 struct ocfs2_dir_entry *dl_entry; /* Target dirent in
22 * unindexed leaf */
23
Mark Fasheh4ed8a6b2008-11-24 17:02:08 -080024 struct buffer_head *dl_dx_root_bh; /* Root of indexed
25 * tree */
Mark Fashehe7c17e42009-01-29 18:17:46 -080026
Mark Fasheh9b7895e2008-11-12 16:27:44 -080027 struct buffer_head *dl_dx_leaf_bh; /* Indexed leaf block */
28 struct ocfs2_dx_entry *dl_dx_entry; /* Target dx_entry in
29 * indexed leaf */
30 struct ocfs2_dx_hinfo dl_hinfo; /* Name hash results */
Mark Fashehe7c17e42009-01-29 18:17:46 -080031
32 struct buffer_head *dl_prev_leaf_bh;/* Previous entry in
33 * dir free space
34 * list. NULL if
35 * previous entry is
36 * dx root block. */
Mark Fasheh4a12ca32008-11-12 15:43:34 -080037};
Mark Fashehe7c17e42009-01-29 18:17:46 -080038
Mark Fasheh4a12ca32008-11-12 15:43:34 -080039void ocfs2_free_dir_lookup_result(struct ocfs2_dir_lookup_result *res);
40
41int ocfs2_find_entry(const char *name, int namelen,
42 struct inode *dir,
43 struct ocfs2_dir_lookup_result *lookup);
Mark Fasheh316f4b92007-09-07 18:21:26 -070044int ocfs2_delete_entry(handle_t *handle,
45 struct inode *dir,
Mark Fasheh4a12ca32008-11-12 15:43:34 -080046 struct ocfs2_dir_lookup_result *res);
Mark Fasheh316f4b92007-09-07 18:21:26 -070047int __ocfs2_add_entry(handle_t *handle,
48 struct inode *dir,
49 const char *name, int namelen,
50 struct inode *inode, u64 blkno,
51 struct buffer_head *parent_fe_bh,
Mark Fasheh4a12ca32008-11-12 15:43:34 -080052 struct ocfs2_dir_lookup_result *lookup);
Mark Fasheh316f4b92007-09-07 18:21:26 -070053static inline int ocfs2_add_entry(handle_t *handle,
54 struct dentry *dentry,
55 struct inode *inode, u64 blkno,
56 struct buffer_head *parent_fe_bh,
Mark Fasheh4a12ca32008-11-12 15:43:34 -080057 struct ocfs2_dir_lookup_result *lookup)
Mark Fasheh316f4b92007-09-07 18:21:26 -070058{
David Howells2b0143b2015-03-17 22:25:59 +000059 return __ocfs2_add_entry(handle, d_inode(dentry->d_parent),
Mark Fasheh316f4b92007-09-07 18:21:26 -070060 dentry->d_name.name, dentry->d_name.len,
Mark Fasheh4a12ca32008-11-12 15:43:34 -080061 inode, blkno, parent_fe_bh, lookup);
Mark Fasheh316f4b92007-09-07 18:21:26 -070062}
Mark Fasheh38760e22007-09-11 17:21:56 -070063int ocfs2_update_entry(struct inode *dir, handle_t *handle,
Mark Fasheh4a12ca32008-11-12 15:43:34 -080064 struct ocfs2_dir_lookup_result *res,
Mark Fasheh38760e22007-09-11 17:21:56 -070065 struct inode *new_entry_inode);
Mark Fasheh316f4b92007-09-07 18:21:26 -070066
Mark Fashehccd979b2005-12-15 14:31:24 -080067int ocfs2_check_dir_for_entry(struct inode *dir,
68 const char *name,
69 int namelen);
Mark Fasheh0bfbbf62007-09-12 11:19:00 -070070int ocfs2_empty_dir(struct inode *inode);
Mark Fasheh4a12ca32008-11-12 15:43:34 -080071
Mark Fashehccd979b2005-12-15 14:31:24 -080072int ocfs2_find_files_on_disk(const char *name,
73 int namelen,
74 u64 *blkno,
75 struct inode *inode,
Mark Fasheh4a12ca32008-11-12 15:43:34 -080076 struct ocfs2_dir_lookup_result *res);
Mark Fashehbe94d112007-09-11 15:22:06 -070077int ocfs2_lookup_ino_from_name(struct inode *dir, const char *name,
78 int namelen, u64 *blkno);
Al Viro3704412b2013-05-22 21:06:00 -040079int ocfs2_readdir(struct file *file, struct dir_context *ctx);
80int ocfs2_dir_foreach(struct inode *inode, struct dir_context *ctx);
Mark Fashehccd979b2005-12-15 14:31:24 -080081int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb,
82 struct inode *dir,
83 struct buffer_head *parent_fe_bh,
84 const char *name,
85 int namelen,
Mark Fasheh4a12ca32008-11-12 15:43:34 -080086 struct ocfs2_dir_lookup_result *lookup);
Mark Fashehccd979b2005-12-15 14:31:24 -080087struct ocfs2_alloc_context;
Mark Fasheh316f4b92007-09-07 18:21:26 -070088int ocfs2_fill_new_dir(struct ocfs2_super *osb,
89 handle_t *handle,
90 struct inode *parent,
91 struct inode *inode,
92 struct buffer_head *fe_bh,
Mark Fasheh9b7895e2008-11-12 16:27:44 -080093 struct ocfs2_alloc_context *data_ac,
94 struct ocfs2_alloc_context *meta_ac);
95
96int ocfs2_dx_dir_truncate(struct inode *dir, struct buffer_head *di_bh);
Mark Fasheh316f4b92007-09-07 18:21:26 -070097
Joel Beckerc175a512008-12-10 17:58:22 -080098struct ocfs2_dir_block_trailer *ocfs2_dir_trailer_from_size(int blocksize,
99 void *data);
Mark Fashehccd979b2005-12-15 14:31:24 -0800100#endif /* OCFS2_DIR_H */