blob: e3e7d5dd29e82a0aca8456472f7cae1aceb1bfb8 [file] [log] [blame]
Thomas Gleixner328970d2019-05-24 12:04:05 +02001/* SPDX-License-Identifier: GPL-2.0-or-later */
Mark Fashehccd979b2005-12-15 14:31:24 -08002/* -*- mode: c; c-basic-offset: 8; -*-
3 * vim: noexpandtab sw=8 ts=8 sts=0:
4 *
5 * dir.h
6 *
7 * Function prototypes
8 *
9 * Copyright (C) 2002, 2004 Oracle. All rights reserved.
Mark Fashehccd979b2005-12-15 14:31:24 -080010 */
11
12#ifndef OCFS2_DIR_H
13#define OCFS2_DIR_H
14
Mark Fasheh9b7895e2008-11-12 16:27:44 -080015struct ocfs2_dx_hinfo {
16 u32 major_hash;
17 u32 minor_hash;
18};
19
Mark Fasheh4a12ca32008-11-12 15:43:34 -080020struct ocfs2_dir_lookup_result {
Mark Fasheh9b7895e2008-11-12 16:27:44 -080021 struct buffer_head *dl_leaf_bh; /* Unindexed leaf
22 * block */
23 struct ocfs2_dir_entry *dl_entry; /* Target dirent in
24 * unindexed leaf */
25
Mark Fasheh4ed8a6b2008-11-24 17:02:08 -080026 struct buffer_head *dl_dx_root_bh; /* Root of indexed
27 * tree */
Mark Fashehe7c17e42009-01-29 18:17:46 -080028
Mark Fasheh9b7895e2008-11-12 16:27:44 -080029 struct buffer_head *dl_dx_leaf_bh; /* Indexed leaf block */
30 struct ocfs2_dx_entry *dl_dx_entry; /* Target dx_entry in
31 * indexed leaf */
32 struct ocfs2_dx_hinfo dl_hinfo; /* Name hash results */
Mark Fashehe7c17e42009-01-29 18:17:46 -080033
34 struct buffer_head *dl_prev_leaf_bh;/* Previous entry in
35 * dir free space
36 * list. NULL if
37 * previous entry is
38 * dx root block. */
Mark Fasheh4a12ca32008-11-12 15:43:34 -080039};
Mark Fashehe7c17e42009-01-29 18:17:46 -080040
Mark Fasheh4a12ca32008-11-12 15:43:34 -080041void ocfs2_free_dir_lookup_result(struct ocfs2_dir_lookup_result *res);
42
43int ocfs2_find_entry(const char *name, int namelen,
44 struct inode *dir,
45 struct ocfs2_dir_lookup_result *lookup);
Mark Fasheh316f4b92007-09-07 18:21:26 -070046int ocfs2_delete_entry(handle_t *handle,
47 struct inode *dir,
Mark Fasheh4a12ca32008-11-12 15:43:34 -080048 struct ocfs2_dir_lookup_result *res);
Mark Fasheh316f4b92007-09-07 18:21:26 -070049int __ocfs2_add_entry(handle_t *handle,
50 struct inode *dir,
51 const char *name, int namelen,
52 struct inode *inode, u64 blkno,
53 struct buffer_head *parent_fe_bh,
Mark Fasheh4a12ca32008-11-12 15:43:34 -080054 struct ocfs2_dir_lookup_result *lookup);
Mark Fasheh316f4b92007-09-07 18:21:26 -070055static inline int ocfs2_add_entry(handle_t *handle,
56 struct dentry *dentry,
57 struct inode *inode, u64 blkno,
58 struct buffer_head *parent_fe_bh,
Mark Fasheh4a12ca32008-11-12 15:43:34 -080059 struct ocfs2_dir_lookup_result *lookup)
Mark Fasheh316f4b92007-09-07 18:21:26 -070060{
David Howells2b0143b2015-03-17 22:25:59 +000061 return __ocfs2_add_entry(handle, d_inode(dentry->d_parent),
Mark Fasheh316f4b92007-09-07 18:21:26 -070062 dentry->d_name.name, dentry->d_name.len,
Mark Fasheh4a12ca32008-11-12 15:43:34 -080063 inode, blkno, parent_fe_bh, lookup);
Mark Fasheh316f4b92007-09-07 18:21:26 -070064}
Mark Fasheh38760e22007-09-11 17:21:56 -070065int ocfs2_update_entry(struct inode *dir, handle_t *handle,
Mark Fasheh4a12ca32008-11-12 15:43:34 -080066 struct ocfs2_dir_lookup_result *res,
Mark Fasheh38760e22007-09-11 17:21:56 -070067 struct inode *new_entry_inode);
Mark Fasheh316f4b92007-09-07 18:21:26 -070068
Mark Fashehccd979b2005-12-15 14:31:24 -080069int ocfs2_check_dir_for_entry(struct inode *dir,
70 const char *name,
71 int namelen);
Mark Fasheh0bfbbf62007-09-12 11:19:00 -070072int ocfs2_empty_dir(struct inode *inode);
Mark Fasheh4a12ca32008-11-12 15:43:34 -080073
Mark Fashehccd979b2005-12-15 14:31:24 -080074int ocfs2_find_files_on_disk(const char *name,
75 int namelen,
76 u64 *blkno,
77 struct inode *inode,
Mark Fasheh4a12ca32008-11-12 15:43:34 -080078 struct ocfs2_dir_lookup_result *res);
Mark Fashehbe94d112007-09-11 15:22:06 -070079int ocfs2_lookup_ino_from_name(struct inode *dir, const char *name,
80 int namelen, u64 *blkno);
Al Viro3704412b2013-05-22 21:06:00 -040081int ocfs2_readdir(struct file *file, struct dir_context *ctx);
82int ocfs2_dir_foreach(struct inode *inode, struct dir_context *ctx);
Mark Fashehccd979b2005-12-15 14:31:24 -080083int ocfs2_prepare_dir_for_insert(struct ocfs2_super *osb,
84 struct inode *dir,
85 struct buffer_head *parent_fe_bh,
86 const char *name,
87 int namelen,
Mark Fasheh4a12ca32008-11-12 15:43:34 -080088 struct ocfs2_dir_lookup_result *lookup);
Mark Fashehccd979b2005-12-15 14:31:24 -080089struct ocfs2_alloc_context;
Mark Fasheh316f4b92007-09-07 18:21:26 -070090int ocfs2_fill_new_dir(struct ocfs2_super *osb,
91 handle_t *handle,
92 struct inode *parent,
93 struct inode *inode,
94 struct buffer_head *fe_bh,
Mark Fasheh9b7895e2008-11-12 16:27:44 -080095 struct ocfs2_alloc_context *data_ac,
96 struct ocfs2_alloc_context *meta_ac);
97
98int ocfs2_dx_dir_truncate(struct inode *dir, struct buffer_head *di_bh);
Mark Fasheh316f4b92007-09-07 18:21:26 -070099
Joel Beckerc175a512008-12-10 17:58:22 -0800100struct ocfs2_dir_block_trailer *ocfs2_dir_trailer_from_size(int blocksize,
101 void *data);
Mark Fashehccd979b2005-12-15 14:31:24 -0800102#endif /* OCFS2_DIR_H */