
Changes in 5.10.94 KVM: VMX: switch blocked_vcpu_on_cpu_lock to raw spinlock HID: uhid: Fix worker destroying device without any protection HID: wacom: Reset expected and received contact counts at the same time HID: wacom: Ignore the confidence flag when a touch is removed HID: wacom: Avoid using stale array indicies to read contact count f2fs: fix to do sanity check in is_alive() nfc: llcp: fix NULL error pointer dereference on sendmsg() after failed bind() mtd: rawnand: gpmi: Add ERR007117 protection for nfc_apply_timings mtd: rawnand: gpmi: Remove explicit default gpmi clock setting for i.MX6 mtd: Fixed breaking list in __mtd_del_partition. mtd: rawnand: davinci: Don't calculate ECC when reading page mtd: rawnand: davinci: Avoid duplicated page read mtd: rawnand: davinci: Rewrite function description x86/gpu: Reserve stolen memory for first integrated Intel GPU tools/nolibc: x86-64: Fix startup code bug tools/nolibc: i386: fix initial stack alignment tools/nolibc: fix incorrect truncation of exit code rtc: cmos: take rtc_lock while reading from CMOS media: v4l2-ioctl.c: readbuffers depends on V4L2_CAP_READWRITE media: flexcop-usb: fix control-message timeouts media: mceusb: fix control-message timeouts media: em28xx: fix control-message timeouts media: cpia2: fix control-message timeouts media: s2255: fix control-message timeouts media: dib0700: fix undefined behavior in tuner shutdown media: redrat3: fix control-message timeouts media: pvrusb2: fix control-message timeouts media: stk1160: fix control-message timeouts media: cec-pin: fix interrupt en/disable handling can: softing_cs: softingcs_probe(): fix memleak on registration failure iio: adc: ti-adc081c: Partial revert of removal of ACPI IDs lkdtm: Fix content of section containing lkdtm_rodata_do_nothing() iommu/io-pgtable-arm-v7s: Add error handle for page table allocation failure gpu: host1x: Add back arm_iommu_detach_device() dma_fence_array: Fix PENDING_ERROR leak in dma_fence_array_signaled() PCI: Add function 1 DMA alias quirk for Marvell 88SE9125 SATA controller mm_zone: add function to check if managed dma zone exists dma/pool: create dma atomic pool only if dma zone has managed pages mm/page_alloc.c: do not warn allocation failure on zone DMA if no managed pages shmem: fix a race between shmem_unused_huge_shrink and shmem_evict_inode drm/ttm: Put BO in its memory manager's lru list Bluetooth: L2CAP: Fix not initializing sk_peer_pid drm/bridge: display-connector: fix an uninitialized pointer in probe() drm: fix null-ptr-deref in drm_dev_init_release() drm/panel: kingdisplay-kd097d04: Delete panel on attach() failure drm/panel: innolux-p079zca: Delete panel on attach() failure drm/rockchip: dsi: Fix unbalanced clock on probe error drm/rockchip: dsi: Hold pm-runtime across bind/unbind drm/rockchip: dsi: Disable PLL clock on bind error drm/rockchip: dsi: Reconfigure hardware on resume() Bluetooth: cmtp: fix possible panic when cmtp_init_sockets() fails clk: bcm-2835: Pick the closest clock rate clk: bcm-2835: Remove rounding up the dividers drm/vc4: hdmi: Set a default HSM rate wcn36xx: ensure pairing of init_scan/finish_scan and start_scan/end_scan wcn36xx: Indicate beacon not connection loss on MISSED_BEACON_IND wcn36xx: Fix DMA channel enable/disable cycle wcn36xx: Release DMA channel descriptor allocations wcn36xx: Put DXE block into reset before freeing memory wcn36xx: populate band before determining rate on RX wcn36xx: fix RX BD rate mapping for 5GHz legacy rates ath11k: Send PPDU_STATS_CFG with proper pdev mask to firmware mtd: hyperbus: rpc-if: Check return value of rpcif_sw_init() media: videobuf2: Fix the size printk format media: atomisp: add missing media_device_cleanup() in atomisp_unregister_entities() media: atomisp: fix punit_ddr_dvfs_enable() argument for mrfld_power up case media: atomisp: fix inverted logic in buffers_needed() media: atomisp: do not use err var when checking port validity for ISP2400 media: atomisp: fix inverted error check for ia_css_mipi_is_source_port_valid() media: atomisp: fix ifdefs in sh_css.c media: staging: media: atomisp: pci: Balance braces around conditional statements in file atomisp_cmd.c media: atomisp: add NULL check for asd obtained from atomisp_video_pipe media: atomisp: fix enum formats logic media: atomisp: fix uninitialized bug in gmin_get_pmic_id_and_addr() media: aspeed: fix mode-detect always time out at 2nd run media: em28xx: fix memory leak in em28xx_init_dev media: aspeed: Update signal status immediately to ensure sane hw state arm64: dts: amlogic: meson-g12: Fix GPU operating point table node name arm64: dts: amlogic: Fix SPI NOR flash node name for ODROID N2/N2+ arm64: dts: meson-gxbb-wetek: fix HDMI in early boot arm64: dts: meson-gxbb-wetek: fix missing GPIO binding fs: dlm: use sk->sk_socket instead of con->sock fs: dlm: don't call kernel_getpeername() in error_report() memory: renesas-rpc-if: Return error in case devm_ioremap_resource() fails Bluetooth: stop proccessing malicious adv data ath11k: Fix ETSI regd with weather radar overlap ath11k: clear the keys properly via DISABLE_KEY ath11k: reset RSN/WPA present state for open BSS tee: fix put order in teedev_close_context() fs: dlm: fix build with CONFIG_IPV6 disabled drm/vboxvideo: fix a NULL vs IS_ERR() check arm64: dts: renesas: cat875: Add rx/tx delays media: dmxdev: fix UAF when dvb_register_device() fails crypto: qce - fix uaf on qce_ahash_register_one crypto: qce - fix uaf on qce_skcipher_register_one mtd: hyperbus: rpc-if: fix bug in rpcif_hb_remove ARM: dts: stm32: fix dtbs_check warning on ili9341 dts binding on stm32f429 disco crypto: qat - fix spelling mistake: "messge" -> "message" crypto: qat - remove unnecessary collision prevention step in PFVF crypto: qat - make pfvf send message direction agnostic crypto: qat - fix undetected PFVF timeout in ACK loop ath11k: Use host CE parameters for CE interrupts configuration arm64: dts: ti: k3-j721e: correct cache-sets info tty: serial: atmel: Check return code of dmaengine_submit() tty: serial: atmel: Call dma_async_issue_pending() mfd: atmel-flexcom: Remove #ifdef CONFIG_PM_SLEEP mfd: atmel-flexcom: Use .resume_noirq media: rcar-csi2: Correct the selection of hsfreqrange media: imx-pxp: Initialize the spinlock prior to using it media: si470x-i2c: fix possible memory leak in si470x_i2c_probe() media: mtk-vcodec: call v4l2_m2m_ctx_release first when file is released media: coda: fix CODA960 JPEG encoder buffer overflow media: venus: pm_helpers: Control core power domain manually media: venus: core, venc, vdec: Fix probe dependency error media: venus: core: Fix a potential NULL pointer dereference in an error handling path media: venus: core: Fix a resource leak in the error handling path of 'venus_probe()' thermal/drivers/imx: Implement runtime PM support netfilter: bridge: add support for pppoe filtering arm64: dts: qcom: msm8916: fix MMC controller aliases cgroup: Trace event cgroup id fields should be u64 ACPI: EC: Rework flushing of EC work while suspended to idle thermal/drivers/imx8mm: Enable ADC when enabling monitor drm/amdgpu: Fix a NULL pointer dereference in amdgpu_connector_lcd_native_mode() drm/radeon/radeon_kms: Fix a NULL pointer dereference in radeon_driver_open_kms() arm64: dts: ti: k3-j7200: Fix the L2 cache sets arm64: dts: ti: k3-j721e: Fix the L2 cache sets arm64: dts: ti: k3-j7200: Correct the d-cache-sets info tty: serial: uartlite: allow 64 bit address serial: amba-pl011: do not request memory region twice floppy: Fix hang in watchdog when disk is ejected staging: rtl8192e: return error code from rtllib_softmac_init() staging: rtl8192e: rtllib_module: fix error handle case in alloc_rtllib() Bluetooth: btmtksdio: fix resume failure sched/fair: Fix detection of per-CPU kthreads waking a task sched/fair: Fix per-CPU kthread and wakee stacking for asym CPU capacity bpf: Adjust BTF log size limit. bpf: Disallow BPF_LOG_KERNEL log level for bpf(BPF_BTF_LOAD) bpf: Remove config check to enable bpf support for branch records arm64: lib: Annotate {clear, copy}_page() as position-independent arm64: clear_page() shouldn't use DC ZVA when DCZID_EL0.DZP == 1 media: dib8000: Fix a memleak in dib8000_init() media: saa7146: mxb: Fix a NULL pointer dereference in mxb_attach() media: si2157: Fix "warm" tuner state detection wireless: iwlwifi: Fix a double free in iwl_txq_dyn_alloc_dma sched/rt: Try to restart rt period timer when rt runtime exceeded drm/msm/dp: displayPort driver need algorithm rational rcu/exp: Mark current CPU as exp-QS in IPI loop second pass mwifiex: Fix possible ABBA deadlock xfrm: fix a small bug in xfrm_sa_len() x86/uaccess: Move variable into switch case statement selftests: clone3: clone3: add case CLONE3_ARGS_NO_TEST selftests: harness: avoid false negatives if test has no ASSERTs crypto: stm32 - Fix last sparse warning in stm32_cryp_check_ctr_counter crypto: stm32/cryp - fix CTR counter carry crypto: stm32/cryp - fix xts and race condition in crypto_engine requests crypto: stm32/cryp - check early input data crypto: stm32/cryp - fix double pm exit crypto: stm32/cryp - fix lrw chaining mode crypto: stm32/cryp - fix bugs and crash in tests crypto: stm32 - Revert broken pm_runtime_resume_and_get changes ath11k: Fix deleting uninitialized kernel timer during fragment cache flush ARM: dts: gemini: NAS4220-B: fis-index-block with 128 KiB sectors media: dw2102: Fix use after free media: msi001: fix possible null-ptr-deref in msi001_probe() media: coda/imx-vdoa: Handle dma_set_coherent_mask error codes ath11k: Fix a NULL pointer dereference in ath11k_mac_op_hw_scan() arm64: dts: qcom: c630: Fix soundcard setup arm64: dts: qcom: ipq6018: Fix gpio-ranges property drm/msm/dpu: fix safe status debugfs file drm/bridge: ti-sn65dsi86: Set max register for regmap drm/tegra: vic: Fix DMA API misuse media: hantro: Fix probe func error path xfrm: interface with if_id 0 should return error xfrm: state and policy should fail if XFRMA_IF_ID 0 ARM: 9159/1: decompressor: Avoid UNPREDICTABLE NOP encoding usb: ftdi-elan: fix memory leak on device disconnect arm64: dts: marvell: cn9130: add GPIO and SPI aliases arm64: dts: marvell: cn9130: enable CP0 GPIO controllers ARM: dts: armada-38x: Add generic compatible to UART nodes iwlwifi: mvm: fix 32-bit build in FTM iwlwifi: mvm: test roc running status bits before removing the sta mmc: meson-mx-sdhc: add IRQ check mmc: meson-mx-sdio: add IRQ check selinux: fix potential memleak in selinux_add_opt() um: fix ndelay/udelay defines um: virtio_uml: Fix time-travel external time propagation Bluetooth: L2CAP: Fix using wrong mode bpftool: Enable line buffering for stdout backlight: qcom-wled: Validate enabled string indices in DT backlight: qcom-wled: Pass number of elements to read to read_u32_array backlight: qcom-wled: Fix off-by-one maximum with default num_strings backlight: qcom-wled: Override default length with qcom,enabled-strings backlight: qcom-wled: Use cpu_to_le16 macro to perform conversion backlight: qcom-wled: Respect enabled-strings in set_brightness software node: fix wrong node passed to find nargs_prop Bluetooth: hci_qca: Stop IBS timer during BT OFF x86/boot/compressed: Move CLANG_FLAGS to beginning of KBUILD_CFLAGS hwmon: (mr75203) fix wrong power-up delay value x86/mce/inject: Avoid out-of-bounds write when setting flags ACPI: scan: Create platform device for BCM4752 and LNV4752 ACPI nodes pcmcia: rsrc_nonstatic: Fix a NULL pointer dereference in __nonstatic_find_io_region() pcmcia: rsrc_nonstatic: Fix a NULL pointer dereference in nonstatic_find_mem_region() power: reset: mt6397: Check for null res pointer netfilter: ipt_CLUSTERIP: fix refcount leak in clusterip_tg_check() bpf: Don't promote bogus looking registers after null check. bpf: Fix SO_RCVBUF/SO_SNDBUF handling in _bpf_setsockopt(). netfilter: nft_set_pipapo: allocate pcpu scratch maps on clone ppp: ensure minimum packet size in ppp_write() rocker: fix a sleeping in atomic bug staging: greybus: audio: Check null pointer fsl/fman: Check for null pointer after calling devm_ioremap Bluetooth: hci_bcm: Check for error irq Bluetooth: hci_qca: Fix NULL vs IS_ERR_OR_NULL check in qca_serdev_probe usb: dwc3: qcom: Fix NULL vs IS_ERR checking in dwc3_qcom_probe HID: hid-uclogic-params: Invalid parameter check in uclogic_params_init HID: hid-uclogic-params: Invalid parameter check in uclogic_params_get_str_desc HID: hid-uclogic-params: Invalid parameter check in uclogic_params_huion_init HID: hid-uclogic-params: Invalid parameter check in uclogic_params_frame_init_v1_buttonpad debugfs: lockdown: Allow reading debugfs files that are not world readable net/mlx5e: Fix page DMA map/unmap attributes net/mlx5e: Don't block routes with nexthop objects in SW Revert "net/mlx5e: Block offload of outer header csum for UDP tunnels" net/mlx5: Set command entry semaphore up once got index free lib/mpi: Add the return value check of kcalloc() Bluetooth: L2CAP: uninitialized variables in l2cap_sock_setsockopt() spi: spi-meson-spifc: Add missing pm_runtime_disable() in meson_spifc_probe ax25: uninitialized variable in ax25_setsockopt() netrom: fix api breakage in nr_setsockopt() regmap: Call regmap_debugfs_exit() prior to _init() can: mcp251xfd: add missing newline to printed strings tpm: add request_locality before write TPM_INT_ENABLE tpm_tis: Fix an error handling path in 'tpm_tis_core_init()' can: softing: softing_startstop(): fix set but not used variable warning can: xilinx_can: xcan_probe(): check for error irq pcmcia: fix setting of kthread task states iwlwifi: mvm: Use div_s64 instead of do_div in iwl_mvm_ftm_rtt_smoothing() net: mcs7830: handle usb read errors properly ext4: avoid trim error on fs with small groups ALSA: jack: Add missing rwsem around snd_ctl_remove() calls ALSA: PCM: Add missing rwsem around snd_ctl_remove() calls ALSA: hda: Add missing rwsem around snd_ctl_remove() calls RDMA/bnxt_re: Scan the whole bitmap when checking if "disabling RCFW with pending cmd-bit" RDMA/hns: Validate the pkey index scsi: pm80xx: Update WARN_ON check in pm8001_mpi_build_cmd() clk: imx8mn: Fix imx8mn_clko1_sels powerpc/prom_init: Fix improper check of prom_getprop() ASoC: uniphier: drop selecting non-existing SND_SOC_UNIPHIER_AIO_DMA dt-bindings: thermal: Fix definition of cooling-maps contribution property powerpc/64s: Convert some cpu_setup() and cpu_restore() functions to C powerpc/perf: MMCR0 control for PMU registers under PMCC=00 powerpc/perf: move perf irq/nmi handling details into traps.c powerpc/irq: Add helper to set regs->softe powerpc/perf: Fix PMU callbacks to clear pending PMI before resetting an overflown PMC powerpc/32s: Fix shift-out-of-bounds in KASAN init clocksource: Reduce clocksource-skew threshold clocksource: Avoid accidental unstable marking of clocksources ALSA: oss: fix compile error when OSS_DEBUG is enabled ALSA: usb-audio: Drop superfluous '0' in Presonus Studio 1810c's ID char/mwave: Adjust io port register size binder: fix handling of error during copy openrisc: Add clone3 ABI wrapper iommu/io-pgtable-arm: Fix table descriptor paddr formatting scsi: ufs: Fix race conditions related to driver data RDMA/qedr: Fix reporting max_{send/recv}_wr attrs PCI/MSI: Fix pci_irq_vector()/pci_irq_get_affinity() powerpc/powermac: Add additional missing lockdep_register_key() RDMA/core: Let ib_find_gid() continue search even after empty entry RDMA/cma: Let cma_resolve_ib_dev() continue search even after empty entry ASoC: rt5663: Handle device_property_read_u32_array error codes of: unittest: fix warning on PowerPC frame size warning of: unittest: 64 bit dma address test requires arch support clk: stm32: Fix ltdc's clock turn off by clk_disable_unused() after system enter shell mips: add SYS_HAS_CPU_MIPS64_R5 config for MIPS Release 5 support mips: fix Kconfig reference to PHYS_ADDR_T_64BIT dmaengine: pxa/mmp: stop referencing config->slave_id iommu/amd: Remove iommu_init_ga() iommu/amd: Restore GA log/tail pointer on host resume ASoC: Intel: catpt: Test dmaengine_submit() result before moving on iommu/iova: Fix race between FQ timeout and teardown scsi: block: pm: Always set request queue runtime active in blk_post_runtime_resume() phy: uniphier-usb3ss: fix unintended writing zeros to PHY register ASoC: mediatek: Check for error clk pointer ASoC: samsung: idma: Check of ioremap return value misc: lattice-ecp3-config: Fix task hung when firmware load failed counter: stm32-lptimer-cnt: remove iio counter abi arm64: tegra: Fix Tegra194 HDA {clock,reset}-names ordering arm64: tegra: Remove non existent Tegra194 reset mips: lantiq: add support for clk_set_parent() mips: bcm63xx: add support for clk_set_parent() powerpc/xive: Add missing null check after calling kmalloc ASoC: fsl_mqs: fix MODULE_ALIAS RDMA/cxgb4: Set queue pair state when being queried ASoC: fsl_asrc: refine the check of available clock divider clk: bm1880: remove kfrees on static allocations of: base: Fix phandle argument length mismatch error message ARM: dts: omap3-n900: Fix lp5523 for multi color Bluetooth: Fix debugfs entry leak in hci_register_dev() fs: dlm: filter user dlm messages for kernel locks drm/lima: fix warning when CONFIG_DEBUG_SG=y & CONFIG_DMA_API_DEBUG=y selftests/bpf: Fix bpf_object leak in skb_ctx selftest ar5523: Fix null-ptr-deref with unexpected WDCMSG_TARGET_START reply drm/bridge: dw-hdmi: handle ELD when DRM_BRIDGE_ATTACH_NO_CONNECTOR drm/nouveau/pmu/gm200-: avoid touching PMU outside of DEVINIT/PREOS/ACR media: atomisp: fix try_fmt logic media: atomisp: set per-device's default mode media: atomisp-ov2680: Fix ov2680_set_fmt() clobbering the exposure ARM: shmobile: rcar-gen2: Add missing of_node_put() batman-adv: allow netlink usage in unprivileged containers media: atomisp: handle errors at sh_css_create_isp_params() ath11k: Fix crash caused by uninitialized TX ring usb: gadget: f_fs: Use stream_open() for endpoint files drm: panel-orientation-quirks: Add quirk for the Lenovo Yoga Book X91F/L HID: apple: Do not reset quirks when the Fn key is not found media: b2c2: Add missing check in flexcop_pci_isr: EDAC/synopsys: Use the quirk for version instead of ddr version ARM: imx: rename DEBUG_IMX21_IMX27_UART to DEBUG_IMX27_UART drm/amd/display: check top_pipe_to_program pointer drm/amdgpu/display: set vblank_disable_immediate for DC soc: ti: pruss: fix referenced node in error message mlxsw: pci: Add shutdown method in PCI driver drm/bridge: megachips: Ensure both bridges are probed before registration tty: serial: imx: disable UCR4_OREN in .stop_rx() instead of .shutdown() gpiolib: acpi: Do not set the IRQ type if the IRQ is already in use HSI: core: Fix return freed object in hsi_new_client crypto: jitter - consider 32 LSB for APT mwifiex: Fix skb_over_panic in mwifiex_usb_recv() rsi: Fix use-after-free in rsi_rx_done_handler() rsi: Fix out-of-bounds read in rsi_read_pkt() ath11k: Avoid NULL ptr access during mgmt tx cleanup media: venus: avoid calling core_clk_setrate() concurrently during concurrent video sessions ACPI / x86: Drop PWM2 device on Lenovo Yoga Book from always present table ACPI: Change acpi_device_always_present() into acpi_device_override_status() ACPI / x86: Allow specifying acpi_device_override_status() quirks by path ACPI / x86: Add not-present quirk for the PCI0.SDHB.BRC1 device on the GPD win arm64: dts: ti: j7200-main: Fix 'dtbs_check' serdes_ln_ctrl node usb: uhci: add aspeed ast2600 uhci support floppy: Add max size check for user space request x86/mm: Flush global TLB when switching to trampoline page-table drm: rcar-du: Fix CRTC timings when CMM is used media: uvcvideo: Increase UVC_CTRL_CONTROL_TIMEOUT to 5 seconds. media: rcar-vin: Update format alignment constraints media: saa7146: hexium_orion: Fix a NULL pointer dereference in hexium_attach() media: m920x: don't use stack on USB reads thunderbolt: Runtime PM activate both ends of the device link iwlwifi: mvm: synchronize with FW after multicast commands iwlwifi: mvm: avoid clearing a just saved session protection id ath11k: avoid deadlock by change ieee80211_queue_work for regd_update_work ath10k: Fix tx hanging net-sysfs: update the queue counts in the unregistration path net: phy: prefer 1000baseT over 1000baseKX gpio: aspeed: Convert aspeed_gpio.lock to raw_spinlock selftests/ftrace: make kprobe profile testcase description unique ath11k: Avoid false DEADLOCK warning reported by lockdep x86/mce: Allow instrumentation during task work queueing x86/mce: Mark mce_panic() noinstr x86/mce: Mark mce_end() noinstr x86/mce: Mark mce_read_aux() noinstr net: bonding: debug: avoid printing debug logs when bond is not notifying peers bpf: Do not WARN in bpf_warn_invalid_xdp_action() HID: quirks: Allow inverting the absolute X/Y values media: igorplugusb: receiver overflow should be reported media: saa7146: hexium_gemini: Fix a NULL pointer dereference in hexium_attach() mmc: core: Fixup storing of OCR for MMC_QUIRK_NONSTD_SDIO audit: ensure userspace is penalized the same as the kernel when under pressure arm64: dts: ls1028a-qds: move rtc node to the correct i2c bus arm64: tegra: Adjust length of CCPLEX cluster MMIO region PM: runtime: Add safety net to supplier device release cpufreq: Fix initialization of min and max frequency QoS requests usb: hub: Add delay for SuperSpeed hub resume to let links transit to U0 ath9k: Fix out-of-bound memcpy in ath9k_hif_usb_rx_stream rtw88: 8822c: update rx settings to prevent potential hw deadlock PM: AVS: qcom-cpr: Use div64_ul instead of do_div iwlwifi: fix leaks/bad data after failed firmware load iwlwifi: remove module loading failure message iwlwifi: mvm: Fix calculation of frame length iwlwifi: pcie: make sure prph_info is set when treating wakeup IRQ um: registers: Rename function names to avoid conflicts and build problems ath11k: Fix napi related hang Bluetooth: vhci: Set HCI_QUIRK_VALID_LE_STATES xfrm: rate limit SA mapping change message to user space drm/etnaviv: consider completed fence seqno in hang check jffs2: GC deadlock reading a page that is used in jffs2_write_begin() ACPICA: actypes.h: Expand the ACPI_ACCESS_ definitions ACPICA: Utilities: Avoid deleting the same object twice in a row ACPICA: Executer: Fix the REFCLASS_REFOF case in acpi_ex_opcode_1A_0T_1R() ACPICA: Fix wrong interpretation of PCC address ACPICA: Hardware: Do not flush CPU cache when entering S4 and S5 drm/amdgpu: fixup bad vram size on gmc v8 amdgpu/pm: Make sysfs pm attributes as read-only for VFs ACPI: battery: Add the ThinkPad "Not Charging" quirk btrfs: remove BUG_ON() in find_parent_nodes() btrfs: remove BUG_ON(!eie) in find_parent_nodes net: mdio: Demote probed message to debug print mac80211: allow non-standard VHT MCS-10/11 dm btree: add a defensive bounds check to insert_at() dm space map common: add bounds check to sm_ll_lookup_bitmap() mlxsw: pci: Avoid flow control for EMAD packets net: phy: marvell: configure RGMII delays for 88E1118 net: gemini: allow any RGMII interface mode regulator: qcom_smd: Align probe function with rpmh-regulator serial: pl010: Drop CR register reset on set_termios serial: core: Keep mctrl register state and cached copy in sync random: do not throw away excess input to crng_fast_load parisc: Avoid calling faulthandler_disabled() twice x86/kbuild: Enable CONFIG_KALLSYMS_ALL=y in the defconfigs powerpc/6xx: add missing of_node_put powerpc/powernv: add missing of_node_put powerpc/cell: add missing of_node_put powerpc/btext: add missing of_node_put powerpc/watchdog: Fix missed watchdog reset due to memory ordering race i2c: i801: Don't silently correct invalid transfer size powerpc/smp: Move setup_profiling_timer() under CONFIG_PROFILING i2c: mpc: Correct I2C reset procedure clk: meson: gxbb: Fix the SDM_EN bit for MPLL0 on GXBB powerpc/powermac: Add missing lockdep_register_key() KVM: PPC: Book3S: Suppress warnings when allocating too big memory slots KVM: PPC: Book3S: Suppress failed alloc warning in H_COPY_TOFROM_GUEST w1: Misuse of get_user()/put_user() reported by sparse nvmem: core: set size for sysfs bin file dm: fix alloc_dax error handling in alloc_dev scsi: lpfc: Trigger SLI4 firmware dump before doing driver cleanup ALSA: seq: Set upper limit of processed events MIPS: Loongson64: Use three arguments for slti powerpc/40x: Map 32Mbytes of memory at startup selftests/powerpc/spectre_v2: Return skip code when miss_percent is high powerpc: handle kdump appropriately with crash_kexec_post_notifiers option powerpc/fadump: Fix inaccurate CPU state info in vmcore generated with panic udf: Fix error handling in udf_new_inode() MIPS: OCTEON: add put_device() after of_find_device_by_node() irqchip/gic-v4: Disable redistributors' view of the VPE table at boot time i2c: designware-pci: Fix to change data types of hcnt and lcnt parameters MIPS: Octeon: Fix build errors using clang scsi: sr: Don't use GFP_DMA ASoC: mediatek: mt8173: fix device_node leak ASoC: mediatek: mt8183: fix device_node leak phy: mediatek: Fix missing check in mtk_mipi_tx_probe rpmsg: core: Clean up resources on announce_create failure. crypto: omap-aes - Fix broken pm_runtime_and_get() usage crypto: stm32/crc32 - Fix kernel BUG triggered in probe() crypto: caam - replace this_cpu_ptr with raw_cpu_ptr ubifs: Error path in ubifs_remount_rw() seems to wrongly free write buffers tpm: fix NPE on probe for missing device spi: uniphier: Fix a bug that doesn't point to private data correctly xen/gntdev: fix unmap notification order fuse: Pass correct lend value to filemap_write_and_wait_range() serial: Fix incorrect rs485 polarity on uart open cputime, cpuacct: Include guest time in user time in cpuacct.stat tracing/kprobes: 'nmissed' not showed correctly for kretprobe iwlwifi: mvm: Increase the scan timeout guard to 30 seconds s390/mm: fix 2KB pgtable release race device property: Fix fwnode_graph_devcon_match() fwnode leak drm/etnaviv: limit submit sizes drm/nouveau/kms/nv04: use vzalloc for nv04_display drm/bridge: analogix_dp: Make PSR-exit block less parisc: Fix lpa and lpa_user defines powerpc/64s/radix: Fix huge vmap false positive PCI: xgene: Fix IB window setup PCI: pciehp: Use down_read/write_nested(reset_lock) to fix lockdep errors PCI: pci-bridge-emul: Make expansion ROM Base Address register read-only PCI: pci-bridge-emul: Properly mark reserved PCIe bits in PCI config space PCI: pci-bridge-emul: Fix definitions of reserved bits PCI: pci-bridge-emul: Correctly set PCIe capabilities PCI: pci-bridge-emul: Set PCI_STATUS_CAP_LIST for PCIe device xfrm: fix policy lookup for ipv6 gre packets btrfs: fix deadlock between quota enable and other quota operations btrfs: check the root node for uptodate before returning it btrfs: respect the max size in the header when activating swap file ext4: make sure to reset inode lockdep class when quota enabling fails ext4: make sure quota gets properly shutdown on error ext4: fix a possible ABBA deadlock due to busy PA ext4: initialize err_blk before calling __ext4_get_inode_loc ext4: fix fast commit may miss tracking range for FALLOC_FL_ZERO_RANGE ext4: set csum seed in tmp inode while migrating to extents ext4: Fix BUG_ON in ext4_bread when write quota data ext4: use ext4_ext_remove_space() for fast commit replay delete range ext4: fast commit may miss tracking unwritten range during ftruncate ext4: destroy ext4_fc_dentry_cachep kmemcache on module removal ext4: fix null-ptr-deref in '__ext4_journal_ensure_credits' ext4: don't use the orphan list when migrating an inode drm/radeon: fix error handling in radeon_driver_open_kms of: base: Improve argument length mismatch error firmware: Update Kconfig help text for Google firmware can: mcp251xfd: mcp251xfd_tef_obj_read(): fix typo in error message media: rcar-csi2: Optimize the selection PHTW register drm/vc4: hdmi: Make sure the device is powered with CEC media: correct MEDIA_TEST_SUPPORT help text Documentation: dmaengine: Correctly describe dmatest with channel unset Documentation: ACPI: Fix data node reference documentation Documentation: refer to config RANDOMIZE_BASE for kernel address-space randomization Documentation: fix firewire.rst ABI file path error Bluetooth: hci_sync: Fix not setting adv set duration scsi: core: Show SCMD_LAST in text form dmaengine: uniphier-xdmac: Fix type of address variables RDMA/hns: Modify the mapping attribute of doorbell to device RDMA/rxe: Fix a typo in opcode name dmaengine: stm32-mdma: fix STM32_MDMA_CTBR_TSEL_MASK Revert "net/mlx5: Add retry mechanism to the command entry index allocation" powerpc/cell: Fix clang -Wimplicit-fallthrough warning powerpc/fsl/dts: Enable WA for erratum A-009885 on fman3l MDIO buses block: Fix fsync always failed if once failed bpftool: Remove inclusion of utilities.mak from Makefiles xdp: check prog type before updating BPF link perf evsel: Override attr->sample_period for non-libpfm4 events ipv4: update fib_info_cnt under spinlock protection ipv4: avoid quadratic behavior in netns dismantle net/fsl: xgmac_mdio: Add workaround for erratum A-009885 net/fsl: xgmac_mdio: Fix incorrect iounmap when removing module parisc: pdc_stable: Fix memory leak in pdcs_register_pathentries f2fs: compress: fix potential deadlock of compress file f2fs: fix to reserve space for IO align feature af_unix: annote lockless accesses to unix_tot_inflight & gc_in_progress clk: Emit a stern warning with writable debugfs enabled clk: si5341: Fix clock HW provider cleanup net/smc: Fix hung_task when removing SMC-R devices net: axienet: increase reset timeout net: axienet: Wait for PhyRstCmplt after core reset net: axienet: reset core on initialization prior to MDIO access net: axienet: add missing memory barriers net: axienet: limit minimum TX ring size net: axienet: Fix TX ring slot available check net: axienet: fix number of TX ring slots for available check net: axienet: fix for TX busy handling net: axienet: increase default TX ring size to 128 HID: vivaldi: fix handling devices not using numbered reports rtc: pxa: fix null pointer dereference vdpa/mlx5: Fix wrong configuration of virtio_version_1_0 virtio_ring: mark ring unused on error taskstats: Cleanup the use of task->exit_code inet: frags: annotate races around fqdir->dead and fqdir->high_thresh netns: add schedule point in ops_exit_list() xfrm: Don't accidentally set RTO_ONLINK in decode_session4() gre: Don't accidentally set RTO_ONLINK in gre_fill_metadata_dst() libcxgb: Don't accidentally set RTO_ONLINK in cxgb_find_route() perf script: Fix hex dump character output dmaengine: at_xdmac: Don't start transactions at tx_submit level dmaengine: at_xdmac: Start transfer for cyclic channels in issue_pending dmaengine: at_xdmac: Print debug message after realeasing the lock dmaengine: at_xdmac: Fix concurrency over xfers_list dmaengine: at_xdmac: Fix lld view setting dmaengine: at_xdmac: Fix at_xdmac_lld struct definition perf probe: Fix ppc64 'perf probe add events failed' case devlink: Remove misleading internal_flags from health reporter dump arm64: dts: qcom: msm8996: drop not documented adreno properties net: bonding: fix bond_xmit_broadcast return value error bug net_sched: restore "mpu xxx" handling bcmgenet: add WOL IRQ check net: ethernet: mtk_eth_soc: fix error checking in mtk_mac_config() net: sfp: fix high power modules without diagnostic monitoring net: mscc: ocelot: fix using match before it is set dt-bindings: display: meson-dw-hdmi: add missing sound-name-prefix property dt-bindings: display: meson-vpu: Add missing amlogic,canvas property dt-bindings: watchdog: Require samsung,syscon-phandle for Exynos7 scripts/dtc: dtx_diff: remove broken example from help text lib82596: Fix IRQ check in sni_82596_probe mm/hmm.c: allow VM_MIXEDMAP to work with hmm_range_fault lib/test_meminit: destroy cache in kmem_cache_alloc_bulk() test mtd: nand: bbt: Fix corner case in bad block table handling ath10k: Fix the MTU size on QCA9377 SDIO scripts: sphinx-pre-install: add required ctex dependency scripts: sphinx-pre-install: Fix ctex support on Debian Linux 5.10.94 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I857f2417c899508815a1ba13d1285fd400a1f133
915 lines
28 KiB
C
915 lines
28 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* fs/f2fs/segment.h
|
|
*
|
|
* Copyright (c) 2012 Samsung Electronics Co., Ltd.
|
|
* http://www.samsung.com/
|
|
*/
|
|
#include <linux/blkdev.h>
|
|
#include <linux/backing-dev.h>
|
|
|
|
/* constant macro */
|
|
#define NULL_SEGNO ((unsigned int)(~0))
|
|
#define NULL_SECNO ((unsigned int)(~0))
|
|
|
|
#define DEF_RECLAIM_PREFREE_SEGMENTS 5 /* 5% over total segments */
|
|
#define DEF_MAX_RECLAIM_PREFREE_SEGMENTS 4096 /* 8GB in maximum */
|
|
|
|
#define F2FS_MIN_SEGMENTS 9 /* SB + 2 (CP + SIT + NAT) + SSA + MAIN */
|
|
#define F2FS_MIN_META_SEGMENTS 8 /* SB + 2 (CP + SIT + NAT) + SSA */
|
|
|
|
/* L: Logical segment # in volume, R: Relative segment # in main area */
|
|
#define GET_L2R_SEGNO(free_i, segno) ((segno) - (free_i)->start_segno)
|
|
#define GET_R2L_SEGNO(free_i, segno) ((segno) + (free_i)->start_segno)
|
|
|
|
#define IS_DATASEG(t) ((t) <= CURSEG_COLD_DATA)
|
|
#define IS_NODESEG(t) ((t) >= CURSEG_HOT_NODE && (t) <= CURSEG_COLD_NODE)
|
|
|
|
static inline void sanity_check_seg_type(struct f2fs_sb_info *sbi,
|
|
unsigned short seg_type)
|
|
{
|
|
f2fs_bug_on(sbi, seg_type >= NR_PERSISTENT_LOG);
|
|
}
|
|
|
|
#define IS_HOT(t) ((t) == CURSEG_HOT_NODE || (t) == CURSEG_HOT_DATA)
|
|
#define IS_WARM(t) ((t) == CURSEG_WARM_NODE || (t) == CURSEG_WARM_DATA)
|
|
#define IS_COLD(t) ((t) == CURSEG_COLD_NODE || (t) == CURSEG_COLD_DATA)
|
|
|
|
#define IS_CURSEG(sbi, seg) \
|
|
(((seg) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno) || \
|
|
((seg) == CURSEG_I(sbi, CURSEG_WARM_DATA)->segno) || \
|
|
((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA)->segno) || \
|
|
((seg) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno) || \
|
|
((seg) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno) || \
|
|
((seg) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno) || \
|
|
((seg) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno) || \
|
|
((seg) == CURSEG_I(sbi, CURSEG_ALL_DATA_ATGC)->segno))
|
|
|
|
#define IS_CURSEC(sbi, secno) \
|
|
(((secno) == CURSEG_I(sbi, CURSEG_HOT_DATA)->segno / \
|
|
(sbi)->segs_per_sec) || \
|
|
((secno) == CURSEG_I(sbi, CURSEG_WARM_DATA)->segno / \
|
|
(sbi)->segs_per_sec) || \
|
|
((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA)->segno / \
|
|
(sbi)->segs_per_sec) || \
|
|
((secno) == CURSEG_I(sbi, CURSEG_HOT_NODE)->segno / \
|
|
(sbi)->segs_per_sec) || \
|
|
((secno) == CURSEG_I(sbi, CURSEG_WARM_NODE)->segno / \
|
|
(sbi)->segs_per_sec) || \
|
|
((secno) == CURSEG_I(sbi, CURSEG_COLD_NODE)->segno / \
|
|
(sbi)->segs_per_sec) || \
|
|
((secno) == CURSEG_I(sbi, CURSEG_COLD_DATA_PINNED)->segno / \
|
|
(sbi)->segs_per_sec) || \
|
|
((secno) == CURSEG_I(sbi, CURSEG_ALL_DATA_ATGC)->segno / \
|
|
(sbi)->segs_per_sec))
|
|
|
|
#define MAIN_BLKADDR(sbi) \
|
|
(SM_I(sbi) ? SM_I(sbi)->main_blkaddr : \
|
|
le32_to_cpu(F2FS_RAW_SUPER(sbi)->main_blkaddr))
|
|
#define SEG0_BLKADDR(sbi) \
|
|
(SM_I(sbi) ? SM_I(sbi)->seg0_blkaddr : \
|
|
le32_to_cpu(F2FS_RAW_SUPER(sbi)->segment0_blkaddr))
|
|
|
|
#define MAIN_SEGS(sbi) (SM_I(sbi)->main_segments)
|
|
#define MAIN_SECS(sbi) ((sbi)->total_sections)
|
|
|
|
#define TOTAL_SEGS(sbi) \
|
|
(SM_I(sbi) ? SM_I(sbi)->segment_count : \
|
|
le32_to_cpu(F2FS_RAW_SUPER(sbi)->segment_count))
|
|
#define TOTAL_BLKS(sbi) (TOTAL_SEGS(sbi) << (sbi)->log_blocks_per_seg)
|
|
|
|
#define MAX_BLKADDR(sbi) (SEG0_BLKADDR(sbi) + TOTAL_BLKS(sbi))
|
|
#define SEGMENT_SIZE(sbi) (1ULL << ((sbi)->log_blocksize + \
|
|
(sbi)->log_blocks_per_seg))
|
|
|
|
#define START_BLOCK(sbi, segno) (SEG0_BLKADDR(sbi) + \
|
|
(GET_R2L_SEGNO(FREE_I(sbi), segno) << (sbi)->log_blocks_per_seg))
|
|
|
|
#define NEXT_FREE_BLKADDR(sbi, curseg) \
|
|
(START_BLOCK(sbi, (curseg)->segno) + (curseg)->next_blkoff)
|
|
|
|
#define GET_SEGOFF_FROM_SEG0(sbi, blk_addr) ((blk_addr) - SEG0_BLKADDR(sbi))
|
|
#define GET_SEGNO_FROM_SEG0(sbi, blk_addr) \
|
|
(GET_SEGOFF_FROM_SEG0(sbi, blk_addr) >> (sbi)->log_blocks_per_seg)
|
|
#define GET_BLKOFF_FROM_SEG0(sbi, blk_addr) \
|
|
(GET_SEGOFF_FROM_SEG0(sbi, blk_addr) & ((sbi)->blocks_per_seg - 1))
|
|
|
|
#define GET_SEGNO(sbi, blk_addr) \
|
|
((!__is_valid_data_blkaddr(blk_addr)) ? \
|
|
NULL_SEGNO : GET_L2R_SEGNO(FREE_I(sbi), \
|
|
GET_SEGNO_FROM_SEG0(sbi, blk_addr)))
|
|
#define BLKS_PER_SEC(sbi) \
|
|
((sbi)->segs_per_sec * (sbi)->blocks_per_seg)
|
|
#define GET_SEC_FROM_SEG(sbi, segno) \
|
|
(((segno) == -1) ? -1: (segno) / (sbi)->segs_per_sec)
|
|
#define GET_SEG_FROM_SEC(sbi, secno) \
|
|
((secno) * (sbi)->segs_per_sec)
|
|
#define GET_ZONE_FROM_SEC(sbi, secno) \
|
|
(((secno) == -1) ? -1: (secno) / (sbi)->secs_per_zone)
|
|
#define GET_ZONE_FROM_SEG(sbi, segno) \
|
|
GET_ZONE_FROM_SEC(sbi, GET_SEC_FROM_SEG(sbi, segno))
|
|
|
|
#define GET_SUM_BLOCK(sbi, segno) \
|
|
((sbi)->sm_info->ssa_blkaddr + (segno))
|
|
|
|
#define GET_SUM_TYPE(footer) ((footer)->entry_type)
|
|
#define SET_SUM_TYPE(footer, type) ((footer)->entry_type = (type))
|
|
|
|
#define SIT_ENTRY_OFFSET(sit_i, segno) \
|
|
((segno) % (sit_i)->sents_per_block)
|
|
#define SIT_BLOCK_OFFSET(segno) \
|
|
((segno) / SIT_ENTRY_PER_BLOCK)
|
|
#define START_SEGNO(segno) \
|
|
(SIT_BLOCK_OFFSET(segno) * SIT_ENTRY_PER_BLOCK)
|
|
#define SIT_BLK_CNT(sbi) \
|
|
DIV_ROUND_UP(MAIN_SEGS(sbi), SIT_ENTRY_PER_BLOCK)
|
|
#define f2fs_bitmap_size(nr) \
|
|
(BITS_TO_LONGS(nr) * sizeof(unsigned long))
|
|
|
|
#define SECTOR_FROM_BLOCK(blk_addr) \
|
|
(((sector_t)blk_addr) << F2FS_LOG_SECTORS_PER_BLOCK)
|
|
#define SECTOR_TO_BLOCK(sectors) \
|
|
((sectors) >> F2FS_LOG_SECTORS_PER_BLOCK)
|
|
|
|
/*
|
|
* indicate a block allocation direction: RIGHT and LEFT.
|
|
* RIGHT means allocating new sections towards the end of volume.
|
|
* LEFT means the opposite direction.
|
|
*/
|
|
enum {
|
|
ALLOC_RIGHT = 0,
|
|
ALLOC_LEFT
|
|
};
|
|
|
|
/*
|
|
* In the victim_sel_policy->alloc_mode, there are two block allocation modes.
|
|
* LFS writes data sequentially with cleaning operations.
|
|
* SSR (Slack Space Recycle) reuses obsolete space without cleaning operations.
|
|
* AT_SSR (Age Threshold based Slack Space Recycle) merges fragments into
|
|
* fragmented segment which has similar aging degree.
|
|
*/
|
|
enum {
|
|
LFS = 0,
|
|
SSR,
|
|
AT_SSR,
|
|
};
|
|
|
|
/*
|
|
* In the victim_sel_policy->gc_mode, there are two gc, aka cleaning, modes.
|
|
* GC_CB is based on cost-benefit algorithm.
|
|
* GC_GREEDY is based on greedy algorithm.
|
|
* GC_AT is based on age-threshold algorithm.
|
|
*/
|
|
enum {
|
|
GC_CB = 0,
|
|
GC_GREEDY,
|
|
GC_AT,
|
|
ALLOC_NEXT,
|
|
FLUSH_DEVICE,
|
|
MAX_GC_POLICY,
|
|
};
|
|
|
|
/*
|
|
* BG_GC means the background cleaning job.
|
|
* FG_GC means the on-demand cleaning job.
|
|
*/
|
|
enum {
|
|
BG_GC = 0,
|
|
FG_GC,
|
|
};
|
|
|
|
/* for a function parameter to select a victim segment */
|
|
struct victim_sel_policy {
|
|
int alloc_mode; /* LFS or SSR */
|
|
int gc_mode; /* GC_CB or GC_GREEDY */
|
|
unsigned long *dirty_bitmap; /* dirty segment/section bitmap */
|
|
unsigned int max_search; /*
|
|
* maximum # of segments/sections
|
|
* to search
|
|
*/
|
|
unsigned int offset; /* last scanned bitmap offset */
|
|
unsigned int ofs_unit; /* bitmap search unit */
|
|
unsigned int min_cost; /* minimum cost */
|
|
unsigned long long oldest_age; /* oldest age of segments having the same min cost */
|
|
unsigned int min_segno; /* segment # having min. cost */
|
|
unsigned long long age; /* mtime of GCed section*/
|
|
unsigned long long age_threshold;/* age threshold */
|
|
};
|
|
|
|
struct seg_entry {
|
|
unsigned int type:6; /* segment type like CURSEG_XXX_TYPE */
|
|
unsigned int valid_blocks:10; /* # of valid blocks */
|
|
unsigned int ckpt_valid_blocks:10; /* # of valid blocks last cp */
|
|
unsigned int padding:6; /* padding */
|
|
unsigned char *cur_valid_map; /* validity bitmap of blocks */
|
|
#ifdef CONFIG_F2FS_CHECK_FS
|
|
unsigned char *cur_valid_map_mir; /* mirror of current valid bitmap */
|
|
#endif
|
|
/*
|
|
* # of valid blocks and the validity bitmap stored in the last
|
|
* checkpoint pack. This information is used by the SSR mode.
|
|
*/
|
|
unsigned char *ckpt_valid_map; /* validity bitmap of blocks last cp */
|
|
unsigned char *discard_map;
|
|
unsigned long long mtime; /* modification time of the segment */
|
|
};
|
|
|
|
struct sec_entry {
|
|
unsigned int valid_blocks; /* # of valid blocks in a section */
|
|
};
|
|
|
|
struct segment_allocation {
|
|
void (*allocate_segment)(struct f2fs_sb_info *, int, bool);
|
|
};
|
|
|
|
#define MAX_SKIP_GC_COUNT 16
|
|
|
|
struct inmem_pages {
|
|
struct list_head list;
|
|
struct page *page;
|
|
block_t old_addr; /* for revoking when fail to commit */
|
|
};
|
|
|
|
struct sit_info {
|
|
const struct segment_allocation *s_ops;
|
|
|
|
block_t sit_base_addr; /* start block address of SIT area */
|
|
block_t sit_blocks; /* # of blocks used by SIT area */
|
|
block_t written_valid_blocks; /* # of valid blocks in main area */
|
|
char *bitmap; /* all bitmaps pointer */
|
|
char *sit_bitmap; /* SIT bitmap pointer */
|
|
#ifdef CONFIG_F2FS_CHECK_FS
|
|
char *sit_bitmap_mir; /* SIT bitmap mirror */
|
|
|
|
/* bitmap of segments to be ignored by GC in case of errors */
|
|
unsigned long *invalid_segmap;
|
|
#endif
|
|
unsigned int bitmap_size; /* SIT bitmap size */
|
|
|
|
unsigned long *tmp_map; /* bitmap for temporal use */
|
|
unsigned long *dirty_sentries_bitmap; /* bitmap for dirty sentries */
|
|
unsigned int dirty_sentries; /* # of dirty sentries */
|
|
unsigned int sents_per_block; /* # of SIT entries per block */
|
|
struct rw_semaphore sentry_lock; /* to protect SIT cache */
|
|
struct seg_entry *sentries; /* SIT segment-level cache */
|
|
struct sec_entry *sec_entries; /* SIT section-level cache */
|
|
|
|
/* for cost-benefit algorithm in cleaning procedure */
|
|
unsigned long long elapsed_time; /* elapsed time after mount */
|
|
unsigned long long mounted_time; /* mount time */
|
|
unsigned long long min_mtime; /* min. modification time */
|
|
unsigned long long max_mtime; /* max. modification time */
|
|
unsigned long long dirty_min_mtime; /* rerange candidates in GC_AT */
|
|
unsigned long long dirty_max_mtime; /* rerange candidates in GC_AT */
|
|
|
|
unsigned int last_victim[MAX_GC_POLICY]; /* last victim segment # */
|
|
};
|
|
|
|
struct free_segmap_info {
|
|
unsigned int start_segno; /* start segment number logically */
|
|
unsigned int free_segments; /* # of free segments */
|
|
unsigned int free_sections; /* # of free sections */
|
|
spinlock_t segmap_lock; /* free segmap lock */
|
|
unsigned long *free_segmap; /* free segment bitmap */
|
|
unsigned long *free_secmap; /* free section bitmap */
|
|
};
|
|
|
|
/* Notice: The order of dirty type is same with CURSEG_XXX in f2fs.h */
|
|
enum dirty_type {
|
|
DIRTY_HOT_DATA, /* dirty segments assigned as hot data logs */
|
|
DIRTY_WARM_DATA, /* dirty segments assigned as warm data logs */
|
|
DIRTY_COLD_DATA, /* dirty segments assigned as cold data logs */
|
|
DIRTY_HOT_NODE, /* dirty segments assigned as hot node logs */
|
|
DIRTY_WARM_NODE, /* dirty segments assigned as warm node logs */
|
|
DIRTY_COLD_NODE, /* dirty segments assigned as cold node logs */
|
|
DIRTY, /* to count # of dirty segments */
|
|
PRE, /* to count # of entirely obsolete segments */
|
|
NR_DIRTY_TYPE
|
|
};
|
|
|
|
struct dirty_seglist_info {
|
|
const struct victim_selection *v_ops; /* victim selction operation */
|
|
unsigned long *dirty_segmap[NR_DIRTY_TYPE];
|
|
unsigned long *dirty_secmap;
|
|
struct mutex seglist_lock; /* lock for segment bitmaps */
|
|
int nr_dirty[NR_DIRTY_TYPE]; /* # of dirty segments */
|
|
unsigned long *victim_secmap; /* background GC victims */
|
|
};
|
|
|
|
/* victim selection function for cleaning and SSR */
|
|
struct victim_selection {
|
|
int (*get_victim)(struct f2fs_sb_info *, unsigned int *,
|
|
int, int, char, unsigned long long);
|
|
};
|
|
|
|
/* for active log information */
|
|
struct curseg_info {
|
|
struct mutex curseg_mutex; /* lock for consistency */
|
|
struct f2fs_summary_block *sum_blk; /* cached summary block */
|
|
struct rw_semaphore journal_rwsem; /* protect journal area */
|
|
struct f2fs_journal *journal; /* cached journal info */
|
|
unsigned char alloc_type; /* current allocation type */
|
|
unsigned short seg_type; /* segment type like CURSEG_XXX_TYPE */
|
|
unsigned int segno; /* current segment number */
|
|
unsigned short next_blkoff; /* next block offset to write */
|
|
unsigned int zone; /* current zone number */
|
|
unsigned int next_segno; /* preallocated segment */
|
|
bool inited; /* indicate inmem log is inited */
|
|
};
|
|
|
|
struct sit_entry_set {
|
|
struct list_head set_list; /* link with all sit sets */
|
|
unsigned int start_segno; /* start segno of sits in set */
|
|
unsigned int entry_cnt; /* the # of sit entries in set */
|
|
};
|
|
|
|
/*
|
|
* inline functions
|
|
*/
|
|
static inline struct curseg_info *CURSEG_I(struct f2fs_sb_info *sbi, int type)
|
|
{
|
|
return (struct curseg_info *)(SM_I(sbi)->curseg_array + type);
|
|
}
|
|
|
|
static inline struct seg_entry *get_seg_entry(struct f2fs_sb_info *sbi,
|
|
unsigned int segno)
|
|
{
|
|
struct sit_info *sit_i = SIT_I(sbi);
|
|
return &sit_i->sentries[segno];
|
|
}
|
|
|
|
static inline struct sec_entry *get_sec_entry(struct f2fs_sb_info *sbi,
|
|
unsigned int segno)
|
|
{
|
|
struct sit_info *sit_i = SIT_I(sbi);
|
|
return &sit_i->sec_entries[GET_SEC_FROM_SEG(sbi, segno)];
|
|
}
|
|
|
|
static inline unsigned int get_valid_blocks(struct f2fs_sb_info *sbi,
|
|
unsigned int segno, bool use_section)
|
|
{
|
|
/*
|
|
* In order to get # of valid blocks in a section instantly from many
|
|
* segments, f2fs manages two counting structures separately.
|
|
*/
|
|
if (use_section && __is_large_section(sbi))
|
|
return get_sec_entry(sbi, segno)->valid_blocks;
|
|
else
|
|
return get_seg_entry(sbi, segno)->valid_blocks;
|
|
}
|
|
|
|
static inline unsigned int get_ckpt_valid_blocks(struct f2fs_sb_info *sbi,
|
|
unsigned int segno, bool use_section)
|
|
{
|
|
if (use_section && __is_large_section(sbi)) {
|
|
unsigned int start_segno = START_SEGNO(segno);
|
|
unsigned int blocks = 0;
|
|
int i;
|
|
|
|
for (i = 0; i < sbi->segs_per_sec; i++, start_segno++) {
|
|
struct seg_entry *se = get_seg_entry(sbi, start_segno);
|
|
|
|
blocks += se->ckpt_valid_blocks;
|
|
}
|
|
return blocks;
|
|
}
|
|
return get_seg_entry(sbi, segno)->ckpt_valid_blocks;
|
|
}
|
|
|
|
static inline void seg_info_from_raw_sit(struct seg_entry *se,
|
|
struct f2fs_sit_entry *rs)
|
|
{
|
|
se->valid_blocks = GET_SIT_VBLOCKS(rs);
|
|
se->ckpt_valid_blocks = GET_SIT_VBLOCKS(rs);
|
|
memcpy(se->cur_valid_map, rs->valid_map, SIT_VBLOCK_MAP_SIZE);
|
|
memcpy(se->ckpt_valid_map, rs->valid_map, SIT_VBLOCK_MAP_SIZE);
|
|
#ifdef CONFIG_F2FS_CHECK_FS
|
|
memcpy(se->cur_valid_map_mir, rs->valid_map, SIT_VBLOCK_MAP_SIZE);
|
|
#endif
|
|
se->type = GET_SIT_TYPE(rs);
|
|
se->mtime = le64_to_cpu(rs->mtime);
|
|
}
|
|
|
|
static inline void __seg_info_to_raw_sit(struct seg_entry *se,
|
|
struct f2fs_sit_entry *rs)
|
|
{
|
|
unsigned short raw_vblocks = (se->type << SIT_VBLOCKS_SHIFT) |
|
|
se->valid_blocks;
|
|
rs->vblocks = cpu_to_le16(raw_vblocks);
|
|
memcpy(rs->valid_map, se->cur_valid_map, SIT_VBLOCK_MAP_SIZE);
|
|
rs->mtime = cpu_to_le64(se->mtime);
|
|
}
|
|
|
|
static inline void seg_info_to_sit_page(struct f2fs_sb_info *sbi,
|
|
struct page *page, unsigned int start)
|
|
{
|
|
struct f2fs_sit_block *raw_sit;
|
|
struct seg_entry *se;
|
|
struct f2fs_sit_entry *rs;
|
|
unsigned int end = min(start + SIT_ENTRY_PER_BLOCK,
|
|
(unsigned long)MAIN_SEGS(sbi));
|
|
int i;
|
|
|
|
raw_sit = (struct f2fs_sit_block *)page_address(page);
|
|
memset(raw_sit, 0, PAGE_SIZE);
|
|
for (i = 0; i < end - start; i++) {
|
|
rs = &raw_sit->entries[i];
|
|
se = get_seg_entry(sbi, start + i);
|
|
__seg_info_to_raw_sit(se, rs);
|
|
}
|
|
}
|
|
|
|
static inline void seg_info_to_raw_sit(struct seg_entry *se,
|
|
struct f2fs_sit_entry *rs)
|
|
{
|
|
__seg_info_to_raw_sit(se, rs);
|
|
|
|
memcpy(se->ckpt_valid_map, rs->valid_map, SIT_VBLOCK_MAP_SIZE);
|
|
se->ckpt_valid_blocks = se->valid_blocks;
|
|
}
|
|
|
|
static inline unsigned int find_next_inuse(struct free_segmap_info *free_i,
|
|
unsigned int max, unsigned int segno)
|
|
{
|
|
unsigned int ret;
|
|
spin_lock(&free_i->segmap_lock);
|
|
ret = find_next_bit(free_i->free_segmap, max, segno);
|
|
spin_unlock(&free_i->segmap_lock);
|
|
return ret;
|
|
}
|
|
|
|
static inline void __set_free(struct f2fs_sb_info *sbi, unsigned int segno)
|
|
{
|
|
struct free_segmap_info *free_i = FREE_I(sbi);
|
|
unsigned int secno = GET_SEC_FROM_SEG(sbi, segno);
|
|
unsigned int start_segno = GET_SEG_FROM_SEC(sbi, secno);
|
|
unsigned int next;
|
|
unsigned int usable_segs = f2fs_usable_segs_in_sec(sbi, segno);
|
|
|
|
spin_lock(&free_i->segmap_lock);
|
|
clear_bit(segno, free_i->free_segmap);
|
|
free_i->free_segments++;
|
|
|
|
next = find_next_bit(free_i->free_segmap,
|
|
start_segno + sbi->segs_per_sec, start_segno);
|
|
if (next >= start_segno + usable_segs) {
|
|
clear_bit(secno, free_i->free_secmap);
|
|
free_i->free_sections++;
|
|
}
|
|
spin_unlock(&free_i->segmap_lock);
|
|
}
|
|
|
|
static inline void __set_inuse(struct f2fs_sb_info *sbi,
|
|
unsigned int segno)
|
|
{
|
|
struct free_segmap_info *free_i = FREE_I(sbi);
|
|
unsigned int secno = GET_SEC_FROM_SEG(sbi, segno);
|
|
|
|
set_bit(segno, free_i->free_segmap);
|
|
free_i->free_segments--;
|
|
if (!test_and_set_bit(secno, free_i->free_secmap))
|
|
free_i->free_sections--;
|
|
}
|
|
|
|
static inline void __set_test_and_free(struct f2fs_sb_info *sbi,
|
|
unsigned int segno, bool inmem)
|
|
{
|
|
struct free_segmap_info *free_i = FREE_I(sbi);
|
|
unsigned int secno = GET_SEC_FROM_SEG(sbi, segno);
|
|
unsigned int start_segno = GET_SEG_FROM_SEC(sbi, secno);
|
|
unsigned int next;
|
|
unsigned int usable_segs = f2fs_usable_segs_in_sec(sbi, segno);
|
|
|
|
spin_lock(&free_i->segmap_lock);
|
|
if (test_and_clear_bit(segno, free_i->free_segmap)) {
|
|
free_i->free_segments++;
|
|
|
|
if (!inmem && IS_CURSEC(sbi, secno))
|
|
goto skip_free;
|
|
next = find_next_bit(free_i->free_segmap,
|
|
start_segno + sbi->segs_per_sec, start_segno);
|
|
if (next >= start_segno + usable_segs) {
|
|
if (test_and_clear_bit(secno, free_i->free_secmap))
|
|
free_i->free_sections++;
|
|
}
|
|
}
|
|
skip_free:
|
|
spin_unlock(&free_i->segmap_lock);
|
|
}
|
|
|
|
static inline void __set_test_and_inuse(struct f2fs_sb_info *sbi,
|
|
unsigned int segno)
|
|
{
|
|
struct free_segmap_info *free_i = FREE_I(sbi);
|
|
unsigned int secno = GET_SEC_FROM_SEG(sbi, segno);
|
|
|
|
spin_lock(&free_i->segmap_lock);
|
|
if (!test_and_set_bit(segno, free_i->free_segmap)) {
|
|
free_i->free_segments--;
|
|
if (!test_and_set_bit(secno, free_i->free_secmap))
|
|
free_i->free_sections--;
|
|
}
|
|
spin_unlock(&free_i->segmap_lock);
|
|
}
|
|
|
|
static inline void get_sit_bitmap(struct f2fs_sb_info *sbi,
|
|
void *dst_addr)
|
|
{
|
|
struct sit_info *sit_i = SIT_I(sbi);
|
|
|
|
#ifdef CONFIG_F2FS_CHECK_FS
|
|
if (memcmp(sit_i->sit_bitmap, sit_i->sit_bitmap_mir,
|
|
sit_i->bitmap_size))
|
|
f2fs_bug_on(sbi, 1);
|
|
#endif
|
|
memcpy(dst_addr, sit_i->sit_bitmap, sit_i->bitmap_size);
|
|
}
|
|
|
|
static inline block_t written_block_count(struct f2fs_sb_info *sbi)
|
|
{
|
|
return SIT_I(sbi)->written_valid_blocks;
|
|
}
|
|
|
|
static inline unsigned int free_segments(struct f2fs_sb_info *sbi)
|
|
{
|
|
return FREE_I(sbi)->free_segments;
|
|
}
|
|
|
|
static inline unsigned int reserved_segments(struct f2fs_sb_info *sbi)
|
|
{
|
|
return SM_I(sbi)->reserved_segments +
|
|
SM_I(sbi)->additional_reserved_segments;
|
|
}
|
|
|
|
static inline unsigned int free_sections(struct f2fs_sb_info *sbi)
|
|
{
|
|
return FREE_I(sbi)->free_sections;
|
|
}
|
|
|
|
static inline unsigned int prefree_segments(struct f2fs_sb_info *sbi)
|
|
{
|
|
return DIRTY_I(sbi)->nr_dirty[PRE];
|
|
}
|
|
|
|
static inline unsigned int dirty_segments(struct f2fs_sb_info *sbi)
|
|
{
|
|
return DIRTY_I(sbi)->nr_dirty[DIRTY_HOT_DATA] +
|
|
DIRTY_I(sbi)->nr_dirty[DIRTY_WARM_DATA] +
|
|
DIRTY_I(sbi)->nr_dirty[DIRTY_COLD_DATA] +
|
|
DIRTY_I(sbi)->nr_dirty[DIRTY_HOT_NODE] +
|
|
DIRTY_I(sbi)->nr_dirty[DIRTY_WARM_NODE] +
|
|
DIRTY_I(sbi)->nr_dirty[DIRTY_COLD_NODE];
|
|
}
|
|
|
|
static inline int overprovision_segments(struct f2fs_sb_info *sbi)
|
|
{
|
|
return SM_I(sbi)->ovp_segments;
|
|
}
|
|
|
|
static inline int reserved_sections(struct f2fs_sb_info *sbi)
|
|
{
|
|
return GET_SEC_FROM_SEG(sbi, reserved_segments(sbi));
|
|
}
|
|
|
|
static inline bool has_curseg_enough_space(struct f2fs_sb_info *sbi)
|
|
{
|
|
unsigned int node_blocks = get_pages(sbi, F2FS_DIRTY_NODES) +
|
|
get_pages(sbi, F2FS_DIRTY_DENTS);
|
|
unsigned int dent_blocks = get_pages(sbi, F2FS_DIRTY_DENTS);
|
|
unsigned int segno, left_blocks;
|
|
int i;
|
|
|
|
/* check current node segment */
|
|
for (i = CURSEG_HOT_NODE; i <= CURSEG_COLD_NODE; i++) {
|
|
segno = CURSEG_I(sbi, i)->segno;
|
|
left_blocks = f2fs_usable_blks_in_seg(sbi, segno) -
|
|
get_seg_entry(sbi, segno)->ckpt_valid_blocks;
|
|
|
|
if (node_blocks > left_blocks)
|
|
return false;
|
|
}
|
|
|
|
/* check current data segment */
|
|
segno = CURSEG_I(sbi, CURSEG_HOT_DATA)->segno;
|
|
left_blocks = f2fs_usable_blks_in_seg(sbi, segno) -
|
|
get_seg_entry(sbi, segno)->ckpt_valid_blocks;
|
|
if (dent_blocks > left_blocks)
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
static inline bool has_not_enough_free_secs(struct f2fs_sb_info *sbi,
|
|
int freed, int needed)
|
|
{
|
|
int node_secs = get_blocktype_secs(sbi, F2FS_DIRTY_NODES);
|
|
int dent_secs = get_blocktype_secs(sbi, F2FS_DIRTY_DENTS);
|
|
int imeta_secs = get_blocktype_secs(sbi, F2FS_DIRTY_IMETA);
|
|
|
|
if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
|
|
return false;
|
|
|
|
if (free_sections(sbi) + freed == reserved_sections(sbi) + needed &&
|
|
has_curseg_enough_space(sbi))
|
|
return false;
|
|
return (free_sections(sbi) + freed) <=
|
|
(node_secs + 2 * dent_secs + imeta_secs +
|
|
reserved_sections(sbi) + needed);
|
|
}
|
|
|
|
static inline bool f2fs_is_checkpoint_ready(struct f2fs_sb_info *sbi)
|
|
{
|
|
if (likely(!is_sbi_flag_set(sbi, SBI_CP_DISABLED)))
|
|
return true;
|
|
if (likely(!has_not_enough_free_secs(sbi, 0, 0)))
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
static inline bool excess_prefree_segs(struct f2fs_sb_info *sbi)
|
|
{
|
|
return prefree_segments(sbi) > SM_I(sbi)->rec_prefree_segments;
|
|
}
|
|
|
|
static inline int utilization(struct f2fs_sb_info *sbi)
|
|
{
|
|
return div_u64((u64)valid_user_blocks(sbi) * 100,
|
|
sbi->user_block_count);
|
|
}
|
|
|
|
/*
|
|
* Sometimes f2fs may be better to drop out-of-place update policy.
|
|
* And, users can control the policy through sysfs entries.
|
|
* There are five policies with triggering conditions as follows.
|
|
* F2FS_IPU_FORCE - all the time,
|
|
* F2FS_IPU_SSR - if SSR mode is activated,
|
|
* F2FS_IPU_UTIL - if FS utilization is over threashold,
|
|
* F2FS_IPU_SSR_UTIL - if SSR mode is activated and FS utilization is over
|
|
* threashold,
|
|
* F2FS_IPU_FSYNC - activated in fsync path only for high performance flash
|
|
* storages. IPU will be triggered only if the # of dirty
|
|
* pages over min_fsync_blocks. (=default option)
|
|
* F2FS_IPU_ASYNC - do IPU given by asynchronous write requests.
|
|
* F2FS_IPU_NOCACHE - disable IPU bio cache.
|
|
* F2FS_IPUT_DISABLE - disable IPU. (=default option in LFS mode)
|
|
*/
|
|
#define DEF_MIN_IPU_UTIL 70
|
|
#define DEF_MIN_FSYNC_BLOCKS 8
|
|
#define DEF_MIN_HOT_BLOCKS 16
|
|
|
|
#define SMALL_VOLUME_SEGMENTS (16 * 512) /* 16GB */
|
|
|
|
enum {
|
|
F2FS_IPU_FORCE,
|
|
F2FS_IPU_SSR,
|
|
F2FS_IPU_UTIL,
|
|
F2FS_IPU_SSR_UTIL,
|
|
F2FS_IPU_FSYNC,
|
|
F2FS_IPU_ASYNC,
|
|
F2FS_IPU_NOCACHE,
|
|
};
|
|
|
|
static inline unsigned int curseg_segno(struct f2fs_sb_info *sbi,
|
|
int type)
|
|
{
|
|
struct curseg_info *curseg = CURSEG_I(sbi, type);
|
|
return curseg->segno;
|
|
}
|
|
|
|
static inline unsigned char curseg_alloc_type(struct f2fs_sb_info *sbi,
|
|
int type)
|
|
{
|
|
struct curseg_info *curseg = CURSEG_I(sbi, type);
|
|
return curseg->alloc_type;
|
|
}
|
|
|
|
static inline unsigned short curseg_blkoff(struct f2fs_sb_info *sbi, int type)
|
|
{
|
|
struct curseg_info *curseg = CURSEG_I(sbi, type);
|
|
return curseg->next_blkoff;
|
|
}
|
|
|
|
static inline void check_seg_range(struct f2fs_sb_info *sbi, unsigned int segno)
|
|
{
|
|
f2fs_bug_on(sbi, segno > TOTAL_SEGS(sbi) - 1);
|
|
}
|
|
|
|
static inline void verify_fio_blkaddr(struct f2fs_io_info *fio)
|
|
{
|
|
struct f2fs_sb_info *sbi = fio->sbi;
|
|
|
|
if (__is_valid_data_blkaddr(fio->old_blkaddr))
|
|
verify_blkaddr(sbi, fio->old_blkaddr, __is_meta_io(fio) ?
|
|
META_GENERIC : DATA_GENERIC);
|
|
verify_blkaddr(sbi, fio->new_blkaddr, __is_meta_io(fio) ?
|
|
META_GENERIC : DATA_GENERIC_ENHANCE);
|
|
}
|
|
|
|
/*
|
|
* Summary block is always treated as an invalid block
|
|
*/
|
|
static inline int check_block_count(struct f2fs_sb_info *sbi,
|
|
int segno, struct f2fs_sit_entry *raw_sit)
|
|
{
|
|
bool is_valid = test_bit_le(0, raw_sit->valid_map) ? true : false;
|
|
int valid_blocks = 0;
|
|
int cur_pos = 0, next_pos;
|
|
unsigned int usable_blks_per_seg = f2fs_usable_blks_in_seg(sbi, segno);
|
|
|
|
/* check bitmap with valid block count */
|
|
do {
|
|
if (is_valid) {
|
|
next_pos = find_next_zero_bit_le(&raw_sit->valid_map,
|
|
usable_blks_per_seg,
|
|
cur_pos);
|
|
valid_blocks += next_pos - cur_pos;
|
|
} else
|
|
next_pos = find_next_bit_le(&raw_sit->valid_map,
|
|
usable_blks_per_seg,
|
|
cur_pos);
|
|
cur_pos = next_pos;
|
|
is_valid = !is_valid;
|
|
} while (cur_pos < usable_blks_per_seg);
|
|
|
|
if (unlikely(GET_SIT_VBLOCKS(raw_sit) != valid_blocks)) {
|
|
f2fs_err(sbi, "Mismatch valid blocks %d vs. %d",
|
|
GET_SIT_VBLOCKS(raw_sit), valid_blocks);
|
|
set_sbi_flag(sbi, SBI_NEED_FSCK);
|
|
return -EFSCORRUPTED;
|
|
}
|
|
|
|
if (usable_blks_per_seg < sbi->blocks_per_seg)
|
|
f2fs_bug_on(sbi, find_next_bit_le(&raw_sit->valid_map,
|
|
sbi->blocks_per_seg,
|
|
usable_blks_per_seg) != sbi->blocks_per_seg);
|
|
|
|
/* check segment usage, and check boundary of a given segment number */
|
|
if (unlikely(GET_SIT_VBLOCKS(raw_sit) > usable_blks_per_seg
|
|
|| segno > TOTAL_SEGS(sbi) - 1)) {
|
|
f2fs_err(sbi, "Wrong valid blocks %d or segno %u",
|
|
GET_SIT_VBLOCKS(raw_sit), segno);
|
|
set_sbi_flag(sbi, SBI_NEED_FSCK);
|
|
return -EFSCORRUPTED;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static inline pgoff_t current_sit_addr(struct f2fs_sb_info *sbi,
|
|
unsigned int start)
|
|
{
|
|
struct sit_info *sit_i = SIT_I(sbi);
|
|
unsigned int offset = SIT_BLOCK_OFFSET(start);
|
|
block_t blk_addr = sit_i->sit_base_addr + offset;
|
|
|
|
check_seg_range(sbi, start);
|
|
|
|
#ifdef CONFIG_F2FS_CHECK_FS
|
|
if (f2fs_test_bit(offset, sit_i->sit_bitmap) !=
|
|
f2fs_test_bit(offset, sit_i->sit_bitmap_mir))
|
|
f2fs_bug_on(sbi, 1);
|
|
#endif
|
|
|
|
/* calculate sit block address */
|
|
if (f2fs_test_bit(offset, sit_i->sit_bitmap))
|
|
blk_addr += sit_i->sit_blocks;
|
|
|
|
return blk_addr;
|
|
}
|
|
|
|
static inline pgoff_t next_sit_addr(struct f2fs_sb_info *sbi,
|
|
pgoff_t block_addr)
|
|
{
|
|
struct sit_info *sit_i = SIT_I(sbi);
|
|
block_addr -= sit_i->sit_base_addr;
|
|
if (block_addr < sit_i->sit_blocks)
|
|
block_addr += sit_i->sit_blocks;
|
|
else
|
|
block_addr -= sit_i->sit_blocks;
|
|
|
|
return block_addr + sit_i->sit_base_addr;
|
|
}
|
|
|
|
static inline void set_to_next_sit(struct sit_info *sit_i, unsigned int start)
|
|
{
|
|
unsigned int block_off = SIT_BLOCK_OFFSET(start);
|
|
|
|
f2fs_change_bit(block_off, sit_i->sit_bitmap);
|
|
#ifdef CONFIG_F2FS_CHECK_FS
|
|
f2fs_change_bit(block_off, sit_i->sit_bitmap_mir);
|
|
#endif
|
|
}
|
|
|
|
static inline unsigned long long get_mtime(struct f2fs_sb_info *sbi,
|
|
bool base_time)
|
|
{
|
|
struct sit_info *sit_i = SIT_I(sbi);
|
|
time64_t diff, now = ktime_get_boottime_seconds();
|
|
|
|
if (now >= sit_i->mounted_time)
|
|
return sit_i->elapsed_time + now - sit_i->mounted_time;
|
|
|
|
/* system time is set to the past */
|
|
if (!base_time) {
|
|
diff = sit_i->mounted_time - now;
|
|
if (sit_i->elapsed_time >= diff)
|
|
return sit_i->elapsed_time - diff;
|
|
return 0;
|
|
}
|
|
return sit_i->elapsed_time;
|
|
}
|
|
|
|
static inline void set_summary(struct f2fs_summary *sum, nid_t nid,
|
|
unsigned int ofs_in_node, unsigned char version)
|
|
{
|
|
sum->nid = cpu_to_le32(nid);
|
|
sum->ofs_in_node = cpu_to_le16(ofs_in_node);
|
|
sum->version = version;
|
|
}
|
|
|
|
static inline block_t start_sum_block(struct f2fs_sb_info *sbi)
|
|
{
|
|
return __start_cp_addr(sbi) +
|
|
le32_to_cpu(F2FS_CKPT(sbi)->cp_pack_start_sum);
|
|
}
|
|
|
|
static inline block_t sum_blk_addr(struct f2fs_sb_info *sbi, int base, int type)
|
|
{
|
|
return __start_cp_addr(sbi) +
|
|
le32_to_cpu(F2FS_CKPT(sbi)->cp_pack_total_block_count)
|
|
- (base + 1) + type;
|
|
}
|
|
|
|
static inline bool sec_usage_check(struct f2fs_sb_info *sbi, unsigned int secno)
|
|
{
|
|
if (IS_CURSEC(sbi, secno) || (sbi->cur_victim_sec == secno))
|
|
return true;
|
|
return false;
|
|
}
|
|
|
|
/*
|
|
* It is very important to gather dirty pages and write at once, so that we can
|
|
* submit a big bio without interfering other data writes.
|
|
* By default, 512 pages for directory data,
|
|
* 512 pages (2MB) * 8 for nodes, and
|
|
* 256 pages * 8 for meta are set.
|
|
*/
|
|
static inline int nr_pages_to_skip(struct f2fs_sb_info *sbi, int type)
|
|
{
|
|
if (sbi->sb->s_bdi->wb.dirty_exceeded)
|
|
return 0;
|
|
|
|
if (type == DATA)
|
|
return sbi->blocks_per_seg;
|
|
else if (type == NODE)
|
|
return 8 * sbi->blocks_per_seg;
|
|
else if (type == META)
|
|
return 8 * BIO_MAX_PAGES;
|
|
else
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* When writing pages, it'd better align nr_to_write for segment size.
|
|
*/
|
|
static inline long nr_pages_to_write(struct f2fs_sb_info *sbi, int type,
|
|
struct writeback_control *wbc)
|
|
{
|
|
long nr_to_write, desired;
|
|
|
|
if (wbc->sync_mode != WB_SYNC_NONE)
|
|
return 0;
|
|
|
|
nr_to_write = wbc->nr_to_write;
|
|
desired = BIO_MAX_PAGES;
|
|
if (type == NODE)
|
|
desired <<= 1;
|
|
|
|
wbc->nr_to_write = desired;
|
|
return desired - nr_to_write;
|
|
}
|
|
|
|
static inline void wake_up_discard_thread(struct f2fs_sb_info *sbi, bool force)
|
|
{
|
|
struct discard_cmd_control *dcc = SM_I(sbi)->dcc_info;
|
|
bool wakeup = false;
|
|
int i;
|
|
|
|
if (force)
|
|
goto wake_up;
|
|
|
|
mutex_lock(&dcc->cmd_lock);
|
|
for (i = MAX_PLIST_NUM - 1; i >= 0; i--) {
|
|
if (i + 1 < dcc->discard_granularity)
|
|
break;
|
|
if (!list_empty(&dcc->pend_list[i])) {
|
|
wakeup = true;
|
|
break;
|
|
}
|
|
}
|
|
mutex_unlock(&dcc->cmd_lock);
|
|
if (!wakeup || !is_idle(sbi, DISCARD_TIME))
|
|
return;
|
|
wake_up:
|
|
dcc->discard_wake = 1;
|
|
wake_up_interruptible_all(&dcc->discard_wait_queue);
|
|
}
|