-----BEGIN PGP SIGNATURE----- iQIzBAABCAAdFiEEZH8oZUiU471FcZm+ONu9yGCSaT4FAmHyVbEACgkQONu9yGCS aT6r6BAA13mGwb3g/n6W1539J2McTd3Wq7HhkvGnOQmJAHJKLzp51QYAXgLbRLCM gUOCPXh6o2gt3+lFrhFy0TE9F1VQY7Igyb2RziF9mdAcvEqcBXL11n6kZHGxx0TO rOpv/SoWMd/QrKC7Ytf5zgH+81dGYWr1L1Ge9g7KWmCev15zAvJQ4mQv6a8CQhCD pUZRBvFx8AGS6q/s9ZPZfvVBcHJDNF89/mkkWNzFgIOcXJh/01JdqNK635stUXu4 +hQYUpG2gj9X2i+e0bc2i95pql7M5OAdX3TBlMeiEjKkyXJuyWTCXSO332QLTeaP xF8Z6JQ0n4W4GI9AgQCWwOaDahtlh6rmpVj+iekeYOMMB6Y5zAoFOIu1DTBEwDK6 F+s5KGfV8t5zkWY6iFOUwHTsjeNc4qqX8B6Br3Yjo7HHBxiggNDD5k4IYe0wAvJL NzOTjdvVbG+qRmhGMQMOpLhDJaHVEJCaXCmv1G97AceaL/RcenUZkn3pQZbn5O7u iMFV620WB0tYyfsiWaQrC7HgVZRyoUYBcxuxdm/g8NqYAPM61HOBKQbyaG9jClyf dq+lnvipJzUmeTsrzkd0NON24HS53hYBZPQjxp7xuoFooBUQjd5iYJvPzeLUm2+g /PlDC4B48pZa3zm8z2amyxf7leaxZUqc2d/J8wSGM/lvaJ3BV7M= =eMMF -----END PGP SIGNATURE----- Merge 5.4.174 into android11-5.4-lts Changes in 5.4.174 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 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 can: softing_cs: softingcs_probe(): fix memleak on registration failure lkdtm: Fix content of section containing lkdtm_rodata_do_nothing() iommu/io-pgtable-arm-v7s: Add error handle for page table allocation failure 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 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/rockchip: dsi: Hold pm-runtime across bind/unbind drm/rockchip: dsi: Reconfigure hardware on resume() 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 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 wcn36xx: Indicate beacon not connection loss on MISSED_BEACON_IND wcn36xx: Release DMA channel descriptor allocations media: videobuf2: Fix the size printk format 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: meson-gxbb-wetek: fix HDMI in early boot arm64: dts: meson-gxbb-wetek: fix missing GPIO binding Bluetooth: stop proccessing malicious adv data tee: fix put order in teedev_close_context() media: dmxdev: fix UAF when dvb_register_device() fails crypto: qce - fix uaf on qce_ahash_register_one 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() 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: venus: core: Fix a resource leak in the error handling path of 'venus_probe()' netfilter: bridge: add support for pppoe filtering arm64: dts: qcom: msm8916: fix MMC controller aliases ACPI: EC: Rework flushing of EC work while suspended to idle 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-j721e: Fix the L2 cache sets 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 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 sched/rt: Try to restart rt period timer when rt runtime exceeded 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() crypto: stm32/cryp - fix xts and race condition in crypto_engine requests crypto: stm32/cryp - fix double pm exit crypto: stm32/cryp - fix lrw chaining mode 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 drm/msm/dpu: fix safe status debugfs file drm/bridge: ti-sn65dsi86: Set max register for regmap 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 ARM: dts: armada-38x: Add generic compatible to UART nodes mmc: meson-mx-sdio: add IRQ check selinux: fix potential memleak in selinux_add_opt() bpftool: Enable line buffering for stdout 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() netfilter: ipt_CLUSTERIP: fix refcount leak in clusterip_tg_check() bpf: Fix SO_RCVBUF/SO_SNDBUF handling in _bpf_setsockopt(). 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 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: 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 spi: spi-meson-spifc: Add missing pm_runtime_disable() in meson_spifc_probe tpm: add request_locality before write TPM_INT_ENABLE 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 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/hns: Validate the pkey index 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 ALSA: oss: fix compile error when OSS_DEBUG is enabled char/mwave: Adjust io port register size binder: fix handling of error during copy iommu/io-pgtable-arm: Fix table descriptor paddr formatting scsi: ufs: Fix race conditions related to driver data 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 clk: stm32: Fix ltdc's clock turn off by clk_disable_unused() after system enter shell dmaengine: pxa/mmp: stop referencing config->slave_id iommu/iova: Fix race between FQ timeout and teardown 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 mips: lantiq: add support for clk_set_parent() mips: bcm63xx: add support for clk_set_parent() RDMA/cxgb4: Set queue pair state when being queried of: base: Fix phandle argument length mismatch error message 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 ar5523: Fix null-ptr-deref with unexpected WDCMSG_TARGET_START reply drm/nouveau/pmu/gm200-: avoid touching PMU outside of DEVINIT/PREOS/ACR ARM: shmobile: rcar-gen2: Add missing of_node_put() batman-adv: allow netlink usage in unprivileged containers 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 mlxsw: pci: Add shutdown method in PCI driver drm/bridge: megachips: Ensure both bridges are probed before registration 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 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() 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 media: uvcvideo: Increase UVC_CTRL_CONTROL_TIMEOUT to 5 seconds. media: saa7146: hexium_orion: Fix a NULL pointer dereference in hexium_attach() media: m920x: don't use stack on USB reads iwlwifi: mvm: synchronize with FW after multicast commands 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 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 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 iwlwifi: fix leaks/bad data after failed firmware load iwlwifi: remove module loading failure message iwlwifi: mvm: Fix calculation of frame length um: registers: Rename function names to avoid conflicts and build problems 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 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() 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 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 failed alloc warning in H_COPY_TOFROM_GUEST w1: Misuse of get_user()/put_user() reported by sparse scsi: lpfc: Trigger SLI4 firmware dump before doing driver cleanup ALSA: seq: Set upper limit of processed events powerpc: handle kdump appropriately with crash_kexec_post_notifiers option MIPS: OCTEON: add put_device() after of_find_device_by_node() 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 power: bq25890: Enable continuous conversion for ADC at charging 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 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 drm/etnaviv: limit submit sizes drm/nouveau/kms/nv04: use vzalloc for nv04_display drm/bridge: analogix_dp: Make PSR-exit block less PCI: pci-bridge-emul: Properly mark reserved PCIe bits in PCI config space 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: set csum seed in tmp inode while migrating to extents ext4: Fix BUG_ON in ext4_bread when write quota data 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 media: rcar-csi2: Optimize the selection PHTW register 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 scsi: core: Show SCMD_LAST in text form 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 bpftool: Remove inclusion of utilities.mak from Makefiles ipv4: avoid quadratic behavior in netns dismantle net/fsl: xgmac_mdio: Fix incorrect iounmap when removing module parisc: pdc_stable: Fix memory leak in pdcs_register_pathentries f2fs: fix to reserve space for IO align feature af_unix: annote lockless accesses to unix_tot_inflight & gc_in_progress clk: si5341: Fix clock HW provider cleanup net: axienet: limit minimum TX ring size net: axienet: fix number of TX ring slots for available check net: axienet: increase default TX ring size to 128 rtc: pxa: fix null pointer dereference 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: 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 arm64: dts: qcom: msm8996: drop not documented adreno properties net_sched: restore "mpu xxx" handling bcmgenet: add WOL IRQ check net: ethernet: mtk_eth_soc: fix error checking in mtk_mac_config() dt-bindings: display: meson-dw-hdmi: add missing sound-name-prefix property dt-bindings: display: meson-vpu: Add missing amlogic,canvas property scripts/dtc: dtx_diff: remove broken example from help text lib82596: Fix IRQ check in sni_82596_probe lib/test_meminit: destroy cache in kmem_cache_alloc_bulk() test mtd: nand: bbt: Fix corner case in bad block table handling Revert "ia64: kprobes: Use generic kretprobe trampoline handler" Linux 5.4.174 Signed-off-by: Greg Kroah-Hartman <gregkh@google.com> Change-Id: Ia656821e4377afa7ca279a6ed92195989be831b3
985 lines
28 KiB
C
985 lines
28 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* f2fs sysfs interface
|
|
*
|
|
* Copyright (c) 2012 Samsung Electronics Co., Ltd.
|
|
* http://www.samsung.com/
|
|
* Copyright (c) 2017 Chao Yu <chao@kernel.org>
|
|
*/
|
|
#include <linux/compiler.h>
|
|
#include <linux/proc_fs.h>
|
|
#include <linux/f2fs_fs.h>
|
|
#include <linux/seq_file.h>
|
|
#include <linux/unicode.h>
|
|
|
|
#include "f2fs.h"
|
|
#include "segment.h"
|
|
#include "gc.h"
|
|
#include <trace/events/f2fs.h>
|
|
|
|
static struct proc_dir_entry *f2fs_proc_root;
|
|
|
|
/* Sysfs support for f2fs */
|
|
enum {
|
|
GC_THREAD, /* struct f2fs_gc_thread */
|
|
SM_INFO, /* struct f2fs_sm_info */
|
|
DCC_INFO, /* struct discard_cmd_control */
|
|
NM_INFO, /* struct f2fs_nm_info */
|
|
F2FS_SBI, /* struct f2fs_sb_info */
|
|
#ifdef CONFIG_F2FS_STAT_FS
|
|
STAT_INFO, /* struct f2fs_stat_info */
|
|
#endif
|
|
#ifdef CONFIG_F2FS_FAULT_INJECTION
|
|
FAULT_INFO_RATE, /* struct f2fs_fault_info */
|
|
FAULT_INFO_TYPE, /* struct f2fs_fault_info */
|
|
#endif
|
|
RESERVED_BLOCKS, /* struct f2fs_sb_info */
|
|
};
|
|
|
|
struct f2fs_attr {
|
|
struct attribute attr;
|
|
ssize_t (*show)(struct f2fs_attr *, struct f2fs_sb_info *, char *);
|
|
ssize_t (*store)(struct f2fs_attr *, struct f2fs_sb_info *,
|
|
const char *, size_t);
|
|
int struct_type;
|
|
int offset;
|
|
int id;
|
|
};
|
|
|
|
static ssize_t f2fs_sbi_show(struct f2fs_attr *a,
|
|
struct f2fs_sb_info *sbi, char *buf);
|
|
|
|
static unsigned char *__struct_ptr(struct f2fs_sb_info *sbi, int struct_type)
|
|
{
|
|
if (struct_type == GC_THREAD)
|
|
return (unsigned char *)sbi->gc_thread;
|
|
else if (struct_type == SM_INFO)
|
|
return (unsigned char *)SM_I(sbi);
|
|
else if (struct_type == DCC_INFO)
|
|
return (unsigned char *)SM_I(sbi)->dcc_info;
|
|
else if (struct_type == NM_INFO)
|
|
return (unsigned char *)NM_I(sbi);
|
|
else if (struct_type == F2FS_SBI || struct_type == RESERVED_BLOCKS)
|
|
return (unsigned char *)sbi;
|
|
#ifdef CONFIG_F2FS_FAULT_INJECTION
|
|
else if (struct_type == FAULT_INFO_RATE ||
|
|
struct_type == FAULT_INFO_TYPE)
|
|
return (unsigned char *)&F2FS_OPTION(sbi).fault_info;
|
|
#endif
|
|
#ifdef CONFIG_F2FS_STAT_FS
|
|
else if (struct_type == STAT_INFO)
|
|
return (unsigned char *)F2FS_STAT(sbi);
|
|
#endif
|
|
return NULL;
|
|
}
|
|
|
|
static ssize_t dirty_segments_show(struct f2fs_attr *a,
|
|
struct f2fs_sb_info *sbi, char *buf)
|
|
{
|
|
return sprintf(buf, "%llu\n",
|
|
(unsigned long long)(dirty_segments(sbi)));
|
|
}
|
|
|
|
static ssize_t free_segments_show(struct f2fs_attr *a,
|
|
struct f2fs_sb_info *sbi, char *buf)
|
|
{
|
|
return sprintf(buf, "%llu\n",
|
|
(unsigned long long)(free_segments(sbi)));
|
|
}
|
|
|
|
static ssize_t lifetime_write_kbytes_show(struct f2fs_attr *a,
|
|
struct f2fs_sb_info *sbi, char *buf)
|
|
{
|
|
struct super_block *sb = sbi->sb;
|
|
|
|
if (!sb->s_bdev->bd_part)
|
|
return sprintf(buf, "0\n");
|
|
|
|
return sprintf(buf, "%llu\n",
|
|
(unsigned long long)(sbi->kbytes_written +
|
|
BD_PART_WRITTEN(sbi)));
|
|
}
|
|
|
|
static ssize_t features_show(struct f2fs_attr *a,
|
|
struct f2fs_sb_info *sbi, char *buf)
|
|
{
|
|
struct super_block *sb = sbi->sb;
|
|
int len = 0;
|
|
|
|
if (!sb->s_bdev->bd_part)
|
|
return sprintf(buf, "0\n");
|
|
|
|
if (f2fs_sb_has_encrypt(sbi))
|
|
len += scnprintf(buf, PAGE_SIZE - len, "%s",
|
|
"encryption");
|
|
if (f2fs_sb_has_blkzoned(sbi))
|
|
len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
|
|
len ? ", " : "", "blkzoned");
|
|
if (f2fs_sb_has_extra_attr(sbi))
|
|
len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
|
|
len ? ", " : "", "extra_attr");
|
|
if (f2fs_sb_has_project_quota(sbi))
|
|
len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
|
|
len ? ", " : "", "projquota");
|
|
if (f2fs_sb_has_inode_chksum(sbi))
|
|
len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
|
|
len ? ", " : "", "inode_checksum");
|
|
if (f2fs_sb_has_flexible_inline_xattr(sbi))
|
|
len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
|
|
len ? ", " : "", "flexible_inline_xattr");
|
|
if (f2fs_sb_has_quota_ino(sbi))
|
|
len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
|
|
len ? ", " : "", "quota_ino");
|
|
if (f2fs_sb_has_inode_crtime(sbi))
|
|
len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
|
|
len ? ", " : "", "inode_crtime");
|
|
if (f2fs_sb_has_lost_found(sbi))
|
|
len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
|
|
len ? ", " : "", "lost_found");
|
|
if (f2fs_sb_has_verity(sbi))
|
|
len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
|
|
len ? ", " : "", "verity");
|
|
if (f2fs_sb_has_sb_chksum(sbi))
|
|
len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
|
|
len ? ", " : "", "sb_checksum");
|
|
if (f2fs_sb_has_casefold(sbi))
|
|
len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
|
|
len ? ", " : "", "casefold");
|
|
if (f2fs_sb_has_readonly(sbi))
|
|
len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
|
|
len ? ", " : "", "readonly");
|
|
if (f2fs_sb_has_compression(sbi))
|
|
len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
|
|
len ? ", " : "", "compression");
|
|
len += scnprintf(buf + len, PAGE_SIZE - len, "%s%s",
|
|
len ? ", " : "", "pin_file");
|
|
len += scnprintf(buf + len, PAGE_SIZE - len, "\n");
|
|
return len;
|
|
}
|
|
|
|
static ssize_t current_reserved_blocks_show(struct f2fs_attr *a,
|
|
struct f2fs_sb_info *sbi, char *buf)
|
|
{
|
|
return sprintf(buf, "%u\n", sbi->current_reserved_blocks);
|
|
}
|
|
|
|
static ssize_t unusable_show(struct f2fs_attr *a,
|
|
struct f2fs_sb_info *sbi, char *buf)
|
|
{
|
|
block_t unusable;
|
|
|
|
if (test_opt(sbi, DISABLE_CHECKPOINT))
|
|
unusable = sbi->unusable_block_count;
|
|
else
|
|
unusable = f2fs_get_unusable_blocks(sbi);
|
|
return sprintf(buf, "%llu\n", (unsigned long long)unusable);
|
|
}
|
|
|
|
static ssize_t encoding_show(struct f2fs_attr *a,
|
|
struct f2fs_sb_info *sbi, char *buf)
|
|
{
|
|
#ifdef CONFIG_UNICODE
|
|
struct super_block *sb = sbi->sb;
|
|
|
|
if (f2fs_sb_has_casefold(sbi))
|
|
return snprintf(buf, PAGE_SIZE, "%s (%d.%d.%d)\n",
|
|
sb->s_encoding->charset,
|
|
(sb->s_encoding->version >> 16) & 0xff,
|
|
(sb->s_encoding->version >> 8) & 0xff,
|
|
sb->s_encoding->version & 0xff);
|
|
#endif
|
|
return sprintf(buf, "(none)");
|
|
}
|
|
|
|
static ssize_t mounted_time_sec_show(struct f2fs_attr *a,
|
|
struct f2fs_sb_info *sbi, char *buf)
|
|
{
|
|
return sprintf(buf, "%llu", SIT_I(sbi)->mounted_time);
|
|
}
|
|
|
|
#ifdef CONFIG_F2FS_STAT_FS
|
|
static ssize_t moved_blocks_foreground_show(struct f2fs_attr *a,
|
|
struct f2fs_sb_info *sbi, char *buf)
|
|
{
|
|
struct f2fs_stat_info *si = F2FS_STAT(sbi);
|
|
|
|
return sprintf(buf, "%llu\n",
|
|
(unsigned long long)(si->tot_blks -
|
|
(si->bg_data_blks + si->bg_node_blks)));
|
|
}
|
|
|
|
static ssize_t moved_blocks_background_show(struct f2fs_attr *a,
|
|
struct f2fs_sb_info *sbi, char *buf)
|
|
{
|
|
struct f2fs_stat_info *si = F2FS_STAT(sbi);
|
|
|
|
return sprintf(buf, "%llu\n",
|
|
(unsigned long long)(si->bg_data_blks + si->bg_node_blks));
|
|
}
|
|
|
|
static ssize_t avg_vblocks_show(struct f2fs_attr *a,
|
|
struct f2fs_sb_info *sbi, char *buf)
|
|
{
|
|
struct f2fs_stat_info *si = F2FS_STAT(sbi);
|
|
|
|
si->dirty_count = dirty_segments(sbi);
|
|
f2fs_update_sit_info(sbi);
|
|
return sprintf(buf, "%llu\n", (unsigned long long)(si->avg_vblocks));
|
|
}
|
|
#endif
|
|
|
|
static ssize_t f2fs_sbi_show(struct f2fs_attr *a,
|
|
struct f2fs_sb_info *sbi, char *buf)
|
|
{
|
|
unsigned char *ptr = NULL;
|
|
unsigned int *ui;
|
|
|
|
ptr = __struct_ptr(sbi, a->struct_type);
|
|
if (!ptr)
|
|
return -EINVAL;
|
|
|
|
if (!strcmp(a->attr.name, "extension_list")) {
|
|
__u8 (*extlist)[F2FS_EXTENSION_LEN] =
|
|
sbi->raw_super->extension_list;
|
|
int cold_count = le32_to_cpu(sbi->raw_super->extension_count);
|
|
int hot_count = sbi->raw_super->hot_ext_count;
|
|
int len = 0, i;
|
|
|
|
len += scnprintf(buf + len, PAGE_SIZE - len,
|
|
"cold file extension:\n");
|
|
for (i = 0; i < cold_count; i++)
|
|
len += scnprintf(buf + len, PAGE_SIZE - len, "%s\n",
|
|
extlist[i]);
|
|
|
|
len += scnprintf(buf + len, PAGE_SIZE - len,
|
|
"hot file extension:\n");
|
|
for (i = cold_count; i < cold_count + hot_count; i++)
|
|
len += scnprintf(buf + len, PAGE_SIZE - len, "%s\n",
|
|
extlist[i]);
|
|
return len;
|
|
}
|
|
|
|
ui = (unsigned int *)(ptr + a->offset);
|
|
|
|
return sprintf(buf, "%u\n", *ui);
|
|
}
|
|
|
|
static ssize_t __sbi_store(struct f2fs_attr *a,
|
|
struct f2fs_sb_info *sbi,
|
|
const char *buf, size_t count)
|
|
{
|
|
unsigned char *ptr;
|
|
unsigned long t;
|
|
unsigned int *ui;
|
|
ssize_t ret;
|
|
|
|
ptr = __struct_ptr(sbi, a->struct_type);
|
|
if (!ptr)
|
|
return -EINVAL;
|
|
|
|
if (!strcmp(a->attr.name, "extension_list")) {
|
|
const char *name = strim((char *)buf);
|
|
bool set = true, hot;
|
|
|
|
if (!strncmp(name, "[h]", 3))
|
|
hot = true;
|
|
else if (!strncmp(name, "[c]", 3))
|
|
hot = false;
|
|
else
|
|
return -EINVAL;
|
|
|
|
name += 3;
|
|
|
|
if (*name == '!') {
|
|
name++;
|
|
set = false;
|
|
}
|
|
|
|
if (strlen(name) >= F2FS_EXTENSION_LEN)
|
|
return -EINVAL;
|
|
|
|
down_write(&sbi->sb_lock);
|
|
|
|
ret = f2fs_update_extension_list(sbi, name, hot, set);
|
|
if (ret)
|
|
goto out;
|
|
|
|
ret = f2fs_commit_super(sbi, false);
|
|
if (ret)
|
|
f2fs_update_extension_list(sbi, name, hot, !set);
|
|
out:
|
|
up_write(&sbi->sb_lock);
|
|
return ret ? ret : count;
|
|
}
|
|
|
|
ui = (unsigned int *)(ptr + a->offset);
|
|
|
|
ret = kstrtoul(skip_spaces(buf), 0, &t);
|
|
if (ret < 0)
|
|
return ret;
|
|
#ifdef CONFIG_F2FS_FAULT_INJECTION
|
|
if (a->struct_type == FAULT_INFO_TYPE && t >= (1 << FAULT_MAX))
|
|
return -EINVAL;
|
|
if (a->struct_type == FAULT_INFO_RATE && t >= UINT_MAX)
|
|
return -EINVAL;
|
|
#endif
|
|
if (a->struct_type == RESERVED_BLOCKS) {
|
|
spin_lock(&sbi->stat_lock);
|
|
if (t > (unsigned long)(sbi->user_block_count -
|
|
F2FS_OPTION(sbi).root_reserved_blocks -
|
|
sbi->blocks_per_seg *
|
|
SM_I(sbi)->additional_reserved_segments)) {
|
|
spin_unlock(&sbi->stat_lock);
|
|
return -EINVAL;
|
|
}
|
|
*ui = t;
|
|
sbi->current_reserved_blocks = min(sbi->reserved_blocks,
|
|
sbi->user_block_count - valid_user_blocks(sbi));
|
|
spin_unlock(&sbi->stat_lock);
|
|
return count;
|
|
}
|
|
|
|
if (!strcmp(a->attr.name, "discard_granularity")) {
|
|
if (t == 0 || t > MAX_PLIST_NUM)
|
|
return -EINVAL;
|
|
if (t == *ui)
|
|
return count;
|
|
*ui = t;
|
|
return count;
|
|
}
|
|
|
|
if (!strcmp(a->attr.name, "migration_granularity")) {
|
|
if (t == 0 || t > sbi->segs_per_sec)
|
|
return -EINVAL;
|
|
}
|
|
|
|
if (!strcmp(a->attr.name, "trim_sections"))
|
|
return -EINVAL;
|
|
|
|
if (!strcmp(a->attr.name, "gc_urgent")) {
|
|
if (t >= 1) {
|
|
sbi->gc_mode = GC_URGENT;
|
|
if (sbi->gc_thread) {
|
|
sbi->gc_thread->gc_wake = 1;
|
|
wake_up_interruptible_all(
|
|
&sbi->gc_thread->gc_wait_queue_head);
|
|
wake_up_discard_thread(sbi, true);
|
|
}
|
|
} else {
|
|
sbi->gc_mode = GC_NORMAL;
|
|
}
|
|
return count;
|
|
}
|
|
if (!strcmp(a->attr.name, "gc_idle")) {
|
|
if (t == GC_IDLE_CB)
|
|
sbi->gc_mode = GC_IDLE_CB;
|
|
else if (t == GC_IDLE_GREEDY)
|
|
sbi->gc_mode = GC_IDLE_GREEDY;
|
|
else
|
|
sbi->gc_mode = GC_NORMAL;
|
|
return count;
|
|
}
|
|
|
|
if (!strcmp(a->attr.name, "iostat_enable")) {
|
|
sbi->iostat_enable = !!t;
|
|
if (!sbi->iostat_enable)
|
|
f2fs_reset_iostat(sbi);
|
|
return count;
|
|
}
|
|
|
|
if (!strcmp(a->attr.name, "iostat_period_ms")) {
|
|
if (t < MIN_IOSTAT_PERIOD_MS || t > MAX_IOSTAT_PERIOD_MS)
|
|
return -EINVAL;
|
|
spin_lock(&sbi->iostat_lock);
|
|
sbi->iostat_period_ms = (unsigned int)t;
|
|
spin_unlock(&sbi->iostat_lock);
|
|
return count;
|
|
}
|
|
|
|
*ui = (unsigned int)t;
|
|
|
|
return count;
|
|
}
|
|
|
|
static ssize_t f2fs_sbi_store(struct f2fs_attr *a,
|
|
struct f2fs_sb_info *sbi,
|
|
const char *buf, size_t count)
|
|
{
|
|
ssize_t ret;
|
|
bool gc_entry = (!strcmp(a->attr.name, "gc_urgent") ||
|
|
a->struct_type == GC_THREAD);
|
|
|
|
if (gc_entry) {
|
|
if (!down_read_trylock(&sbi->sb->s_umount))
|
|
return -EAGAIN;
|
|
}
|
|
ret = __sbi_store(a, sbi, buf, count);
|
|
if (gc_entry)
|
|
up_read(&sbi->sb->s_umount);
|
|
|
|
return ret;
|
|
}
|
|
|
|
static ssize_t f2fs_attr_show(struct kobject *kobj,
|
|
struct attribute *attr, char *buf)
|
|
{
|
|
struct f2fs_sb_info *sbi = container_of(kobj, struct f2fs_sb_info,
|
|
s_kobj);
|
|
struct f2fs_attr *a = container_of(attr, struct f2fs_attr, attr);
|
|
|
|
return a->show ? a->show(a, sbi, buf) : 0;
|
|
}
|
|
|
|
static ssize_t f2fs_attr_store(struct kobject *kobj, struct attribute *attr,
|
|
const char *buf, size_t len)
|
|
{
|
|
struct f2fs_sb_info *sbi = container_of(kobj, struct f2fs_sb_info,
|
|
s_kobj);
|
|
struct f2fs_attr *a = container_of(attr, struct f2fs_attr, attr);
|
|
|
|
return a->store ? a->store(a, sbi, buf, len) : 0;
|
|
}
|
|
|
|
static void f2fs_sb_release(struct kobject *kobj)
|
|
{
|
|
struct f2fs_sb_info *sbi = container_of(kobj, struct f2fs_sb_info,
|
|
s_kobj);
|
|
complete(&sbi->s_kobj_unregister);
|
|
}
|
|
|
|
enum feat_id {
|
|
FEAT_CRYPTO = 0,
|
|
FEAT_BLKZONED,
|
|
FEAT_ATOMIC_WRITE,
|
|
FEAT_EXTRA_ATTR,
|
|
FEAT_PROJECT_QUOTA,
|
|
FEAT_INODE_CHECKSUM,
|
|
FEAT_FLEXIBLE_INLINE_XATTR,
|
|
FEAT_QUOTA_INO,
|
|
FEAT_INODE_CRTIME,
|
|
FEAT_LOST_FOUND,
|
|
FEAT_VERITY,
|
|
FEAT_SB_CHECKSUM,
|
|
FEAT_CASEFOLD,
|
|
FEAT_COMPRESSION,
|
|
FEAT_RO,
|
|
FEAT_TEST_DUMMY_ENCRYPTION_V2,
|
|
FEAT_ENCRYPTED_CASEFOLD,
|
|
};
|
|
|
|
static ssize_t f2fs_feature_show(struct f2fs_attr *a,
|
|
struct f2fs_sb_info *sbi, char *buf)
|
|
{
|
|
switch (a->id) {
|
|
case FEAT_CRYPTO:
|
|
case FEAT_BLKZONED:
|
|
case FEAT_ATOMIC_WRITE:
|
|
case FEAT_EXTRA_ATTR:
|
|
case FEAT_PROJECT_QUOTA:
|
|
case FEAT_INODE_CHECKSUM:
|
|
case FEAT_FLEXIBLE_INLINE_XATTR:
|
|
case FEAT_QUOTA_INO:
|
|
case FEAT_INODE_CRTIME:
|
|
case FEAT_LOST_FOUND:
|
|
case FEAT_VERITY:
|
|
case FEAT_SB_CHECKSUM:
|
|
case FEAT_CASEFOLD:
|
|
case FEAT_COMPRESSION:
|
|
case FEAT_RO:
|
|
case FEAT_TEST_DUMMY_ENCRYPTION_V2:
|
|
case FEAT_ENCRYPTED_CASEFOLD:
|
|
return sprintf(buf, "supported\n");
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
#define F2FS_ATTR_OFFSET(_struct_type, _name, _mode, _show, _store, _offset) \
|
|
static struct f2fs_attr f2fs_attr_##_name = { \
|
|
.attr = {.name = __stringify(_name), .mode = _mode }, \
|
|
.show = _show, \
|
|
.store = _store, \
|
|
.struct_type = _struct_type, \
|
|
.offset = _offset \
|
|
}
|
|
|
|
#define F2FS_RW_ATTR(struct_type, struct_name, name, elname) \
|
|
F2FS_ATTR_OFFSET(struct_type, name, 0644, \
|
|
f2fs_sbi_show, f2fs_sbi_store, \
|
|
offsetof(struct struct_name, elname))
|
|
|
|
#define F2FS_GENERAL_RO_ATTR(name) \
|
|
static struct f2fs_attr f2fs_attr_##name = __ATTR(name, 0444, name##_show, NULL)
|
|
|
|
#define F2FS_FEATURE_RO_ATTR(_name, _id) \
|
|
static struct f2fs_attr f2fs_attr_##_name = { \
|
|
.attr = {.name = __stringify(_name), .mode = 0444 }, \
|
|
.show = f2fs_feature_show, \
|
|
.id = _id, \
|
|
}
|
|
|
|
#define F2FS_STAT_ATTR(_struct_type, _struct_name, _name, _elname) \
|
|
static struct f2fs_attr f2fs_attr_##_name = { \
|
|
.attr = {.name = __stringify(_name), .mode = 0444 }, \
|
|
.show = f2fs_sbi_show, \
|
|
.struct_type = _struct_type, \
|
|
.offset = offsetof(struct _struct_name, _elname), \
|
|
}
|
|
|
|
F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_urgent_sleep_time,
|
|
urgent_sleep_time);
|
|
F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_min_sleep_time, min_sleep_time);
|
|
F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_max_sleep_time, max_sleep_time);
|
|
F2FS_RW_ATTR(GC_THREAD, f2fs_gc_kthread, gc_no_gc_sleep_time, no_gc_sleep_time);
|
|
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_idle, gc_mode);
|
|
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_urgent, gc_mode);
|
|
F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, reclaim_segments, rec_prefree_segments);
|
|
F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, main_blkaddr, main_blkaddr);
|
|
F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, max_small_discards, max_discards);
|
|
F2FS_RW_ATTR(DCC_INFO, discard_cmd_control, discard_granularity, discard_granularity);
|
|
F2FS_RW_ATTR(RESERVED_BLOCKS, f2fs_sb_info, reserved_blocks, reserved_blocks);
|
|
F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, batched_trim_sections, trim_sections);
|
|
F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, ipu_policy, ipu_policy);
|
|
F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_ipu_util, min_ipu_util);
|
|
F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_fsync_blocks, min_fsync_blocks);
|
|
F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_seq_blocks, min_seq_blocks);
|
|
F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_hot_blocks, min_hot_blocks);
|
|
F2FS_RW_ATTR(SM_INFO, f2fs_sm_info, min_ssr_sections, min_ssr_sections);
|
|
F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ram_thresh, ram_thresh);
|
|
F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, ra_nid_pages, ra_nid_pages);
|
|
F2FS_RW_ATTR(NM_INFO, f2fs_nm_info, dirty_nats_ratio, dirty_nats_ratio);
|
|
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, max_victim_search, max_victim_search);
|
|
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, migration_granularity, migration_granularity);
|
|
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, dir_level, dir_level);
|
|
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, cp_interval, interval_time[CP_TIME]);
|
|
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, idle_interval, interval_time[REQ_TIME]);
|
|
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, discard_idle_interval,
|
|
interval_time[DISCARD_TIME]);
|
|
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_idle_interval, interval_time[GC_TIME]);
|
|
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info,
|
|
umount_discard_timeout, interval_time[UMOUNT_DISCARD_TIMEOUT]);
|
|
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, iostat_enable, iostat_enable);
|
|
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, iostat_period_ms, iostat_period_ms);
|
|
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, readdir_ra, readdir_ra);
|
|
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, gc_pin_file_thresh, gc_pin_file_threshold);
|
|
F2FS_RW_ATTR(F2FS_SBI, f2fs_super_block, extension_list, extension_list);
|
|
#ifdef CONFIG_F2FS_FAULT_INJECTION
|
|
F2FS_RW_ATTR(FAULT_INFO_RATE, f2fs_fault_info, inject_rate, inject_rate);
|
|
F2FS_RW_ATTR(FAULT_INFO_TYPE, f2fs_fault_info, inject_type, inject_type);
|
|
#endif
|
|
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, data_io_flag, data_io_flag);
|
|
F2FS_RW_ATTR(F2FS_SBI, f2fs_sb_info, node_io_flag, node_io_flag);
|
|
F2FS_GENERAL_RO_ATTR(dirty_segments);
|
|
F2FS_GENERAL_RO_ATTR(free_segments);
|
|
F2FS_GENERAL_RO_ATTR(lifetime_write_kbytes);
|
|
F2FS_GENERAL_RO_ATTR(features);
|
|
F2FS_GENERAL_RO_ATTR(current_reserved_blocks);
|
|
F2FS_GENERAL_RO_ATTR(unusable);
|
|
F2FS_GENERAL_RO_ATTR(encoding);
|
|
F2FS_GENERAL_RO_ATTR(mounted_time_sec);
|
|
#ifdef CONFIG_F2FS_STAT_FS
|
|
F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_foreground_calls, cp_count);
|
|
F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, cp_background_calls, bg_cp_count);
|
|
F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, gc_foreground_calls, call_count);
|
|
F2FS_STAT_ATTR(STAT_INFO, f2fs_stat_info, gc_background_calls, bg_gc);
|
|
F2FS_GENERAL_RO_ATTR(moved_blocks_background);
|
|
F2FS_GENERAL_RO_ATTR(moved_blocks_foreground);
|
|
F2FS_GENERAL_RO_ATTR(avg_vblocks);
|
|
#endif
|
|
|
|
#ifdef CONFIG_FS_ENCRYPTION
|
|
F2FS_FEATURE_RO_ATTR(encryption, FEAT_CRYPTO);
|
|
F2FS_FEATURE_RO_ATTR(test_dummy_encryption_v2, FEAT_TEST_DUMMY_ENCRYPTION_V2);
|
|
#ifdef CONFIG_UNICODE
|
|
F2FS_FEATURE_RO_ATTR(encrypted_casefold, FEAT_ENCRYPTED_CASEFOLD);
|
|
#endif
|
|
#endif /* CONFIG_FS_ENCRYPTION */
|
|
#ifdef CONFIG_BLK_DEV_ZONED
|
|
F2FS_FEATURE_RO_ATTR(block_zoned, FEAT_BLKZONED);
|
|
#endif
|
|
F2FS_FEATURE_RO_ATTR(atomic_write, FEAT_ATOMIC_WRITE);
|
|
F2FS_FEATURE_RO_ATTR(extra_attr, FEAT_EXTRA_ATTR);
|
|
F2FS_FEATURE_RO_ATTR(project_quota, FEAT_PROJECT_QUOTA);
|
|
F2FS_FEATURE_RO_ATTR(inode_checksum, FEAT_INODE_CHECKSUM);
|
|
F2FS_FEATURE_RO_ATTR(flexible_inline_xattr, FEAT_FLEXIBLE_INLINE_XATTR);
|
|
F2FS_FEATURE_RO_ATTR(quota_ino, FEAT_QUOTA_INO);
|
|
F2FS_FEATURE_RO_ATTR(inode_crtime, FEAT_INODE_CRTIME);
|
|
F2FS_FEATURE_RO_ATTR(lost_found, FEAT_LOST_FOUND);
|
|
#ifdef CONFIG_FS_VERITY
|
|
F2FS_FEATURE_RO_ATTR(verity, FEAT_VERITY);
|
|
#endif
|
|
F2FS_FEATURE_RO_ATTR(sb_checksum, FEAT_SB_CHECKSUM);
|
|
#ifdef CONFIG_UNICODE
|
|
F2FS_FEATURE_RO_ATTR(casefold, FEAT_CASEFOLD);
|
|
#endif
|
|
F2FS_FEATURE_RO_ATTR(readonly, FEAT_RO);
|
|
#ifdef CONFIG_F2FS_FS_COMPRESSION
|
|
F2FS_FEATURE_RO_ATTR(compression, FEAT_COMPRESSION);
|
|
#endif
|
|
|
|
#define ATTR_LIST(name) (&f2fs_attr_##name.attr)
|
|
static struct attribute *f2fs_attrs[] = {
|
|
ATTR_LIST(gc_urgent_sleep_time),
|
|
ATTR_LIST(gc_min_sleep_time),
|
|
ATTR_LIST(gc_max_sleep_time),
|
|
ATTR_LIST(gc_no_gc_sleep_time),
|
|
ATTR_LIST(gc_idle),
|
|
ATTR_LIST(gc_urgent),
|
|
ATTR_LIST(reclaim_segments),
|
|
ATTR_LIST(main_blkaddr),
|
|
ATTR_LIST(max_small_discards),
|
|
ATTR_LIST(discard_granularity),
|
|
ATTR_LIST(batched_trim_sections),
|
|
ATTR_LIST(ipu_policy),
|
|
ATTR_LIST(min_ipu_util),
|
|
ATTR_LIST(min_fsync_blocks),
|
|
ATTR_LIST(min_seq_blocks),
|
|
ATTR_LIST(min_hot_blocks),
|
|
ATTR_LIST(min_ssr_sections),
|
|
ATTR_LIST(max_victim_search),
|
|
ATTR_LIST(migration_granularity),
|
|
ATTR_LIST(dir_level),
|
|
ATTR_LIST(ram_thresh),
|
|
ATTR_LIST(ra_nid_pages),
|
|
ATTR_LIST(dirty_nats_ratio),
|
|
ATTR_LIST(cp_interval),
|
|
ATTR_LIST(idle_interval),
|
|
ATTR_LIST(discard_idle_interval),
|
|
ATTR_LIST(gc_idle_interval),
|
|
ATTR_LIST(umount_discard_timeout),
|
|
ATTR_LIST(iostat_enable),
|
|
ATTR_LIST(iostat_period_ms),
|
|
ATTR_LIST(readdir_ra),
|
|
ATTR_LIST(gc_pin_file_thresh),
|
|
ATTR_LIST(extension_list),
|
|
#ifdef CONFIG_F2FS_FAULT_INJECTION
|
|
ATTR_LIST(inject_rate),
|
|
ATTR_LIST(inject_type),
|
|
#endif
|
|
ATTR_LIST(data_io_flag),
|
|
ATTR_LIST(node_io_flag),
|
|
ATTR_LIST(dirty_segments),
|
|
ATTR_LIST(free_segments),
|
|
ATTR_LIST(unusable),
|
|
ATTR_LIST(lifetime_write_kbytes),
|
|
ATTR_LIST(features),
|
|
ATTR_LIST(reserved_blocks),
|
|
ATTR_LIST(current_reserved_blocks),
|
|
ATTR_LIST(encoding),
|
|
ATTR_LIST(mounted_time_sec),
|
|
#ifdef CONFIG_F2FS_STAT_FS
|
|
ATTR_LIST(cp_foreground_calls),
|
|
ATTR_LIST(cp_background_calls),
|
|
ATTR_LIST(gc_foreground_calls),
|
|
ATTR_LIST(gc_background_calls),
|
|
ATTR_LIST(moved_blocks_foreground),
|
|
ATTR_LIST(moved_blocks_background),
|
|
ATTR_LIST(avg_vblocks),
|
|
#endif
|
|
NULL,
|
|
};
|
|
ATTRIBUTE_GROUPS(f2fs);
|
|
|
|
static struct attribute *f2fs_feat_attrs[] = {
|
|
#ifdef CONFIG_FS_ENCRYPTION
|
|
ATTR_LIST(encryption),
|
|
ATTR_LIST(test_dummy_encryption_v2),
|
|
#ifdef CONFIG_UNICODE
|
|
ATTR_LIST(encrypted_casefold),
|
|
#endif
|
|
#endif /* CONFIG_FS_ENCRYPTION */
|
|
#ifdef CONFIG_BLK_DEV_ZONED
|
|
ATTR_LIST(block_zoned),
|
|
#endif
|
|
ATTR_LIST(atomic_write),
|
|
ATTR_LIST(extra_attr),
|
|
ATTR_LIST(project_quota),
|
|
ATTR_LIST(inode_checksum),
|
|
ATTR_LIST(flexible_inline_xattr),
|
|
ATTR_LIST(quota_ino),
|
|
ATTR_LIST(inode_crtime),
|
|
ATTR_LIST(lost_found),
|
|
#ifdef CONFIG_FS_VERITY
|
|
ATTR_LIST(verity),
|
|
#endif
|
|
ATTR_LIST(sb_checksum),
|
|
#ifdef CONFIG_UNICODE
|
|
ATTR_LIST(casefold),
|
|
#endif
|
|
ATTR_LIST(readonly),
|
|
#ifdef CONFIG_F2FS_FS_COMPRESSION
|
|
ATTR_LIST(compression),
|
|
#endif
|
|
NULL,
|
|
};
|
|
ATTRIBUTE_GROUPS(f2fs_feat);
|
|
|
|
static const struct sysfs_ops f2fs_attr_ops = {
|
|
.show = f2fs_attr_show,
|
|
.store = f2fs_attr_store,
|
|
};
|
|
|
|
static struct kobj_type f2fs_sb_ktype = {
|
|
.default_groups = f2fs_groups,
|
|
.sysfs_ops = &f2fs_attr_ops,
|
|
.release = f2fs_sb_release,
|
|
};
|
|
|
|
static struct kobj_type f2fs_ktype = {
|
|
.sysfs_ops = &f2fs_attr_ops,
|
|
};
|
|
|
|
static struct kset f2fs_kset = {
|
|
.kobj = {.ktype = &f2fs_ktype},
|
|
};
|
|
|
|
static struct kobj_type f2fs_feat_ktype = {
|
|
.default_groups = f2fs_feat_groups,
|
|
.sysfs_ops = &f2fs_attr_ops,
|
|
};
|
|
|
|
static struct kobject f2fs_feat = {
|
|
.kset = &f2fs_kset,
|
|
};
|
|
|
|
static int __maybe_unused segment_info_seq_show(struct seq_file *seq,
|
|
void *offset)
|
|
{
|
|
struct super_block *sb = seq->private;
|
|
struct f2fs_sb_info *sbi = F2FS_SB(sb);
|
|
unsigned int total_segs =
|
|
le32_to_cpu(sbi->raw_super->segment_count_main);
|
|
int i;
|
|
|
|
seq_puts(seq, "format: segment_type|valid_blocks\n"
|
|
"segment_type(0:HD, 1:WD, 2:CD, 3:HN, 4:WN, 5:CN)\n");
|
|
|
|
for (i = 0; i < total_segs; i++) {
|
|
struct seg_entry *se = get_seg_entry(sbi, i);
|
|
|
|
if ((i % 10) == 0)
|
|
seq_printf(seq, "%-10d", i);
|
|
seq_printf(seq, "%d|%-3u", se->type, se->valid_blocks);
|
|
if ((i % 10) == 9 || i == (total_segs - 1))
|
|
seq_putc(seq, '\n');
|
|
else
|
|
seq_putc(seq, ' ');
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int __maybe_unused segment_bits_seq_show(struct seq_file *seq,
|
|
void *offset)
|
|
{
|
|
struct super_block *sb = seq->private;
|
|
struct f2fs_sb_info *sbi = F2FS_SB(sb);
|
|
unsigned int total_segs =
|
|
le32_to_cpu(sbi->raw_super->segment_count_main);
|
|
int i, j;
|
|
|
|
seq_puts(seq, "format: segment_type|valid_blocks|bitmaps\n"
|
|
"segment_type(0:HD, 1:WD, 2:CD, 3:HN, 4:WN, 5:CN)\n");
|
|
|
|
for (i = 0; i < total_segs; i++) {
|
|
struct seg_entry *se = get_seg_entry(sbi, i);
|
|
|
|
seq_printf(seq, "%-10d", i);
|
|
seq_printf(seq, "%d|%-3u|", se->type, se->valid_blocks);
|
|
for (j = 0; j < SIT_VBLOCK_MAP_SIZE; j++)
|
|
seq_printf(seq, " %.2x", se->cur_valid_map[j]);
|
|
seq_putc(seq, '\n');
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void f2fs_record_iostat(struct f2fs_sb_info *sbi)
|
|
{
|
|
unsigned long long iostat_diff[NR_IO_TYPE];
|
|
int i;
|
|
|
|
if (time_is_after_jiffies(sbi->iostat_next_period))
|
|
return;
|
|
|
|
/* Need double check under the lock */
|
|
spin_lock(&sbi->iostat_lock);
|
|
if (time_is_after_jiffies(sbi->iostat_next_period)) {
|
|
spin_unlock(&sbi->iostat_lock);
|
|
return;
|
|
}
|
|
sbi->iostat_next_period = jiffies +
|
|
msecs_to_jiffies(sbi->iostat_period_ms);
|
|
|
|
for (i = 0; i < NR_IO_TYPE; i++) {
|
|
iostat_diff[i] = sbi->rw_iostat[i] -
|
|
sbi->prev_rw_iostat[i];
|
|
sbi->prev_rw_iostat[i] = sbi->rw_iostat[i];
|
|
}
|
|
spin_unlock(&sbi->iostat_lock);
|
|
|
|
trace_f2fs_iostat(sbi, iostat_diff);
|
|
}
|
|
|
|
static int __maybe_unused iostat_info_seq_show(struct seq_file *seq,
|
|
void *offset)
|
|
{
|
|
struct super_block *sb = seq->private;
|
|
struct f2fs_sb_info *sbi = F2FS_SB(sb);
|
|
time64_t now = ktime_get_real_seconds();
|
|
|
|
if (!sbi->iostat_enable)
|
|
return 0;
|
|
|
|
seq_printf(seq, "time: %-16llu\n", now);
|
|
|
|
/* print app write IOs */
|
|
seq_puts(seq, "[WRITE]\n");
|
|
seq_printf(seq, "app buffered: %-16llu\n",
|
|
sbi->rw_iostat[APP_BUFFERED_IO]);
|
|
seq_printf(seq, "app direct: %-16llu\n",
|
|
sbi->rw_iostat[APP_DIRECT_IO]);
|
|
seq_printf(seq, "app mapped: %-16llu\n",
|
|
sbi->rw_iostat[APP_MAPPED_IO]);
|
|
|
|
/* print fs write IOs */
|
|
seq_printf(seq, "fs data: %-16llu\n",
|
|
sbi->rw_iostat[FS_DATA_IO]);
|
|
seq_printf(seq, "fs node: %-16llu\n",
|
|
sbi->rw_iostat[FS_NODE_IO]);
|
|
seq_printf(seq, "fs meta: %-16llu\n",
|
|
sbi->rw_iostat[FS_META_IO]);
|
|
seq_printf(seq, "fs gc data: %-16llu\n",
|
|
sbi->rw_iostat[FS_GC_DATA_IO]);
|
|
seq_printf(seq, "fs gc node: %-16llu\n",
|
|
sbi->rw_iostat[FS_GC_NODE_IO]);
|
|
seq_printf(seq, "fs cp data: %-16llu\n",
|
|
sbi->rw_iostat[FS_CP_DATA_IO]);
|
|
seq_printf(seq, "fs cp node: %-16llu\n",
|
|
sbi->rw_iostat[FS_CP_NODE_IO]);
|
|
seq_printf(seq, "fs cp meta: %-16llu\n",
|
|
sbi->rw_iostat[FS_CP_META_IO]);
|
|
|
|
/* print app read IOs */
|
|
seq_puts(seq, "[READ]\n");
|
|
seq_printf(seq, "app buffered: %-16llu\n",
|
|
sbi->rw_iostat[APP_BUFFERED_READ_IO]);
|
|
seq_printf(seq, "app direct: %-16llu\n",
|
|
sbi->rw_iostat[APP_DIRECT_READ_IO]);
|
|
seq_printf(seq, "app mapped: %-16llu\n",
|
|
sbi->rw_iostat[APP_MAPPED_READ_IO]);
|
|
|
|
/* print fs read IOs */
|
|
seq_printf(seq, "fs data: %-16llu\n",
|
|
sbi->rw_iostat[FS_DATA_READ_IO]);
|
|
seq_printf(seq, "fs gc data: %-16llu\n",
|
|
sbi->rw_iostat[FS_GDATA_READ_IO]);
|
|
seq_printf(seq, "fs compr_data: %-16llu\n",
|
|
sbi->rw_iostat[FS_CDATA_READ_IO]);
|
|
seq_printf(seq, "fs node: %-16llu\n",
|
|
sbi->rw_iostat[FS_NODE_READ_IO]);
|
|
seq_printf(seq, "fs meta: %-16llu\n",
|
|
sbi->rw_iostat[FS_META_READ_IO]);
|
|
|
|
/* print other IOs */
|
|
seq_puts(seq, "[OTHER]\n");
|
|
seq_printf(seq, "fs discard: %-16llu\n",
|
|
sbi->rw_iostat[FS_DISCARD]);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int __maybe_unused victim_bits_seq_show(struct seq_file *seq,
|
|
void *offset)
|
|
{
|
|
struct super_block *sb = seq->private;
|
|
struct f2fs_sb_info *sbi = F2FS_SB(sb);
|
|
struct dirty_seglist_info *dirty_i = DIRTY_I(sbi);
|
|
int i;
|
|
|
|
seq_puts(seq, "format: victim_secmap bitmaps\n");
|
|
|
|
for (i = 0; i < MAIN_SECS(sbi); i++) {
|
|
if ((i % 10) == 0)
|
|
seq_printf(seq, "%-10d", i);
|
|
seq_printf(seq, "%d", test_bit(i, dirty_i->victim_secmap) ? 1 : 0);
|
|
if ((i % 10) == 9 || i == (MAIN_SECS(sbi) - 1))
|
|
seq_putc(seq, '\n');
|
|
else
|
|
seq_putc(seq, ' ');
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
int __init f2fs_init_sysfs(void)
|
|
{
|
|
int ret;
|
|
|
|
kobject_set_name(&f2fs_kset.kobj, "f2fs");
|
|
f2fs_kset.kobj.parent = fs_kobj;
|
|
ret = kset_register(&f2fs_kset);
|
|
if (ret)
|
|
return ret;
|
|
|
|
ret = kobject_init_and_add(&f2fs_feat, &f2fs_feat_ktype,
|
|
NULL, "features");
|
|
if (ret) {
|
|
kobject_put(&f2fs_feat);
|
|
kset_unregister(&f2fs_kset);
|
|
} else {
|
|
f2fs_proc_root = proc_mkdir("fs/f2fs", NULL);
|
|
}
|
|
return ret;
|
|
}
|
|
|
|
void f2fs_exit_sysfs(void)
|
|
{
|
|
kobject_put(&f2fs_feat);
|
|
kset_unregister(&f2fs_kset);
|
|
remove_proc_entry("fs/f2fs", NULL);
|
|
f2fs_proc_root = NULL;
|
|
}
|
|
|
|
int f2fs_register_sysfs(struct f2fs_sb_info *sbi)
|
|
{
|
|
struct super_block *sb = sbi->sb;
|
|
int err;
|
|
|
|
sbi->s_kobj.kset = &f2fs_kset;
|
|
init_completion(&sbi->s_kobj_unregister);
|
|
err = kobject_init_and_add(&sbi->s_kobj, &f2fs_sb_ktype, NULL,
|
|
"%s", sb->s_id);
|
|
if (err) {
|
|
kobject_put(&sbi->s_kobj);
|
|
wait_for_completion(&sbi->s_kobj_unregister);
|
|
return err;
|
|
}
|
|
|
|
if (f2fs_proc_root)
|
|
sbi->s_proc = proc_mkdir(sb->s_id, f2fs_proc_root);
|
|
|
|
if (sbi->s_proc) {
|
|
proc_create_single_data("segment_info", S_IRUGO, sbi->s_proc,
|
|
segment_info_seq_show, sb);
|
|
proc_create_single_data("segment_bits", S_IRUGO, sbi->s_proc,
|
|
segment_bits_seq_show, sb);
|
|
proc_create_single_data("iostat_info", S_IRUGO, sbi->s_proc,
|
|
iostat_info_seq_show, sb);
|
|
proc_create_single_data("victim_bits", S_IRUGO, sbi->s_proc,
|
|
victim_bits_seq_show, sb);
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void f2fs_unregister_sysfs(struct f2fs_sb_info *sbi)
|
|
{
|
|
if (sbi->s_proc) {
|
|
remove_proc_entry("iostat_info", sbi->s_proc);
|
|
remove_proc_entry("segment_info", sbi->s_proc);
|
|
remove_proc_entry("segment_bits", sbi->s_proc);
|
|
remove_proc_entry("victim_bits", sbi->s_proc);
|
|
remove_proc_entry(sbi->sb->s_id, f2fs_proc_root);
|
|
}
|
|
kobject_del(&sbi->s_kobj);
|
|
kobject_put(&sbi->s_kobj);
|
|
wait_for_completion(&sbi->s_kobj_unregister);
|
|
}
|