* refs/heads/tmp-8ee67bc
Revert "nl80211: fix non-split wiphy information"
Reverting usb changes
Linux 4.19.157
powercap: restrict energy meter to root access
Revert "ANDROID: Kbuild, LLVMLinux: allow overriding clang target triple"
Linux 4.19.156
arm64: dts: marvell: espressobin: Add ethernet switch aliases
net: dsa: read mac address from DT for slave device
tools: perf: Fix build error in v4.19.y
perf/core: Fix a memory leak in perf_event_parse_addr_filter()
PM: runtime: Resume the device earlier in __device_release_driver()
Revert "ARC: entry: fix potential EFA clobber when TIF_SYSCALL_TRACE"
ARC: stack unwinding: avoid indefinite looping
usb: mtu3: fix panic in mtu3_gadget_stop()
USB: Add NO_LPM quirk for Kingston flash drive
USB: serial: option: add Telit FN980 composition 0x1055
USB: serial: option: add LE910Cx compositions 0x1203, 0x1230, 0x1231
USB: serial: option: add Quectel EC200T module support
USB: serial: cyberjack: fix write-URB completion race
serial: txx9: add missing platform_driver_unregister() on error in serial_txx9_init
serial: 8250_mtk: Fix uart_get_baud_rate warning
fork: fix copy_process(CLONE_PARENT) race with the exiting ->real_parent
vt: Disable KD_FONT_OP_COPY
ACPI: NFIT: Fix comparison to '-ENXIO'
drm/vc4: drv: Add error handding for bind
vsock: use ns_capable_noaudit() on socket create
scsi: core: Don't start concurrent async scan on same host
blk-cgroup: Pre-allocate tree node on blkg_conf_prep
blk-cgroup: Fix memleak on error path
of: Fix reserved-memory overlap detection
x86/kexec: Use up-to-dated screen_info copy to fill boot params
ARM: dts: sun4i-a10: fix cpu_alert temperature
futex: Handle transient "ownerless" rtmutex state correctly
tracing: Fix out of bounds write in get_trace_buf
ftrace: Handle tracing when switching between context
ftrace: Fix recursion check for NMI test
ring-buffer: Fix recursion protection transitions between interrupt context
gfs2: Wake up when sd_glock_disposal becomes zero
mm: always have io_remap_pfn_range() set pgprot_decrypted()
kthread_worker: prevent queuing delayed work from timer_fn when it is being canceled
lib/crc32test: remove extra local_irq_disable/enable
mm: mempolicy: fix potential pte_unmap_unlock pte error
ALSA: usb-audio: Add implicit feedback quirk for MODX
ALSA: usb-audio: Add implicit feedback quirk for Qu-16
ALSA: usb-audio: add usb vendor id as DSD-capable for Khadas devices
ALSA: usb-audio: Add implicit feedback quirk for Zoom UAC-2
Fonts: Replace discarded const qualifier
btrfs: tree-checker: fix the error message for transid error
btrfs: tree-checker: Verify inode item
btrfs: tree-checker: Enhance chunk checker to validate chunk profile
btrfs: tree-checker: Fix wrong check on max devid
btrfs: tree-checker: Verify dev item
btrfs: tree-checker: Check chunk item at tree block read time
btrfs: tree-checker: Make btrfs_check_chunk_valid() return EUCLEAN instead of EIO
btrfs: tree-checker: Make chunk item checker messages more readable
btrfs: Move btrfs_check_chunk_valid() to tree-check.[ch] and export it
btrfs: Don't submit any btree write bio if the fs has errors
Btrfs: fix unwritten extent buffers and hangs on future writeback attempts
btrfs: extent_io: add proper error handling to lock_extent_buffer_for_io()
btrfs: extent_io: Handle errors better in btree_write_cache_pages()
btrfs: extent_io: Handle errors better in extent_write_full_page()
btrfs: flush write bio if we loop in extent_write_cache_pages
Revert "btrfs: flush write bio if we loop in extent_write_cache_pages"
btrfs: extent_io: Move the BUG_ON() in flush_write_bio() one level up
btrfs: extent_io: Kill the forward declaration of flush_write_bio
blktrace: fix debugfs use after free
sfp: Fix error handing in sfp_probe()
sctp: Fix COMM_LOST/CANT_STR_ASSOC err reporting on big-endian platforms
net: usb: qmi_wwan: add Telit LE910Cx 0x1230 composition
gianfar: Account for Tx PTP timestamp in the skb headroom
gianfar: Replace skb_realloc_headroom with skb_cow_head for PTP
chelsio/chtls: fix always leaking ctrl_skb
chelsio/chtls: fix memory leaks caused by a race
cadence: force nonlinear buffers to be cloned
ptrace: fix task_join_group_stop() for the case when current is traced
tipc: fix use-after-free in tipc_bcast_get_mode
drm/i915: Break up error capture compression loops with cond_resched()
ANDROID: fuse: Add support for d_canonical_path
ANDROID: vfs: add d_canonical_path for stacked filesystem support
ANDROID: Temporarily disable XFRM_USER_COMPAT filtering
Linux 4.19.155
staging: octeon: Drop on uncorrectable alignment or FCS error
staging: octeon: repair "fixed-link" support
staging: comedi: cb_pcidas: Allow 2-channel commands for AO subdevice
KVM: arm64: Fix AArch32 handling of DBGD{CCINT,SCRext} and DBGVCR
device property: Don't clear secondary pointer for shared primary firmware node
device property: Keep secondary firmware node secondary by type
ARM: s3c24xx: fix missing system reset
ARM: samsung: fix PM debug build with DEBUG_LL but !MMU
arm: dts: mt7623: add missing pause for switchport
hil/parisc: Disable HIL driver when it gets stuck
cachefiles: Handle readpage error correctly
arm64: berlin: Select DW_APB_TIMER_OF
tty: make FONTX ioctl use the tty pointer they were actually passed
rtc: rx8010: don't modify the global rtc ops
drm/ttm: fix eviction valuable range check.
ext4: fix invalid inode checksum
ext4: fix error handling code in add_new_gdb
ext4: fix leaking sysfs kobject after failed mount
vringh: fix __vringh_iov() when riov and wiov are different
ring-buffer: Return 0 on success from ring_buffer_resize()
9P: Cast to loff_t before multiplying
libceph: clear con->out_msg on Policy::stateful_server faults
ceph: promote to unsigned long long before shifting
drm/amd/display: Don't invoke kgdb_breakpoint() unconditionally
drm/amdgpu: don't map BO in reserved region
i2c: imx: Fix external abort on interrupt in exit paths
ia64: fix build error with !COREDUMP
ubi: check kthread_should_stop() after the setting of task state
perf python scripting: Fix printable strings in python3 scripts
ubifs: dent: Fix some potential memory leaks while iterating entries
NFSD: Add missing NFSv2 .pc_func methods
NFSv4.2: support EXCHGID4_FLAG_SUPP_FENCE_OPS 4.2 EXCHANGE_ID flag
powerpc: Fix undetected data corruption with P9N DD2.1 VSX CI load emulation
powerpc/powernv/elog: Fix race while processing OPAL error log event.
powerpc: Warn about use of smt_snooze_delay
powerpc/rtas: Restrict RTAS requests from userspace
s390/stp: add locking to sysfs functions
powerpc/drmem: Make lmb_size 64 bit
iio:gyro:itg3200: Fix timestamp alignment and prevent data leak.
iio:adc:ti-adc12138 Fix alignment issue with timestamp
iio:adc:ti-adc0832 Fix alignment issue with timestamp
iio:light:si1145: Fix timestamp alignment and prevent data leak.
dmaengine: dma-jz4780: Fix race in jz4780_dma_tx_status
udf: Fix memory leak when mounting
HID: wacom: Avoid entering wacom_wac_pen_report for pad / battery
vt: keyboard, extend func_buf_lock to readers
vt: keyboard, simplify vt_kdgkbsent
drm/i915: Force VT'd workarounds when running as a guest OS
usb: host: fsl-mph-dr-of: check return of dma_set_mask()
usb: typec: tcpm: reset hard_reset_count for any disconnect
usb: cdc-acm: fix cooldown mechanism
usb: dwc3: core: don't trigger runtime pm when remove driver
usb: dwc3: core: add phy cleanup for probe error handling
usb: dwc3: gadget: Check MPS of the request length
usb: dwc3: ep0: Fix ZLP for OUT ep0 requests
usb: xhci: Workaround for S3 issue on AMD SNPS 3.0 xHC
btrfs: fix use-after-free on readahead extent after failure to create it
btrfs: cleanup cow block on error
btrfs: use kvzalloc() to allocate clone_roots in btrfs_ioctl_send()
btrfs: send, recompute reference path after orphanization of a directory
btrfs: reschedule if necessary when logging directory items
btrfs: improve device scanning messages
btrfs: qgroup: fix wrong qgroup metadata reserve for delayed inode
scsi: qla2xxx: Fix crash on session cleanup with unload
scsi: mptfusion: Fix null pointer dereferences in mptscsih_remove()
w1: mxc_w1: Fix timeout resolution problem leading to bus error
acpi-cpufreq: Honor _PSD table setting on new AMD CPUs
ACPI: debug: don't allow debugging when ACPI is disabled
ACPI: video: use ACPI backlight for HP 635 Notebook
ACPI / extlog: Check for RDMSR failure
ACPI: button: fix handling lid state changes when input device closed
NFS: fix nfs_path in case of a rename retry
fs: Don't invalidate page buffers in block_write_full_page()
media: uvcvideo: Fix uvc_ctrl_fixup_xu_info() not having any effect
leds: bcm6328, bcm6358: use devres LED registering function
perf/x86/amd/ibs: Fix raw sample data accumulation
perf/x86/amd/ibs: Don't include randomized bits in get_ibs_op_count()
mmc: sdhci-acpi: AMDI0040: Set SDHCI_QUIRK2_PRESET_VALUE_BROKEN
md/raid5: fix oops during stripe resizing
nvme-rdma: fix crash when connect rejected
sgl_alloc_order: fix memory leak
nbd: make the config put is called before the notifying the waiter
ARM: dts: s5pv210: remove dedicated 'audio-subsystem' node
ARM: dts: s5pv210: move PMU node out of clock controller
ARM: dts: s5pv210: remove DMA controller bus node name to fix dtschema warnings
memory: emif: Remove bogus debugfs error handling
ARM: dts: omap4: Fix sgx clock rate for 4430
arm64: dts: renesas: ulcb: add full-pwr-cycle-in-suspend into eMMC nodes
cifs: handle -EINTR in cifs_setattr
gfs2: add validation checks for size of superblock
ext4: Detect already used quota file early
drivers: watchdog: rdc321x_wdt: Fix race condition bugs
net: 9p: initialize sun_server.sun_path to have addr's value only when addr is valid
clk: ti: clockdomain: fix static checker warning
rpmsg: glink: Use complete_all for open states
bnxt_en: Log unknown link speed appropriately.
md/bitmap: md_bitmap_get_counter returns wrong blocks
btrfs: fix replace of seed device
drm/amd/display: HDMI remote sink need mode validation for Linux
power: supply: test_power: add missing newlines when printing parameters by sysfs
bus/fsl_mc: Do not rely on caller to provide non NULL mc_io
drivers/net/wan/hdlc_fr: Correctly handle special skb->protocol values
ACPI: Add out of bounds and numa_off protections to pxm_to_node()
xfs: don't free rt blocks when we're doing a REMAP bunmapi call
arm64/mm: return cpu_all_mask when node is NUMA_NO_NODE
usb: xhci: omit duplicate actions when suspending a runtime suspended host.
uio: free uio id after uio file node is freed
USB: adutux: fix debugging
cpufreq: sti-cpufreq: add stih418 support
riscv: Define AT_VECTOR_SIZE_ARCH for ARCH_DLINFO
media: uvcvideo: Fix dereference of out-of-bound list iterator
kgdb: Make "kgdbcon" work properly with "kgdb_earlycon"
ia64: kprobes: Use generic kretprobe trampoline handler
printk: reduce LOG_BUF_SHIFT range for H8300
arm64: topology: Stop using MPIDR for topology information
drm/bridge/synopsys: dsi: add support for non-continuous HS clock
mmc: via-sdmmc: Fix data race bug
media: imx274: fix frame interval handling
media: tw5864: check status of tw5864_frameinterval_get
usb: typec: tcpm: During PR_SWAP, source caps should be sent only after tSwapSourceStart
media: platform: Improve queue set up flow for bug fixing
media: videodev2.h: RGB BT2020 and HSV are always full range
drm/brige/megachips: Add checking if ge_b850v3_lvds_init() is working correctly
ath10k: fix VHT NSS calculation when STBC is enabled
ath10k: start recovery process when payload length exceeds max htc length for sdio
video: fbdev: pvr2fb: initialize variables
xfs: fix realtime bitmap/summary file truncation when growing rt volume
power: supply: bq27xxx: report "not charging" on all types
ARM: 8997/2: hw_breakpoint: Handle inexact watchpoint addresses
um: change sigio_spinlock to a mutex
f2fs: fix to check segment boundary during SIT page readahead
f2fs: fix uninit-value in f2fs_lookup
f2fs: add trace exit in exception path
sparc64: remove mm_cpumask clearing to fix kthread_use_mm race
powerpc: select ARCH_WANT_IRQS_OFF_ACTIVATE_MM
mm: fix exec activate_mm vs TLB shootdown and lazy tlb switching race
powerpc/powernv/smp: Fix spurious DBG() warning
futex: Fix incorrect should_fail_futex() handling
ata: sata_nv: Fix retrieving of active qcs
RDMA/qedr: Fix memory leak in iWARP CM
mlxsw: core: Fix use-after-free in mlxsw_emad_trans_finish()
x86/unwind/orc: Fix inactive tasks with stack pointer in %sp on GCC 10 compiled kernels
xen/events: block rogue events for some time
xen/events: defer eoi in case of excessive number of events
xen/events: use a common cpu hotplug hook for event channels
xen/events: switch user event channels to lateeoi model
xen/pciback: use lateeoi irq binding
xen/pvcallsback: use lateeoi irq binding
xen/scsiback: use lateeoi irq binding
xen/netback: use lateeoi irq binding
xen/blkback: use lateeoi irq binding
xen/events: add a new "late EOI" evtchn framework
xen/events: fix race in evtchn_fifo_unmask()
xen/events: add a proper barrier to 2-level uevent unmasking
xen/events: avoid removing an event channel while handling it
xen/events: don't use chip_data for legacy IRQs
Revert "block: ratelimit handle_bad_sector() message"
fscrypt: fix race where ->lookup() marks plaintext dentry as ciphertext
fscrypt: only set dentry_operations on ciphertext dentries
fs, fscrypt: clear DCACHE_ENCRYPTED_NAME when unaliasing directory
fscrypt: fix race allowing rename() and link() of ciphertext dentries
fscrypt: clean up and improve dentry revalidation
fscrypt: return -EXDEV for incompatible rename or link into encrypted dir
ata: sata_rcar: Fix DMA boundary mask
serial: pl011: Fix lockdep splat when handling magic-sysrq interrupt
mtd: lpddr: Fix bad logic in print_drs_error
RDMA/addr: Fix race with netevent_callback()/rdma_addr_cancel()
cxl: Rework error message for incompatible slots
p54: avoid accessing the data mapped to streaming DMA
evm: Check size of security.evm before using it
bpf: Fix comment for helper bpf_current_task_under_cgroup()
fuse: fix page dereference after free
x86/xen: disable Firmware First mode for correctable memory errors
arch/x86/amd/ibs: Fix re-arming IBS Fetch
cxgb4: set up filter action after rewrites
r8169: fix issue with forced threading in combination with shared interrupts
tipc: fix memory leak caused by tipc_buf_append()
tcp: Prevent low rmem stalls with SO_RCVLOWAT.
ravb: Fix bit fields checking in ravb_hwtstamp_get()
netem: fix zero division in tabledist
mlxsw: core: Fix memory leak on module removal
gtp: fix an use-before-init in gtp_newlink()
chelsio/chtls: fix tls record info to user
chelsio/chtls: fix memory leaks in CPL handlers
chelsio/chtls: fix deadlock issue
efivarfs: Replace invalid slashes with exclamation marks in dentries.
x86/PCI: Fix intel_mid_pci.c build error when ACPI is not enabled
arm64: link with -z norelro regardless of CONFIG_RELOCATABLE
arm64: Run ARCH_WORKAROUND_1 enabling code on all CPUs
scripts/setlocalversion: make git describe output more reliable
objtool: Support Clang non-section symbols in ORC generation
ANDROID: GKI: Enable DEBUG_INFO_DWARF4
UPSTREAM: mm/sl[uo]b: export __kmalloc_track(_node)_caller
BACKPORT: xfrm/compat: Translate 32-bit user_policy from sockptr
BACKPORT: xfrm/compat: Add 32=>64-bit messages translator
UPSTREAM: xfrm/compat: Attach xfrm dumps to 64=>32 bit translator
UPSTREAM: xfrm/compat: Add 64=>32-bit messages translator
BACKPORT: xfrm: Provide API to register translator module
ANDROID: Publish uncompressed Image on aarch64
FROMLIST: crypto: arm64/poly1305-neon - reorder PAC authentication with SP update
UPSTREAM: crypto: arm64/chacha - fix chacha_4block_xor_neon() for big endian
UPSTREAM: crypto: arm64/chacha - fix hchacha_block_neon() for big endian
Linux 4.19.154
usb: gadget: f_ncm: allow using NCM in SuperSpeed Plus gadgets.
eeprom: at25: set minimum read/write access stride to 1
USB: cdc-wdm: Make wdm_flush() interruptible and add wdm_fsync().
usb: cdc-acm: add quirk to blacklist ETAS ES58X devices
tty: serial: fsl_lpuart: fix lpuart32_poll_get_char
net: korina: cast KSEG0 address to pointer in kfree
ath10k: check idx validity in __ath10k_htt_rx_ring_fill_n()
scsi: ufs: ufs-qcom: Fix race conditions caused by ufs_qcom_testbus_config()
usb: core: Solve race condition in anchor cleanup functions
brcm80211: fix possible memleak in brcmf_proto_msgbuf_attach
mwifiex: don't call del_timer_sync() on uninitialized timer
reiserfs: Fix memory leak in reiserfs_parse_options()
ipvs: Fix uninit-value in do_ip_vs_set_ctl()
tty: ipwireless: fix error handling
scsi: qedi: Fix list_del corruption while removing active I/O
scsi: qedi: Protect active command list to avoid list corruption
Fix use after free in get_capset_info callback.
rtl8xxxu: prevent potential memory leak
brcmsmac: fix memory leak in wlc_phy_attach_lcnphy
scsi: ibmvfc: Fix error return in ibmvfc_probe()
Bluetooth: Only mark socket zapped after unlocking
usb: ohci: Default to per-port over-current protection
xfs: make sure the rt allocator doesn't run off the end
reiserfs: only call unlock_new_inode() if I_NEW
misc: rtsx: Fix memory leak in rtsx_pci_probe
ath9k: hif_usb: fix race condition between usb_get_urb() and usb_kill_anchored_urbs()
can: flexcan: flexcan_chip_stop(): add error handling and propagate error value
usb: dwc3: simple: add support for Hikey 970
USB: cdc-acm: handle broken union descriptors
udf: Avoid accessing uninitialized data on failed inode read
udf: Limit sparing table size
usb: gadget: function: printer: fix use-after-free in __lock_acquire
misc: vop: add round_up(x,4) for vring_size to avoid kernel panic
mic: vop: copy data to kernel space then write to io memory
scsi: target: core: Add CONTROL field for trace events
scsi: mvumi: Fix error return in mvumi_io_attach()
PM: hibernate: remove the bogus call to get_gendisk() in software_resume()
mac80211: handle lack of sband->bitrates in rates
ip_gre: set dev->hard_header_len and dev->needed_headroom properly
ntfs: add check for mft record size in superblock
media: venus: core: Fix runtime PM imbalance in venus_probe
fs: dlm: fix configfs memory leak
media: saa7134: avoid a shift overflow
mmc: sdio: Check for CISTPL_VERS_1 buffer size
media: uvcvideo: Ensure all probed info is returned to v4l2
media: media/pci: prevent memory leak in bttv_probe
media: bdisp: Fix runtime PM imbalance on error
media: platform: sti: hva: Fix runtime PM imbalance on error
media: platform: s3c-camif: Fix runtime PM imbalance on error
media: vsp1: Fix runtime PM imbalance on error
media: exynos4-is: Fix a reference count leak
media: exynos4-is: Fix a reference count leak due to pm_runtime_get_sync
media: exynos4-is: Fix several reference count leaks due to pm_runtime_get_sync
media: sti: Fix reference count leaks
media: st-delta: Fix reference count leak in delta_run_work
media: ati_remote: sanity check for both endpoints
media: firewire: fix memory leak
crypto: ccp - fix error handling
block: ratelimit handle_bad_sector() message
i2c: core: Restore acpi_walk_dep_device_list() getting called after registering the ACPI i2c devs
perf: correct SNOOPX field offset
sched/features: Fix !CONFIG_JUMP_LABEL case
NTB: hw: amd: fix an issue about leak system resources
nvmet: fix uninitialized work for zero kato
powerpc/powernv/dump: Fix race while processing OPAL dump
arm64: dts: zynqmp: Remove additional compatible string for i2c IPs
ARM: dts: owl-s500: Fix incorrect PPI interrupt specifiers
arm64: dts: qcom: msm8916: Fix MDP/DSI interrupts
arm64: dts: qcom: pm8916: Remove invalid reg size from wcd_codec
memory: fsl-corenet-cf: Fix handling of platform_get_irq() error
memory: omap-gpmc: Fix build error without CONFIG_OF
memory: omap-gpmc: Fix a couple off by ones
ARM: dts: sun8i: r40: bananapi-m2-ultra: Fix dcdc1 regulator
ARM: dts: imx6sl: fix rng node
netfilter: nf_fwd_netdev: clear timestamp in forwarding path
netfilter: conntrack: connection timeout after re-register
KVM: x86: emulating RDPID failure shall return #UD rather than #GP
Input: sun4i-ps2 - fix handling of platform_get_irq() error
Input: twl4030_keypad - fix handling of platform_get_irq() error
Input: omap4-keypad - fix handling of platform_get_irq() error
Input: ep93xx_keypad - fix handling of platform_get_irq() error
Input: stmfts - fix a & vs && typo
Input: imx6ul_tsc - clean up some errors in imx6ul_tsc_resume()
SUNRPC: fix copying of multiple pages in gss_read_proxy_verf()
vfio iommu type1: Fix memory leak in vfio_iommu_type1_pin_pages
vfio/pci: Clear token on bypass registration failure
ext4: limit entries returned when counting fsmap records
svcrdma: fix bounce buffers for unaligned offsets and multiple pages
watchdog: sp5100: Fix definition of EFCH_PM_DECODEEN3
watchdog: Use put_device on error
watchdog: Fix memleak in watchdog_cdev_register
clk: bcm2835: add missing release if devm_clk_hw_register fails
clk: at91: clk-main: update key before writing AT91_CKGR_MOR
clk: rockchip: Initialize hw to error to avoid undefined behavior
pwm: img: Fix null pointer access in probe
rpmsg: smd: Fix a kobj leak in in qcom_smd_parse_edge()
PCI: iproc: Set affinity mask on MSI interrupts
i2c: rcar: Auto select RESET_CONTROLLER
mailbox: avoid timer start from callback
rapidio: fix the missed put_device() for rio_mport_add_riodev
rapidio: fix error handling path
ramfs: fix nommu mmap with gaps in the page cache
lib/crc32.c: fix trivial typo in preprocessor condition
f2fs: wait for sysfs kobject removal before freeing f2fs_sb_info
IB/rdmavt: Fix sizeof mismatch
cpufreq: powernv: Fix frame-size-overflow in powernv_cpufreq_reboot_notifier
powerpc/perf/hv-gpci: Fix starting index value
powerpc/perf: Exclude pmc5/6 from the irrelevant PMU group constraints
overflow: Include header file with SIZE_MAX declaration
kdb: Fix pager search for multi-line strings
RDMA/hns: Fix missing sq_sig_type when querying QP
RDMA/hns: Set the unsupported wr opcode
perf intel-pt: Fix "context_switch event has no tid" error
RDMA/cma: Consolidate the destruction of a cma_multicast in one place
RDMA/cma: Remove dead code for kernel rdmacm multicast
powerpc/64s/radix: Fix mm_cpumask trimming race vs kthread_use_mm
powerpc/tau: Disable TAU between measurements
powerpc/tau: Check processor type before enabling TAU interrupt
ANDROID: GKI: update the ABI xml
Linux 4.19.153
powerpc/tau: Remove duplicated set_thresholds() call
powerpc/tau: Convert from timer to workqueue
powerpc/tau: Use appropriate temperature sample interval
RDMA/qedr: Fix inline size returned for iWARP
RDMA/qedr: Fix use of uninitialized field
xfs: fix high key handling in the rt allocator's query_range function
xfs: limit entries returned when counting fsmap records
arc: plat-hsdk: fix kconfig dependency warning when !RESET_CONTROLLER
ARM: 9007/1: l2c: fix prefetch bits init in L2X0_AUX_CTRL using DT values
mtd: mtdoops: Don't write panic data twice
powerpc/pseries: explicitly reschedule during drmem_lmb list traversal
mtd: lpddr: fix excessive stack usage with clang
RDMA/ucma: Add missing locking around rdma_leave_multicast()
RDMA/ucma: Fix locking for ctx->events_reported
powerpc/icp-hv: Fix missing of_node_put() in success path
powerpc/pseries: Fix missing of_node_put() in rng_init()
IB/mlx4: Adjust delayed work when a dup is observed
IB/mlx4: Fix starvation in paravirt mux/demux
mm, oom_adj: don't loop through tasks in __set_oom_adj when not necessary
mm/memcg: fix device private memcg accounting
netfilter: nf_log: missing vlan offload tag and proto
net: korina: fix kfree of rx/tx descriptor array
ipvs: clear skb->tstamp in forwarding path
mwifiex: fix double free
platform/x86: mlx-platform: Remove PSU EEPROM configuration
scsi: be2iscsi: Fix a theoretical leak in beiscsi_create_eqs()
scsi: target: tcmu: Fix warning: 'page' may be used uninitialized
usb: dwc2: Fix INTR OUT transfers in DDMA mode.
nl80211: fix non-split wiphy information
usb: gadget: u_ether: enable qmult on SuperSpeed Plus as well
usb: gadget: f_ncm: fix ncm_bitrate for SuperSpeed and above.
iwlwifi: mvm: split a print to avoid a WARNING in ROC
mfd: sm501: Fix leaks in probe()
net: enic: Cure the enic api locking trainwreck
qtnfmac: fix resource leaks on unsupported iftype error return path
HID: hid-input: fix stylus battery reporting
slimbus: qcom-ngd-ctrl: disable ngd in qmi server down callback
slimbus: core: do not enter to clock pause mode in core
slimbus: core: check get_addr before removing laddr ida
quota: clear padding in v2r1_mem2diskdqb()
usb: dwc2: Fix parameter type in function pointer prototype
ALSA: seq: oss: Avoid mutex lock for a long-time ioctl
misc: mic: scif: Fix error handling path
ath6kl: wmi: prevent a shift wrapping bug in ath6kl_wmi_delete_pstream_cmd()
net: dsa: rtl8366rb: Support all 4096 VLANs
net: dsa: rtl8366: Skip PVID setting if not requested
net: dsa: rtl8366: Refactor VLAN/PVID init
net: dsa: rtl8366: Check validity of passed VLANs
cpufreq: armada-37xx: Add missing MODULE_DEVICE_TABLE
net: stmmac: use netif_tx_start|stop_all_queues() function
net/mlx5: Don't call timecounter cyc2time directly from 1PPS flow
pinctrl: mcp23s08: Fix mcp23x17 precious range
pinctrl: mcp23s08: Fix mcp23x17_regmap initialiser
HID: roccat: add bounds checking in kone_sysfs_write_settings()
video: fbdev: radeon: Fix memleak in radeonfb_pci_register
video: fbdev: sis: fix null ptr dereference
video: fbdev: vga16fb: fix setting of pixclock because a pass-by-value error
drivers/virt/fsl_hypervisor: Fix error handling path
pwm: lpss: Add range limit check for the base_unit register value
pwm: lpss: Fix off by one error in base_unit math in pwm_lpss_prepare()
pty: do tty_flip_buffer_push without port->lock in pty_write
tty: hvcs: Don't NULL tty->driver_data until hvcs_cleanup()
tty: serial: earlycon dependency
VMCI: check return value of get_user_pages_fast() for errors
backlight: sky81452-backlight: Fix refcount imbalance on error
scsi: csiostor: Fix wrong return value in csio_hw_prep_fw()
scsi: qla2xxx: Fix wrong return value in qla_nvme_register_hba()
scsi: qla4xxx: Fix an error handling path in 'qla4xxx_get_host_stats()'
drm/gma500: fix error check
staging: rtl8192u: Do not use GFP_KERNEL in atomic context
mwifiex: Do not use GFP_KERNEL in atomic context
brcmfmac: check ndev pointer
ASoC: qcom: lpass-cpu: fix concurrency issue
ASoC: qcom: lpass-platform: fix memory leak
wcn36xx: Fix reported 802.11n rx_highest rate wcn3660/wcn3680
ath10k: Fix the size used in a 'dma_free_coherent()' call in an error handling path
ath9k: Fix potential out of bounds in ath9k_htc_txcompletion_cb()
ath6kl: prevent potential array overflow in ath6kl_add_new_sta()
Bluetooth: hci_uart: Cancel init work before unregistering
ath10k: provide survey info as accumulated data
spi: spi-s3c64xx: Check return values
spi: spi-s3c64xx: swap s3c64xx_spi_set_cs() and s3c64xx_enable_datapath()
pinctrl: bcm: fix kconfig dependency warning when !GPIOLIB
regulator: resolve supply after creating regulator
media: ti-vpe: Fix a missing check and reference count leak
media: stm32-dcmi: Fix a reference count leak
media: s5p-mfc: Fix a reference count leak
media: camss: Fix a reference count leak.
media: platform: fcp: Fix a reference count leak.
media: rockchip/rga: Fix a reference count leak.
media: rcar-vin: Fix a reference count leak.
media: tc358743: cleanup tc358743_cec_isr
media: tc358743: initialize variable
media: mx2_emmaprp: Fix memleak in emmaprp_probe
cypto: mediatek - fix leaks in mtk_desc_ring_alloc
hwmon: (pmbus/max34440) Fix status register reads for MAX344{51,60,61}
crypto: omap-sham - fix digcnt register handling with export/import
media: omap3isp: Fix memleak in isp_probe
media: uvcvideo: Silence shift-out-of-bounds warning
media: uvcvideo: Set media controller entity functions
media: m5mols: Check function pointer in m5mols_sensor_power
media: Revert "media: exynos4-is: Add missed check for pinctrl_lookup_state()"
media: tuner-simple: fix regression in simple_set_radio_freq
crypto: picoxcell - Fix potential race condition bug
crypto: ixp4xx - Fix the size used in a 'dma_free_coherent()' call
crypto: mediatek - Fix wrong return value in mtk_desc_ring_alloc()
crypto: algif_skcipher - EBUSY on aio should be an error
x86/events/amd/iommu: Fix sizeof mismatch
x86/nmi: Fix nmi_handle() duration miscalculation
drivers/perf: xgene_pmu: Fix uninitialized resource struct
x86/fpu: Allow multiple bits in clearcpuid= parameter
EDAC/ti: Fix handling of platform_get_irq() error
EDAC/i5100: Fix error handling order in i5100_init_one()
crypto: algif_aead - Do not set MAY_BACKLOG on the async path
ima: Don't ignore errors from crypto_shash_update()
KVM: SVM: Initialize prev_ga_tag before use
KVM: x86/mmu: Commit zap of remaining invalid pages when recovering lpages
cifs: Return the error from crypt_message when enc/dec key not found.
cifs: remove bogus debug code
ALSA: hda/realtek: Enable audio jacks of ASUS D700SA with ALC887
icmp: randomize the global rate limiter
r8169: fix operation under forced interrupt threading
tcp: fix to update snd_wl1 in bulk receiver fast path
nfc: Ensure presence of NFC_ATTR_FIRMWARE_NAME attribute in nfc_genl_fw_download()
net/sched: act_tunnel_key: fix OOB write in case of IPv6 ERSPAN tunnels
net: hdlc_raw_eth: Clear the IFF_TX_SKB_SHARING flag after calling ether_setup
net: hdlc: In hdlc_rcv, check to make sure dev is an HDLC device
chelsio/chtls: correct function return and return type
chelsio/chtls: correct netdevice for vlan interface
chelsio/chtls: fix socket lock
ALSA: bebob: potential info leak in hwdep_read()
binder: fix UAF when releasing todo list
net/tls: sendfile fails with ktls offload
r8169: fix data corruption issue on RTL8402
net/ipv4: always honour route mtu during forwarding
tipc: fix the skb_unshare() in tipc_buf_append()
net: usb: qmi_wwan: add Cellient MPL200 card
net/smc: fix valid DMBE buffer sizes
net: fix pos incrementment in ipv6_route_seq_next
net: fec: Fix PHY init after phy_reset_after_clk_enable()
net: fec: Fix phy_device lookup for phy_reset_after_clk_enable()
mlx4: handle non-napi callers to napi_poll
ipv4: Restore flowi4_oif update before call to xfrm_lookup_route
ibmveth: Identify ingress large send packets.
ibmveth: Switch order of ibmveth_helper calls.
ANDROID: clang: update to 11.0.5
FROMLIST: arm64: link with -z norelro regardless of CONFIG_RELOCATABLE
ANDROID: GKI: enable CONFIG_WIREGUARD
UPSTREAM: wireguard: peerlookup: take lock before checking hash in replace operation
UPSTREAM: wireguard: noise: take lock when removing handshake entry from table
UPSTREAM: wireguard: queueing: make use of ip_tunnel_parse_protocol
UPSTREAM: net: ip_tunnel: add header_ops for layer 3 devices
UPSTREAM: wireguard: receive: account for napi_gro_receive never returning GRO_DROP
UPSTREAM: wireguard: device: avoid circular netns references
UPSTREAM: wireguard: noise: do not assign initiation time in if condition
UPSTREAM: wireguard: noise: separate receive counter from send counter
UPSTREAM: wireguard: queueing: preserve flow hash across packet scrubbing
UPSTREAM: wireguard: noise: read preshared key while taking lock
UPSTREAM: wireguard: selftests: use newer iproute2 for gcc-10
UPSTREAM: wireguard: send/receive: use explicit unlikely branch instead of implicit coalescing
UPSTREAM: wireguard: selftests: initalize ipv6 members to NULL to squelch clang warning
UPSTREAM: wireguard: send/receive: cond_resched() when processing worker ringbuffers
UPSTREAM: wireguard: socket: remove errant restriction on looping to self
UPSTREAM: wireguard: selftests: use normal kernel stack size on ppc64
UPSTREAM: wireguard: receive: use tunnel helpers for decapsulating ECN markings
UPSTREAM: wireguard: queueing: cleanup ptr_ring in error path of packet_queue_init
UPSTREAM: wireguard: send: remove errant newline from packet_encrypt_worker
UPSTREAM: wireguard: noise: error out precomputed DH during handshake rather than config
UPSTREAM: wireguard: receive: remove dead code from default packet type case
UPSTREAM: wireguard: queueing: account for skb->protocol==0
UPSTREAM: wireguard: selftests: remove duplicated include <sys/types.h>
UPSTREAM: wireguard: socket: remove extra call to synchronize_net
UPSTREAM: wireguard: send: account for mtu=0 devices
UPSTREAM: wireguard: receive: reset last_under_load to zero
UPSTREAM: wireguard: selftests: reduce complexity and fix make races
UPSTREAM: wireguard: device: use icmp_ndo_send helper
UPSTREAM: wireguard: selftests: tie socket waiting to target pid
UPSTREAM: wireguard: selftests: ensure non-addition of peers with failed precomputation
UPSTREAM: wireguard: noise: reject peers with low order public keys
UPSTREAM: wireguard: allowedips: fix use-after-free in root_remove_peer_lists
UPSTREAM: net: skbuff: disambiguate argument and member for skb_list_walk_safe helper
UPSTREAM: net: introduce skb_list_walk_safe for skb segment walking
UPSTREAM: wireguard: socket: mark skbs as not on list when receiving via gro
UPSTREAM: wireguard: queueing: do not account for pfmemalloc when clearing skb header
UPSTREAM: wireguard: selftests: remove ancient kernel compatibility code
UPSTREAM: wireguard: allowedips: use kfree_rcu() instead of call_rcu()
UPSTREAM: wireguard: main: remove unused include <linux/version.h>
UPSTREAM: wireguard: global: fix spelling mistakes in comments
UPSTREAM: wireguard: Kconfig: select parent dependency for crypto
UPSTREAM: wireguard: selftests: import harness makefile for test suite
UPSTREAM: net: WireGuard secure network tunnel
UPSTREAM: timekeeping: Boot should be boottime for coarse ns accessor
UPSTREAM: timekeeping: Add missing _ns functions for coarse accessors
UPSTREAM: icmp: introduce helper for nat'd source address in network device context
UPSTREAM: crypto: poly1305-x86_64 - Use XORL r32,32
UPSTREAM: crypto: curve25519-x86_64 - Use XORL r32,32
UPSTREAM: crypto: arm/poly1305 - Add prototype for poly1305_blocks_neon
UPSTREAM: crypto: arm/curve25519 - include <linux/scatterlist.h>
UPSTREAM: crypto: x86/curve25519 - Remove unused carry variables
UPSTREAM: crypto: x86/chacha-sse3 - use unaligned loads for state array
UPSTREAM: crypto: lib/chacha20poly1305 - Add missing function declaration
UPSTREAM: crypto: arch/lib - limit simd usage to 4k chunks
UPSTREAM: crypto: arm[64]/poly1305 - add artifact to .gitignore files
UPSTREAM: crypto: x86/curve25519 - leave r12 as spare register
UPSTREAM: crypto: x86/curve25519 - replace with formally verified implementation
UPSTREAM: crypto: arm64/chacha - correctly walk through blocks
UPSTREAM: crypto: x86/curve25519 - support assemblers with no adx support
UPSTREAM: crypto: chacha20poly1305 - prevent integer overflow on large input
UPSTREAM: crypto: Kconfig - allow tests to be disabled when manager is disabled
UPSTREAM: crypto: arm/chacha - fix build failured when kernel mode NEON is disabled
UPSTREAM: crypto: x86/poly1305 - emit does base conversion itself
UPSTREAM: crypto: chacha20poly1305 - add back missing test vectors and test chunking
UPSTREAM: crypto: x86/poly1305 - fix .gitignore typo
UPSTREAM: crypto: curve25519 - Fix selftest build error
UPSTREAM: crypto: {arm,arm64,mips}/poly1305 - remove redundant non-reduction from emit
UPSTREAM: crypto: x86/poly1305 - wire up faster implementations for kernel
UPSTREAM: crypto: x86/poly1305 - import unmodified cryptogams implementation
UPSTREAM: crypto: poly1305 - add new 32 and 64-bit generic versions
UPSTREAM: crypto: lib/curve25519 - re-add selftests
UPSTREAM: crypto: arm/curve25519 - add arch-specific key generation function
UPSTREAM: crypto: chacha - fix warning message in header file
UPSTREAM: crypto: arch - conditionalize crypto api in arch glue for lib code
UPSTREAM: crypto: lib/chacha20poly1305 - use chacha20_crypt()
UPSTREAM: crypto: x86/chacha - only unregister algorithms if registered
UPSTREAM: crypto: chacha_generic - remove unnecessary setkey() functions
UPSTREAM: crypto: lib/chacha20poly1305 - reimplement crypt_from_sg() routine
UPSTREAM: crypto: chacha20poly1305 - import construction and selftest from Zinc
UPSTREAM: crypto: arm/curve25519 - wire up NEON implementation
UPSTREAM: crypto: arm/curve25519 - import Bernstein and Schwabe's Curve25519 ARM implementation
UPSTREAM: crypto: curve25519 - x86_64 library and KPP implementations
UPSTREAM: crypto: lib/curve25519 - work around Clang stack spilling issue
UPSTREAM: crypto: curve25519 - implement generic KPP driver
UPSTREAM: crypto: curve25519 - add kpp selftest
UPSTREAM: crypto: curve25519 - generic C library implementations
UPSTREAM: crypto: blake2s - x86_64 SIMD implementation
UPSTREAM: crypto: blake2s - implement generic shash driver
UPSTREAM: crypto: testmgr - add test cases for Blake2s
UPSTREAM: crypto: blake2s - generic C library implementation and selftest
UPSTREAM: crypto: mips/poly1305 - incorporate OpenSSL/CRYPTOGAMS optimized implementation
UPSTREAM: crypto: arm/poly1305 - incorporate OpenSSL/CRYPTOGAMS NEON implementation
UPSTREAM: crypto: arm64/poly1305 - incorporate OpenSSL/CRYPTOGAMS NEON implementation
UPSTREAM: crypto: x86/poly1305 - expose existing driver as poly1305 library
UPSTREAM: crypto: x86/poly1305 - depend on generic library not generic shash
UPSTREAM: crypto: poly1305 - expose init/update/final library interface
UPSTREAM: crypto: x86/poly1305 - unify Poly1305 state struct with generic code
UPSTREAM: crypto: poly1305 - move core routines into a separate library
UPSTREAM: crypto: chacha - unexport chacha_generic routines
UPSTREAM: crypto: mips/chacha - wire up accelerated 32r2 code from Zinc
UPSTREAM: crypto: mips/chacha - import 32r2 ChaCha code from Zinc
UPSTREAM: crypto: arm/chacha - expose ARM ChaCha routine as library function
UPSTREAM: crypto: arm/chacha - remove dependency on generic ChaCha driver
UPSTREAM: crypto: arm/chacha - import Eric Biggers's scalar accelerated ChaCha code
UPSTREAM: crypto: arm64/chacha - expose arm64 ChaCha routine as library function
UPSTREAM: crypto: arm64/chacha - depend on generic chacha library instead of crypto driver
UPSTREAM: crypto: arm64/chacha - use combined SIMD/ALU routine for more speed
UPSTREAM: crypto: arm64/chacha - optimize for arbitrary length inputs
UPSTREAM: crypto: x86/chacha - expose SIMD ChaCha routine as library function
UPSTREAM: crypto: x86/chacha - depend on generic chacha library instead of crypto driver
UPSTREAM: crypto: chacha - move existing library code into lib/crypto
UPSTREAM: crypto: lib - tidy up lib/crypto Kconfig and Makefile
UPSTREAM: crypto: chacha - constify ctx and iv arguments
UPSTREAM: crypto: x86/poly1305 - Clear key material from stack in SSE2 variant
UPSTREAM: crypto: xchacha20 - fix comments for test vectors
UPSTREAM: crypto: xchacha - add test vector from XChaCha20 draft RFC
UPSTREAM: crypto: arm64/chacha - add XChaCha12 support
UPSTREAM: crypto: arm64/chacha20 - refactor to allow varying number of rounds
UPSTREAM: crypto: arm64/chacha20 - add XChaCha20 support
UPSTREAM: crypto: x86/chacha - avoid sleeping under kernel_fpu_begin()
UPSTREAM: crypto: x86/chacha - yield the FPU occasionally
UPSTREAM: crypto: x86/chacha - add XChaCha12 support
UPSTREAM: crypto: x86/chacha20 - refactor to allow varying number of rounds
UPSTREAM: crypto: x86/chacha20 - add XChaCha20 support
UPSTREAM: crypto: x86/chacha20 - Add a 4-block AVX-512VL variant
UPSTREAM: crypto: x86/chacha20 - Add a 2-block AVX-512VL variant
UPSTREAM: crypto: x86/chacha20 - Add a 8-block AVX-512VL variant
UPSTREAM: crypto: x86/chacha20 - Add a 4-block AVX2 variant
UPSTREAM: crypto: x86/chacha20 - Add a 2-block AVX2 variant
UPSTREAM: crypto: x86/chacha20 - Use larger block functions more aggressively
UPSTREAM: crypto: x86/chacha20 - Support partial lengths in 8-block AVX2 variant
UPSTREAM: crypto: x86/chacha20 - Support partial lengths in 4-block SSSE3 variant
UPSTREAM: crypto: x86/chacha20 - Support partial lengths in 1-block SSSE3 variant
ANDROID: GKI: Enable CONFIG_USB_ANNOUNCE_NEW_DEVICES
ANDROID: GKI: Enable CONFIG_X86_X2APIC
ANDROID: move builds to use gas prebuilts
UPSTREAM: binder: fix UAF when releasing todo list
Conflicts:
crypto/algif_aead.c
drivers/rpmsg/qcom_glink_native.c
drivers/scsi/ufs/ufs-qcom.c
drivers/slimbus/qcom-ngd-ctrl.c
fs/notify/inotify/inotify_user.c
include/linux/dcache.h
include/linux/fsnotify.h
mm/oom_kill.c
Fixed build errors:
fs/fuse/dir.c
Change-Id: I95bdbb1b183fa2c569023f18e09799d9cb96fc9f
Signed-off-by: Srinivasarao P <spathi@codeaurora.org>
1694 lines
42 KiB
C
1694 lines
42 KiB
C
// SPDX-License-Identifier: GPL-2.0
|
|
/*
|
|
* fs/f2fs/checkpoint.c
|
|
*
|
|
* Copyright (c) 2012 Samsung Electronics Co., Ltd.
|
|
* http://www.samsung.com/
|
|
*/
|
|
#include <linux/fs.h>
|
|
#include <linux/bio.h>
|
|
#include <linux/mpage.h>
|
|
#include <linux/writeback.h>
|
|
#include <linux/blkdev.h>
|
|
#include <linux/f2fs_fs.h>
|
|
#include <linux/pagevec.h>
|
|
#include <linux/swap.h>
|
|
|
|
#include "f2fs.h"
|
|
#include "node.h"
|
|
#include "segment.h"
|
|
#include "trace.h"
|
|
#include <trace/events/f2fs.h>
|
|
|
|
static struct kmem_cache *ino_entry_slab;
|
|
struct kmem_cache *f2fs_inode_entry_slab;
|
|
|
|
void f2fs_stop_checkpoint(struct f2fs_sb_info *sbi, bool end_io)
|
|
{
|
|
f2fs_build_fault_attr(sbi, 0, 0);
|
|
set_ckpt_flags(sbi, CP_ERROR_FLAG);
|
|
if (!end_io)
|
|
f2fs_flush_merged_writes(sbi);
|
|
}
|
|
|
|
/*
|
|
* We guarantee no failure on the returned page.
|
|
*/
|
|
struct page *f2fs_grab_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)
|
|
{
|
|
struct address_space *mapping = META_MAPPING(sbi);
|
|
struct page *page = NULL;
|
|
repeat:
|
|
page = f2fs_grab_cache_page(mapping, index, false);
|
|
if (!page) {
|
|
cond_resched();
|
|
goto repeat;
|
|
}
|
|
f2fs_wait_on_page_writeback(page, META, true, true);
|
|
if (!PageUptodate(page))
|
|
SetPageUptodate(page);
|
|
return page;
|
|
}
|
|
|
|
static struct page *__get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index,
|
|
bool is_meta)
|
|
{
|
|
struct address_space *mapping = META_MAPPING(sbi);
|
|
struct page *page;
|
|
struct f2fs_io_info fio = {
|
|
.sbi = sbi,
|
|
.type = META,
|
|
.op = REQ_OP_READ,
|
|
.op_flags = REQ_META | REQ_PRIO,
|
|
.old_blkaddr = index,
|
|
.new_blkaddr = index,
|
|
.encrypted_page = NULL,
|
|
.is_por = !is_meta,
|
|
};
|
|
int err;
|
|
|
|
if (unlikely(!is_meta))
|
|
fio.op_flags &= ~REQ_META;
|
|
repeat:
|
|
page = f2fs_grab_cache_page(mapping, index, false);
|
|
if (!page) {
|
|
cond_resched();
|
|
goto repeat;
|
|
}
|
|
if (PageUptodate(page))
|
|
goto out;
|
|
|
|
fio.page = page;
|
|
|
|
err = f2fs_submit_page_bio(&fio);
|
|
if (err) {
|
|
f2fs_put_page(page, 1);
|
|
return ERR_PTR(err);
|
|
}
|
|
|
|
f2fs_update_iostat(sbi, FS_META_READ_IO, F2FS_BLKSIZE);
|
|
|
|
lock_page(page);
|
|
if (unlikely(page->mapping != mapping)) {
|
|
f2fs_put_page(page, 1);
|
|
goto repeat;
|
|
}
|
|
|
|
if (unlikely(!PageUptodate(page))) {
|
|
f2fs_put_page(page, 1);
|
|
return ERR_PTR(-EIO);
|
|
}
|
|
out:
|
|
return page;
|
|
}
|
|
|
|
struct page *f2fs_get_meta_page(struct f2fs_sb_info *sbi, pgoff_t index)
|
|
{
|
|
return __get_meta_page(sbi, index, true);
|
|
}
|
|
|
|
struct page *f2fs_get_meta_page_nofail(struct f2fs_sb_info *sbi, pgoff_t index)
|
|
{
|
|
struct page *page;
|
|
int count = 0;
|
|
|
|
retry:
|
|
page = __get_meta_page(sbi, index, true);
|
|
if (IS_ERR(page)) {
|
|
if (PTR_ERR(page) == -EIO &&
|
|
++count <= DEFAULT_RETRY_IO_COUNT)
|
|
goto retry;
|
|
f2fs_stop_checkpoint(sbi, false);
|
|
}
|
|
return page;
|
|
}
|
|
|
|
/* for POR only */
|
|
struct page *f2fs_get_tmp_page(struct f2fs_sb_info *sbi, pgoff_t index)
|
|
{
|
|
return __get_meta_page(sbi, index, false);
|
|
}
|
|
|
|
static bool __is_bitmap_valid(struct f2fs_sb_info *sbi, block_t blkaddr,
|
|
int type)
|
|
{
|
|
struct seg_entry *se;
|
|
unsigned int segno, offset;
|
|
bool exist;
|
|
|
|
if (type != DATA_GENERIC_ENHANCE && type != DATA_GENERIC_ENHANCE_READ)
|
|
return true;
|
|
|
|
segno = GET_SEGNO(sbi, blkaddr);
|
|
offset = GET_BLKOFF_FROM_SEG0(sbi, blkaddr);
|
|
se = get_seg_entry(sbi, segno);
|
|
|
|
exist = f2fs_test_bit(offset, se->cur_valid_map);
|
|
if (!exist && type == DATA_GENERIC_ENHANCE) {
|
|
f2fs_err(sbi, "Inconsistent error blkaddr:%u, sit bitmap:%d",
|
|
blkaddr, exist);
|
|
set_sbi_flag(sbi, SBI_NEED_FSCK);
|
|
WARN_ON(1);
|
|
}
|
|
return exist;
|
|
}
|
|
|
|
bool f2fs_is_valid_blkaddr(struct f2fs_sb_info *sbi,
|
|
block_t blkaddr, int type)
|
|
{
|
|
switch (type) {
|
|
case META_NAT:
|
|
break;
|
|
case META_SIT:
|
|
if (unlikely(blkaddr >= SIT_BLK_CNT(sbi)))
|
|
return false;
|
|
break;
|
|
case META_SSA:
|
|
if (unlikely(blkaddr >= MAIN_BLKADDR(sbi) ||
|
|
blkaddr < SM_I(sbi)->ssa_blkaddr))
|
|
return false;
|
|
break;
|
|
case META_CP:
|
|
if (unlikely(blkaddr >= SIT_I(sbi)->sit_base_addr ||
|
|
blkaddr < __start_cp_addr(sbi)))
|
|
return false;
|
|
break;
|
|
case META_POR:
|
|
if (unlikely(blkaddr >= MAX_BLKADDR(sbi) ||
|
|
blkaddr < MAIN_BLKADDR(sbi)))
|
|
return false;
|
|
break;
|
|
case DATA_GENERIC:
|
|
case DATA_GENERIC_ENHANCE:
|
|
case DATA_GENERIC_ENHANCE_READ:
|
|
if (unlikely(blkaddr >= MAX_BLKADDR(sbi) ||
|
|
blkaddr < MAIN_BLKADDR(sbi))) {
|
|
f2fs_warn(sbi, "access invalid blkaddr:%u",
|
|
blkaddr);
|
|
set_sbi_flag(sbi, SBI_NEED_FSCK);
|
|
WARN_ON(1);
|
|
return false;
|
|
} else {
|
|
return __is_bitmap_valid(sbi, blkaddr, type);
|
|
}
|
|
break;
|
|
case META_GENERIC:
|
|
if (unlikely(blkaddr < SEG0_BLKADDR(sbi) ||
|
|
blkaddr >= MAIN_BLKADDR(sbi)))
|
|
return false;
|
|
break;
|
|
default:
|
|
BUG();
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/*
|
|
* Readahead CP/NAT/SIT/SSA/POR pages
|
|
*/
|
|
int f2fs_ra_meta_pages(struct f2fs_sb_info *sbi, block_t start, int nrpages,
|
|
int type, bool sync)
|
|
{
|
|
struct page *page;
|
|
block_t blkno = start;
|
|
struct f2fs_io_info fio = {
|
|
.sbi = sbi,
|
|
.type = META,
|
|
.op = REQ_OP_READ,
|
|
.op_flags = sync ? (REQ_META | REQ_PRIO) : REQ_RAHEAD,
|
|
.encrypted_page = NULL,
|
|
.in_list = false,
|
|
.is_por = (type == META_POR),
|
|
};
|
|
struct blk_plug plug;
|
|
int err;
|
|
|
|
if (unlikely(type == META_POR))
|
|
fio.op_flags &= ~REQ_META;
|
|
|
|
blk_start_plug(&plug);
|
|
for (; nrpages-- > 0; blkno++) {
|
|
|
|
if (!f2fs_is_valid_blkaddr(sbi, blkno, type))
|
|
goto out;
|
|
|
|
switch (type) {
|
|
case META_NAT:
|
|
if (unlikely(blkno >=
|
|
NAT_BLOCK_OFFSET(NM_I(sbi)->max_nid)))
|
|
blkno = 0;
|
|
/* get nat block addr */
|
|
fio.new_blkaddr = current_nat_addr(sbi,
|
|
blkno * NAT_ENTRY_PER_BLOCK);
|
|
break;
|
|
case META_SIT:
|
|
if (unlikely(blkno >= TOTAL_SEGS(sbi)))
|
|
goto out;
|
|
/* get sit block addr */
|
|
fio.new_blkaddr = current_sit_addr(sbi,
|
|
blkno * SIT_ENTRY_PER_BLOCK);
|
|
break;
|
|
case META_SSA:
|
|
case META_CP:
|
|
case META_POR:
|
|
fio.new_blkaddr = blkno;
|
|
break;
|
|
default:
|
|
BUG();
|
|
}
|
|
|
|
page = f2fs_grab_cache_page(META_MAPPING(sbi),
|
|
fio.new_blkaddr, false);
|
|
if (!page)
|
|
continue;
|
|
if (PageUptodate(page)) {
|
|
f2fs_put_page(page, 1);
|
|
continue;
|
|
}
|
|
|
|
fio.page = page;
|
|
err = f2fs_submit_page_bio(&fio);
|
|
f2fs_put_page(page, err ? 1 : 0);
|
|
|
|
if (!err)
|
|
f2fs_update_iostat(sbi, FS_META_READ_IO, F2FS_BLKSIZE);
|
|
}
|
|
out:
|
|
blk_finish_plug(&plug);
|
|
return blkno - start;
|
|
}
|
|
|
|
void f2fs_ra_meta_pages_cond(struct f2fs_sb_info *sbi, pgoff_t index)
|
|
{
|
|
struct page *page;
|
|
bool readahead = false;
|
|
|
|
page = find_get_page(META_MAPPING(sbi), index);
|
|
if (!page || !PageUptodate(page))
|
|
readahead = true;
|
|
f2fs_put_page(page, 0);
|
|
|
|
if (readahead)
|
|
f2fs_ra_meta_pages(sbi, index, BIO_MAX_PAGES, META_POR, true);
|
|
}
|
|
|
|
static int __f2fs_write_meta_page(struct page *page,
|
|
struct writeback_control *wbc,
|
|
enum iostat_type io_type)
|
|
{
|
|
struct f2fs_sb_info *sbi = F2FS_P_SB(page);
|
|
|
|
trace_f2fs_writepage(page, META);
|
|
|
|
if (unlikely(f2fs_cp_error(sbi)))
|
|
goto redirty_out;
|
|
if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
|
|
goto redirty_out;
|
|
if (wbc->for_reclaim && page->index < GET_SUM_BLOCK(sbi, 0))
|
|
goto redirty_out;
|
|
|
|
f2fs_do_write_meta_page(sbi, page, io_type);
|
|
dec_page_count(sbi, F2FS_DIRTY_META);
|
|
|
|
if (wbc->for_reclaim)
|
|
f2fs_submit_merged_write_cond(sbi, NULL, page, 0, META);
|
|
|
|
unlock_page(page);
|
|
|
|
if (unlikely(f2fs_cp_error(sbi)))
|
|
f2fs_submit_merged_write(sbi, META);
|
|
|
|
return 0;
|
|
|
|
redirty_out:
|
|
redirty_page_for_writepage(wbc, page);
|
|
return AOP_WRITEPAGE_ACTIVATE;
|
|
}
|
|
|
|
static int f2fs_write_meta_page(struct page *page,
|
|
struct writeback_control *wbc)
|
|
{
|
|
return __f2fs_write_meta_page(page, wbc, FS_META_IO);
|
|
}
|
|
|
|
static int f2fs_write_meta_pages(struct address_space *mapping,
|
|
struct writeback_control *wbc)
|
|
{
|
|
struct f2fs_sb_info *sbi = F2FS_M_SB(mapping);
|
|
long diff, written;
|
|
|
|
if (unlikely(is_sbi_flag_set(sbi, SBI_POR_DOING)))
|
|
goto skip_write;
|
|
|
|
/* collect a number of dirty meta pages and write together */
|
|
if (wbc->sync_mode != WB_SYNC_ALL &&
|
|
get_pages(sbi, F2FS_DIRTY_META) <
|
|
nr_pages_to_skip(sbi, META))
|
|
goto skip_write;
|
|
|
|
/* if locked failed, cp will flush dirty pages instead */
|
|
if (!mutex_trylock(&sbi->cp_mutex))
|
|
goto skip_write;
|
|
|
|
trace_f2fs_writepages(mapping->host, wbc, META);
|
|
diff = nr_pages_to_write(sbi, META, wbc);
|
|
written = f2fs_sync_meta_pages(sbi, META, wbc->nr_to_write, FS_META_IO);
|
|
mutex_unlock(&sbi->cp_mutex);
|
|
wbc->nr_to_write = max((long)0, wbc->nr_to_write - written - diff);
|
|
return 0;
|
|
|
|
skip_write:
|
|
wbc->pages_skipped += get_pages(sbi, F2FS_DIRTY_META);
|
|
trace_f2fs_writepages(mapping->host, wbc, META);
|
|
return 0;
|
|
}
|
|
|
|
long f2fs_sync_meta_pages(struct f2fs_sb_info *sbi, enum page_type type,
|
|
long nr_to_write, enum iostat_type io_type)
|
|
{
|
|
struct address_space *mapping = META_MAPPING(sbi);
|
|
pgoff_t index = 0, prev = ULONG_MAX;
|
|
struct pagevec pvec;
|
|
long nwritten = 0;
|
|
int nr_pages;
|
|
struct writeback_control wbc = {
|
|
.for_reclaim = 0,
|
|
};
|
|
struct blk_plug plug;
|
|
|
|
pagevec_init(&pvec);
|
|
|
|
blk_start_plug(&plug);
|
|
|
|
while ((nr_pages = pagevec_lookup_tag(&pvec, mapping, &index,
|
|
PAGECACHE_TAG_DIRTY))) {
|
|
int i;
|
|
|
|
for (i = 0; i < nr_pages; i++) {
|
|
struct page *page = pvec.pages[i];
|
|
|
|
if (prev == ULONG_MAX)
|
|
prev = page->index - 1;
|
|
if (nr_to_write != LONG_MAX && page->index != prev + 1) {
|
|
pagevec_release(&pvec);
|
|
goto stop;
|
|
}
|
|
|
|
lock_page(page);
|
|
|
|
if (unlikely(page->mapping != mapping)) {
|
|
continue_unlock:
|
|
unlock_page(page);
|
|
continue;
|
|
}
|
|
if (!PageDirty(page)) {
|
|
/* someone wrote it for us */
|
|
goto continue_unlock;
|
|
}
|
|
|
|
f2fs_wait_on_page_writeback(page, META, true, true);
|
|
|
|
if (!clear_page_dirty_for_io(page))
|
|
goto continue_unlock;
|
|
|
|
if (__f2fs_write_meta_page(page, &wbc, io_type)) {
|
|
unlock_page(page);
|
|
break;
|
|
}
|
|
nwritten++;
|
|
prev = page->index;
|
|
if (unlikely(nwritten >= nr_to_write))
|
|
break;
|
|
}
|
|
pagevec_release(&pvec);
|
|
cond_resched();
|
|
}
|
|
stop:
|
|
if (nwritten)
|
|
f2fs_submit_merged_write(sbi, type);
|
|
|
|
blk_finish_plug(&plug);
|
|
|
|
return nwritten;
|
|
}
|
|
|
|
static int f2fs_set_meta_page_dirty(struct page *page)
|
|
{
|
|
trace_f2fs_set_page_dirty(page, META);
|
|
|
|
if (!PageUptodate(page))
|
|
SetPageUptodate(page);
|
|
if (!PageDirty(page)) {
|
|
__set_page_dirty_nobuffers(page);
|
|
inc_page_count(F2FS_P_SB(page), F2FS_DIRTY_META);
|
|
f2fs_set_page_private(page, 0);
|
|
f2fs_trace_pid(page);
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
const struct address_space_operations f2fs_meta_aops = {
|
|
.writepage = f2fs_write_meta_page,
|
|
.writepages = f2fs_write_meta_pages,
|
|
.set_page_dirty = f2fs_set_meta_page_dirty,
|
|
.invalidatepage = f2fs_invalidate_page,
|
|
.releasepage = f2fs_release_page,
|
|
#ifdef CONFIG_MIGRATION
|
|
.migratepage = f2fs_migrate_page,
|
|
#endif
|
|
};
|
|
|
|
static void __add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino,
|
|
unsigned int devidx, int type)
|
|
{
|
|
struct inode_management *im = &sbi->im[type];
|
|
struct ino_entry *e, *tmp;
|
|
|
|
tmp = f2fs_kmem_cache_alloc(ino_entry_slab, GFP_NOFS);
|
|
|
|
radix_tree_preload(GFP_NOFS | __GFP_NOFAIL);
|
|
|
|
spin_lock(&im->ino_lock);
|
|
e = radix_tree_lookup(&im->ino_root, ino);
|
|
if (!e) {
|
|
e = tmp;
|
|
if (unlikely(radix_tree_insert(&im->ino_root, ino, e)))
|
|
f2fs_bug_on(sbi, 1);
|
|
|
|
memset(e, 0, sizeof(struct ino_entry));
|
|
e->ino = ino;
|
|
|
|
list_add_tail(&e->list, &im->ino_list);
|
|
if (type != ORPHAN_INO)
|
|
im->ino_num++;
|
|
}
|
|
|
|
if (type == FLUSH_INO)
|
|
f2fs_set_bit(devidx, (char *)&e->dirty_device);
|
|
|
|
spin_unlock(&im->ino_lock);
|
|
radix_tree_preload_end();
|
|
|
|
if (e != tmp)
|
|
kmem_cache_free(ino_entry_slab, tmp);
|
|
}
|
|
|
|
static void __remove_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type)
|
|
{
|
|
struct inode_management *im = &sbi->im[type];
|
|
struct ino_entry *e;
|
|
|
|
spin_lock(&im->ino_lock);
|
|
e = radix_tree_lookup(&im->ino_root, ino);
|
|
if (e) {
|
|
list_del(&e->list);
|
|
radix_tree_delete(&im->ino_root, ino);
|
|
im->ino_num--;
|
|
spin_unlock(&im->ino_lock);
|
|
kmem_cache_free(ino_entry_slab, e);
|
|
return;
|
|
}
|
|
spin_unlock(&im->ino_lock);
|
|
}
|
|
|
|
void f2fs_add_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type)
|
|
{
|
|
/* add new dirty ino entry into list */
|
|
__add_ino_entry(sbi, ino, 0, type);
|
|
}
|
|
|
|
void f2fs_remove_ino_entry(struct f2fs_sb_info *sbi, nid_t ino, int type)
|
|
{
|
|
/* remove dirty ino entry from list */
|
|
__remove_ino_entry(sbi, ino, type);
|
|
}
|
|
|
|
/* mode should be APPEND_INO or UPDATE_INO */
|
|
bool f2fs_exist_written_data(struct f2fs_sb_info *sbi, nid_t ino, int mode)
|
|
{
|
|
struct inode_management *im = &sbi->im[mode];
|
|
struct ino_entry *e;
|
|
|
|
spin_lock(&im->ino_lock);
|
|
e = radix_tree_lookup(&im->ino_root, ino);
|
|
spin_unlock(&im->ino_lock);
|
|
return e ? true : false;
|
|
}
|
|
|
|
void f2fs_release_ino_entry(struct f2fs_sb_info *sbi, bool all)
|
|
{
|
|
struct ino_entry *e, *tmp;
|
|
int i;
|
|
|
|
for (i = all ? ORPHAN_INO : APPEND_INO; i < MAX_INO_ENTRY; i++) {
|
|
struct inode_management *im = &sbi->im[i];
|
|
|
|
spin_lock(&im->ino_lock);
|
|
list_for_each_entry_safe(e, tmp, &im->ino_list, list) {
|
|
list_del(&e->list);
|
|
radix_tree_delete(&im->ino_root, e->ino);
|
|
kmem_cache_free(ino_entry_slab, e);
|
|
im->ino_num--;
|
|
}
|
|
spin_unlock(&im->ino_lock);
|
|
}
|
|
}
|
|
|
|
void f2fs_set_dirty_device(struct f2fs_sb_info *sbi, nid_t ino,
|
|
unsigned int devidx, int type)
|
|
{
|
|
__add_ino_entry(sbi, ino, devidx, type);
|
|
}
|
|
|
|
bool f2fs_is_dirty_device(struct f2fs_sb_info *sbi, nid_t ino,
|
|
unsigned int devidx, int type)
|
|
{
|
|
struct inode_management *im = &sbi->im[type];
|
|
struct ino_entry *e;
|
|
bool is_dirty = false;
|
|
|
|
spin_lock(&im->ino_lock);
|
|
e = radix_tree_lookup(&im->ino_root, ino);
|
|
if (e && f2fs_test_bit(devidx, (char *)&e->dirty_device))
|
|
is_dirty = true;
|
|
spin_unlock(&im->ino_lock);
|
|
return is_dirty;
|
|
}
|
|
|
|
int f2fs_acquire_orphan_inode(struct f2fs_sb_info *sbi)
|
|
{
|
|
struct inode_management *im = &sbi->im[ORPHAN_INO];
|
|
int err = 0;
|
|
|
|
spin_lock(&im->ino_lock);
|
|
|
|
if (time_to_inject(sbi, FAULT_ORPHAN)) {
|
|
spin_unlock(&im->ino_lock);
|
|
f2fs_show_injection_info(sbi, FAULT_ORPHAN);
|
|
return -ENOSPC;
|
|
}
|
|
|
|
if (unlikely(im->ino_num >= sbi->max_orphans))
|
|
err = -ENOSPC;
|
|
else
|
|
im->ino_num++;
|
|
spin_unlock(&im->ino_lock);
|
|
|
|
return err;
|
|
}
|
|
|
|
void f2fs_release_orphan_inode(struct f2fs_sb_info *sbi)
|
|
{
|
|
struct inode_management *im = &sbi->im[ORPHAN_INO];
|
|
|
|
spin_lock(&im->ino_lock);
|
|
f2fs_bug_on(sbi, im->ino_num == 0);
|
|
im->ino_num--;
|
|
spin_unlock(&im->ino_lock);
|
|
}
|
|
|
|
void f2fs_add_orphan_inode(struct inode *inode)
|
|
{
|
|
/* add new orphan ino entry into list */
|
|
__add_ino_entry(F2FS_I_SB(inode), inode->i_ino, 0, ORPHAN_INO);
|
|
f2fs_update_inode_page(inode);
|
|
}
|
|
|
|
void f2fs_remove_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
|
|
{
|
|
/* remove orphan entry from orphan list */
|
|
__remove_ino_entry(sbi, ino, ORPHAN_INO);
|
|
}
|
|
|
|
static int recover_orphan_inode(struct f2fs_sb_info *sbi, nid_t ino)
|
|
{
|
|
struct inode *inode;
|
|
struct node_info ni;
|
|
int err;
|
|
|
|
inode = f2fs_iget_retry(sbi->sb, ino);
|
|
if (IS_ERR(inode)) {
|
|
/*
|
|
* there should be a bug that we can't find the entry
|
|
* to orphan inode.
|
|
*/
|
|
f2fs_bug_on(sbi, PTR_ERR(inode) == -ENOENT);
|
|
return PTR_ERR(inode);
|
|
}
|
|
|
|
err = dquot_initialize(inode);
|
|
if (err) {
|
|
iput(inode);
|
|
goto err_out;
|
|
}
|
|
|
|
clear_nlink(inode);
|
|
|
|
/* truncate all the data during iput */
|
|
iput(inode);
|
|
|
|
err = f2fs_get_node_info(sbi, ino, &ni);
|
|
if (err)
|
|
goto err_out;
|
|
|
|
/* ENOMEM was fully retried in f2fs_evict_inode. */
|
|
if (ni.blk_addr != NULL_ADDR) {
|
|
err = -EIO;
|
|
goto err_out;
|
|
}
|
|
return 0;
|
|
|
|
err_out:
|
|
set_sbi_flag(sbi, SBI_NEED_FSCK);
|
|
f2fs_warn(sbi, "%s: orphan failed (ino=%x), run fsck to fix.",
|
|
__func__, ino);
|
|
return err;
|
|
}
|
|
|
|
int f2fs_recover_orphan_inodes(struct f2fs_sb_info *sbi)
|
|
{
|
|
block_t start_blk, orphan_blocks, i, j;
|
|
unsigned int s_flags = sbi->sb->s_flags;
|
|
int err = 0;
|
|
#ifdef CONFIG_QUOTA
|
|
int quota_enabled;
|
|
#endif
|
|
|
|
if (!is_set_ckpt_flags(sbi, CP_ORPHAN_PRESENT_FLAG))
|
|
return 0;
|
|
|
|
if (bdev_read_only(sbi->sb->s_bdev)) {
|
|
f2fs_info(sbi, "write access unavailable, skipping orphan cleanup");
|
|
return 0;
|
|
}
|
|
|
|
if (s_flags & SB_RDONLY) {
|
|
f2fs_info(sbi, "orphan cleanup on readonly fs");
|
|
sbi->sb->s_flags &= ~SB_RDONLY;
|
|
}
|
|
|
|
#ifdef CONFIG_QUOTA
|
|
/* Needed for iput() to work correctly and not trash data */
|
|
sbi->sb->s_flags |= SB_ACTIVE;
|
|
|
|
/*
|
|
* Turn on quotas which were not enabled for read-only mounts if
|
|
* filesystem has quota feature, so that they are updated correctly.
|
|
*/
|
|
quota_enabled = f2fs_enable_quota_files(sbi, s_flags & SB_RDONLY);
|
|
#endif
|
|
|
|
start_blk = __start_cp_addr(sbi) + 1 + __cp_payload(sbi);
|
|
orphan_blocks = __start_sum_addr(sbi) - 1 - __cp_payload(sbi);
|
|
|
|
f2fs_ra_meta_pages(sbi, start_blk, orphan_blocks, META_CP, true);
|
|
|
|
for (i = 0; i < orphan_blocks; i++) {
|
|
struct page *page;
|
|
struct f2fs_orphan_block *orphan_blk;
|
|
|
|
page = f2fs_get_meta_page(sbi, start_blk + i);
|
|
if (IS_ERR(page)) {
|
|
err = PTR_ERR(page);
|
|
goto out;
|
|
}
|
|
|
|
orphan_blk = (struct f2fs_orphan_block *)page_address(page);
|
|
for (j = 0; j < le32_to_cpu(orphan_blk->entry_count); j++) {
|
|
nid_t ino = le32_to_cpu(orphan_blk->ino[j]);
|
|
err = recover_orphan_inode(sbi, ino);
|
|
if (err) {
|
|
f2fs_put_page(page, 1);
|
|
goto out;
|
|
}
|
|
}
|
|
f2fs_put_page(page, 1);
|
|
}
|
|
/* clear Orphan Flag */
|
|
clear_ckpt_flags(sbi, CP_ORPHAN_PRESENT_FLAG);
|
|
out:
|
|
set_sbi_flag(sbi, SBI_IS_RECOVERED);
|
|
|
|
#ifdef CONFIG_QUOTA
|
|
/* Turn quotas off */
|
|
if (quota_enabled)
|
|
f2fs_quota_off_umount(sbi->sb);
|
|
#endif
|
|
sbi->sb->s_flags = s_flags; /* Restore SB_RDONLY status */
|
|
|
|
return err;
|
|
}
|
|
|
|
static void write_orphan_inodes(struct f2fs_sb_info *sbi, block_t start_blk)
|
|
{
|
|
struct list_head *head;
|
|
struct f2fs_orphan_block *orphan_blk = NULL;
|
|
unsigned int nentries = 0;
|
|
unsigned short index = 1;
|
|
unsigned short orphan_blocks;
|
|
struct page *page = NULL;
|
|
struct ino_entry *orphan = NULL;
|
|
struct inode_management *im = &sbi->im[ORPHAN_INO];
|
|
|
|
orphan_blocks = GET_ORPHAN_BLOCKS(im->ino_num);
|
|
|
|
/*
|
|
* we don't need to do spin_lock(&im->ino_lock) here, since all the
|
|
* orphan inode operations are covered under f2fs_lock_op().
|
|
* And, spin_lock should be avoided due to page operations below.
|
|
*/
|
|
head = &im->ino_list;
|
|
|
|
/* loop for each orphan inode entry and write them in Jornal block */
|
|
list_for_each_entry(orphan, head, list) {
|
|
if (!page) {
|
|
page = f2fs_grab_meta_page(sbi, start_blk++);
|
|
orphan_blk =
|
|
(struct f2fs_orphan_block *)page_address(page);
|
|
memset(orphan_blk, 0, sizeof(*orphan_blk));
|
|
}
|
|
|
|
orphan_blk->ino[nentries++] = cpu_to_le32(orphan->ino);
|
|
|
|
if (nentries == F2FS_ORPHANS_PER_BLOCK) {
|
|
/*
|
|
* an orphan block is full of 1020 entries,
|
|
* then we need to flush current orphan blocks
|
|
* and bring another one in memory
|
|
*/
|
|
orphan_blk->blk_addr = cpu_to_le16(index);
|
|
orphan_blk->blk_count = cpu_to_le16(orphan_blocks);
|
|
orphan_blk->entry_count = cpu_to_le32(nentries);
|
|
set_page_dirty(page);
|
|
f2fs_put_page(page, 1);
|
|
index++;
|
|
nentries = 0;
|
|
page = NULL;
|
|
}
|
|
}
|
|
|
|
if (page) {
|
|
orphan_blk->blk_addr = cpu_to_le16(index);
|
|
orphan_blk->blk_count = cpu_to_le16(orphan_blocks);
|
|
orphan_blk->entry_count = cpu_to_le32(nentries);
|
|
set_page_dirty(page);
|
|
f2fs_put_page(page, 1);
|
|
}
|
|
}
|
|
|
|
static __u32 f2fs_checkpoint_chksum(struct f2fs_sb_info *sbi,
|
|
struct f2fs_checkpoint *ckpt)
|
|
{
|
|
unsigned int chksum_ofs = le32_to_cpu(ckpt->checksum_offset);
|
|
__u32 chksum;
|
|
|
|
chksum = f2fs_crc32(sbi, ckpt, chksum_ofs);
|
|
if (chksum_ofs < CP_CHKSUM_OFFSET) {
|
|
chksum_ofs += sizeof(chksum);
|
|
chksum = f2fs_chksum(sbi, chksum, (__u8 *)ckpt + chksum_ofs,
|
|
F2FS_BLKSIZE - chksum_ofs);
|
|
}
|
|
return chksum;
|
|
}
|
|
|
|
static int get_checkpoint_version(struct f2fs_sb_info *sbi, block_t cp_addr,
|
|
struct f2fs_checkpoint **cp_block, struct page **cp_page,
|
|
unsigned long long *version)
|
|
{
|
|
size_t crc_offset = 0;
|
|
__u32 crc;
|
|
|
|
*cp_page = f2fs_get_meta_page(sbi, cp_addr);
|
|
if (IS_ERR(*cp_page))
|
|
return PTR_ERR(*cp_page);
|
|
|
|
*cp_block = (struct f2fs_checkpoint *)page_address(*cp_page);
|
|
|
|
crc_offset = le32_to_cpu((*cp_block)->checksum_offset);
|
|
if (crc_offset < CP_MIN_CHKSUM_OFFSET ||
|
|
crc_offset > CP_CHKSUM_OFFSET) {
|
|
f2fs_put_page(*cp_page, 1);
|
|
f2fs_warn(sbi, "invalid crc_offset: %zu", crc_offset);
|
|
return -EINVAL;
|
|
}
|
|
|
|
crc = f2fs_checkpoint_chksum(sbi, *cp_block);
|
|
if (crc != cur_cp_crc(*cp_block)) {
|
|
f2fs_put_page(*cp_page, 1);
|
|
f2fs_warn(sbi, "invalid crc value");
|
|
return -EINVAL;
|
|
}
|
|
|
|
*version = cur_cp_version(*cp_block);
|
|
return 0;
|
|
}
|
|
|
|
static struct page *validate_checkpoint(struct f2fs_sb_info *sbi,
|
|
block_t cp_addr, unsigned long long *version)
|
|
{
|
|
struct page *cp_page_1 = NULL, *cp_page_2 = NULL;
|
|
struct f2fs_checkpoint *cp_block = NULL;
|
|
unsigned long long cur_version = 0, pre_version = 0;
|
|
int err;
|
|
|
|
err = get_checkpoint_version(sbi, cp_addr, &cp_block,
|
|
&cp_page_1, version);
|
|
if (err)
|
|
return NULL;
|
|
|
|
if (le32_to_cpu(cp_block->cp_pack_total_block_count) >
|
|
sbi->blocks_per_seg) {
|
|
f2fs_warn(sbi, "invalid cp_pack_total_block_count:%u",
|
|
le32_to_cpu(cp_block->cp_pack_total_block_count));
|
|
goto invalid_cp;
|
|
}
|
|
pre_version = *version;
|
|
|
|
cp_addr += le32_to_cpu(cp_block->cp_pack_total_block_count) - 1;
|
|
err = get_checkpoint_version(sbi, cp_addr, &cp_block,
|
|
&cp_page_2, version);
|
|
if (err)
|
|
goto invalid_cp;
|
|
cur_version = *version;
|
|
|
|
if (cur_version == pre_version) {
|
|
*version = cur_version;
|
|
f2fs_put_page(cp_page_2, 1);
|
|
return cp_page_1;
|
|
}
|
|
f2fs_put_page(cp_page_2, 1);
|
|
invalid_cp:
|
|
f2fs_put_page(cp_page_1, 1);
|
|
return NULL;
|
|
}
|
|
|
|
int f2fs_get_valid_checkpoint(struct f2fs_sb_info *sbi)
|
|
{
|
|
struct f2fs_checkpoint *cp_block;
|
|
struct f2fs_super_block *fsb = sbi->raw_super;
|
|
struct page *cp1, *cp2, *cur_page;
|
|
unsigned long blk_size = sbi->blocksize;
|
|
unsigned long long cp1_version = 0, cp2_version = 0;
|
|
unsigned long long cp_start_blk_no;
|
|
unsigned int cp_blks = 1 + __cp_payload(sbi);
|
|
block_t cp_blk_no;
|
|
int i;
|
|
int err;
|
|
|
|
sbi->ckpt = f2fs_kvzalloc(sbi, array_size(blk_size, cp_blks),
|
|
GFP_KERNEL);
|
|
if (!sbi->ckpt)
|
|
return -ENOMEM;
|
|
/*
|
|
* Finding out valid cp block involves read both
|
|
* sets( cp pack 1 and cp pack 2)
|
|
*/
|
|
cp_start_blk_no = le32_to_cpu(fsb->cp_blkaddr);
|
|
cp1 = validate_checkpoint(sbi, cp_start_blk_no, &cp1_version);
|
|
|
|
/* The second checkpoint pack should start at the next segment */
|
|
cp_start_blk_no += ((unsigned long long)1) <<
|
|
le32_to_cpu(fsb->log_blocks_per_seg);
|
|
cp2 = validate_checkpoint(sbi, cp_start_blk_no, &cp2_version);
|
|
|
|
if (cp1 && cp2) {
|
|
if (ver_after(cp2_version, cp1_version))
|
|
cur_page = cp2;
|
|
else
|
|
cur_page = cp1;
|
|
} else if (cp1) {
|
|
cur_page = cp1;
|
|
} else if (cp2) {
|
|
cur_page = cp2;
|
|
} else {
|
|
err = -EFSCORRUPTED;
|
|
goto fail_no_cp;
|
|
}
|
|
|
|
cp_block = (struct f2fs_checkpoint *)page_address(cur_page);
|
|
memcpy(sbi->ckpt, cp_block, blk_size);
|
|
|
|
if (cur_page == cp1)
|
|
sbi->cur_cp_pack = 1;
|
|
else
|
|
sbi->cur_cp_pack = 2;
|
|
|
|
/* Sanity checking of checkpoint */
|
|
if (f2fs_sanity_check_ckpt(sbi)) {
|
|
err = -EFSCORRUPTED;
|
|
goto free_fail_no_cp;
|
|
}
|
|
|
|
if (cp_blks <= 1)
|
|
goto done;
|
|
|
|
cp_blk_no = le32_to_cpu(fsb->cp_blkaddr);
|
|
if (cur_page == cp2)
|
|
cp_blk_no += 1 << le32_to_cpu(fsb->log_blocks_per_seg);
|
|
|
|
for (i = 1; i < cp_blks; i++) {
|
|
void *sit_bitmap_ptr;
|
|
unsigned char *ckpt = (unsigned char *)sbi->ckpt;
|
|
|
|
cur_page = f2fs_get_meta_page(sbi, cp_blk_no + i);
|
|
if (IS_ERR(cur_page)) {
|
|
err = PTR_ERR(cur_page);
|
|
goto free_fail_no_cp;
|
|
}
|
|
sit_bitmap_ptr = page_address(cur_page);
|
|
memcpy(ckpt + i * blk_size, sit_bitmap_ptr, blk_size);
|
|
f2fs_put_page(cur_page, 1);
|
|
}
|
|
done:
|
|
f2fs_put_page(cp1, 1);
|
|
f2fs_put_page(cp2, 1);
|
|
return 0;
|
|
|
|
free_fail_no_cp:
|
|
f2fs_put_page(cp1, 1);
|
|
f2fs_put_page(cp2, 1);
|
|
fail_no_cp:
|
|
kvfree(sbi->ckpt);
|
|
return err;
|
|
}
|
|
|
|
static void __add_dirty_inode(struct inode *inode, enum inode_type type)
|
|
{
|
|
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
|
|
int flag = (type == DIR_INODE) ? FI_DIRTY_DIR : FI_DIRTY_FILE;
|
|
|
|
if (is_inode_flag_set(inode, flag))
|
|
return;
|
|
|
|
set_inode_flag(inode, flag);
|
|
if (!f2fs_is_volatile_file(inode))
|
|
list_add_tail(&F2FS_I(inode)->dirty_list,
|
|
&sbi->inode_list[type]);
|
|
stat_inc_dirty_inode(sbi, type);
|
|
}
|
|
|
|
static void __remove_dirty_inode(struct inode *inode, enum inode_type type)
|
|
{
|
|
int flag = (type == DIR_INODE) ? FI_DIRTY_DIR : FI_DIRTY_FILE;
|
|
|
|
if (get_dirty_pages(inode) || !is_inode_flag_set(inode, flag))
|
|
return;
|
|
|
|
list_del_init(&F2FS_I(inode)->dirty_list);
|
|
clear_inode_flag(inode, flag);
|
|
stat_dec_dirty_inode(F2FS_I_SB(inode), type);
|
|
}
|
|
|
|
void f2fs_update_dirty_page(struct inode *inode, struct page *page)
|
|
{
|
|
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
|
|
enum inode_type type = S_ISDIR(inode->i_mode) ? DIR_INODE : FILE_INODE;
|
|
|
|
if (!S_ISDIR(inode->i_mode) && !S_ISREG(inode->i_mode) &&
|
|
!S_ISLNK(inode->i_mode))
|
|
return;
|
|
|
|
spin_lock(&sbi->inode_lock[type]);
|
|
if (type != FILE_INODE || test_opt(sbi, DATA_FLUSH))
|
|
__add_dirty_inode(inode, type);
|
|
inode_inc_dirty_pages(inode);
|
|
spin_unlock(&sbi->inode_lock[type]);
|
|
|
|
f2fs_set_page_private(page, 0);
|
|
f2fs_trace_pid(page);
|
|
}
|
|
|
|
void f2fs_remove_dirty_inode(struct inode *inode)
|
|
{
|
|
struct f2fs_sb_info *sbi = F2FS_I_SB(inode);
|
|
enum inode_type type = S_ISDIR(inode->i_mode) ? DIR_INODE : FILE_INODE;
|
|
|
|
if (!S_ISDIR(inode->i_mode) && !S_ISREG(inode->i_mode) &&
|
|
!S_ISLNK(inode->i_mode))
|
|
return;
|
|
|
|
if (type == FILE_INODE && !test_opt(sbi, DATA_FLUSH))
|
|
return;
|
|
|
|
spin_lock(&sbi->inode_lock[type]);
|
|
__remove_dirty_inode(inode, type);
|
|
spin_unlock(&sbi->inode_lock[type]);
|
|
}
|
|
|
|
int f2fs_sync_dirty_inodes(struct f2fs_sb_info *sbi, enum inode_type type)
|
|
{
|
|
struct list_head *head;
|
|
struct inode *inode;
|
|
struct f2fs_inode_info *fi;
|
|
bool is_dir = (type == DIR_INODE);
|
|
unsigned long ino = 0;
|
|
|
|
trace_f2fs_sync_dirty_inodes_enter(sbi->sb, is_dir,
|
|
get_pages(sbi, is_dir ?
|
|
F2FS_DIRTY_DENTS : F2FS_DIRTY_DATA));
|
|
retry:
|
|
if (unlikely(f2fs_cp_error(sbi))) {
|
|
trace_f2fs_sync_dirty_inodes_exit(sbi->sb, is_dir,
|
|
get_pages(sbi, is_dir ?
|
|
F2FS_DIRTY_DENTS : F2FS_DIRTY_DATA));
|
|
return -EIO;
|
|
}
|
|
|
|
spin_lock(&sbi->inode_lock[type]);
|
|
|
|
head = &sbi->inode_list[type];
|
|
if (list_empty(head)) {
|
|
spin_unlock(&sbi->inode_lock[type]);
|
|
trace_f2fs_sync_dirty_inodes_exit(sbi->sb, is_dir,
|
|
get_pages(sbi, is_dir ?
|
|
F2FS_DIRTY_DENTS : F2FS_DIRTY_DATA));
|
|
return 0;
|
|
}
|
|
fi = list_first_entry(head, struct f2fs_inode_info, dirty_list);
|
|
inode = igrab(&fi->vfs_inode);
|
|
spin_unlock(&sbi->inode_lock[type]);
|
|
if (inode) {
|
|
unsigned long cur_ino = inode->i_ino;
|
|
|
|
F2FS_I(inode)->cp_task = current;
|
|
|
|
filemap_fdatawrite(inode->i_mapping);
|
|
|
|
F2FS_I(inode)->cp_task = NULL;
|
|
|
|
iput(inode);
|
|
/* We need to give cpu to another writers. */
|
|
if (ino == cur_ino)
|
|
cond_resched();
|
|
else
|
|
ino = cur_ino;
|
|
} else {
|
|
/*
|
|
* We should submit bio, since it exists several
|
|
* wribacking dentry pages in the freeing inode.
|
|
*/
|
|
f2fs_submit_merged_write(sbi, DATA);
|
|
cond_resched();
|
|
}
|
|
goto retry;
|
|
}
|
|
|
|
int f2fs_sync_inode_meta(struct f2fs_sb_info *sbi)
|
|
{
|
|
struct list_head *head = &sbi->inode_list[DIRTY_META];
|
|
struct inode *inode;
|
|
struct f2fs_inode_info *fi;
|
|
s64 total = get_pages(sbi, F2FS_DIRTY_IMETA);
|
|
|
|
while (total--) {
|
|
if (unlikely(f2fs_cp_error(sbi)))
|
|
return -EIO;
|
|
|
|
spin_lock(&sbi->inode_lock[DIRTY_META]);
|
|
if (list_empty(head)) {
|
|
spin_unlock(&sbi->inode_lock[DIRTY_META]);
|
|
return 0;
|
|
}
|
|
fi = list_first_entry(head, struct f2fs_inode_info,
|
|
gdirty_list);
|
|
inode = igrab(&fi->vfs_inode);
|
|
spin_unlock(&sbi->inode_lock[DIRTY_META]);
|
|
if (inode) {
|
|
sync_inode_metadata(inode, 0);
|
|
|
|
/* it's on eviction */
|
|
if (is_inode_flag_set(inode, FI_DIRTY_INODE))
|
|
f2fs_update_inode_page(inode);
|
|
iput(inode);
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static void __prepare_cp_block(struct f2fs_sb_info *sbi)
|
|
{
|
|
struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
|
|
struct f2fs_nm_info *nm_i = NM_I(sbi);
|
|
nid_t last_nid = nm_i->next_scan_nid;
|
|
|
|
next_free_nid(sbi, &last_nid);
|
|
ckpt->valid_block_count = cpu_to_le64(valid_user_blocks(sbi));
|
|
ckpt->valid_node_count = cpu_to_le32(valid_node_count(sbi));
|
|
ckpt->valid_inode_count = cpu_to_le32(valid_inode_count(sbi));
|
|
ckpt->next_free_nid = cpu_to_le32(last_nid);
|
|
}
|
|
|
|
static bool __need_flush_quota(struct f2fs_sb_info *sbi)
|
|
{
|
|
bool ret = false;
|
|
|
|
if (!is_journalled_quota(sbi))
|
|
return false;
|
|
|
|
down_write(&sbi->quota_sem);
|
|
if (is_sbi_flag_set(sbi, SBI_QUOTA_SKIP_FLUSH)) {
|
|
ret = false;
|
|
} else if (is_sbi_flag_set(sbi, SBI_QUOTA_NEED_REPAIR)) {
|
|
ret = false;
|
|
} else if (is_sbi_flag_set(sbi, SBI_QUOTA_NEED_FLUSH)) {
|
|
clear_sbi_flag(sbi, SBI_QUOTA_NEED_FLUSH);
|
|
ret = true;
|
|
} else if (get_pages(sbi, F2FS_DIRTY_QDATA)) {
|
|
ret = true;
|
|
}
|
|
up_write(&sbi->quota_sem);
|
|
return ret;
|
|
}
|
|
|
|
/*
|
|
* Freeze all the FS-operations for checkpoint.
|
|
*/
|
|
static int block_operations(struct f2fs_sb_info *sbi)
|
|
{
|
|
struct writeback_control wbc = {
|
|
.sync_mode = WB_SYNC_ALL,
|
|
.nr_to_write = LONG_MAX,
|
|
.for_reclaim = 0,
|
|
};
|
|
int err = 0, cnt = 0;
|
|
|
|
/*
|
|
* Let's flush inline_data in dirty node pages.
|
|
*/
|
|
f2fs_flush_inline_data(sbi);
|
|
|
|
retry_flush_quotas:
|
|
f2fs_lock_all(sbi);
|
|
if (__need_flush_quota(sbi)) {
|
|
int locked;
|
|
|
|
if (++cnt > DEFAULT_RETRY_QUOTA_FLUSH_COUNT) {
|
|
set_sbi_flag(sbi, SBI_QUOTA_SKIP_FLUSH);
|
|
set_sbi_flag(sbi, SBI_QUOTA_NEED_FLUSH);
|
|
goto retry_flush_dents;
|
|
}
|
|
f2fs_unlock_all(sbi);
|
|
|
|
/* only failed during mount/umount/freeze/quotactl */
|
|
locked = down_read_trylock(&sbi->sb->s_umount);
|
|
f2fs_quota_sync(sbi->sb, -1);
|
|
if (locked)
|
|
up_read(&sbi->sb->s_umount);
|
|
cond_resched();
|
|
goto retry_flush_quotas;
|
|
}
|
|
|
|
retry_flush_dents:
|
|
/* write all the dirty dentry pages */
|
|
if (get_pages(sbi, F2FS_DIRTY_DENTS)) {
|
|
f2fs_unlock_all(sbi);
|
|
err = f2fs_sync_dirty_inodes(sbi, DIR_INODE);
|
|
if (err)
|
|
return err;
|
|
cond_resched();
|
|
goto retry_flush_quotas;
|
|
}
|
|
|
|
/*
|
|
* POR: we should ensure that there are no dirty node pages
|
|
* until finishing nat/sit flush. inode->i_blocks can be updated.
|
|
*/
|
|
down_write(&sbi->node_change);
|
|
|
|
if (get_pages(sbi, F2FS_DIRTY_IMETA)) {
|
|
up_write(&sbi->node_change);
|
|
f2fs_unlock_all(sbi);
|
|
err = f2fs_sync_inode_meta(sbi);
|
|
if (err)
|
|
return err;
|
|
cond_resched();
|
|
goto retry_flush_quotas;
|
|
}
|
|
|
|
retry_flush_nodes:
|
|
down_write(&sbi->node_write);
|
|
|
|
if (get_pages(sbi, F2FS_DIRTY_NODES)) {
|
|
up_write(&sbi->node_write);
|
|
atomic_inc(&sbi->wb_sync_req[NODE]);
|
|
err = f2fs_sync_node_pages(sbi, &wbc, false, FS_CP_NODE_IO);
|
|
atomic_dec(&sbi->wb_sync_req[NODE]);
|
|
if (err) {
|
|
up_write(&sbi->node_change);
|
|
f2fs_unlock_all(sbi);
|
|
return err;
|
|
}
|
|
cond_resched();
|
|
goto retry_flush_nodes;
|
|
}
|
|
|
|
/*
|
|
* sbi->node_change is used only for AIO write_begin path which produces
|
|
* dirty node blocks and some checkpoint values by block allocation.
|
|
*/
|
|
__prepare_cp_block(sbi);
|
|
up_write(&sbi->node_change);
|
|
return err;
|
|
}
|
|
|
|
static void unblock_operations(struct f2fs_sb_info *sbi)
|
|
{
|
|
up_write(&sbi->node_write);
|
|
f2fs_unlock_all(sbi);
|
|
}
|
|
|
|
void f2fs_wait_on_all_pages(struct f2fs_sb_info *sbi, int type)
|
|
{
|
|
DEFINE_WAIT(wait);
|
|
|
|
for (;;) {
|
|
if (!get_pages(sbi, type))
|
|
break;
|
|
|
|
if (unlikely(f2fs_cp_error(sbi)))
|
|
break;
|
|
|
|
if (type == F2FS_DIRTY_META)
|
|
f2fs_sync_meta_pages(sbi, META, LONG_MAX,
|
|
FS_CP_META_IO);
|
|
else if (type == F2FS_WB_CP_DATA)
|
|
f2fs_submit_merged_write(sbi, DATA);
|
|
|
|
prepare_to_wait(&sbi->cp_wait, &wait, TASK_UNINTERRUPTIBLE);
|
|
io_schedule_timeout(DEFAULT_IO_TIMEOUT);
|
|
}
|
|
finish_wait(&sbi->cp_wait, &wait);
|
|
}
|
|
|
|
static void update_ckpt_flags(struct f2fs_sb_info *sbi, struct cp_control *cpc)
|
|
{
|
|
unsigned long orphan_num = sbi->im[ORPHAN_INO].ino_num;
|
|
struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&sbi->cp_lock, flags);
|
|
|
|
if ((cpc->reason & CP_UMOUNT) &&
|
|
le32_to_cpu(ckpt->cp_pack_total_block_count) >
|
|
sbi->blocks_per_seg - NM_I(sbi)->nat_bits_blocks)
|
|
disable_nat_bits(sbi, false);
|
|
|
|
if (cpc->reason & CP_TRIMMED)
|
|
__set_ckpt_flags(ckpt, CP_TRIMMED_FLAG);
|
|
else
|
|
__clear_ckpt_flags(ckpt, CP_TRIMMED_FLAG);
|
|
|
|
if (cpc->reason & CP_UMOUNT)
|
|
__set_ckpt_flags(ckpt, CP_UMOUNT_FLAG);
|
|
else
|
|
__clear_ckpt_flags(ckpt, CP_UMOUNT_FLAG);
|
|
|
|
if (cpc->reason & CP_FASTBOOT)
|
|
__set_ckpt_flags(ckpt, CP_FASTBOOT_FLAG);
|
|
else
|
|
__clear_ckpt_flags(ckpt, CP_FASTBOOT_FLAG);
|
|
|
|
if (orphan_num)
|
|
__set_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG);
|
|
else
|
|
__clear_ckpt_flags(ckpt, CP_ORPHAN_PRESENT_FLAG);
|
|
|
|
if (is_sbi_flag_set(sbi, SBI_NEED_FSCK))
|
|
__set_ckpt_flags(ckpt, CP_FSCK_FLAG);
|
|
|
|
if (is_sbi_flag_set(sbi, SBI_IS_RESIZEFS))
|
|
__set_ckpt_flags(ckpt, CP_RESIZEFS_FLAG);
|
|
else
|
|
__clear_ckpt_flags(ckpt, CP_RESIZEFS_FLAG);
|
|
|
|
if (is_sbi_flag_set(sbi, SBI_CP_DISABLED))
|
|
__set_ckpt_flags(ckpt, CP_DISABLED_FLAG);
|
|
else
|
|
__clear_ckpt_flags(ckpt, CP_DISABLED_FLAG);
|
|
|
|
if (is_sbi_flag_set(sbi, SBI_CP_DISABLED_QUICK))
|
|
__set_ckpt_flags(ckpt, CP_DISABLED_QUICK_FLAG);
|
|
else
|
|
__clear_ckpt_flags(ckpt, CP_DISABLED_QUICK_FLAG);
|
|
|
|
if (is_sbi_flag_set(sbi, SBI_QUOTA_SKIP_FLUSH))
|
|
__set_ckpt_flags(ckpt, CP_QUOTA_NEED_FSCK_FLAG);
|
|
else
|
|
__clear_ckpt_flags(ckpt, CP_QUOTA_NEED_FSCK_FLAG);
|
|
|
|
if (is_sbi_flag_set(sbi, SBI_QUOTA_NEED_REPAIR))
|
|
__set_ckpt_flags(ckpt, CP_QUOTA_NEED_FSCK_FLAG);
|
|
|
|
/* set this flag to activate crc|cp_ver for recovery */
|
|
__set_ckpt_flags(ckpt, CP_CRC_RECOVERY_FLAG);
|
|
__clear_ckpt_flags(ckpt, CP_NOCRC_RECOVERY_FLAG);
|
|
|
|
spin_unlock_irqrestore(&sbi->cp_lock, flags);
|
|
}
|
|
|
|
static void commit_checkpoint(struct f2fs_sb_info *sbi,
|
|
void *src, block_t blk_addr)
|
|
{
|
|
struct writeback_control wbc = {
|
|
.for_reclaim = 0,
|
|
};
|
|
|
|
/*
|
|
* pagevec_lookup_tag and lock_page again will take
|
|
* some extra time. Therefore, f2fs_update_meta_pages and
|
|
* f2fs_sync_meta_pages are combined in this function.
|
|
*/
|
|
struct page *page = f2fs_grab_meta_page(sbi, blk_addr);
|
|
int err;
|
|
|
|
f2fs_wait_on_page_writeback(page, META, true, true);
|
|
|
|
memcpy(page_address(page), src, PAGE_SIZE);
|
|
|
|
set_page_dirty(page);
|
|
if (unlikely(!clear_page_dirty_for_io(page)))
|
|
f2fs_bug_on(sbi, 1);
|
|
|
|
/* writeout cp pack 2 page */
|
|
err = __f2fs_write_meta_page(page, &wbc, FS_CP_META_IO);
|
|
if (unlikely(err && f2fs_cp_error(sbi))) {
|
|
f2fs_put_page(page, 1);
|
|
return;
|
|
}
|
|
|
|
f2fs_bug_on(sbi, err);
|
|
f2fs_put_page(page, 0);
|
|
|
|
/* submit checkpoint (with barrier if NOBARRIER is not set) */
|
|
f2fs_submit_merged_write(sbi, META_FLUSH);
|
|
}
|
|
|
|
static int do_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
|
|
{
|
|
struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
|
|
struct f2fs_nm_info *nm_i = NM_I(sbi);
|
|
unsigned long orphan_num = sbi->im[ORPHAN_INO].ino_num, flags;
|
|
block_t start_blk;
|
|
unsigned int data_sum_blocks, orphan_blocks;
|
|
__u32 crc32 = 0;
|
|
int i;
|
|
int cp_payload_blks = __cp_payload(sbi);
|
|
struct super_block *sb = sbi->sb;
|
|
struct curseg_info *seg_i = CURSEG_I(sbi, CURSEG_HOT_NODE);
|
|
u64 kbytes_written;
|
|
int err;
|
|
|
|
/* Flush all the NAT/SIT pages */
|
|
f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
|
|
if (get_pages(sbi, F2FS_DIRTY_META) && !f2fs_cp_error(sbi)) {
|
|
WARN_ON(1);
|
|
set_sbi_flag(sbi, SBI_NEED_FSCK);
|
|
}
|
|
|
|
/* start to update checkpoint, cp ver is already updated previously */
|
|
ckpt->elapsed_time = cpu_to_le64(get_mtime(sbi, true));
|
|
ckpt->free_segment_count = cpu_to_le32(free_segments(sbi));
|
|
for (i = 0; i < NR_CURSEG_NODE_TYPE; i++) {
|
|
ckpt->cur_node_segno[i] =
|
|
cpu_to_le32(curseg_segno(sbi, i + CURSEG_HOT_NODE));
|
|
ckpt->cur_node_blkoff[i] =
|
|
cpu_to_le16(curseg_blkoff(sbi, i + CURSEG_HOT_NODE));
|
|
ckpt->alloc_type[i + CURSEG_HOT_NODE] =
|
|
curseg_alloc_type(sbi, i + CURSEG_HOT_NODE);
|
|
}
|
|
for (i = 0; i < NR_CURSEG_DATA_TYPE; i++) {
|
|
ckpt->cur_data_segno[i] =
|
|
cpu_to_le32(curseg_segno(sbi, i + CURSEG_HOT_DATA));
|
|
ckpt->cur_data_blkoff[i] =
|
|
cpu_to_le16(curseg_blkoff(sbi, i + CURSEG_HOT_DATA));
|
|
ckpt->alloc_type[i + CURSEG_HOT_DATA] =
|
|
curseg_alloc_type(sbi, i + CURSEG_HOT_DATA);
|
|
}
|
|
|
|
/* 2 cp + n data seg summary + orphan inode blocks */
|
|
data_sum_blocks = f2fs_npages_for_summary_flush(sbi, false);
|
|
spin_lock_irqsave(&sbi->cp_lock, flags);
|
|
if (data_sum_blocks < NR_CURSEG_DATA_TYPE)
|
|
__set_ckpt_flags(ckpt, CP_COMPACT_SUM_FLAG);
|
|
else
|
|
__clear_ckpt_flags(ckpt, CP_COMPACT_SUM_FLAG);
|
|
spin_unlock_irqrestore(&sbi->cp_lock, flags);
|
|
|
|
orphan_blocks = GET_ORPHAN_BLOCKS(orphan_num);
|
|
ckpt->cp_pack_start_sum = cpu_to_le32(1 + cp_payload_blks +
|
|
orphan_blocks);
|
|
|
|
if (__remain_node_summaries(cpc->reason))
|
|
ckpt->cp_pack_total_block_count = cpu_to_le32(F2FS_CP_PACKS+
|
|
cp_payload_blks + data_sum_blocks +
|
|
orphan_blocks + NR_CURSEG_NODE_TYPE);
|
|
else
|
|
ckpt->cp_pack_total_block_count = cpu_to_le32(F2FS_CP_PACKS +
|
|
cp_payload_blks + data_sum_blocks +
|
|
orphan_blocks);
|
|
|
|
/* update ckpt flag for checkpoint */
|
|
update_ckpt_flags(sbi, cpc);
|
|
|
|
/* update SIT/NAT bitmap */
|
|
get_sit_bitmap(sbi, __bitmap_ptr(sbi, SIT_BITMAP));
|
|
get_nat_bitmap(sbi, __bitmap_ptr(sbi, NAT_BITMAP));
|
|
|
|
crc32 = f2fs_checkpoint_chksum(sbi, ckpt);
|
|
*((__le32 *)((unsigned char *)ckpt +
|
|
le32_to_cpu(ckpt->checksum_offset)))
|
|
= cpu_to_le32(crc32);
|
|
|
|
start_blk = __start_cp_next_addr(sbi);
|
|
|
|
/* write nat bits */
|
|
if (enabled_nat_bits(sbi, cpc)) {
|
|
__u64 cp_ver = cur_cp_version(ckpt);
|
|
block_t blk;
|
|
|
|
cp_ver |= ((__u64)crc32 << 32);
|
|
*(__le64 *)nm_i->nat_bits = cpu_to_le64(cp_ver);
|
|
|
|
blk = start_blk + sbi->blocks_per_seg - nm_i->nat_bits_blocks;
|
|
for (i = 0; i < nm_i->nat_bits_blocks; i++)
|
|
f2fs_update_meta_page(sbi, nm_i->nat_bits +
|
|
(i << F2FS_BLKSIZE_BITS), blk + i);
|
|
}
|
|
|
|
/* write out checkpoint buffer at block 0 */
|
|
f2fs_update_meta_page(sbi, ckpt, start_blk++);
|
|
|
|
for (i = 1; i < 1 + cp_payload_blks; i++)
|
|
f2fs_update_meta_page(sbi, (char *)ckpt + i * F2FS_BLKSIZE,
|
|
start_blk++);
|
|
|
|
if (orphan_num) {
|
|
write_orphan_inodes(sbi, start_blk);
|
|
start_blk += orphan_blocks;
|
|
}
|
|
|
|
f2fs_write_data_summaries(sbi, start_blk);
|
|
start_blk += data_sum_blocks;
|
|
|
|
/* Record write statistics in the hot node summary */
|
|
kbytes_written = sbi->kbytes_written;
|
|
if (sb->s_bdev->bd_part)
|
|
kbytes_written += BD_PART_WRITTEN(sbi);
|
|
|
|
seg_i->journal->info.kbytes_written = cpu_to_le64(kbytes_written);
|
|
|
|
if (__remain_node_summaries(cpc->reason)) {
|
|
f2fs_write_node_summaries(sbi, start_blk);
|
|
start_blk += NR_CURSEG_NODE_TYPE;
|
|
}
|
|
|
|
/* update user_block_counts */
|
|
sbi->last_valid_block_count = sbi->total_valid_block_count;
|
|
percpu_counter_set(&sbi->alloc_valid_block_count, 0);
|
|
|
|
/* Here, we have one bio having CP pack except cp pack 2 page */
|
|
f2fs_sync_meta_pages(sbi, META, LONG_MAX, FS_CP_META_IO);
|
|
if (get_pages(sbi, F2FS_DIRTY_META) && !f2fs_cp_error(sbi)) {
|
|
WARN_ON(1);
|
|
set_sbi_flag(sbi, SBI_NEED_FSCK);
|
|
}
|
|
/* Wait for all dirty meta pages to be submitted for IO */
|
|
f2fs_wait_on_all_pages(sbi, F2FS_DIRTY_META);
|
|
|
|
/* wait for previous submitted meta pages writeback */
|
|
f2fs_wait_on_all_pages(sbi, F2FS_WB_CP_DATA);
|
|
|
|
/* flush all device cache */
|
|
err = f2fs_flush_device_cache(sbi);
|
|
if (err)
|
|
return err;
|
|
|
|
/* barrier and flush checkpoint cp pack 2 page if it can */
|
|
commit_checkpoint(sbi, ckpt, start_blk);
|
|
f2fs_wait_on_all_pages(sbi, F2FS_WB_CP_DATA);
|
|
|
|
/*
|
|
* invalidate intermediate page cache borrowed from meta inode which are
|
|
* used for migration of encrypted or verity inode's blocks.
|
|
*/
|
|
if (f2fs_sb_has_encrypt(sbi) || f2fs_sb_has_verity(sbi))
|
|
invalidate_mapping_pages(META_MAPPING(sbi),
|
|
MAIN_BLKADDR(sbi), MAX_BLKADDR(sbi) - 1);
|
|
|
|
f2fs_release_ino_entry(sbi, false);
|
|
|
|
f2fs_reset_fsync_node_info(sbi);
|
|
|
|
clear_sbi_flag(sbi, SBI_IS_DIRTY);
|
|
clear_sbi_flag(sbi, SBI_NEED_CP);
|
|
clear_sbi_flag(sbi, SBI_QUOTA_SKIP_FLUSH);
|
|
|
|
spin_lock(&sbi->stat_lock);
|
|
sbi->unusable_block_count = 0;
|
|
spin_unlock(&sbi->stat_lock);
|
|
|
|
__set_cp_next_pack(sbi);
|
|
|
|
/*
|
|
* redirty superblock if metadata like node page or inode cache is
|
|
* updated during writing checkpoint.
|
|
*/
|
|
if (get_pages(sbi, F2FS_DIRTY_NODES) ||
|
|
get_pages(sbi, F2FS_DIRTY_IMETA))
|
|
set_sbi_flag(sbi, SBI_IS_DIRTY);
|
|
|
|
f2fs_bug_on(sbi, get_pages(sbi, F2FS_DIRTY_DENTS));
|
|
|
|
return unlikely(f2fs_cp_error(sbi)) ? -EIO : 0;
|
|
}
|
|
|
|
int f2fs_write_checkpoint(struct f2fs_sb_info *sbi, struct cp_control *cpc)
|
|
{
|
|
struct f2fs_checkpoint *ckpt = F2FS_CKPT(sbi);
|
|
unsigned long long ckpt_ver;
|
|
int err = 0;
|
|
|
|
if (f2fs_readonly(sbi->sb) || f2fs_hw_is_readonly(sbi))
|
|
return -EROFS;
|
|
|
|
if (unlikely(is_sbi_flag_set(sbi, SBI_CP_DISABLED))) {
|
|
if (cpc->reason != CP_PAUSE)
|
|
return 0;
|
|
f2fs_warn(sbi, "Start checkpoint disabled!");
|
|
}
|
|
if (cpc->reason != CP_RESIZE)
|
|
mutex_lock(&sbi->cp_mutex);
|
|
|
|
if (!is_sbi_flag_set(sbi, SBI_IS_DIRTY) &&
|
|
((cpc->reason & CP_FASTBOOT) || (cpc->reason & CP_SYNC) ||
|
|
((cpc->reason & CP_DISCARD) && !sbi->discard_blks)))
|
|
goto out;
|
|
if (unlikely(f2fs_cp_error(sbi))) {
|
|
err = -EIO;
|
|
goto out;
|
|
}
|
|
|
|
trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "start block_ops");
|
|
|
|
err = block_operations(sbi);
|
|
if (err)
|
|
goto out;
|
|
|
|
trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish block_ops");
|
|
|
|
f2fs_flush_merged_writes(sbi);
|
|
|
|
/* this is the case of multiple fstrims without any changes */
|
|
if (cpc->reason & CP_DISCARD) {
|
|
if (!f2fs_exist_trim_candidates(sbi, cpc)) {
|
|
unblock_operations(sbi);
|
|
goto out;
|
|
}
|
|
|
|
if (NM_I(sbi)->dirty_nat_cnt == 0 &&
|
|
SIT_I(sbi)->dirty_sentries == 0 &&
|
|
prefree_segments(sbi) == 0) {
|
|
f2fs_flush_sit_entries(sbi, cpc);
|
|
f2fs_clear_prefree_segments(sbi, cpc);
|
|
unblock_operations(sbi);
|
|
goto out;
|
|
}
|
|
}
|
|
|
|
/*
|
|
* update checkpoint pack index
|
|
* Increase the version number so that
|
|
* SIT entries and seg summaries are written at correct place
|
|
*/
|
|
ckpt_ver = cur_cp_version(ckpt);
|
|
ckpt->checkpoint_ver = cpu_to_le64(++ckpt_ver);
|
|
|
|
/* write cached NAT/SIT entries to NAT/SIT area */
|
|
err = f2fs_flush_nat_entries(sbi, cpc);
|
|
if (err)
|
|
goto stop;
|
|
|
|
f2fs_flush_sit_entries(sbi, cpc);
|
|
|
|
err = do_checkpoint(sbi, cpc);
|
|
if (err)
|
|
f2fs_release_discard_addrs(sbi);
|
|
else
|
|
f2fs_clear_prefree_segments(sbi, cpc);
|
|
stop:
|
|
unblock_operations(sbi);
|
|
stat_inc_cp_count(sbi->stat_info);
|
|
|
|
if (cpc->reason & CP_RECOVERY)
|
|
f2fs_notice(sbi, "checkpoint: version = %llx", ckpt_ver);
|
|
|
|
/* update CP_TIME to trigger checkpoint periodically */
|
|
f2fs_update_time(sbi, CP_TIME);
|
|
trace_f2fs_write_checkpoint(sbi->sb, cpc->reason, "finish checkpoint");
|
|
out:
|
|
if (cpc->reason != CP_RESIZE)
|
|
mutex_unlock(&sbi->cp_mutex);
|
|
return err;
|
|
}
|
|
|
|
void f2fs_init_ino_entry_info(struct f2fs_sb_info *sbi)
|
|
{
|
|
int i;
|
|
|
|
for (i = 0; i < MAX_INO_ENTRY; i++) {
|
|
struct inode_management *im = &sbi->im[i];
|
|
|
|
INIT_RADIX_TREE(&im->ino_root, GFP_ATOMIC);
|
|
spin_lock_init(&im->ino_lock);
|
|
INIT_LIST_HEAD(&im->ino_list);
|
|
im->ino_num = 0;
|
|
}
|
|
|
|
sbi->max_orphans = (sbi->blocks_per_seg - F2FS_CP_PACKS -
|
|
NR_CURSEG_TYPE - __cp_payload(sbi)) *
|
|
F2FS_ORPHANS_PER_BLOCK;
|
|
}
|
|
|
|
int __init f2fs_create_checkpoint_caches(void)
|
|
{
|
|
ino_entry_slab = f2fs_kmem_cache_create("f2fs_ino_entry",
|
|
sizeof(struct ino_entry));
|
|
if (!ino_entry_slab)
|
|
return -ENOMEM;
|
|
f2fs_inode_entry_slab = f2fs_kmem_cache_create("f2fs_inode_entry",
|
|
sizeof(struct inode_entry));
|
|
if (!f2fs_inode_entry_slab) {
|
|
kmem_cache_destroy(ino_entry_slab);
|
|
return -ENOMEM;
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
void f2fs_destroy_checkpoint_caches(void)
|
|
{
|
|
kmem_cache_destroy(ino_entry_slab);
|
|
kmem_cache_destroy(f2fs_inode_entry_slab);
|
|
}
|