Changes in 4.19.191 s390/disassembler: increase ebpf disasm buffer size ACPI: custom_method: fix potential use-after-free issue ACPI: custom_method: fix a possible memory leak ftrace: Handle commands when closing set_ftrace_filter file ARM: 9056/1: decompressor: fix BSS size calculation for LLVM ld.lld arm64: dts: marvell: armada-37xx: add syscon compatible to NB clk node arm64: dts: mt8173: fix property typo of 'phys' in dsi node ecryptfs: fix kernel panic with null dev_name mtd: spinand: core: add missing MODULE_DEVICE_TABLE() mtd: rawnand: atmel: Update ecc_stats.corrected counter spi: spi-ti-qspi: Free DMA resources scsi: qla2xxx: Fix crash in qla2xxx_mqueuecommand() mmc: sdhci-pci: Fix initialization of some SD cards for Intel BYT-based controllers mmc: block: Update ext_csd.cache_ctrl if it was written mmc: block: Issue a cache flush only when it's enabled mmc: core: Do a power cycle when the CMD11 fails mmc: core: Set read only for SD cards with permanent write protect bit erofs: add unsupported inode i_format check cifs: Return correct error code from smb2_get_enc_key btrfs: fix metadata extent leak after failure to create subvolume intel_th: pci: Add Rocket Lake CPU support fbdev: zero-fill colormap in fbcmap.c staging: wimax/i2400m: fix byte-order issue crypto: api - check for ERR pointers in crypto_destroy_tfm() usb: gadget: uvc: add bInterval checking for HS mode genirq/matrix: Prevent allocation counter corruption usb: gadget: f_uac1: validate input parameters usb: dwc3: gadget: Ignore EP queue requests during bus reset usb: xhci: Fix port minor revision PCI: PM: Do not read power state in pci_enable_device_flags() x86/build: Propagate $(CLANG_FLAGS) to $(REALMODE_FLAGS) tee: optee: do not check memref size on return from Secure World perf/arm_pmu_platform: Fix error handling usb: xhci-mtk: support quirk to disable usb2 lpm xhci: check control context is valid before dereferencing it. xhci: fix potential array out of bounds with several interrupters spi: dln2: Fix reference leak to master spi: omap-100k: Fix reference leak to master intel_th: Consistency and off-by-one fix phy: phy-twl4030-usb: Fix possible use-after-free in twl4030_usb_remove() btrfs: convert logic BUG_ON()'s in replace_path to ASSERT()'s scsi: lpfc: Fix incorrect dbde assignment when building target abts wqe scsi: lpfc: Fix pt2pt connection does not recover after LOGO scsi: target: pscsi: Fix warning in pscsi_complete_cmd() media: ite-cir: check for receive overflow media: drivers: media: pci: sta2x11: fix Kconfig dependency on GPIOLIB power: supply: bq27xxx: fix power_avg for newer ICs extcon: arizona: Fix some issues when HPDET IRQ fires after the jack has been unplugged media: media/saa7164: fix saa7164_encoder_register() memory leak bugs media: gspca/sq905.c: fix uninitialized variable power: supply: Use IRQF_ONESHOT drm/amdgpu : Fix asic reset regression issue introduce by 8f211fe8ac7c4f scsi: qla2xxx: Always check the return value of qla24xx_get_isp_stats() scsi: qla2xxx: Fix use after free in bsg scsi: scsi_dh_alua: Remove check for ASC 24h in alua_rtpg() media: em28xx: fix memory leak media: vivid: update EDID clk: socfpga: arria10: Fix memory leak of socfpga_clk on error return power: supply: generic-adc-battery: fix possible use-after-free in gab_remove() power: supply: s3c_adc_battery: fix possible use-after-free in s3c_adc_bat_remove() media: tc358743: fix possible use-after-free in tc358743_remove() media: adv7604: fix possible use-after-free in adv76xx_remove() media: i2c: adv7511-v4l2: fix possible use-after-free in adv7511_remove() media: i2c: adv7842: fix possible use-after-free in adv7842_remove() media: dvb-usb: fix memory leak in dvb_usb_adapter_init media: gscpa/stv06xx: fix memory leak drm/msm/mdp5: Configure PP_SYNC_HEIGHT to double the vtotal amdgpu: avoid incorrect %hu format string drm/amdgpu: fix NULL pointer dereference scsi: lpfc: Fix crash when a REG_RPI mailbox fails triggering a LOGO response scsi: lpfc: Remove unsupported mbox PORT_CAPABILITIES logic scsi: libfc: Fix a format specifier s390/archrandom: add parameter check for s390_arch_random_generate ALSA: emu8000: Fix a use after free in snd_emu8000_create_mixer ALSA: hda/conexant: Re-order CX5066 quirk table entries ALSA: sb: Fix two use after free in snd_sb_qsound_build ALSA: usb-audio: Explicitly set up the clock selector ALSA: usb-audio: More constifications ALSA: usb-audio: Add dB range mapping for Sennheiser Communications Headset PC 8 ALSA: hda/realtek: Add quirk for Intel Clevo PCx0Dx btrfs: fix race when picking most recent mod log operation for an old root arm64/vdso: Discard .note.gnu.property sections in vDSO ubifs: Only check replay with inode type to judge if inode linked f2fs: fix to avoid out-of-bounds memory access mlxsw: spectrum_mr: Update egress RIF list before route's action openvswitch: fix stack OOB read while fragmenting IPv4 packets ACPI: GTDT: Don't corrupt interrupt mappings on watchdow probe failure NFS: Don't discard pNFS layout segments that are marked for return NFSv4: Don't discard segments marked for return in _pnfs_return_layout() jffs2: Fix kasan slab-out-of-bounds problem powerpc/eeh: Fix EEH handling for hugepages in ioremap space. powerpc: fix EDEADLOCK redefinition error in uapi/asm/errno.h intel_th: pci: Add Alder Lake-M support tpm: vtpm_proxy: Avoid reading host log when using a virtual device md/raid1: properly indicate failure when ending a failed write request dm raid: fix inconclusive reshape layout on fast raid4/5/6 table reload sequences security: commoncap: fix -Wstringop-overread warning Fix misc new gcc warnings jffs2: check the validity of dstlen in jffs2_zlib_compress() Revert337f13046f("futex: Allow FUTEX_CLOCK_REALTIME with FUTEX_WAIT op") posix-timers: Preserve return value in clock_adjtime32() arm64: vdso: remove commas between macro name and arguments ext4: fix check to prevent false positive report of incorrect used inodes ext4: do not set SB_ACTIVE in ext4_orphan_cleanup() ext4: fix error code in ext4_commit_super media: dvbdev: Fix memory leak in dvb_media_device_free() usb: gadget: dummy_hcd: fix gpf in gadget_setup usb: gadget: Fix double free of device descriptor pointers usb: gadget/function/f_fs string table fix for multiple languages usb: dwc3: gadget: Fix START_TRANSFER link state check usb: dwc2: Fix session request interrupt handler tty: fix memory leak in vc_deallocate rsi: Use resume_noirq for SDIO tracing: Map all PIDs to command lines tracing: Restructure trace_clock_global() to never block dm persistent data: packed struct should have an aligned() attribute too dm space map common: fix division bug in sm_ll_find_free_block() dm rq: fix double free of blk_mq_tag_set in dev remove after table load fails modules: mark ref_module static modules: mark find_symbol static modules: mark each_symbol_section static modules: unexport __module_text_address modules: unexport __module_address modules: rename the licence field in struct symsearch to license modules: return licensing information from find_symbol modules: inherit TAINT_PROPRIETARY_MODULE Bluetooth: verify AMP hci_chan before amp_destroy hsr: use netdev_err() instead of WARN_ONCE() bluetooth: eliminate the potential race condition when removing the HCI controller net/nfc: fix use-after-free llcp_sock_bind/connect ASoC: samsung: tm2_wm5110: check of of_parse return value MIPS: pci-mt7620: fix PLL lock check MIPS: pci-rt2880: fix slot 0 configuration FDDI: defxx: Bail out gracefully with unassigned PCI resource for CSR iio:accel:adis16201: Fix wrong axis assignment that prevents loading misc: lis3lv02d: Fix false-positive WARN on various HP models misc: vmw_vmci: explicitly initialize vmci_notify_bm_set_msg struct misc: vmw_vmci: explicitly initialize vmci_datagram payload md/bitmap: wait for external bitmap writes to complete during tear down md-cluster: fix use-after-free issue when removing rdev md: split mddev_find md: factor out a mddev_find_locked helper from mddev_find md: md_open returns -EBUSY when entering racing area md: Fix missing unused status line of /proc/mdstat ipw2x00: potential buffer overflow in libipw_wx_set_encodeext() cfg80211: scan: drop entry from hidden_list on overflow drm/radeon: fix copy of uninitialized variable back to userspace ALSA: hda/realtek: Re-order ALC882 Acer quirk table entries ALSA: hda/realtek: Re-order ALC882 Sony quirk table entries ALSA: hda/realtek: Re-order ALC882 Clevo quirk table entries ALSA: hda/realtek: Re-order ALC269 HP quirk table entries ALSA: hda/realtek: Re-order ALC269 Dell quirk table entries ALSA: hda/realtek: Re-order ALC269 Sony quirk table entries ALSA: hda/realtek: Re-order ALC269 Lenovo quirk table entries ALSA: hda/realtek: Remove redundant entry for ALC861 Haier/Uniwill devices x86/cpu: Initialize MSR_TSC_AUX if RDTSCP *or* RDPID is supported KVM: s390: split kvm_s390_logical_to_effective KVM: s390: fix guarded storage control register handling KVM: s390: split kvm_s390_real_to_abs ovl: fix missing revert_creds() on error path usb: gadget: pch_udc: Revertd3cb25a121completely memory: gpmc: fix out of bounds read and dereference on gpmc_cs[] ARM: dts: exynos: correct fuel gauge interrupt trigger level on Midas family ARM: dts: exynos: correct MUIC interrupt trigger level on Midas family ARM: dts: exynos: correct PMIC interrupt trigger level on Midas family ARM: dts: exynos: correct PMIC interrupt trigger level on Odroid X/U3 family ARM: dts: exynos: correct PMIC interrupt trigger level on SMDK5250 ARM: dts: exynos: correct PMIC interrupt trigger level on Snow serial: stm32: fix incorrect characters on console serial: stm32: fix tx_empty condition usb: typec: tcpci: Check ROLE_CONTROL while interpreting CC_STATUS regmap: set debugfs_name to NULL after it is freed mtd: rawnand: fsmc: Fix error code in fsmc_nand_probe() mtd: rawnand: brcmnand: fix OOB R/W with Hamming ECC mtd: Handle possible -EPROBE_DEFER from parse_mtd_partitions() mtd: rawnand: qcom: Return actual error code instead of -ENODEV x86/microcode: Check for offline CPUs before requesting new microcode usb: gadget: pch_udc: Replace cpu_to_le32() by lower_32_bits() usb: gadget: pch_udc: Check if driver is present before calling ->setup() usb: gadget: pch_udc: Check for DMA mapping error crypto: qat - don't release uninitialized resources crypto: qat - ADF_STATUS_PF_RUNNING should be set after adf_dev_init fotg210-udc: Fix DMA on EP0 for length > max packet size fotg210-udc: Fix EP0 IN requests bigger than two packets fotg210-udc: Remove a dubious condition leading to fotg210_done fotg210-udc: Mask GRP2 interrupts we don't handle fotg210-udc: Don't DMA more than the buffer can take fotg210-udc: Complete OUT requests on short packets mtd: require write permissions for locking and badblock ioctls bus: qcom: Put child node before return soundwire: bus: Fix device found flag correctly phy: marvell: ARMADA375_USBCLUSTER_PHY should not default to y, unconditionally crypto: qat - fix error path in adf_isr_resource_alloc() usb: gadget: aspeed: fix dma map failure USB: gadget: udc: fix wrong pointer passed to IS_ERR() and PTR_ERR() soundwire: stream: fix memory leak in stream config error path mtd: rawnand: gpmi: Fix a double free in gpmi_nand_init irqchip/gic-v3: Fix OF_BAD_ADDR error handling staging: rtl8192u: Fix potential infinite loop staging: greybus: uart: fix unprivileged TIOCCSERIAL spi: Fix use-after-free with devm_spi_alloc_* soc: qcom: mdt_loader: Validate that p_filesz < p_memsz soc: qcom: mdt_loader: Detect truncated read of segments ACPI: CPPC: Replace cppc_attr with kobj_attribute crypto: qat - Fix a double free in adf_create_ring cpufreq: armada-37xx: Fix setting TBG parent for load levels clk: mvebu: armada-37xx-periph: remove .set_parent method for CPU PM clock cpufreq: armada-37xx: Fix the AVS value for load L1 clk: mvebu: armada-37xx-periph: Fix switching CPU freq from 250 Mhz to 1 GHz clk: mvebu: armada-37xx-periph: Fix workaround for switching from L1 to L0 cpufreq: armada-37xx: Fix driver cleanup when registration failed cpufreq: armada-37xx: Fix determining base CPU frequency usb: gadget: r8a66597: Add missing null check on return from platform_get_resource USB: cdc-acm: fix unprivileged TIOCCSERIAL tty: actually undefine superseded ASYNC flags tty: fix return value for unsupported ioctls firmware: qcom-scm: Fix QCOM_SCM configuration usbip: vudc: fix missing unlock on error in usbip_sockfd_store() platform/x86: pmc_atom: Match all Beckhoff Automation baytrail boards with critclk_systems DMI table x86/platform/uv: Fix !KEXEC build failure Drivers: hv: vmbus: Increase wait time for VMbus unload usb: dwc2: Fix host mode hibernation exit with remote wakeup flow. usb: dwc2: Fix hibernation between host and device modes. ttyprintk: Add TTY hangup callback. soc: aspeed: fix a ternary sign expansion bug media: vivid: fix assignment of dev->fbuf_out_flags media: omap4iss: return error code when omap4iss_get() failed media: m88rs6000t: avoid potential out-of-bounds reads on arrays drm/amdkfd: fix build error with AMD_IOMMU_V2=m x86/kprobes: Fix to check non boostable prefixes correctly pata_arasan_cf: fix IRQ check pata_ipx4xx_cf: fix IRQ check sata_mv: add IRQ checks ata: libahci_platform: fix IRQ check nvme: retrigger ANA log update if group descriptor isn't found vfio/mdev: Do not allow a mdev_type to have a NULL parent pointer clk: qcom: a53-pll: Add missing MODULE_DEVICE_TABLE clk: uniphier: Fix potential infinite loop scsi: jazz_esp: Add IRQ check scsi: sun3x_esp: Add IRQ check scsi: sni_53c710: Add IRQ check scsi: ibmvfc: Fix invalid state machine BUG_ON() mfd: stm32-timers: Avoid clearing auto reload register HSI: core: fix resource leaks in hsi_add_client_from_dt() x86/events/amd/iommu: Fix sysfs type mismatch sched/debug: Fix cgroup_path[] serialization drivers/block/null_blk/main: Fix a double free in null_init. HID: plantronics: Workaround for double volume key presses perf symbols: Fix dso__fprintf_symbols_by_name() to return the number of printed chars net: lapbether: Prevent racing when checking whether the netif is running powerpc/prom: Mark identical_pvr_fixup as __init powerpc: Fix HAVE_HARDLOCKUP_DETECTOR_ARCH build configuration ALSA: core: remove redundant spin_lock pair in snd_card_disconnect bug: Remove redundant condition check in report_bug nfc: pn533: prevent potential memory corruption net: hns3: Limiting the scope of vector_ring_chain variable ALSA: usb-audio: Add error checks for usb_driver_claim_interface() calls liquidio: Fix unintented sign extension of a left shift of a u16 powerpc/64s: Fix pte update for kernel memory on radix powerpc/perf: Fix PMU constraint check for EBB events powerpc: iommu: fix build when neither PCI or IBMVIO is set mac80211: bail out if cipher schemes are invalid mt7601u: fix always true expression IB/hfi1: Fix error return code in parse_platform_config() net: thunderx: Fix unintentional sign extension issue RDMA/srpt: Fix error return code in srpt_cm_req_recv() i2c: cadence: add IRQ check i2c: emev2: add IRQ check i2c: jz4780: add IRQ check i2c: sh7760: add IRQ check ASoC: ak5558: correct reset polarity drm/i915/gvt: Fix error code in intel_gvt_init_device() MIPS: pci-legacy: stop using of_pci_range_to_resource powerpc/pseries: extract host bridge from pci_bus prior to bus removal rtlwifi: 8821ae: upgrade PHY and RF parameters i2c: sh7760: fix IRQ error path mwl8k: Fix a double Free in mwl8k_probe_hw vsock/vmci: log once the failed queue pair allocation RDMA/i40iw: Fix error unwinding when i40iw_hmc_sd_one fails ALSA: usb: midi: don't return -ENOMEM when usb_urb_ep_type_check fails net: davinci_emac: Fix incorrect masking of tx and rx error channel ath9k: Fix error check in ath9k_hw_read_revisions() for PCI devices ath10k: Fix ath10k_wmi_tlv_op_pull_peer_stats_info() unlock without lock powerpc/52xx: Fix an invalid ASM expression ('addi' used instead of 'add') bnxt_en: fix ternary sign extension bug in bnxt_show_temp() ARM: dts: uniphier: Change phy-mode to RGMII-ID to enable delay pins for RTL8211E arm64: dts: uniphier: Change phy-mode to RGMII-ID to enable delay pins for RTL8211E net: geneve: modify IP header check in geneve6_xmit_skb and geneve_xmit_skb net:emac/emac-mac: Fix a use after free in emac_mac_tx_buf_send RDMA/bnxt_re: Fix a double free in bnxt_qplib_alloc_res net:nfc:digital: Fix a double free in digital_tg_recv_dep_req kfifo: fix ternary sign extension bugs mm/sparse: add the missing sparse_buffer_fini() in error branch mm/memory-failure: unnecessary amount of unmapping net: Only allow init netns to set default tcp cong to a restricted algo smp: Fix smp_call_function_single_async prototype Revert "net/sctp: fix race condition in sctp_destroy_sock" sctp: delay auto_asconf init until binding the first addr Revert "of/fdt: Make sure no-map does not remove already reserved regions" Revert "fdt: Properly handle "no-map" field in the memory region" tpm: fix error return code in tpm2_get_cc_attrs_tbl() fs: dlm: fix debugfs dump tipc: convert dest node's address to network order ASoC: Intel: bytcr_rt5640: Enable jack-detect support on Asus T100TAF net: stmmac: Set FIFO sizes for ipq806x i2c: bail out early when RDWR parameters are wrong ALSA: hdsp: don't disable if not enabled ALSA: hdspm: don't disable if not enabled ALSA: rme9652: don't disable if not enabled Bluetooth: Set CONF_NOT_COMPLETE as l2cap_chan default Bluetooth: initialize skb_queue_head at l2cap_chan_create() net: bridge: when suppression is enabled exclude RARP packets Bluetooth: check for zapped sk before connecting ip6_vti: proper dev_{hold|put} in ndo_[un]init methods ASoC: Intel: bytcr_rt5640: Add quirk for the Chuwi Hi8 tablet i2c: Add I2C_AQ_NO_REP_START adapter quirk mac80211: clear the beacon's CRC after channel switch pinctrl: samsung: use 'int' for register masks in Exynos cuse: prevent clone selftests: Set CC to clang in lib.mk if LLVM is set kconfig: nconf: stop endless search loops sctp: Fix out-of-bounds warning in sctp_process_asconf_param() powerpc/smp: Set numa node before updating mask ASoC: rt286: Generalize support for ALC3263 codec ethtool: ioctl: Fix out-of-bounds warning in store_link_ksettings_for_user() samples/bpf: Fix broken tracex1 due to kprobe argument change powerpc/pseries: Stop calling printk in rtas_stop_self() wl3501_cs: Fix out-of-bounds warnings in wl3501_send_pkt wl3501_cs: Fix out-of-bounds warnings in wl3501_mgmt_join powerpc/iommu: Annotate nested lock for lockdep net: ethernet: mtk_eth_soc: fix RX VLAN offload ia64: module: fix symbolizer crash on fdescr ASoC: rt286: Make RT286_SET_GPIO_* readable and writable f2fs: fix a redundant call to f2fs_balance_fs if an error occurs PCI: iproc: Fix return value of iproc_msi_irq_domain_alloc() PCI: Release OF node in pci_scan_device()'s error path ARM: 9064/1: hw_breakpoint: Do not directly check the event's overflow_handler hook rpmsg: qcom_glink_native: fix error return code of qcom_glink_rx_data() NFSv4.2: Always flush out writes in nfs42_proc_fallocate() NFS: Deal correctly with attribute generation counter overflow PCI: endpoint: Fix missing destroy_workqueue() pNFS/flexfiles: fix incorrect size check in decode_nfs_fh() NFSv4.2 fix handling of sr_eof in SEEK's reply rtc: ds1307: Fix wday settings for rx8130 net: hns3: disable phy loopback setting in hclge_mac_start_phy sctp: do asoc update earlier in sctp_sf_do_dupcook_a ethernet:enic: Fix a use after free bug in enic_hard_start_xmit sctp: fix a SCTP_MIB_CURRESTAB leak in sctp_sf_do_dupcook_b netfilter: xt_SECMARK: add new revision to fix structure layout drm/radeon: Fix off-by-one power_state index heap overwrite drm/radeon: Avoid power table parsing memory leaks khugepaged: fix wrong result value for trace_mm_collapse_huge_page_isolate() mm/hugeltb: handle the error case in hugetlb_fix_reserve_counts() ksm: fix potential missing rmap_item for stable_node net: fix nla_strcmp to handle more then one trailing null character smc: disallow TCP_ULP in smc_setsockopt() netfilter: nfnetlink_osf: Fix a missing skb_header_pointer() NULL check sched/fair: Fix unfairness caused by missing load decay kernel: kexec_file: fix error return code of kexec_calculate_store_digests() netfilter: nftables: avoid overflows in nft_hash_buckets() i40e: Fix use-after-free in i40e_client_subtask() ARC: entry: fix off-by-one error in syscall number validation powerpc/64s: Fix crashes when toggling stf barrier powerpc/64s: Fix crashes when toggling entry flush barrier hfsplus: prevent corruption in shrinking truncate squashfs: fix divide error in calculate_skip() userfaultfd: release page in error path to avoid BUG_ON drm/radeon/dpm: Disable sclk switching on Oland when two 4K 60Hz monitors are connected iio: proximity: pulsedlight: Fix rumtime PM imbalance on error usb: fotg210-hcd: Fix an error message ACPI: scan: Fix a memory leak in an error handling path blk-mq: Swap two calls in blk_mq_exit_queue() usb: dwc3: omap: improve extcon initialization usb: dwc3: pci: Enable usb2-gadget-lpm-disable for Intel Merrifield usb: xhci: Increase timeout for HC halt usb: dwc2: Fix gadget DMA unmap direction usb: core: hub: fix race condition about TRSMRCY of resume usb: dwc3: gadget: Return success always for kick transfer in ep queue xhci: Do not use GFP_KERNEL in (potentially) atomic context xhci: Add reset resume quirk for AMD xhci controller. iio: gyro: mpu3050: Fix reported temperature value iio: tsl2583: Fix division by a zero lux_val cdc-wdm: untangle a circular dependency between callback and softint KVM: x86: Cancel pvclock_gtod_work on module removal FDDI: defxx: Make MMIO the configuration default except for EISA MIPS: Reinstate platform `__div64_32' handler MIPS: Avoid DIVU in `__div64_32' is result would be zero MIPS: Avoid handcoded DIVU in `__div64_32' altogether thermal/core/fair share: Lock the thermal zone while looping over instances kobject_uevent: remove warning in init_uevent_argv() netfilter: conntrack: Make global sysctls readonly in non-init netns clk: exynos7: Mark aclk_fsys1_200 as critical nvme: do not try to reconfigure APST when the controller is not live x86/msr: Fix wr/rdmsr_safe_regs_on_cpu() prototypes kgdb: fix gcc-11 warning on indentation usb: sl811-hcd: improve misleading indentation cxgb4: Fix the -Wmisleading-indentation warning isdn: capi: fix mismatched prototypes pinctrl: ingenic: Improve unreachable code generation xsk: Simplify detection of empty and full rings PCI: thunder: Fix compile testing ARM: 9066/1: ftrace: pause/unpause function graph tracer in cpu_suspend() ACPI / hotplug / PCI: Fix reference count leak in enable_slot() Input: elants_i2c - do not bind to i2c-hid compatible ACPI instantiated devices Input: silead - add workaround for x86 BIOS-es which bring the chip up in a stuck state um: Mark all kernel symbols as local ARM: 9075/1: kernel: Fix interrupted SMC calls scripts/recordmcount.pl: Fix RISC-V regex for clang riscv: Workaround mcount name prior to clang-13 ceph: fix fscache invalidation scsi: target: tcmu: Return from tcmu_handle_completions() if cmd_id not found gpiolib: acpi: Add quirk to ignore EC wakeups on Dell Venue 10 Pro 5055 ALSA: hda: generic: change the DAC ctl name for LO+SPK or LO+HP block: reexpand iov_iter after read/write lib: stackdepot: turn depot_lock spinlock to raw_spinlock net: stmmac: Do not enable RX FIFO overflow interrupts ip6_gre: proper dev_{hold|put} in ndo_[un]init methods sit: proper dev_{hold|put} in ndo_[un]init methods ip6_tunnel: sit: proper dev_{hold|put} in ndo_[un]init methods ipv6: remove extra dev_hold() for fallback tunnels iomap: fix sub-page uptodate handling KVM: arm64: Initialize VCPU mdcr_el2 before loading it tweewide: Fix most Shebang lines scripts: switch explicitly to Python 3 Linux 4.19.191 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: I2ea4fc6350bb5c5b5ae38ec7ad52ec20cf3b7aae
810 lines
19 KiB
C
810 lines
19 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* fs/f2fs/inline.c
|
|
* Copyright (c) 2013, Intel Corporation
|
|
* Authors: Huajun Li <huajun.li@intel.com>
|
|
* Haicheng Li <haicheng.li@intel.com>
|
|
*/
|
|
|
|
#include <linux/fs.h>
|
|
#include <linux/f2fs_fs.h>
|
|
|
|
#include "f2fs.h"
|
|
#include "node.h"
|
|
#include <trace/events/android_fs.h>
|
|
|
|
bool f2fs_may_inline_data(struct inode *inode)
|
|
{
|
|
if (f2fs_is_atomic_file(inode))
|
|
return false;
|
|
|
|
if (!S_ISREG(inode->i_mode) && !S_ISLNK(inode->i_mode))
|
|
return false;
|
|
|
|
if (i_size_read(inode) > MAX_INLINE_DATA(inode))
|
|
return false;
|
|
|
|
if (f2fs_post_read_required(inode))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
bool f2fs_may_inline_dentry(struct inode *inode)
|
|
{
|
|
if (!test_opt(F2FS_I_SB(inode), INLINE_DENTRY))
|
|
return false;
|
|
|
|
if (!S_ISDIR(inode->i_mode))
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
void f2fs_do_read_inline_data(struct page *page, struct page *ipage)
|
|
{
|
|
struct inode *inode = page->mapping->host;
|
|
void *src_addr, *dst_addr;
|
|
|
|
if (PageUptodate(page))
|
|
return;
|
|
|
|
f2fs_bug_on(F2FS_P_SB(page), page->index);
|
|
|
|
zero_user_segment(page, MAX_INLINE_DATA(inode), PAGE_SIZE);
|
|
|
|
/* Copy the whole inline data block */
|
|
src_addr = inline_data_addr(inode, ipage);
|
|
dst_addr = kmap_atomic(page);
|
|
memcpy(dst_addr, src_addr, MAX_INLINE_DATA(inode));
|
|
flush_dcache_page(page);
|
|
kunmap_atomic(dst_addr);
|
|
if (!PageUptodate(page))
|
|
SetPageUptodate(page);
|
|
}
|
|
|
|
void f2fs_truncate_inline_inode(struct inode *inode,
|
|
struct page *ipage, u64 from)
|
|
{
|
|
void *addr;
|
|
|
|
if (from >= MAX_INLINE_DATA(inode))
|
|
return;
|
|
|
|
addr = inline_data_addr(inode, ipage);
|
|
|
|
f2fs_wait_on_page_writeback(ipage, NODE, true, true);
|
|
memset(addr + from, 0, MAX_INLINE_DATA(inode) - from);
|
|
set_page_dirty(ipage);
|
|
|
|
if (from == 0)
|
|
clear_inode_flag(inode, FI_DATA_EXIST);
|
|
}
|
|
|
|
int f2fs_read_inline_data(struct inode *inode, struct page *page)
|
|
{
|
|
struct page *ipage;
|
|
|
|
if (trace_android_fs_dataread_start_enabled()) {
|
|
char *path, pathbuf[MAX_TRACE_PATHBUF_LEN];
|
|
|
|
path = android_fstrace_get_pathname(pathbuf,
|
|
MAX_TRACE_PATHBUF_LEN,
|
|
inode);
|
|
trace_android_fs_dataread_start(inode, page_offset(page),
|
|
PAGE_SIZE, current->pid,
|
|
path, current->comm);
|
|
}
|
|
|
|
ipage = f2fs_get_node_page(F2FS_I_SB(inode), inode->i_ino);
|
|
if (IS_ERR(ipage)) {
|
|
trace_android_fs_dataread_end(inode, page_offset(page),
|
|
PAGE_SIZE);
|
|
unlock_page(page);
|
|
return PTR_ERR(ipage);
|
|
}
|
|
|
|
if (!f2fs_has_inline_data(inode)) {
|
|
f2fs_put_page(ipage, 1);
|
|
trace_android_fs_dataread_end(inode, page_offset(page),
|
|
PAGE_SIZE);
|
|
return -EAGAIN;
|
|
}
|
|
|
|
if (page->index)
|
|
zero_user_segment(page, 0, PAGE_SIZE);
|
|
else
|
|
f2fs_do_read_inline_data(page, ipage);
|
|
|
|
if (!PageUptodate(page))
|
|
SetPageUptodate(page);
|
|
f2fs_put_page(ipage, 1);
|
|
trace_android_fs_dataread_end(inode, page_offset(page),
|
|
PAGE_SIZE);
|
|
unlock_page(page);
|
|
return 0;
|
|
}
|
|
|
|
int f2fs_convert_inline_page(struct dnode_of_data *dn, struct page *page)
|
|
{
|
|
struct f2fs_io_info fio = {
|
|
.sbi = F2FS_I_SB(dn->inode),
|
|
.ino = dn->inode->i_ino,
|
|
.type = DATA,
|
|
.op = REQ_OP_WRITE,
|
|
.op_flags = REQ_SYNC | REQ_PRIO,
|
|
.page = page,
|
|
.encrypted_page = NULL,
|
|
.io_type = FS_DATA_IO,
|
|
};
|
|
struct node_info ni;
|
|
int dirty, err;
|
|
|
|
if (!f2fs_exist_data(dn->inode))
|
|
goto clear_out;
|
|
|
|
err = f2fs_reserve_block(dn, 0);
|
|
if (err)
|
|
return err;
|
|
|
|
err = f2fs_get_node_info(fio.sbi, dn->nid, &ni);
|
|
if (err) {
|
|
f2fs_truncate_data_blocks_range(dn, 1);
|
|
f2fs_put_dnode(dn);
|
|
return err;
|
|
}
|
|
|
|
fio.version = ni.version;
|
|
|
|
if (unlikely(dn->data_blkaddr != NEW_ADDR)) {
|
|
f2fs_put_dnode(dn);
|
|
set_sbi_flag(fio.sbi, SBI_NEED_FSCK);
|
|
f2fs_warn(fio.sbi, "%s: corrupted inline inode ino=%lx, i_addr[0]:0x%x, run fsck to fix.",
|
|
__func__, dn->inode->i_ino, dn->data_blkaddr);
|
|
return -EFSCORRUPTED;
|
|
}
|
|
|
|
f2fs_bug_on(F2FS_P_SB(page), PageWriteback(page));
|
|
|
|
f2fs_do_read_inline_data(page, dn->inode_page);
|
|
set_page_dirty(page);
|
|
|
|
/* clear dirty state */
|
|
dirty = clear_page_dirty_for_io(page);
|
|
|
|
/* write data page to try to make data consistent */
|
|
set_page_writeback(page);
|
|
ClearPageError(page);
|
|
fio.old_blkaddr = dn->data_blkaddr;
|
|
set_inode_flag(dn->inode, FI_HOT_DATA);
|
|
f2fs_outplace_write_data(dn, &fio);
|
|
f2fs_wait_on_page_writeback(page, DATA, true, true);
|
|
if (dirty) {
|
|
inode_dec_dirty_pages(dn->inode);
|
|
f2fs_remove_dirty_inode(dn->inode);
|
|
}
|
|
|
|
/* this converted inline_data should be recovered. */
|
|
set_inode_flag(dn->inode, FI_APPEND_WRITE);
|
|
|
|
/* clear inline data and flag after data writeback */
|
|
f2fs_truncate_inline_inode(dn->inode, dn->inode_page, 0);
|
|
clear_inline_node(dn->inode_page);
|
|
clear_out:
|
|
stat_dec_inline_inode(dn->inode);
|
|
clear_inode_flag(dn->inode, FI_INLINE_DATA);
|
|
f2fs_put_dnode(dn);
|
|
return 0;
|
|
}
|
|
|
|
int f2fs_convert_inline_inode(struct inode *inode)
|
|
{
|
|
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
|
|
struct dnode_of_data dn;
|
|
struct page *ipage, *page;
|
|
int err = 0;
|
|
|
|
if (!f2fs_has_inline_data(inode))
|
|
return 0;
|
|
|
|
err = dquot_initialize(inode);
|
|
if (err)
|
|
return err;
|
|
|
|
page = f2fs_grab_cache_page(inode->i_mapping, 0, false);
|
|
if (!page)
|
|
return -ENOMEM;
|
|
|
|
f2fs_lock_op(sbi);
|
|
|
|
ipage = f2fs_get_node_page(sbi, inode->i_ino);
|
|
if (IS_ERR(ipage)) {
|
|
err = PTR_ERR(ipage);
|
|
goto out;
|
|
}
|
|
|
|
set_new_dnode(&dn, inode, ipage, ipage, 0);
|
|
|
|
if (f2fs_has_inline_data(inode))
|
|
err = f2fs_convert_inline_page(&dn, page);
|
|
|
|
f2fs_put_dnode(&dn);
|
|
out:
|
|
f2fs_unlock_op(sbi);
|
|
|
|
f2fs_put_page(page, 1);
|
|
|
|
if (!err)
|
|
f2fs_balance_fs(sbi, dn.node_changed);
|
|
|
|
return err;
|
|
}
|
|
|
|
int f2fs_write_inline_data(struct inode *inode, struct page *page)
|
|
{
|
|
void *src_addr, *dst_addr;
|
|
struct dnode_of_data dn;
|
|
int err;
|
|
|
|
set_new_dnode(&dn, inode, NULL, NULL, 0);
|
|
err = f2fs_get_dnode_of_data(&dn, 0, LOOKUP_NODE);
|
|
if (err)
|
|
return err;
|
|
|
|
if (!f2fs_has_inline_data(inode)) {
|
|
f2fs_put_dnode(&dn);
|
|
return -EAGAIN;
|
|
}
|
|
|
|
f2fs_bug_on(F2FS_I_SB(inode), page->index);
|
|
|
|
f2fs_wait_on_page_writeback(dn.inode_page, NODE, true, true);
|
|
src_addr = kmap_atomic(page);
|
|
dst_addr = inline_data_addr(inode, dn.inode_page);
|
|
memcpy(dst_addr, src_addr, MAX_INLINE_DATA(inode));
|
|
kunmap_atomic(src_addr);
|
|
set_page_dirty(dn.inode_page);
|
|
|
|
f2fs_clear_radix_tree_dirty_tag(page);
|
|
|
|
set_inode_flag(inode, FI_APPEND_WRITE);
|
|
set_inode_flag(inode, FI_DATA_EXIST);
|
|
|
|
clear_inline_node(dn.inode_page);
|
|
f2fs_put_dnode(&dn);
|
|
return 0;
|
|
}
|
|
|
|
int f2fs_recover_inline_data(struct inode *inode, struct page *npage)
|
|
{
|
|
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
|
|
struct f2fs_inode *ri = NULL;
|
|
void *src_addr, *dst_addr;
|
|
struct page *ipage;
|
|
|
|
/*
|
|
* The inline_data recovery policy is as follows.
|
|
* [prev.] [next] of inline_data flag
|
|
* o o -> recover inline_data
|
|
* o x -> remove inline_data, and then recover data blocks
|
|
* x o -> remove inline_data, and then recover inline_data
|
|
* x x -> recover data blocks
|
|
*/
|
|
if (IS_INODE(npage))
|
|
ri = F2FS_INODE(npage);
|
|
|
|
if (f2fs_has_inline_data(inode) &&
|
|
ri && (ri->i_inline & F2FS_INLINE_DATA)) {
|
|
process_inline:
|
|
ipage = f2fs_get_node_page(sbi, inode->i_ino);
|
|
if (IS_ERR(ipage))
|
|
return PTR_ERR(ipage);
|
|
|
|
f2fs_wait_on_page_writeback(ipage, NODE, true, true);
|
|
|
|
src_addr = inline_data_addr(inode, npage);
|
|
dst_addr = inline_data_addr(inode, ipage);
|
|
memcpy(dst_addr, src_addr, MAX_INLINE_DATA(inode));
|
|
|
|
set_inode_flag(inode, FI_INLINE_DATA);
|
|
set_inode_flag(inode, FI_DATA_EXIST);
|
|
|
|
set_page_dirty(ipage);
|
|
f2fs_put_page(ipage, 1);
|
|
return 1;
|
|
}
|
|
|
|
if (f2fs_has_inline_data(inode)) {
|
|
ipage = f2fs_get_node_page(sbi, inode->i_ino);
|
|
if (IS_ERR(ipage))
|
|
return PTR_ERR(ipage);
|
|
f2fs_truncate_inline_inode(inode, ipage, 0);
|
|
clear_inode_flag(inode, FI_INLINE_DATA);
|
|
f2fs_put_page(ipage, 1);
|
|
} else if (ri && (ri->i_inline & F2FS_INLINE_DATA)) {
|
|
int ret;
|
|
|
|
ret = f2fs_truncate_blocks(inode, 0, false);
|
|
if (ret)
|
|
return ret;
|
|
goto process_inline;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
struct f2fs_dir_entry *f2fs_find_in_inline_dir(struct inode *dir,
|
|
const struct f2fs_filename *fname,
|
|
struct page **res_page)
|
|
{
|
|
struct f2fs_sb_info *sbi = F2FS_SB(dir->i_sb);
|
|
struct f2fs_dir_entry *de;
|
|
struct f2fs_dentry_ptr d;
|
|
struct page *ipage;
|
|
void *inline_dentry;
|
|
|
|
ipage = f2fs_get_node_page(sbi, dir->i_ino);
|
|
if (IS_ERR(ipage)) {
|
|
*res_page = ipage;
|
|
return NULL;
|
|
}
|
|
|
|
inline_dentry = inline_data_addr(dir, ipage);
|
|
|
|
make_dentry_ptr_inline(dir, &d, inline_dentry);
|
|
de = f2fs_find_target_dentry(&d, fname, NULL);
|
|
unlock_page(ipage);
|
|
if (de)
|
|
*res_page = ipage;
|
|
else
|
|
f2fs_put_page(ipage, 0);
|
|
|
|
return de;
|
|
}
|
|
|
|
int f2fs_make_empty_inline_dir(struct inode *inode, struct inode *parent,
|
|
struct page *ipage)
|
|
{
|
|
struct f2fs_dentry_ptr d;
|
|
void *inline_dentry;
|
|
|
|
inline_dentry = inline_data_addr(inode, ipage);
|
|
|
|
make_dentry_ptr_inline(inode, &d, inline_dentry);
|
|
f2fs_do_make_empty_dir(inode, parent, &d);
|
|
|
|
set_page_dirty(ipage);
|
|
|
|
/* update i_size to MAX_INLINE_DATA */
|
|
if (i_size_read(inode) < MAX_INLINE_DATA(inode))
|
|
f2fs_i_size_write(inode, MAX_INLINE_DATA(inode));
|
|
return 0;
|
|
}
|
|
|
|
/*
|
|
* NOTE: ipage is grabbed by caller, but if any error occurs, we should
|
|
* release ipage in this function.
|
|
*/
|
|
static int f2fs_move_inline_dirents(struct inode *dir, struct page *ipage,
|
|
void *inline_dentry)
|
|
{
|
|
struct page *page;
|
|
struct dnode_of_data dn;
|
|
struct f2fs_dentry_block *dentry_blk;
|
|
struct f2fs_dentry_ptr src, dst;
|
|
int err;
|
|
|
|
page = f2fs_grab_cache_page(dir->i_mapping, 0, true);
|
|
if (!page) {
|
|
f2fs_put_page(ipage, 1);
|
|
return -ENOMEM;
|
|
}
|
|
|
|
set_new_dnode(&dn, dir, ipage, NULL, 0);
|
|
err = f2fs_reserve_block(&dn, 0);
|
|
if (err)
|
|
goto out;
|
|
|
|
if (unlikely(dn.data_blkaddr != NEW_ADDR)) {
|
|
f2fs_put_dnode(&dn);
|
|
set_sbi_flag(F2FS_P_SB(page), SBI_NEED_FSCK);
|
|
f2fs_warn(F2FS_P_SB(page), "%s: corrupted inline inode ino=%lx, i_addr[0]:0x%x, run fsck to fix.",
|
|
__func__, dir->i_ino, dn.data_blkaddr);
|
|
err = -EFSCORRUPTED;
|
|
goto out;
|
|
}
|
|
|
|
f2fs_wait_on_page_writeback(page, DATA, true, true);
|
|
|
|
dentry_blk = page_address(page);
|
|
|
|
make_dentry_ptr_inline(dir, &src, inline_dentry);
|
|
make_dentry_ptr_block(dir, &dst, dentry_blk);
|
|
|
|
/* copy data from inline dentry block to new dentry block */
|
|
memcpy(dst.bitmap, src.bitmap, src.nr_bitmap);
|
|
memset(dst.bitmap + src.nr_bitmap, 0, dst.nr_bitmap - src.nr_bitmap);
|
|
/*
|
|
* we do not need to zero out remainder part of dentry and filename
|
|
* field, since we have used bitmap for marking the usage status of
|
|
* them, besides, we can also ignore copying/zeroing reserved space
|
|
* of dentry block, because them haven't been used so far.
|
|
*/
|
|
memcpy(dst.dentry, src.dentry, SIZE_OF_DIR_ENTRY * src.max);
|
|
memcpy(dst.filename, src.filename, src.max * F2FS_SLOT_LEN);
|
|
|
|
if (!PageUptodate(page))
|
|
SetPageUptodate(page);
|
|
set_page_dirty(page);
|
|
|
|
/* clear inline dir and flag after data writeback */
|
|
f2fs_truncate_inline_inode(dir, ipage, 0);
|
|
|
|
stat_dec_inline_dir(dir);
|
|
clear_inode_flag(dir, FI_INLINE_DENTRY);
|
|
|
|
/*
|
|
* should retrieve reserved space which was used to keep
|
|
* inline_dentry's structure for backward compatibility.
|
|
*/
|
|
if (!f2fs_sb_has_flexible_inline_xattr(F2FS_I_SB(dir)) &&
|
|
!f2fs_has_inline_xattr(dir))
|
|
F2FS_I(dir)->i_inline_xattr_size = 0;
|
|
|
|
f2fs_i_depth_write(dir, 1);
|
|
if (i_size_read(dir) < PAGE_SIZE)
|
|
f2fs_i_size_write(dir, PAGE_SIZE);
|
|
out:
|
|
f2fs_put_page(page, 1);
|
|
return err;
|
|
}
|
|
|
|
static int f2fs_add_inline_entries(struct inode *dir, void *inline_dentry)
|
|
{
|
|
struct f2fs_dentry_ptr d;
|
|
unsigned long bit_pos = 0;
|
|
int err = 0;
|
|
|
|
make_dentry_ptr_inline(dir, &d, inline_dentry);
|
|
|
|
while (bit_pos < d.max) {
|
|
struct f2fs_dir_entry *de;
|
|
struct f2fs_filename fname;
|
|
nid_t ino;
|
|
umode_t fake_mode;
|
|
|
|
if (!test_bit_le(bit_pos, d.bitmap)) {
|
|
bit_pos++;
|
|
continue;
|
|
}
|
|
|
|
de = &d.dentry[bit_pos];
|
|
|
|
if (unlikely(!de->name_len)) {
|
|
bit_pos++;
|
|
continue;
|
|
}
|
|
|
|
/*
|
|
* We only need the disk_name and hash to move the dentry.
|
|
* We don't need the original or casefolded filenames.
|
|
*/
|
|
memset(&fname, 0, sizeof(fname));
|
|
fname.disk_name.name = d.filename[bit_pos];
|
|
fname.disk_name.len = le16_to_cpu(de->name_len);
|
|
fname.hash = de->hash_code;
|
|
|
|
ino = le32_to_cpu(de->ino);
|
|
fake_mode = f2fs_get_de_type(de) << S_SHIFT;
|
|
|
|
err = f2fs_add_regular_entry(dir, &fname, NULL, ino, fake_mode);
|
|
if (err)
|
|
goto punch_dentry_pages;
|
|
|
|
bit_pos += GET_DENTRY_SLOTS(le16_to_cpu(de->name_len));
|
|
}
|
|
return 0;
|
|
punch_dentry_pages:
|
|
truncate_inode_pages(&dir->i_data, 0);
|
|
f2fs_truncate_blocks(dir, 0, false);
|
|
f2fs_remove_dirty_inode(dir);
|
|
return err;
|
|
}
|
|
|
|
static int f2fs_move_rehashed_dirents(struct inode *dir, struct page *ipage,
|
|
void *inline_dentry)
|
|
{
|
|
void *backup_dentry;
|
|
int err;
|
|
|
|
backup_dentry = f2fs_kmalloc(F2FS_I_SB(dir),
|
|
MAX_INLINE_DATA(dir), GFP_F2FS_ZERO);
|
|
if (!backup_dentry) {
|
|
f2fs_put_page(ipage, 1);
|
|
return -ENOMEM;
|
|
}
|
|
|
|
memcpy(backup_dentry, inline_dentry, MAX_INLINE_DATA(dir));
|
|
f2fs_truncate_inline_inode(dir, ipage, 0);
|
|
|
|
unlock_page(ipage);
|
|
|
|
err = f2fs_add_inline_entries(dir, backup_dentry);
|
|
if (err)
|
|
goto recover;
|
|
|
|
lock_page(ipage);
|
|
|
|
stat_dec_inline_dir(dir);
|
|
clear_inode_flag(dir, FI_INLINE_DENTRY);
|
|
|
|
/*
|
|
* should retrieve reserved space which was used to keep
|
|
* inline_dentry's structure for backward compatibility.
|
|
*/
|
|
if (!f2fs_sb_has_flexible_inline_xattr(F2FS_I_SB(dir)) &&
|
|
!f2fs_has_inline_xattr(dir))
|
|
F2FS_I(dir)->i_inline_xattr_size = 0;
|
|
|
|
kvfree(backup_dentry);
|
|
return 0;
|
|
recover:
|
|
lock_page(ipage);
|
|
f2fs_wait_on_page_writeback(ipage, NODE, true, true);
|
|
memcpy(inline_dentry, backup_dentry, MAX_INLINE_DATA(dir));
|
|
f2fs_i_depth_write(dir, 0);
|
|
f2fs_i_size_write(dir, MAX_INLINE_DATA(dir));
|
|
set_page_dirty(ipage);
|
|
f2fs_put_page(ipage, 1);
|
|
|
|
kvfree(backup_dentry);
|
|
return err;
|
|
}
|
|
|
|
static int do_convert_inline_dir(struct inode *dir, struct page *ipage,
|
|
void *inline_dentry)
|
|
{
|
|
if (!F2FS_I(dir)->i_dir_level)
|
|
return f2fs_move_inline_dirents(dir, ipage, inline_dentry);
|
|
else
|
|
return f2fs_move_rehashed_dirents(dir, ipage, inline_dentry);
|
|
}
|
|
|
|
int f2fs_try_convert_inline_dir(struct inode *dir, struct dentry *dentry)
|
|
{
|
|
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
|
|
struct page *ipage;
|
|
struct f2fs_filename fname;
|
|
void *inline_dentry = NULL;
|
|
int err = 0;
|
|
|
|
if (!f2fs_has_inline_dentry(dir))
|
|
return 0;
|
|
|
|
f2fs_lock_op(sbi);
|
|
|
|
err = f2fs_setup_filename(dir, &dentry->d_name, 0, &fname);
|
|
if (err)
|
|
goto out;
|
|
|
|
ipage = f2fs_get_node_page(sbi, dir->i_ino);
|
|
if (IS_ERR(ipage)) {
|
|
err = PTR_ERR(ipage);
|
|
goto out_fname;
|
|
}
|
|
|
|
if (f2fs_has_enough_room(dir, ipage, &fname)) {
|
|
f2fs_put_page(ipage, 1);
|
|
goto out_fname;
|
|
}
|
|
|
|
inline_dentry = inline_data_addr(dir, ipage);
|
|
|
|
err = do_convert_inline_dir(dir, ipage, inline_dentry);
|
|
if (!err)
|
|
f2fs_put_page(ipage, 1);
|
|
out_fname:
|
|
f2fs_free_filename(&fname);
|
|
out:
|
|
f2fs_unlock_op(sbi);
|
|
return err;
|
|
}
|
|
|
|
int f2fs_add_inline_entry(struct inode *dir, const struct f2fs_filename *fname,
|
|
struct inode *inode, nid_t ino, umode_t mode)
|
|
{
|
|
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
|
|
struct page *ipage;
|
|
unsigned int bit_pos;
|
|
void *inline_dentry = NULL;
|
|
struct f2fs_dentry_ptr d;
|
|
int slots = GET_DENTRY_SLOTS(fname->disk_name.len);
|
|
struct page *page = NULL;
|
|
int err = 0;
|
|
|
|
ipage = f2fs_get_node_page(sbi, dir->i_ino);
|
|
if (IS_ERR(ipage))
|
|
return PTR_ERR(ipage);
|
|
|
|
inline_dentry = inline_data_addr(dir, ipage);
|
|
make_dentry_ptr_inline(dir, &d, inline_dentry);
|
|
|
|
bit_pos = f2fs_room_for_filename(d.bitmap, slots, d.max);
|
|
if (bit_pos >= d.max) {
|
|
err = do_convert_inline_dir(dir, ipage, inline_dentry);
|
|
if (err)
|
|
return err;
|
|
err = -EAGAIN;
|
|
goto out;
|
|
}
|
|
|
|
if (inode) {
|
|
down_write(&F2FS_I(inode)->i_sem);
|
|
page = f2fs_init_inode_metadata(inode, dir, fname, ipage);
|
|
if (IS_ERR(page)) {
|
|
err = PTR_ERR(page);
|
|
goto fail;
|
|
}
|
|
}
|
|
|
|
f2fs_wait_on_page_writeback(ipage, NODE, true, true);
|
|
|
|
f2fs_update_dentry(ino, mode, &d, &fname->disk_name, fname->hash,
|
|
bit_pos);
|
|
|
|
set_page_dirty(ipage);
|
|
|
|
/* we don't need to mark_inode_dirty now */
|
|
if (inode) {
|
|
f2fs_i_pino_write(inode, dir->i_ino);
|
|
|
|
/* synchronize inode page's data from inode cache */
|
|
if (is_inode_flag_set(inode, FI_NEW_INODE))
|
|
f2fs_update_inode(inode, page);
|
|
|
|
f2fs_put_page(page, 1);
|
|
}
|
|
|
|
f2fs_update_parent_metadata(dir, inode, 0);
|
|
fail:
|
|
if (inode)
|
|
up_write(&F2FS_I(inode)->i_sem);
|
|
out:
|
|
f2fs_put_page(ipage, 1);
|
|
return err;
|
|
}
|
|
|
|
void f2fs_delete_inline_entry(struct f2fs_dir_entry *dentry, struct page *page,
|
|
struct inode *dir, struct inode *inode)
|
|
{
|
|
struct f2fs_dentry_ptr d;
|
|
void *inline_dentry;
|
|
int slots = GET_DENTRY_SLOTS(le16_to_cpu(dentry->name_len));
|
|
unsigned int bit_pos;
|
|
int i;
|
|
|
|
lock_page(page);
|
|
f2fs_wait_on_page_writeback(page, NODE, true, true);
|
|
|
|
inline_dentry = inline_data_addr(dir, page);
|
|
make_dentry_ptr_inline(dir, &d, inline_dentry);
|
|
|
|
bit_pos = dentry - d.dentry;
|
|
for (i = 0; i < slots; i++)
|
|
__clear_bit_le(bit_pos + i, d.bitmap);
|
|
|
|
set_page_dirty(page);
|
|
f2fs_put_page(page, 1);
|
|
|
|
dir->i_ctime = dir->i_mtime = current_time(dir);
|
|
f2fs_mark_inode_dirty_sync(dir, false);
|
|
|
|
if (inode)
|
|
f2fs_drop_nlink(dir, inode);
|
|
}
|
|
|
|
bool f2fs_empty_inline_dir(struct inode *dir)
|
|
{
|
|
struct f2fs_sb_info *sbi = F2FS_I_SB(dir);
|
|
struct page *ipage;
|
|
unsigned int bit_pos = 2;
|
|
void *inline_dentry;
|
|
struct f2fs_dentry_ptr d;
|
|
|
|
ipage = f2fs_get_node_page(sbi, dir->i_ino);
|
|
if (IS_ERR(ipage))
|
|
return false;
|
|
|
|
inline_dentry = inline_data_addr(dir, ipage);
|
|
make_dentry_ptr_inline(dir, &d, inline_dentry);
|
|
|
|
bit_pos = find_next_bit_le(d.bitmap, d.max, bit_pos);
|
|
|
|
f2fs_put_page(ipage, 1);
|
|
|
|
if (bit_pos < d.max)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
int f2fs_read_inline_dir(struct file *file, struct dir_context *ctx,
|
|
struct fscrypt_str *fstr)
|
|
{
|
|
struct inode *inode = file_inode(file);
|
|
struct page *ipage = NULL;
|
|
struct f2fs_dentry_ptr d;
|
|
void *inline_dentry = NULL;
|
|
int err;
|
|
|
|
make_dentry_ptr_inline(inode, &d, inline_dentry);
|
|
|
|
if (ctx->pos == d.max)
|
|
return 0;
|
|
|
|
ipage = f2fs_get_node_page(F2FS_I_SB(inode), inode->i_ino);
|
|
if (IS_ERR(ipage))
|
|
return PTR_ERR(ipage);
|
|
|
|
/*
|
|
* f2fs_readdir was protected by inode.i_rwsem, it is safe to access
|
|
* ipage without page's lock held.
|
|
*/
|
|
unlock_page(ipage);
|
|
|
|
inline_dentry = inline_data_addr(inode, ipage);
|
|
|
|
make_dentry_ptr_inline(inode, &d, inline_dentry);
|
|
|
|
err = f2fs_fill_dentries(ctx, &d, 0, fstr);
|
|
if (!err)
|
|
ctx->pos = d.max;
|
|
|
|
f2fs_put_page(ipage, 0);
|
|
return err < 0 ? err : 0;
|
|
}
|
|
|
|
int f2fs_inline_data_fiemap(struct inode *inode,
|
|
struct fiemap_extent_info *fieinfo, __u64 start, __u64 len)
|
|
{
|
|
__u64 byteaddr, ilen;
|
|
__u32 flags = FIEMAP_EXTENT_DATA_INLINE | FIEMAP_EXTENT_NOT_ALIGNED |
|
|
FIEMAP_EXTENT_LAST;
|
|
struct node_info ni;
|
|
struct page *ipage;
|
|
int err = 0;
|
|
|
|
ipage = f2fs_get_node_page(F2FS_I_SB(inode), inode->i_ino);
|
|
if (IS_ERR(ipage))
|
|
return PTR_ERR(ipage);
|
|
|
|
if ((S_ISREG(inode->i_mode) || S_ISLNK(inode->i_mode)) &&
|
|
!f2fs_has_inline_data(inode)) {
|
|
err = -EAGAIN;
|
|
goto out;
|
|
}
|
|
|
|
if (S_ISDIR(inode->i_mode) && !f2fs_has_inline_dentry(inode)) {
|
|
err = -EAGAIN;
|
|
goto out;
|
|
}
|
|
|
|
ilen = min_t(size_t, MAX_INLINE_DATA(inode), i_size_read(inode));
|
|
if (start >= ilen)
|
|
goto out;
|
|
if (start + len < ilen)
|
|
ilen = start + len;
|
|
ilen -= start;
|
|
|
|
err = f2fs_get_node_info(F2FS_I_SB(inode), inode->i_ino, &ni);
|
|
if (err)
|
|
goto out;
|
|
|
|
byteaddr = (__u64)ni.blk_addr << inode->i_sb->s_blocksize_bits;
|
|
byteaddr += (char *)inline_data_addr(inode, ipage) -
|
|
(char *)F2FS_INODE(ipage);
|
|
err = fiemap_fill_next_extent(fieinfo, start, byteaddr, ilen, flags);
|
|
out:
|
|
f2fs_put_page(ipage, 1);
|
|
return err;
|
|
}
|