Lines Matching refs:dentry

47  * dentry.
66 * Try to keep struct dentry aligned on 64 byte cachelines (this will
82 struct dentry {
85 seqcount_spinlock_t d_seq; /* per dentry seqlock */
87 struct dentry *d_parent; /* parent directory */
94 struct lockref d_lockref; /* per-dentry lock and refcount */
96 struct super_block *d_sb; /* The root of the dentry tree */
117 * dentry->d_lock spinlock nesting subclasses:
134 int (*d_revalidate)(struct dentry *, unsigned int);
135 int (*d_weak_revalidate)(struct dentry *, unsigned int);
136 int (*d_hash)(const struct dentry *, struct qstr *);
137 int (*d_compare)(const struct dentry *,
139 int (*d_delete)(const struct dentry *);
140 int (*d_init)(struct dentry *);
141 void (*d_release)(struct dentry *);
142 void (*d_prune)(struct dentry *);
143 void (*d_iput)(struct dentry *, struct inode *);
144 char *(*d_dname)(struct dentry *, char *, int);
147 struct dentry *(*d_real)(struct dentry *, enum d_real_type type);
166 /* This dentry is possibly not currently connected to the dcache tree, in
168 * well. nfsd will not use a dentry with this bit set, but will first
172 * directory inode with a DCACHE_DISCONNECTED dentry, will d_move that
173 * dentry into place and return that dentry rather than the passed one,
187 /* this dentry has been "silly renamed" and has to be deleted on the last
203 #define DCACHE_MISS_TYPE (0 << 20) /* Negative dentry */
204 #define DCACHE_WHITEOUT_TYPE (1 << 20) /* Whiteout dentry (stop pathwalk) */
223 extern void d_instantiate(struct dentry *, struct inode *);
224 extern void d_instantiate_new(struct dentry *, struct inode *);
225 extern void __d_drop(struct dentry *dentry);
226 extern void d_drop(struct dentry *dentry);
227 extern void d_delete(struct dentry *);
228 extern void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op);
231 extern struct dentry * d_alloc(struct dentry *, const struct qstr *);
232 extern struct dentry * d_alloc_anon(struct super_block *);
233 extern struct dentry * d_alloc_parallel(struct dentry *, const struct qstr *,
235 extern struct dentry * d_splice_alias(struct inode *, struct dentry *);
236 extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qstr *);
237 extern bool d_same_name(const struct dentry *dentry, const struct dentry *parent,
239 extern struct dentry * d_exact_alias(struct dentry *, struct inode *);
240 extern struct dentry *d_find_any_alias(struct inode *inode);
241 extern struct dentry * d_obtain_alias(struct inode *);
242 extern struct dentry * d_obtain_root(struct inode *);
244 extern void shrink_dcache_parent(struct dentry *);
245 extern void d_invalidate(struct dentry *);
248 extern struct dentry * d_make_root(struct inode *);
253 extern struct dentry *d_find_alias(struct inode *);
256 extern struct dentry *d_find_alias_rcu(struct inode *);
264 extern void d_rehash(struct dentry *);
266 extern void d_add(struct dentry *, struct inode *);
269 extern void d_move(struct dentry *, struct dentry *);
270 extern void d_exchange(struct dentry *, struct dentry *);
271 extern struct dentry *d_ancestor(struct dentry *, struct dentry *);
273 extern struct dentry *d_lookup(const struct dentry *, const struct qstr *);
274 extern struct dentry *d_hash_and_lookup(struct dentry *, struct qstr *);
276 static inline unsigned d_count(const struct dentry *dentry)
278 return dentry->d_lockref.count;
290 extern char *dentry_path_raw(const struct dentry *, char *, int);
291 extern char *dentry_path(const struct dentry *, char *, int);
296 * dget_dlock - get a reference to a dentry
297 * @dentry: dentry to get a reference to
299 * Given a live dentry, increment the reference count and return the dentry.
300 * Caller must hold @dentry->d_lock. Making sure that dentry is alive is
305 static inline struct dentry *dget_dlock(struct dentry *dentry)
307 dentry->d_lockref.count++;
308 return dentry;
313 * dget - get a reference to a dentry
314 * @dentry: dentry to get a reference to
316 * Given a dentry or %NULL pointer increment the reference count
317 * if appropriate and return the dentry. A dentry will not be
318 * destroyed when it has references. Conversely, a dentry with
324 * NOTE: it will spin if @dentry->d_lock is held. From the deadlock
326 * refcount/spin_unlock(), so calling it under @dentry->d_lock is
330 static inline struct dentry *dget(struct dentry *dentry)
332 if (dentry)
333 lockref_get(&dentry->d_lockref);
334 return dentry;
337 extern struct dentry *dget_parent(struct dentry *dentry);
340 * d_unhashed - is dentry hashed
341 * @dentry: entry to check
343 * Returns true if the dentry passed is not currently hashed.
345 static inline int d_unhashed(const struct dentry *dentry)
347 return hlist_bl_unhashed(&dentry->d_hash);
350 static inline int d_unlinked(const struct dentry *dentry)
352 return d_unhashed(dentry) && !IS_ROOT(dentry);
355 static inline int cant_mount(const struct dentry *dentry)
357 return (dentry->d_flags & DCACHE_CANT_MOUNT);
360 static inline void dont_mount(struct dentry *dentry)
362 spin_lock(&dentry->d_lock);
363 dentry->d_flags |= DCACHE_CANT_MOUNT;
364 spin_unlock(&dentry->d_lock);
367 extern void __d_lookup_unhash_wake(struct dentry *dentry);
369 static inline int d_in_lookup(const struct dentry *dentry)
371 return dentry->d_flags & DCACHE_PAR_LOOKUP;
374 static inline void d_lookup_done(struct dentry *dentry)
376 if (unlikely(d_in_lookup(dentry)))
377 __d_lookup_unhash_wake(dentry);
380 extern void dput(struct dentry *);
382 static inline bool d_managed(const struct dentry *dentry)
384 return dentry->d_flags & DCACHE_MANAGED_DENTRY;
387 static inline bool d_mountpoint(const struct dentry *dentry)
389 return dentry->d_flags & DCACHE_MOUNTED;
395 static inline unsigned __d_entry_type(const struct dentry *dentry)
397 return dentry->d_flags & DCACHE_ENTRY_TYPE;
400 static inline bool d_is_miss(const struct dentry *dentry)
402 return __d_entry_type(dentry) == DCACHE_MISS_TYPE;
405 static inline bool d_is_whiteout(const struct dentry *dentry)
407 return __d_entry_type(dentry) == DCACHE_WHITEOUT_TYPE;
410 static inline bool d_can_lookup(const struct dentry *dentry)
412 return __d_entry_type(dentry) == DCACHE_DIRECTORY_TYPE;
415 static inline bool d_is_autodir(const struct dentry *dentry)
417 return __d_entry_type(dentry) == DCACHE_AUTODIR_TYPE;
420 static inline bool d_is_dir(const struct dentry *dentry)
422 return d_can_lookup(dentry) || d_is_autodir(dentry);
425 static inline bool d_is_symlink(const struct dentry *dentry)
427 return __d_entry_type(dentry) == DCACHE_SYMLINK_TYPE;
430 static inline bool d_is_reg(const struct dentry *dentry)
432 return __d_entry_type(dentry) == DCACHE_REGULAR_TYPE;
435 static inline bool d_is_special(const struct dentry *dentry)
437 return __d_entry_type(dentry) == DCACHE_SPECIAL_TYPE;
440 static inline bool d_is_file(const struct dentry *dentry)
442 return d_is_reg(dentry) || d_is_special(dentry);
445 static inline bool d_is_negative(const struct dentry *dentry)
447 // TODO: check d_is_whiteout(dentry) also.
448 return d_is_miss(dentry);
456 static inline bool d_is_positive(const struct dentry *dentry)
458 return !d_is_negative(dentry);
462 * d_really_is_negative - Determine if a dentry is really negative (ignoring fallthroughs)
463 * @dentry: The dentry in question
465 * Returns true if the dentry represents either an absent name or a name that
466 * doesn't map to an inode (ie. ->d_inode is NULL). The dentry could represent
473 * the inode. (3) The dentry may have something attached to ->d_lower and the
476 static inline bool d_really_is_negative(const struct dentry *dentry)
478 return dentry->d_inode == NULL;
482 * d_really_is_positive - Determine if a dentry is really positive (ignoring fallthroughs)
483 * @dentry: The dentry in question
485 * Returns true if the dentry represents a name that maps to an inode
486 * (ie. ->d_inode is not NULL). The dentry might still represent a whiteout if
494 static inline bool d_really_is_positive(const struct dentry *dentry)
496 return dentry->d_inode != NULL;
499 static inline int simple_positive(const struct dentry *dentry)
501 return d_really_is_positive(dentry) && !d_unhashed(dentry);
512 * d_inode - Get the actual inode of this dentry
513 * @dentry: The dentry to query
518 static inline struct inode *d_inode(const struct dentry *dentry)
520 return dentry->d_inode;
524 * d_inode_rcu - Get the actual inode of this dentry with READ_ONCE()
525 * @dentry: The dentry to query
530 static inline struct inode *d_inode_rcu(const struct dentry *dentry)
532 return READ_ONCE(dentry->d_inode);
540 * if this dentry were to be opened as a file. The inode may be on the upper
541 * dentry or it may be on a lower dentry pinned by the upper.
545 static inline struct inode *d_backing_inode(const struct dentry *upper)
553 * d_real - Return the real dentry
554 * @dentry: the dentry to query
555 * @type: the type of real dentry (data or metadata)
557 * If dentry is on a union/overlay, then return the underlying, real dentry.
558 * Otherwise return the dentry itself.
562 static inline struct dentry *d_real(struct dentry *dentry, enum d_real_type type)
564 if (unlikely(dentry->d_flags & DCACHE_OP_REAL))
565 return dentry->d_op->d_real(dentry, type);
567 return dentry;
572 * @dentry: The dentry to query
574 * If dentry is on a union/overlay, then return the underlying, real inode.
577 static inline struct inode *d_real_inode(const struct dentry *dentry)
579 /* This usage of d_real() results in const dentry */
580 return d_inode(d_real((struct dentry *) dentry, D_REAL_DATA));
587 void take_dentry_name_snapshot(struct name_snapshot *, struct dentry *);
590 static inline struct dentry *d_first_child(const struct dentry *dentry)
592 return hlist_entry_safe(dentry->d_children.first, struct dentry, d_sib);
595 static inline struct dentry *d_next_sibling(const struct dentry *dentry)
597 return hlist_entry_safe(dentry->d_sib.next, struct dentry, d_sib);