Files
ack-tegra/include/linux/dcache.h
Greg Kroah-Hartman 9222a6a6c0 Merge 6.12.37 into android16-6.12-lts
GKI (arm64) relevant 35 out of 230 changes, affecting 67 files +612/-427
  ec9be081c5 Revert "mmc: sdhci: Disable SD card clock before changing parameters" [1 file, +2/-7]
  0698a2eb7d Bluetooth: HCI: Set extended advertising data synchronously [2 files, +130/-113]
  3672fe9d1e Bluetooth: hci_sync: revert some mesh modifications [1 file, +4/-12]
  44bb1e13b4 Bluetooth: MGMT: set_mesh: update LE scan interval and window [1 file, +22/-0]
  a99f80c88a Bluetooth: MGMT: mesh_send: check instances prior disabling advertising [1 file, +2/-1]
  5581e694d3 usb: typec: altmodes/displayport: do not index invalid pin_assignments [2 files, +2/-1]
  b1abc5ab47 scsi: sd: Fix VPD page 0xb7 length check [1 file, +1/-1]
  381c1c1219 Bluetooth: Prevent unintended pause by checking if advertising is active [1 file, +4/-0]
  f0fee863a7 nvme: Fix incorrect cdw15 value in passthru error logging [1 file, +1/-1]
  50c86c0945 netfs: Fix i_size updating [2 files, +8/-2]
  a553afd91f net/sched: Always pass notifications when child class becomes empty [1 file, +5/-14]
  d78f79a2c1 spinlock: extend guard with spinlock_bh variants [1 file, +13/-0]
  0cc4721a71 sched/fair: Rename h_nr_running into h_nr_queued [5 files, +53/-53]
  a2562bdd35 sched/fair: Fixup wake_up_sync() vs DELAYED_DEQUEUE [1 file, +11/-2]
  5833026221 f2fs: decrease spare area for pinned files for zoned devices [3 files, +5/-2]
  8912b139a8 f2fs: zone: fix to calculate first_zoned_segno correctly [4 files, +69/-20]
  c5474a7b04 bpf: use common instruction history across all states [2 files, +63/-63]
  4265682c29 bpf: Do not include stack ptr register in precision backtracking bookkeeping [2 files, +24/-6]
  e0fefe9bc0 netfs: Fix oops in write-retry from mis-resetting the subreq iterator [1 file, +3/-2]
  acf9ab15ec selinux: change security_compute_sid to return the ssid or tsid on match [1 file, +11/-5]
  42c5a4b47d rcu: Return early if callback is not specified [1 file, +4/-0]
  e036efbe58 add a string-to-qstr constructor [10 files, +13/-23]
  f94c422157 fs: export anon_inode_make_secure_inode() and fix secretmem LSM bypass [3 files, +21/-13]
  8caccd2eac usb: xhci: Skip xhci_reset in xhci_resume if xhci is being removed [1 file, +4/-1]
  9f75893189 Revert "usb: xhci: Implement xhci_handshake_check_state() helper" [3 files, +3/-30]
  fbebc2254a usb: xhci: quirk for data loss in ISOC transfers [3 files, +30/-0]
  195597e0be xhci: Disable stream for xHC controller with XHCI_BROKEN_STREAMS [1 file, +2/-1]
  dbdd2a2320 Input: xpad - support Acer NGR 200 Controller [1 file, +2/-0]
  3b1407caac usb: dwc3: Abort suspend on soft disconnect failure [2 files, +16/-15]
  7cb8750160 usb: acpi: fix device link removal [3 files, +8/-1]
  c745744a82 dma-buf: fix timeout handling in dma_resv_wait_timeout v2 [1 file, +7/-5]
  ccdc472b4d Logitech C-270 even more broken [1 file, +2/-1]
  c782f98eef usb: typec: displayport: Fix potential deadlock [1 file, +1/-2]
  ead91de35d mm/vmalloc: fix data race in show_numa_info() [1 file, +35/-28]
  4c443046d8 mm: userfaultfd: fix race of userfaultfd_move and swap cache [1 file, +31/-2]

Changes in 6.12.37
        rtc: pcf2127: add missing semicolon after statement
        rtc: pcf2127: fix SPI command byte for PCF2131
        rtc: cmos: use spin_lock_irqsave in cmos_interrupt
        virtio-net: xsk: rx: fix the frame's length check
        virtio-net: ensure the received length does not exceed allocated size
        s390/pci: Fix stale function handles in error handling
        s390/pci: Do not try re-enabling load/store if device is disabled
        net: txgbe: request MISC IRQ in ndo_open
        vsock/vmci: Clear the vmci transport packet properly when initializing it
        net: libwx: fix the incorrect display of the queue number
        mmc: sdhci: Add a helper function for dump register in dynamic debug mode
        Revert "mmc: sdhci: Disable SD card clock before changing parameters"
        mmc: core: sd: Apply BROKEN_SD_DISCARD quirk earlier
        Bluetooth: HCI: Set extended advertising data synchronously
        Bluetooth: hci_sync: revert some mesh modifications
        Bluetooth: MGMT: set_mesh: update LE scan interval and window
        Bluetooth: MGMT: mesh_send: check instances prior disabling advertising
        iommufd/selftest: Fix iommufd_dirty_tracking with large hugepage sizes
        regulator: gpio: Fix the out-of-bounds access to drvdata::gpiods
        Input: cs40l50-vibra - fix potential NULL dereference in cs40l50_upload_owt()
        usb: typec: altmodes/displayport: do not index invalid pin_assignments
        mtk-sd: Fix a pagefault in dma_unmap_sg() for not prepared data
        mtk-sd: Prevent memory corruption from DMA map failure
        mtk-sd: reset host->mrq on prepare_data() error
        drm/v3d: Disable interrupts before resetting the GPU
        firmware: arm_ffa: Fix memory leak by freeing notifier callback node
        firmware: arm_ffa: Move memory allocation outside the mutex locking
        firmware: arm_ffa: Replace mutex with rwlock to avoid sleep in atomic context
        arm64: dts: apple: t8103: Fix PCIe BCM4377 nodename
        platform/mellanox: mlxbf-tmfifo: fix vring_desc.len assignment
        RDMA/mlx5: Fix unsafe xarray access in implicit ODP handling
        RDMA/mlx5: Initialize obj_event->obj_sub_list before xa_insert
        nfs: Clean up /proc/net/rpc/nfs when nfs_fs_proc_net_init() fails.
        NFSv4/pNFS: Fix a race to wake on NFS_LAYOUT_DRAIN
        scsi: qla2xxx: Fix DMA mapping test in qla24xx_get_port_database()
        scsi: qla4xxx: Fix missing DMA mapping error in qla4xxx_alloc_pdu()
        scsi: sd: Fix VPD page 0xb7 length check
        scsi: ufs: core: Fix spelling of a sysfs attribute name
        RDMA/mlx5: Fix HW counters query for non-representor devices
        RDMA/mlx5: Fix CC counters query for MPV
        RDMA/mlx5: Fix vport loopback for MPV device
        platform/mellanox: mlxbf-pmc: Fix duplicate event ID for CACHE_DATA1
        platform/mellanox: nvsw-sn2201: Fix bus number in adapter error message
        Bluetooth: Prevent unintended pause by checking if advertising is active
        btrfs: fix missing error handling when searching for inode refs during log replay
        btrfs: fix iteration of extrefs during log replay
        btrfs: return a btrfs_inode from btrfs_iget_logging()
        btrfs: return a btrfs_inode from read_one_inode()
        btrfs: fix invalid inode pointer dereferences during log replay
        btrfs: fix inode lookup error handling during log replay
        btrfs: record new subvolume in parent dir earlier to avoid dir logging races
        btrfs: propagate last_unlink_trans earlier when doing a rmdir
        btrfs: use btrfs_record_snapshot_destroy() during rmdir
        ethernet: atl1: Add missing DMA mapping error checks and count errors
        dpaa2-eth: fix xdp_rxq_info leak
        drm/exynos: fimd: Guard display clock control with runtime PM calls
        spi: spi-fsl-dspi: Clear completion counter before initiating transfer
        drm/i915/selftests: Change mock_request() to return error pointers
        nvme: Fix incorrect cdw15 value in passthru error logging
        nvmet: fix memory leak of bio integrity
        platform/x86: dell-wmi-sysman: Fix WMI data block retrieval in sysfs callbacks
        platform/x86: hp-bioscfg: Directly use firmware_attributes_class
        platform/x86: hp-bioscfg: Fix class device unregistration
        platform/x86: firmware_attributes_class: Move include linux/device/class.h
        platform/x86: firmware_attributes_class: Simplify API
        platform/x86: think-lmi: Directly use firmware_attributes_class
        platform/x86: think-lmi: Fix class device unregistration
        platform/x86: dell-sysman: Directly use firmware_attributes_class
        platform/x86: dell-wmi-sysman: Fix class device unregistration
        platform/mellanox: mlxreg-lc: Fix logic error in power state check
        drm/bridge: aux-hpd-bridge: fix assignment of the of_node
        smb: client: fix warning when reconnecting channel
        net: usb: lan78xx: fix WARN in __netif_napi_del_locked on disconnect
        drm/i915/gt: Fix timeline left held on VMA alloc error
        drm/i915/gsc: mei interrupt top half should be in irq disabled context
        idpf: return 0 size for RSS key if not supported
        idpf: convert control queue mutex to a spinlock
        igc: disable L1.2 PCI-E link substate to avoid performance issue
        smb: client: set missing retry flag in smb2_writev_callback()
        smb: client: set missing retry flag in cifs_readv_callback()
        smb: client: set missing retry flag in cifs_writev_callback()
        netfs: Fix i_size updating
        lib: test_objagg: Set error message in check_expect_hints_stats()
        amd-xgbe: align CL37 AN sequence as per databook
        enic: fix incorrect MTU comparison in enic_change_mtu()
        rose: fix dangling neighbour pointers in rose_rt_device_down()
        nui: Fix dma_mapping_error() check
        net/sched: Always pass notifications when child class becomes empty
        amd-xgbe: do not double read link status
        smb: client: fix race condition in negotiate timeout by using more precise timing
        arm64: dts: rockchip: fix internal USB hub instability on RK3399 Puma
        crypto: iaa - Remove dst_null support
        crypto: iaa - Do not clobber req->base.data
        spinlock: extend guard with spinlock_bh variants
        crypto: zynqmp-sha - Add locking
        kunit: qemu_configs: sparc: use Zilog console
        kunit: qemu_configs: sparc: Explicitly enable CONFIG_SPARC32=y
        kunit: qemu_configs: Disable faulting tests on 32-bit SPARC
        gfs2: Initialize gl_no_formal_ino earlier
        gfs2: Rename GIF_{DEFERRED -> DEFER}_DELETE
        gfs2: Rename dinode_demise to evict_behavior
        gfs2: Prevent inode creation race
        gfs2: Decode missing glock flags in tracepoints
        gfs2: Add GLF_PENDING_REPLY flag
        gfs2: Replace GIF_DEFER_DELETE with GLF_DEFER_DELETE
        gfs2: Move gfs2_dinode_dealloc
        gfs2: Move GIF_ALLOC_FAILED check out of gfs2_ea_dealloc
        gfs2: deallocate inodes in gfs2_create_inode
        btrfs: prepare btrfs_page_mkwrite() for large folios
        btrfs: fix wrong start offset for delalloc space release during mmap write
        sched/fair: Rename h_nr_running into h_nr_queued
        sched/fair: Add new cfs_rq.h_nr_runnable
        sched/fair: Fixup wake_up_sync() vs DELAYED_DEQUEUE
        gfs2: Move gfs2_trans_add_databufs
        gfs2: Don't start unnecessary transactions during log flush
        ASoC: tas2764: Extend driver to SN012776
        ASoC: tas2764: Reinit cache on part reset
        ACPI: thermal: Fix stale comment regarding trip points
        ACPI: thermal: Execute _SCP before reading trip points
        bonding: Mark active offloaded xfrm_states
        wifi: ath12k: fix skb_ext_desc leak in ath12k_dp_tx() error path
        wifi: ath12k: Handle error cases during extended skb allocation
        wifi: ath12k: fix wrong handling of CCMP256 and GCMP ciphers
        RDMA/rxe: Fix "trying to register non-static key in rxe_qp_do_cleanup" bug
        iommu: ipmmu-vmsa: avoid Wformat-security warning
        f2fs: decrease spare area for pinned files for zoned devices
        f2fs: zone: introduce first_zoned_segno in f2fs_sb_info
        f2fs: zone: fix to calculate first_zoned_segno correctly
        scsi: lpfc: Remove NLP_RELEASE_RPI flag from nodelist structure
        scsi: lpfc: Change lpfc_nodelist nlp_flag member into a bitmask
        scsi: lpfc: Avoid potential ndlp use-after-free in dev_loss_tmo_callbk
        hisi_acc_vfio_pci: bugfix cache write-back issue
        hisi_acc_vfio_pci: bugfix the problem of uninstalling driver
        bpf: use common instruction history across all states
        bpf: Do not include stack ptr register in precision backtracking bookkeeping
        arm64: dts: qcom: sm8650: change labels to lower-case
        arm64: dts: qcom: sm8650: Fix domain-idle-state for CPU2
        arm64: dts: renesas: Use interrupts-extended for Ethernet PHYs
        arm64: dts: renesas: Factor out White Hawk Single board support
        arm64: dts: renesas: white-hawk-single: Improve Ethernet TSN description
        arm64: dts: qcom: sm8650: add the missing l2 cache node
        ubsan: integer-overflow: depend on BROKEN to keep this out of CI
        remoteproc: k3: Call of_node_put(rmem_np) only once in three functions
        remoteproc: k3-r5: Add devm action to release reserved memory
        remoteproc: k3-r5: Use devm_kcalloc() helper
        remoteproc: k3-r5: Use devm_ioremap_wc() helper
        remoteproc: k3-r5: Use devm_rproc_add() helper
        remoteproc: k3-r5: Refactor sequential core power up/down operations
        netfs: Fix oops in write-retry from mis-resetting the subreq iterator
        mfd: exynos-lpass: Fix another error handling path in exynos_lpass_probe()
        drm/xe: Fix DSB buffer coherency
        drm/xe: Move DSB l2 flush to a more sensible place
        drm/xe: add interface to request physical alignment for buffer objects
        drm/xe: Allow bo mapping on multiple ggtts
        drm/xe: move DPT l2 flush to a more sensible place
        drm/xe: Replace double space with single space after comma
        drm/xe/guc: Dead CT helper
        drm/xe/guc: Explicitly exit CT safe mode on unwind
        selinux: change security_compute_sid to return the ssid or tsid on match
        drm/simpledrm: Do not upcast in release helpers
        drm/amdgpu: VCN v5_0_1 to prevent FW checking RB during DPG pause
        drm/i915/dp_mst: Work around Thunderbolt sink disconnect after SINK_COUNT_ESI read
        drm/amdgpu: add kicker fws loading for gfx11/smu13/psp13
        drm/amd/display: Add more checks for DSC / HUBP ONO guarantees
        arm64: dts: qcom: x1e80100-crd: mark l12b and l15b always-on
        drm/amdgpu/mes: add missing locking in helper functions
        sched_ext: Make scx_group_set_weight() always update tg->scx.weight
        scsi: lpfc: Restore clearing of NLP_UNREG_INP in ndlp->nlp_flag
        drm/msm: Fix a fence leak in submit error path
        drm/msm: Fix another leak in the submit error path
        ALSA: sb: Don't allow changing the DMA mode during operations
        ALSA: sb: Force to disable DMAs once when DMA mode is changed
        ata: libata-acpi: Do not assume 40 wire cable if no devices are enabled
        ata: pata_cs5536: fix build on 32-bit UML
        ASoC: amd: yc: Add quirk for MSI Bravo 17 D7VF internal mic
        platform/x86/amd/pmc: Add PCSpecialist Lafite Pro V 14M to 8042 quirks list
        genirq/irq_sim: Initialize work context pointers properly
        powerpc: Fix struct termio related ioctl macros
        ASoC: amd: yc: update quirk data for HP Victus
        regulator: fan53555: add enable_time support and soft-start times
        scsi: target: Fix NULL pointer dereference in core_scsi3_decode_spec_i_port()
        aoe: defer rexmit timer downdev work to workqueue
        wifi: mac80211: drop invalid source address OCB frames
        wifi: ath6kl: remove WARN on bad firmware input
        ACPICA: Refuse to evaluate a method if arguments are missing
        mtd: spinand: fix memory leak of ECC engine conf
        rcu: Return early if callback is not specified
        add a string-to-qstr constructor
        module: Provide EXPORT_SYMBOL_GPL_FOR_MODULES() helper
        fs: export anon_inode_make_secure_inode() and fix secretmem LSM bypass
        RDMA/mlx5: Fix cache entry update on dereg error
        IB/mlx5: Fix potential deadlock in MR deregistration
        drm/xe/bmg: Update Wa_22019338487
        drm/xe: Allow dropping kunit dependency as built-in
        NFSv4/flexfiles: Fix handling of NFS level errors in I/O
        usb: xhci: Skip xhci_reset in xhci_resume if xhci is being removed
        Revert "usb: xhci: Implement xhci_handshake_check_state() helper"
        usb: xhci: quirk for data loss in ISOC transfers
        xhci: dbctty: disable ECHO flag by default
        xhci: dbc: Flush queued requests before stopping dbc
        xhci: Disable stream for xHC controller with XHCI_BROKEN_STREAMS
        Input: xpad - support Acer NGR 200 Controller
        Input: iqs7222 - explicitly define number of external channels
        usb: cdnsp: do not disable slot for disabled slot
        usb: cdnsp: Fix issue with CV Bad Descriptor test
        usb: dwc3: Abort suspend on soft disconnect failure
        usb: chipidea: udc: disconnect/reconnect from host when do suspend/resume
        usb: acpi: fix device link removal
        smb: client: fix readdir returning wrong type with POSIX extensions
        cifs: all initializations for tcon should happen in tcon_info_alloc
        dma-buf: fix timeout handling in dma_resv_wait_timeout v2
        i2c/designware: Fix an initialization issue
        Logitech C-270 even more broken
        optee: ffa: fix sleep in atomic context
        iommu/rockchip: prevent iommus dead loop when two masters share one IOMMU
        powercap: intel_rapl: Do not change CLAMPING bit if ENABLE bit cannot be changed
        riscv: cpu_ops_sbi: Use static array for boot_data
        platform/x86: think-lmi: Create ksets consecutively
        platform/x86: think-lmi: Fix kobject cleanup
        platform/x86: think-lmi: Fix sysfs group cleanup
        usb: typec: displayport: Fix potential deadlock
        powerpc/kernel: Fix ppc_save_regs inclusion in build
        mm/vmalloc: fix data race in show_numa_info()
        mm: userfaultfd: fix race of userfaultfd_move and swap cache
        x86/bugs: Rename MDS machinery to something more generic
        x86/bugs: Add a Transient Scheduler Attacks mitigation
        KVM: SVM: Advertise TSA CPUID bits to guests
        x86/microcode/AMD: Add TSA microcode SHAs
        x86/process: Move the buffer clearing before MONITOR
        Linux 6.12.37

Change-Id: If1d8d0f83e11df1540bebaf0fb136fe340f25dcb
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
2025-07-13 12:24:55 +00:00

619 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/math.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>
#include <linux/android_kabi.h>
struct path;
struct file;
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 }
#define QSTR(n) (struct qstr)QSTR_INIT(n, strlen(n))
extern const struct qstr empty_name;
extern const struct qstr slash_name;
extern const struct qstr dotdot_name;
/*
* 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 40 /* 192 bytes */
#else
# ifdef CONFIG_SMP
# define DNAME_INLINE_LEN 36 /* 128 bytes */
# else
# define DNAME_INLINE_LEN 44 /* 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_spinlock_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 */
/* --- cacheline 1 boundary (64 bytes) was 32 bytes ago --- */
/* Ref lookup also touches following */
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 */
/* --- cacheline 2 boundary (128 bytes) --- */
struct lockref d_lockref; /* per-dentry lock and refcount
* keep separate from RCU lookup area if
* possible!
*/
union {
struct list_head d_lru; /* LRU list */
wait_queue_head_t *d_wait; /* in-lookup ones only */
};
struct hlist_node d_sib; /* child of parent list */
struct hlist_head d_children; /* 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;
ANDROID_KABI_RESERVE(1);
ANDROID_KABI_RESERVE(2);
};
/*
* 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
};
enum d_real_type {
D_REAL_DATA,
D_REAL_METADATA,
};
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 *, enum d_real_type type);
int (*d_canonical_path)(const struct path *, struct path *);
ANDROID_KABI_RESERVE(1);
ANDROID_KABI_RESERVE(2);
ANDROID_KABI_RESERVE(3);
ANDROID_KABI_RESERVE(4);
} ____cacheline_aligned;
/*
* Locking rules for dentry_operations callbacks are to be found in
* Documentation/filesystems/locking.rst. Keep it updated!
*
* FUrther descriptions are found in Documentation/filesystems/vfs.rst.
* Keep it updated too!
*/
/* d_flags entries */
#define DCACHE_OP_HASH BIT(0)
#define DCACHE_OP_COMPARE BIT(1)
#define DCACHE_OP_REVALIDATE BIT(2)
#define DCACHE_OP_DELETE BIT(3)
#define DCACHE_OP_PRUNE BIT(4)
#define DCACHE_DISCONNECTED BIT(5)
/* 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 BIT(6) /* Recently used, don't discard. */
#define DCACHE_DONTCACHE BIT(7) /* Purge from memory on final dput() */
#define DCACHE_CANT_MOUNT BIT(8)
#define DCACHE_GENOCIDE BIT(9)
#define DCACHE_SHRINK_LIST BIT(10)
#define DCACHE_OP_WEAK_REVALIDATE BIT(11)
#define DCACHE_NFSFS_RENAMED BIT(12)
/* this dentry has been "silly renamed" and has to be deleted on the last
* dput() */
#define DCACHE_FSNOTIFY_PARENT_WATCHED BIT(14)
/* Parent inode is watched by some fsnotify listener */
#define DCACHE_DENTRY_KILLED BIT(15)
#define DCACHE_MOUNTED BIT(16) /* is a mountpoint */
#define DCACHE_NEED_AUTOMOUNT BIT(17) /* handle automount on this dir */
#define DCACHE_MANAGE_TRANSIT BIT(18) /* manage transit from this dirent */
#define DCACHE_MANAGED_DENTRY \
(DCACHE_MOUNTED|DCACHE_NEED_AUTOMOUNT|DCACHE_MANAGE_TRANSIT)
#define DCACHE_LRU_LIST BIT(19)
#define DCACHE_ENTRY_TYPE (7 << 20) /* bits 20..22 are for storing type: */
#define DCACHE_MISS_TYPE (0 << 20) /* Negative dentry */
#define DCACHE_WHITEOUT_TYPE (1 << 20) /* Whiteout dentry (stop pathwalk) */
#define DCACHE_DIRECTORY_TYPE (2 << 20) /* Normal directory */
#define DCACHE_AUTODIR_TYPE (3 << 20) /* Lookupless directory (presumed automount) */
#define DCACHE_REGULAR_TYPE (4 << 20) /* Regular file type */
#define DCACHE_SPECIAL_TYPE (5 << 20) /* Other file type */
#define DCACHE_SYMLINK_TYPE (6 << 20) /* Symlink */
#define DCACHE_NOKEY_NAME BIT(25) /* Encrypted name encoded without key */
#define DCACHE_OP_REAL BIT(26)
#define DCACHE_PAR_LOOKUP BIT(28) /* being looked up (with parent locked shared) */
#define DCACHE_DENTRY_CURSOR BIT(29)
#define DCACHE_NORCU BIT(30) /* No RCU delay for freeing */
extern seqlock_t rename_lock;
/*
* These are the low-level FS interfaces to the dcache..
*/
extern void d_instantiate(struct dentry *, struct inode *);
extern void d_instantiate_new(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_anon(struct super_block *);
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 bool d_same_name(const struct dentry *dentry, const struct dentry *parent,
const struct qstr *name);
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 d_invalidate(struct dentry *);
/* only used at mount-time */
extern struct dentry * d_make_root(struct inode *);
extern void d_mark_tmpfile(struct file *, struct inode *);
extern void d_tmpfile(struct file *, struct inode *);
extern struct dentry *d_find_alias(struct inode *);
extern void d_prune_aliases(struct inode *);
extern struct dentry *d_find_alias_rcu(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 *);
/* 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 *);
extern struct dentry *d_lookup(const struct dentry *, const struct qstr *);
extern struct dentry *d_hash_and_lookup(struct dentry *, struct qstr *);
static inline unsigned d_count(const struct dentry *dentry)
{
return dentry->d_lockref.count;
}
ino_t d_parent_ino(struct dentry *dentry);
/*
* helper function for dentry_operations.d_dname() members
*/
extern __printf(3, 4)
char *dynamic_dname(char *, int, const char *, ...);
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(const struct dentry *, char *, int);
extern char *dentry_path(const struct dentry *, char *, int);
/* Allocation counts.. */
/**
* dget_dlock - get a reference to a dentry
* @dentry: dentry to get a reference to
*
* Given a live dentry, increment the reference count and return the dentry.
* Caller must hold @dentry->d_lock. Making sure that dentry is alive is
* caller's resonsibility. There are many conditions sufficient to guarantee
* that; e.g. anything with non-negative refcount is alive, so's anything
* hashed, anything positive, anyone's parent, etc.
*/
static inline struct dentry *dget_dlock(struct dentry *dentry)
{
dentry->d_lockref.count++;
return dentry;
}
/**
* dget - 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. Conversely, a dentry with
* no references can disappear for any number of reasons, starting
* with memory pressure. In other words, that primitive is
* used to clone an existing reference; using it on something with
* zero refcount is a bug.
*
* NOTE: it will spin if @dentry->d_lock is held. From the deadlock
* avoidance point of view it is equivalent to spin_lock()/increment
* refcount/spin_unlock(), so calling it under @dentry->d_lock is
* always a bug; so's calling it under ->d_lock on any of its descendents.
*
*/
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_unhash_wake(struct dentry *dentry);
static inline int d_in_lookup(const 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)))
__d_lookup_unhash_wake(dentry);
}
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_flags_negative(unsigned flags)
{
return (flags & DCACHE_ENTRY_TYPE) == DCACHE_MISS_TYPE;
}
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(const struct dentry *dentry)
{
return d_really_is_positive(dentry) && !d_unhashed(dentry);
}
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 READ_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 READ_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_real - Return the real dentry
* @dentry: the dentry to query
* @type: the type of real dentry (data or metadata)
*
* If dentry is on a union/overlay, then return the underlying, real dentry.
* Otherwise return the dentry itself.
*
* See also: Documentation/filesystems/vfs.rst
*/
static inline struct dentry *d_real(struct dentry *dentry, enum d_real_type type)
{
if (unlikely(dentry->d_flags & DCACHE_OP_REAL))
return dentry->d_op->d_real(dentry, type);
else
return dentry;
}
/**
* d_real_inode - Return the real inode hosting the data
* @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_inode(d_real((struct dentry *) dentry, D_REAL_DATA));
}
struct name_snapshot {
struct qstr 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 *);
static inline struct dentry *d_first_child(const struct dentry *dentry)
{
return hlist_entry_safe(dentry->d_children.first, struct dentry, d_sib);
}
static inline struct dentry *d_next_sibling(const struct dentry *dentry)
{
return hlist_entry_safe(dentry->d_sib.next, struct dentry, d_sib);
}
#endif /* __LINUX_DCACHE_H */