mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
* remotes/msm-4.9/tmp-39dae59: Linux 4.14-rc8 x86/module: Detect and skip invalid relocations objtool: Prevent GCC from merging annotate_unreachable(), take 2 Revert "x86/mm: Stop calling leave_mm() in idle code" Documentation: Add Frank Rowand to list of enforcement statement endorsers doc: add Willy Tarreau to the list of enforcement statement endorsers tools/headers: Synchronize kernel ABI headers objtool: Resync objtool's instruction decoder source code copy with the kernel's latest version Input: sparse-keymap - send sync event for KE_SW/KE_VSW Input: ar1021_i2c - set INPUT_PROP_DIRECT arch/tile: Implement ->set_state_oneshot_stopped() Update MIPS email addresses x86: CPU: Fix up "cpu MHz" in /proc/cpuinfo mm, swap: fix race between swap count continuation operations mm/huge_memory.c: deposit page table when copying a PMD migration entry initramfs: fix initramfs rebuilds w/ compression after disabling fs/hugetlbfs/inode.c: fix hwpoison reserve accounting ocfs2: fstrim: Fix start offset of first cluster group during fstrim mm, /proc/pid/pagemap: fix soft dirty marking for PMD migration entry userfaultfd: hugetlbfs: prevent UFFDIO_COPY to fill beyond the end of i_size Documentation: Add Tim Bird to list of enforcement statement endorsers net: systemport: Correct IPG length settings tcp: do not mangle skb->cb[] in tcp_make_synack() fib: fib_dump_info can no longer use __in_dev_get_rtnl stmmac: use of_property_read_u32 instead of read_u8 net_sched: hold netns refcnt for each action net_sched: acquire RTNL in tc_action_net_exit() powerpc/perf: Fix core-imc hotplug callback failure during imc initialization Kbuild: don't pass "-C" to preprocessor when processing linker scripts Revert "x86: do not use cpufreq_quick_get() for /proc/cpuinfo "cpu MHz"" arm64: ensure __dump_instr() checks addr_limit KVM: x86: Update APICv on APIC reset KVM: VMX: Do not fully reset PI descriptor on vCPU reset kvm: Return -ENODEV from update_persistent_clock futex: futex_wake_op, do not fail on invalid op MIPS: Update email address for Marcin Nowakowski License cleanup: add SPDX license identifier to uapi header files with a license License cleanup: add SPDX license identifier to uapi header files with no license License cleanup: add SPDX GPL-2.0 license identifier to files with no license KEYS: fix out-of-bounds read during ASN.1 parsing KEYS: trusted: fix writing past end of buffer in trusted_read() KEYS: return full count in keyring_read() if buffer is too small net: vrf: correct FRA_L3MDEV encode type tcp_nv: fix division by zero in tcpnv_acked() drm/amdgpu: allow harvesting check for Polaris VCE drm/amdgpu: return -ENOENT from uvd 6.0 early init for harvesting ARM: add debug ".edata_real" symbol MIPS: smp-cmp: Fix vpe_id build error MAINTAINERS: Update Pistachio platform maintainers MIPS: smp-cmp: Use right include for task_struct signal: Fix name of SIGEMT in #if defined() check MIPS: Update Goldfish RTC driver maintainer email address MIPS: Update RINT emulation maintainer email address MIPS: CPS: Fix use of current_cpu_data in preemptible code x86/mcelog: Get rid of RCU remnants watchdog/hardlockup/perf: Use atomics to track in-use cpu counter watchdog/harclockup/perf: Revert a33d44843d45 ("watchdog/hardlockup/perf: Simplify deferred event destroy") ARM: 8716/1: pass endianness info to sparse drm/i915: Check incoming alignment for unfenced buffers (on i915gm) x86/mm: fix use-after-free of vma during userfaultfd fault ide:ide-cd: fix kernel panic resulting from missing scsi_req_init mmc: dw_mmc: Fix the DTO timeout calculation tcp: fix tcp_mtu_probe() vs highest_sack ipv6: addrconf: increment ifp refcount before ipv6_del_addr() tun/tap: sanitize TUNSETSNDBUF input mlxsw: i2c: Fix buffer increment counter for write transaction netfilter: nf_reject_ipv4: Fix use-after-free in send_reset futex: Fix more put_pi_state() vs. exit_pi_state_list() races powerpc/kprobes: Dereference function pointers only if the address does not belong to kernel text Revert "powerpc64/elfv1: Only dereference function descriptor for non-text symbols" mlxsw: reg: Add high and low temperature thresholds MAINTAINERS: Remove Yotam from mlxfw MAINTAINERS: Update Yotam's E-mail net: hns: set correct return value net: lapbether: fix double free bpf: remove SK_REDIRECT from UAPI net: phy: marvell: Only configure RGMII delays when using RGMII MIPS: SMP: Fix deadlock & online race MIPS: bpf: Fix a typo in build_one_insn() MIPS: microMIPS: Fix incorrect mask in insn_table_MM MIPS: Fix CM region target definitions MIPS: generic: Fix compilation error from include asm/mips-cpc.h MIPS: Fix exception entry when CONFIG_EVA enabled irqchip/irq-mvebu-gicp: Add missing spin_lock init drm/nouveau/kms/nv50: use the correct state for base channel notifier setup MIPS: generic: Fix NI 169445 its build Update MIPS email addresses tile: pass machine size to sparse selftests: lib.mk: print individual test results to console by default RDMA/nldev: Enforce device index check for port callback Revert "PM / QoS: Fix device resume latency PM QoS" Revert "PM / QoS: Fix default runtime_pm device resume latency" scsi: qla2xxx: Fix oops in qla2x00_probe_one error path xfrm: Fix GSO for IPsec with GRE tunnel. ALSA: seq: Fix nested rwsem annotation for lockdep splat ALSA: timer: Add missing mutex lock for compat ioctls tc-testing: fix arg to ip command: -s -> -n net_sched: remove tcf_block_put_deferred() l2tp: hold tunnel in pppol2tp_connect() drm/i915: Hold rcu_read_lock when iterating over the radixtree (vma idr) drm/i915: Hold rcu_read_lock when iterating over the radixtree (objects) drm/i915/edp: read edp display control registers unconditionally drm/i915: Do not rely on wm preservation for ILK watermarks drm/i915: Cancel the modeset retry work during modeset cleanup Mark 'ioremap_page_range()' as possibly sleeping nvme: Fix setting logical block format when revalidating mmc: dw_mmc: Add locking to the CTO timer mmc: dw_mmc: Fix the CTO timeout calculation mmc: dw_mmc: cancel the CTO timer after a voltage switch perf/cgroup: Fix perf cgroup hierarchy support PM / QoS: Fix default runtime_pm device resume latency Revert "ath10k: fix napi_poll budget overflow" ath10k: rebuild crypto header in rx data frames cifs: check MaxPathNameComponentLength != 0 before using it KVM: arm/arm64: vgic-its: Check GITS_BASER Valid bit before saving tables KVM: arm/arm64: vgic-its: Check CBASER/BASER validity before enabling the ITS KVM: arm/arm64: vgic-its: Fix vgic_its_restore_collection_table returned value KVM: arm/arm64: vgic-its: Fix return value for device table restore efi/libstub: arm: omit sorting of the UEFI memory map perf tools: Unwind properly location after REJECT virtio_blk: Fix an SG_IO regression wcn36xx: Remove unnecessary rcu_read_unlock in wcn36xx_bss_info_changed ARM: dts: mvebu: pl310-cache disable double-linefill xfrm: Clear sk_dst_cache when applying per-socket policy. perf symbols: Fix memory corruption because of zero length symbols powerpc/64s/radix: Fix preempt imbalance in TLB flush netfilter: nft_set_hash: disable fast_ops for 2-len keys powerpc: Fix check for copy/paste instructions in alignment handler powerpc/perf: Fix IMC allocation routine xfrm: Fix xfrm_dst_cache memleak ARM: 8715/1: add a private asm/unaligned.h clk: uniphier: fix clock data for PXs3 Documentation: Add my name to kernel enforcement statement nvme-rdma: fix possible hang when issuing commands during ctrl removal arm/arm64: kvm: Disable branch profiling in HYP code arm/arm64: kvm: Move initialization completion message arm/arm64: KVM: set right LR register value for 32 bit guest when inject abort Documentation: kernel-enforcement-statement.rst: proper sort names ASoC: rt5616: fix 0x91 default value Documentation: Add Arm Ltd to kernel-enforcement-statement.rst arm64: dts: uniphier: add STDMAC clock to EHCI nodes ARM: dts: uniphier: add STDMAC clock to EHCI nodes mmc: renesas_sdhi: fix kernel panic in _internal_dmac.c mmc: tmio: fix swiotlb buffer is full Documentation: kernel-enforcement-statement.rst: Remove Red Hat markings Documentation: Add myself to the enforcement statement list Documentation: Sign kernel enforcement statement Add ack for Trond Myklebust to the enforcement statement Documentation: update kernel enforcement support list Documentation: add my name to supporters ASoC: rt5659: connect LOUT Amp with Charge Pump ASoC: rt5659: register power bit of LOUT Amp KVM: arm64: its: Fix missing dynamic allocation check in scan_its_table crypto: x86/chacha20 - satisfy stack validation 2.0 ASoC: rt5663: Change the dev getting function in rt5663_irq ASoC: rt5514: Revert Hotword Model control ASoC: topology: Fix a potential memory leak in 'soc_tplg_dapm_widget_denum_create()' ASoC: topology: Fix a potential NULL pointer dereference in 'soc_tplg_dapm_widget_denum_create()' ASoC: rt5514-spi: check irq status to schedule data copy ASoC: adau17x1: Workaround for noise bug in ADC Conflicts: drivers/gpu/drm/msm/Makefile drivers/soc/qcom/Makefile drivers/staging/android/ion/Makefile include/linux/coresight-stm.h include/trace/events/kmem.h Change-Id: I01f1779762b652b9213924caa3d54f29cf03d285 Signed-off-by: Runmin Wang <runminw@codeaurora.org>
613 lines
19 KiB
C
613 lines
19 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef __LINUX_DCACHE_H
|
|
#define __LINUX_DCACHE_H
|
|
|
|
#include <linux/atomic.h>
|
|
#include <linux/list.h>
|
|
#include <linux/rculist.h>
|
|
#include <linux/rculist_bl.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/seqlock.h>
|
|
#include <linux/cache.h>
|
|
#include <linux/rcupdate.h>
|
|
#include <linux/lockref.h>
|
|
#include <linux/stringhash.h>
|
|
#include <linux/wait.h>
|
|
|
|
struct path;
|
|
struct vfsmount;
|
|
|
|
/*
|
|
* linux/include/linux/dcache.h
|
|
*
|
|
* Dirent cache data structures
|
|
*
|
|
* (C) Copyright 1997 Thomas Schoebel-Theuer,
|
|
* with heavy changes by Linus Torvalds
|
|
*/
|
|
|
|
#define IS_ROOT(x) ((x) == (x)->d_parent)
|
|
|
|
/* The hash is always the low bits of hash_len */
|
|
#ifdef __LITTLE_ENDIAN
|
|
#define HASH_LEN_DECLARE u32 hash; u32 len
|
|
#define bytemask_from_count(cnt) (~(~0ul << (cnt)*8))
|
|
#else
|
|
#define HASH_LEN_DECLARE u32 len; u32 hash
|
|
#define bytemask_from_count(cnt) (~(~0ul >> (cnt)*8))
|
|
#endif
|
|
|
|
/*
|
|
* "quick string" -- eases parameter passing, but more importantly
|
|
* saves "metadata" about the string (ie length and the hash).
|
|
*
|
|
* hash comes first so it snuggles against d_parent in the
|
|
* dentry.
|
|
*/
|
|
struct qstr {
|
|
union {
|
|
struct {
|
|
HASH_LEN_DECLARE;
|
|
};
|
|
u64 hash_len;
|
|
};
|
|
const unsigned char *name;
|
|
};
|
|
|
|
#define QSTR_INIT(n,l) { { { .len = l } }, .name = n }
|
|
|
|
extern const char empty_string[];
|
|
extern const struct qstr empty_name;
|
|
extern const char slash_string[];
|
|
extern const struct qstr slash_name;
|
|
|
|
struct dentry_stat_t {
|
|
long nr_dentry;
|
|
long nr_unused;
|
|
long age_limit; /* age in seconds */
|
|
long want_pages; /* pages requested by system */
|
|
long dummy[2];
|
|
};
|
|
extern struct dentry_stat_t dentry_stat;
|
|
|
|
/*
|
|
* Try to keep struct dentry aligned on 64 byte cachelines (this will
|
|
* give reasonable cacheline footprint with larger lines without the
|
|
* large memory footprint increase).
|
|
*/
|
|
#ifdef CONFIG_64BIT
|
|
# define DNAME_INLINE_LEN 32 /* 192 bytes */
|
|
#else
|
|
# ifdef CONFIG_SMP
|
|
# define DNAME_INLINE_LEN 36 /* 128 bytes */
|
|
# else
|
|
# define DNAME_INLINE_LEN 40 /* 128 bytes */
|
|
# endif
|
|
#endif
|
|
|
|
#define d_lock d_lockref.lock
|
|
|
|
struct dentry {
|
|
/* RCU lookup touched fields */
|
|
unsigned int d_flags; /* protected by d_lock */
|
|
seqcount_t d_seq; /* per dentry seqlock */
|
|
struct hlist_bl_node d_hash; /* lookup hash list */
|
|
struct dentry *d_parent; /* parent directory */
|
|
struct qstr d_name;
|
|
struct inode *d_inode; /* Where the name belongs to - NULL is
|
|
* negative */
|
|
unsigned char d_iname[DNAME_INLINE_LEN]; /* small names */
|
|
|
|
/* Ref lookup also touches following */
|
|
struct lockref d_lockref; /* per-dentry lock and refcount */
|
|
const struct dentry_operations *d_op;
|
|
struct super_block *d_sb; /* The root of the dentry tree */
|
|
unsigned long d_time; /* used by d_revalidate */
|
|
void *d_fsdata; /* fs-specific data */
|
|
|
|
union {
|
|
struct list_head d_lru; /* LRU list */
|
|
wait_queue_head_t *d_wait; /* in-lookup ones only */
|
|
};
|
|
struct list_head d_child; /* child of parent list */
|
|
struct list_head d_subdirs; /* our children */
|
|
/*
|
|
* d_alias and d_rcu can share memory
|
|
*/
|
|
union {
|
|
struct hlist_node d_alias; /* inode alias list */
|
|
struct hlist_bl_node d_in_lookup_hash; /* only for in-lookup ones */
|
|
struct rcu_head d_rcu;
|
|
} d_u;
|
|
} __randomize_layout;
|
|
|
|
/*
|
|
* dentry->d_lock spinlock nesting subclasses:
|
|
*
|
|
* 0: normal
|
|
* 1: nested
|
|
*/
|
|
enum dentry_d_lock_class
|
|
{
|
|
DENTRY_D_LOCK_NORMAL, /* implicitly used by plain spin_lock() APIs. */
|
|
DENTRY_D_LOCK_NESTED
|
|
};
|
|
|
|
struct dentry_operations {
|
|
int (*d_revalidate)(struct dentry *, unsigned int);
|
|
int (*d_weak_revalidate)(struct dentry *, unsigned int);
|
|
int (*d_hash)(const struct dentry *, struct qstr *);
|
|
int (*d_compare)(const struct dentry *,
|
|
unsigned int, const char *, const struct qstr *);
|
|
int (*d_delete)(const struct dentry *);
|
|
int (*d_init)(struct dentry *);
|
|
void (*d_release)(struct dentry *);
|
|
void (*d_prune)(struct dentry *);
|
|
void (*d_iput)(struct dentry *, struct inode *);
|
|
char *(*d_dname)(struct dentry *, char *, int);
|
|
struct vfsmount *(*d_automount)(struct path *);
|
|
int (*d_manage)(const struct path *, bool);
|
|
struct dentry *(*d_real)(struct dentry *, const struct inode *,
|
|
unsigned int, unsigned int);
|
|
void (*d_canonical_path)(const struct path *, struct path *);
|
|
} ____cacheline_aligned;
|
|
|
|
/*
|
|
* Locking rules for dentry_operations callbacks are to be found in
|
|
* Documentation/filesystems/Locking. Keep it updated!
|
|
*
|
|
* FUrther descriptions are found in Documentation/filesystems/vfs.txt.
|
|
* Keep it updated too!
|
|
*/
|
|
|
|
/* d_flags entries */
|
|
#define DCACHE_OP_HASH 0x00000001
|
|
#define DCACHE_OP_COMPARE 0x00000002
|
|
#define DCACHE_OP_REVALIDATE 0x00000004
|
|
#define DCACHE_OP_DELETE 0x00000008
|
|
#define DCACHE_OP_PRUNE 0x00000010
|
|
|
|
#define DCACHE_DISCONNECTED 0x00000020
|
|
/* This dentry is possibly not currently connected to the dcache tree, in
|
|
* which case its parent will either be itself, or will have this flag as
|
|
* well. nfsd will not use a dentry with this bit set, but will first
|
|
* endeavour to clear the bit either by discovering that it is connected,
|
|
* or by performing lookup operations. Any filesystem which supports
|
|
* nfsd_operations MUST have a lookup function which, if it finds a
|
|
* directory inode with a DCACHE_DISCONNECTED dentry, will d_move that
|
|
* dentry into place and return that dentry rather than the passed one,
|
|
* typically using d_splice_alias. */
|
|
|
|
#define DCACHE_REFERENCED 0x00000040 /* Recently used, don't discard. */
|
|
#define DCACHE_RCUACCESS 0x00000080 /* Entry has ever been RCU-visible */
|
|
|
|
#define DCACHE_CANT_MOUNT 0x00000100
|
|
#define DCACHE_GENOCIDE 0x00000200
|
|
#define DCACHE_SHRINK_LIST 0x00000400
|
|
|
|
#define DCACHE_OP_WEAK_REVALIDATE 0x00000800
|
|
|
|
#define DCACHE_NFSFS_RENAMED 0x00001000
|
|
/* this dentry has been "silly renamed" and has to be deleted on the last
|
|
* dput() */
|
|
#define DCACHE_COOKIE 0x00002000 /* For use by dcookie subsystem */
|
|
#define DCACHE_FSNOTIFY_PARENT_WATCHED 0x00004000
|
|
/* Parent inode is watched by some fsnotify listener */
|
|
|
|
#define DCACHE_DENTRY_KILLED 0x00008000
|
|
|
|
#define DCACHE_MOUNTED 0x00010000 /* is a mountpoint */
|
|
#define DCACHE_NEED_AUTOMOUNT 0x00020000 /* handle automount on this dir */
|
|
#define DCACHE_MANAGE_TRANSIT 0x00040000 /* manage transit from this dirent */
|
|
#define DCACHE_MANAGED_DENTRY \
|
|
(DCACHE_MOUNTED|DCACHE_NEED_AUTOMOUNT|DCACHE_MANAGE_TRANSIT)
|
|
|
|
#define DCACHE_LRU_LIST 0x00080000
|
|
|
|
#define DCACHE_ENTRY_TYPE 0x00700000
|
|
#define DCACHE_MISS_TYPE 0x00000000 /* Negative dentry (maybe fallthru to nowhere) */
|
|
#define DCACHE_WHITEOUT_TYPE 0x00100000 /* Whiteout dentry (stop pathwalk) */
|
|
#define DCACHE_DIRECTORY_TYPE 0x00200000 /* Normal directory */
|
|
#define DCACHE_AUTODIR_TYPE 0x00300000 /* Lookupless directory (presumed automount) */
|
|
#define DCACHE_REGULAR_TYPE 0x00400000 /* Regular file type (or fallthru to such) */
|
|
#define DCACHE_SPECIAL_TYPE 0x00500000 /* Other file type (or fallthru to such) */
|
|
#define DCACHE_SYMLINK_TYPE 0x00600000 /* Symlink (or fallthru to such) */
|
|
|
|
#define DCACHE_MAY_FREE 0x00800000
|
|
#define DCACHE_FALLTHRU 0x01000000 /* Fall through to lower layer */
|
|
#define DCACHE_ENCRYPTED_WITH_KEY 0x02000000 /* dir is encrypted with a valid key */
|
|
#define DCACHE_OP_REAL 0x04000000
|
|
|
|
#define DCACHE_PAR_LOOKUP 0x10000000 /* being looked up (with parent locked shared) */
|
|
#define DCACHE_DENTRY_CURSOR 0x20000000
|
|
|
|
extern seqlock_t rename_lock;
|
|
|
|
/*
|
|
* These are the low-level FS interfaces to the dcache..
|
|
*/
|
|
extern void d_instantiate(struct dentry *, struct inode *);
|
|
extern struct dentry * d_instantiate_unique(struct dentry *, struct inode *);
|
|
extern int d_instantiate_no_diralias(struct dentry *, struct inode *);
|
|
extern void __d_drop(struct dentry *dentry);
|
|
extern void d_drop(struct dentry *dentry);
|
|
extern void d_delete(struct dentry *);
|
|
extern void d_set_d_op(struct dentry *dentry, const struct dentry_operations *op);
|
|
|
|
/* allocate/de-allocate */
|
|
extern struct dentry * d_alloc(struct dentry *, const struct qstr *);
|
|
extern struct dentry * d_alloc_pseudo(struct super_block *, const struct qstr *);
|
|
extern struct dentry * d_alloc_parallel(struct dentry *, const struct qstr *,
|
|
wait_queue_head_t *);
|
|
extern struct dentry * d_splice_alias(struct inode *, struct dentry *);
|
|
extern struct dentry * d_add_ci(struct dentry *, struct inode *, struct qstr *);
|
|
extern struct dentry * d_exact_alias(struct dentry *, struct inode *);
|
|
extern struct dentry *d_find_any_alias(struct inode *inode);
|
|
extern struct dentry * d_obtain_alias(struct inode *);
|
|
extern struct dentry * d_obtain_root(struct inode *);
|
|
extern void shrink_dcache_sb(struct super_block *);
|
|
extern void shrink_dcache_parent(struct dentry *);
|
|
extern void shrink_dcache_for_umount(struct super_block *);
|
|
extern void d_invalidate(struct dentry *);
|
|
|
|
/* only used at mount-time */
|
|
extern struct dentry * d_make_root(struct inode *);
|
|
|
|
/* <clickety>-<click> the ramfs-type tree */
|
|
extern void d_genocide(struct dentry *);
|
|
|
|
extern void d_tmpfile(struct dentry *, struct inode *);
|
|
|
|
extern struct dentry *d_find_alias(struct inode *);
|
|
extern void d_prune_aliases(struct inode *);
|
|
|
|
/* test whether we have any submounts in a subdir tree */
|
|
extern int path_has_submounts(const struct path *);
|
|
|
|
/*
|
|
* This adds the entry to the hash queues.
|
|
*/
|
|
extern void d_rehash(struct dentry *);
|
|
|
|
extern void d_add(struct dentry *, struct inode *);
|
|
|
|
extern void dentry_update_name_case(struct dentry *, const struct qstr *);
|
|
|
|
/* used for rename() and baskets */
|
|
extern void d_move(struct dentry *, struct dentry *);
|
|
extern void d_exchange(struct dentry *, struct dentry *);
|
|
extern struct dentry *d_ancestor(struct dentry *, struct dentry *);
|
|
|
|
/* appendix may either be NULL or be used for transname suffixes */
|
|
extern struct dentry *d_lookup(const struct dentry *, const struct qstr *);
|
|
extern struct dentry *d_hash_and_lookup(struct dentry *, struct qstr *);
|
|
extern struct dentry *__d_lookup(const struct dentry *, const struct qstr *);
|
|
extern struct dentry *__d_lookup_rcu(const struct dentry *parent,
|
|
const struct qstr *name, unsigned *seq);
|
|
|
|
static inline unsigned d_count(const struct dentry *dentry)
|
|
{
|
|
return dentry->d_lockref.count;
|
|
}
|
|
|
|
/*
|
|
* helper function for dentry_operations.d_dname() members
|
|
*/
|
|
extern __printf(4, 5)
|
|
char *dynamic_dname(struct dentry *, char *, int, const char *, ...);
|
|
extern char *simple_dname(struct dentry *, char *, int);
|
|
|
|
extern char *__d_path(const struct path *, const struct path *, char *, int);
|
|
extern char *d_absolute_path(const struct path *, char *, int);
|
|
extern char *d_path(const struct path *, char *, int);
|
|
extern char *dentry_path_raw(struct dentry *, char *, int);
|
|
extern char *dentry_path(struct dentry *, char *, int);
|
|
|
|
/* Allocation counts.. */
|
|
|
|
/**
|
|
* dget, dget_dlock - get a reference to a dentry
|
|
* @dentry: dentry to get a reference to
|
|
*
|
|
* Given a dentry or %NULL pointer increment the reference count
|
|
* if appropriate and return the dentry. A dentry will not be
|
|
* destroyed when it has references.
|
|
*/
|
|
static inline struct dentry *dget_dlock(struct dentry *dentry)
|
|
{
|
|
if (dentry)
|
|
dentry->d_lockref.count++;
|
|
return dentry;
|
|
}
|
|
|
|
static inline struct dentry *dget(struct dentry *dentry)
|
|
{
|
|
if (dentry)
|
|
lockref_get(&dentry->d_lockref);
|
|
return dentry;
|
|
}
|
|
|
|
extern struct dentry *dget_parent(struct dentry *dentry);
|
|
|
|
/**
|
|
* d_unhashed - is dentry hashed
|
|
* @dentry: entry to check
|
|
*
|
|
* Returns true if the dentry passed is not currently hashed.
|
|
*/
|
|
|
|
static inline int d_unhashed(const struct dentry *dentry)
|
|
{
|
|
return hlist_bl_unhashed(&dentry->d_hash);
|
|
}
|
|
|
|
static inline int d_unlinked(const struct dentry *dentry)
|
|
{
|
|
return d_unhashed(dentry) && !IS_ROOT(dentry);
|
|
}
|
|
|
|
static inline int cant_mount(const struct dentry *dentry)
|
|
{
|
|
return (dentry->d_flags & DCACHE_CANT_MOUNT);
|
|
}
|
|
|
|
static inline void dont_mount(struct dentry *dentry)
|
|
{
|
|
spin_lock(&dentry->d_lock);
|
|
dentry->d_flags |= DCACHE_CANT_MOUNT;
|
|
spin_unlock(&dentry->d_lock);
|
|
}
|
|
|
|
extern void __d_lookup_done(struct dentry *);
|
|
|
|
static inline int d_in_lookup(struct dentry *dentry)
|
|
{
|
|
return dentry->d_flags & DCACHE_PAR_LOOKUP;
|
|
}
|
|
|
|
static inline void d_lookup_done(struct dentry *dentry)
|
|
{
|
|
if (unlikely(d_in_lookup(dentry))) {
|
|
spin_lock(&dentry->d_lock);
|
|
__d_lookup_done(dentry);
|
|
spin_unlock(&dentry->d_lock);
|
|
}
|
|
}
|
|
|
|
extern void dput(struct dentry *);
|
|
|
|
static inline bool d_managed(const struct dentry *dentry)
|
|
{
|
|
return dentry->d_flags & DCACHE_MANAGED_DENTRY;
|
|
}
|
|
|
|
static inline bool d_mountpoint(const struct dentry *dentry)
|
|
{
|
|
return dentry->d_flags & DCACHE_MOUNTED;
|
|
}
|
|
|
|
/*
|
|
* Directory cache entry type accessor functions.
|
|
*/
|
|
static inline unsigned __d_entry_type(const struct dentry *dentry)
|
|
{
|
|
return dentry->d_flags & DCACHE_ENTRY_TYPE;
|
|
}
|
|
|
|
static inline bool d_is_miss(const struct dentry *dentry)
|
|
{
|
|
return __d_entry_type(dentry) == DCACHE_MISS_TYPE;
|
|
}
|
|
|
|
static inline bool d_is_whiteout(const struct dentry *dentry)
|
|
{
|
|
return __d_entry_type(dentry) == DCACHE_WHITEOUT_TYPE;
|
|
}
|
|
|
|
static inline bool d_can_lookup(const struct dentry *dentry)
|
|
{
|
|
return __d_entry_type(dentry) == DCACHE_DIRECTORY_TYPE;
|
|
}
|
|
|
|
static inline bool d_is_autodir(const struct dentry *dentry)
|
|
{
|
|
return __d_entry_type(dentry) == DCACHE_AUTODIR_TYPE;
|
|
}
|
|
|
|
static inline bool d_is_dir(const struct dentry *dentry)
|
|
{
|
|
return d_can_lookup(dentry) || d_is_autodir(dentry);
|
|
}
|
|
|
|
static inline bool d_is_symlink(const struct dentry *dentry)
|
|
{
|
|
return __d_entry_type(dentry) == DCACHE_SYMLINK_TYPE;
|
|
}
|
|
|
|
static inline bool d_is_reg(const struct dentry *dentry)
|
|
{
|
|
return __d_entry_type(dentry) == DCACHE_REGULAR_TYPE;
|
|
}
|
|
|
|
static inline bool d_is_special(const struct dentry *dentry)
|
|
{
|
|
return __d_entry_type(dentry) == DCACHE_SPECIAL_TYPE;
|
|
}
|
|
|
|
static inline bool d_is_file(const struct dentry *dentry)
|
|
{
|
|
return d_is_reg(dentry) || d_is_special(dentry);
|
|
}
|
|
|
|
static inline bool d_is_negative(const struct dentry *dentry)
|
|
{
|
|
// TODO: check d_is_whiteout(dentry) also.
|
|
return d_is_miss(dentry);
|
|
}
|
|
|
|
static inline bool d_is_positive(const struct dentry *dentry)
|
|
{
|
|
return !d_is_negative(dentry);
|
|
}
|
|
|
|
/**
|
|
* d_really_is_negative - Determine if a dentry is really negative (ignoring fallthroughs)
|
|
* @dentry: The dentry in question
|
|
*
|
|
* Returns true if the dentry represents either an absent name or a name that
|
|
* doesn't map to an inode (ie. ->d_inode is NULL). The dentry could represent
|
|
* a true miss, a whiteout that isn't represented by a 0,0 chardev or a
|
|
* fallthrough marker in an opaque directory.
|
|
*
|
|
* Note! (1) This should be used *only* by a filesystem to examine its own
|
|
* dentries. It should not be used to look at some other filesystem's
|
|
* dentries. (2) It should also be used in combination with d_inode() to get
|
|
* the inode. (3) The dentry may have something attached to ->d_lower and the
|
|
* type field of the flags may be set to something other than miss or whiteout.
|
|
*/
|
|
static inline bool d_really_is_negative(const struct dentry *dentry)
|
|
{
|
|
return dentry->d_inode == NULL;
|
|
}
|
|
|
|
/**
|
|
* d_really_is_positive - Determine if a dentry is really positive (ignoring fallthroughs)
|
|
* @dentry: The dentry in question
|
|
*
|
|
* Returns true if the dentry represents a name that maps to an inode
|
|
* (ie. ->d_inode is not NULL). The dentry might still represent a whiteout if
|
|
* that is represented on medium as a 0,0 chardev.
|
|
*
|
|
* Note! (1) This should be used *only* by a filesystem to examine its own
|
|
* dentries. It should not be used to look at some other filesystem's
|
|
* dentries. (2) It should also be used in combination with d_inode() to get
|
|
* the inode.
|
|
*/
|
|
static inline bool d_really_is_positive(const struct dentry *dentry)
|
|
{
|
|
return dentry->d_inode != NULL;
|
|
}
|
|
|
|
static inline int simple_positive(struct dentry *dentry)
|
|
{
|
|
return d_really_is_positive(dentry) && !d_unhashed(dentry);
|
|
}
|
|
|
|
extern void d_set_fallthru(struct dentry *dentry);
|
|
|
|
static inline bool d_is_fallthru(const struct dentry *dentry)
|
|
{
|
|
return dentry->d_flags & DCACHE_FALLTHRU;
|
|
}
|
|
|
|
|
|
extern int sysctl_vfs_cache_pressure;
|
|
|
|
static inline unsigned long vfs_pressure_ratio(unsigned long val)
|
|
{
|
|
return mult_frac(val, sysctl_vfs_cache_pressure, 100);
|
|
}
|
|
|
|
/**
|
|
* d_inode - Get the actual inode of this dentry
|
|
* @dentry: The dentry to query
|
|
*
|
|
* This is the helper normal filesystems should use to get at their own inodes
|
|
* in their own dentries and ignore the layering superimposed upon them.
|
|
*/
|
|
static inline struct inode *d_inode(const struct dentry *dentry)
|
|
{
|
|
return dentry->d_inode;
|
|
}
|
|
|
|
/**
|
|
* d_inode_rcu - Get the actual inode of this dentry with ACCESS_ONCE()
|
|
* @dentry: The dentry to query
|
|
*
|
|
* This is the helper normal filesystems should use to get at their own inodes
|
|
* in their own dentries and ignore the layering superimposed upon them.
|
|
*/
|
|
static inline struct inode *d_inode_rcu(const struct dentry *dentry)
|
|
{
|
|
return ACCESS_ONCE(dentry->d_inode);
|
|
}
|
|
|
|
/**
|
|
* d_backing_inode - Get upper or lower inode we should be using
|
|
* @upper: The upper layer
|
|
*
|
|
* This is the helper that should be used to get at the inode that will be used
|
|
* if this dentry were to be opened as a file. The inode may be on the upper
|
|
* dentry or it may be on a lower dentry pinned by the upper.
|
|
*
|
|
* Normal filesystems should not use this to access their own inodes.
|
|
*/
|
|
static inline struct inode *d_backing_inode(const struct dentry *upper)
|
|
{
|
|
struct inode *inode = upper->d_inode;
|
|
|
|
return inode;
|
|
}
|
|
|
|
/**
|
|
* d_backing_dentry - Get upper or lower dentry we should be using
|
|
* @upper: The upper layer
|
|
*
|
|
* This is the helper that should be used to get the dentry of the inode that
|
|
* will be used if this dentry were opened as a file. It may be the upper
|
|
* dentry or it may be a lower dentry pinned by the upper.
|
|
*
|
|
* Normal filesystems should not use this to access their own dentries.
|
|
*/
|
|
static inline struct dentry *d_backing_dentry(struct dentry *upper)
|
|
{
|
|
return upper;
|
|
}
|
|
|
|
/* d_real() flags */
|
|
#define D_REAL_UPPER 0x2 /* return upper dentry or NULL if non-upper */
|
|
|
|
/**
|
|
* d_real - Return the real dentry
|
|
* @dentry: the dentry to query
|
|
* @inode: inode to select the dentry from multiple layers (can be NULL)
|
|
* @open_flags: open flags to control copy-up behavior
|
|
* @flags: flags to control what is returned by this function
|
|
*
|
|
* If dentry is on a union/overlay, then return the underlying, real dentry.
|
|
* Otherwise return the dentry itself.
|
|
*
|
|
* See also: Documentation/filesystems/vfs.txt
|
|
*/
|
|
static inline struct dentry *d_real(struct dentry *dentry,
|
|
const struct inode *inode,
|
|
unsigned int open_flags, unsigned int flags)
|
|
{
|
|
if (unlikely(dentry->d_flags & DCACHE_OP_REAL))
|
|
return dentry->d_op->d_real(dentry, inode, open_flags, flags);
|
|
else
|
|
return dentry;
|
|
}
|
|
|
|
/**
|
|
* d_real_inode - Return the real inode
|
|
* @dentry: The dentry to query
|
|
*
|
|
* If dentry is on a union/overlay, then return the underlying, real inode.
|
|
* Otherwise return d_inode().
|
|
*/
|
|
static inline struct inode *d_real_inode(const struct dentry *dentry)
|
|
{
|
|
/* This usage of d_real() results in const dentry */
|
|
return d_backing_inode(d_real((struct dentry *) dentry, NULL, 0, 0));
|
|
}
|
|
|
|
struct name_snapshot {
|
|
const unsigned char *name;
|
|
unsigned char inline_name[DNAME_INLINE_LEN];
|
|
};
|
|
void take_dentry_name_snapshot(struct name_snapshot *, struct dentry *);
|
|
void release_dentry_name_snapshot(struct name_snapshot *);
|
|
|
|
#endif /* __LINUX_DCACHE_H */
|