Changes in 5.15.75
Revert "fs: check FMODE_LSEEK to control internal pipe splicing"
ALSA: oss: Fix potential deadlock at unregistration
ALSA: rawmidi: Drop register_mutex in snd_rawmidi_free()
ALSA: usb-audio: Fix potential memory leaks
ALSA: usb-audio: Fix NULL dererence at error path
ALSA: hda/realtek: remove ALC289_FIXUP_DUAL_SPK for Dell 5530
ALSA: hda/realtek: Correct pin configs for ASUS G533Z
ALSA: hda/realtek: Add quirk for ASUS GV601R laptop
ALSA: hda/realtek: Add Intel Reference SSID to support headset keys
mtd: rawnand: atmel: Unmap streaming DMA mappings
io_uring/net: don't update msg_name if not provided
hv_netvsc: Fix race between VF offering and VF association message from host
cifs: destage dirty pages before re-reading them for cache=none
cifs: Fix the error length of VALIDATE_NEGOTIATE_INFO message
iio: dac: ad5593r: Fix i2c read protocol requirements
iio: ltc2497: Fix reading conversion results
iio: adc: ad7923: fix channel readings for some variants
iio: pressure: dps310: Refactor startup procedure
iio: pressure: dps310: Reset chip after timeout
xhci: dbc: Fix memory leak in xhci_alloc_dbc()
usb: add quirks for Lenovo OneLink+ Dock
can: kvaser_usb: Fix use of uninitialized completion
can: kvaser_usb_leaf: Fix overread with an invalid command
can: kvaser_usb_leaf: Fix TX queue out of sync after restart
can: kvaser_usb_leaf: Fix CAN state after restart
mmc: sdhci-sprd: Fix minimum clock limit
i2c: designware: Fix handling of real but unexpected device interrupts
fs: dlm: fix race between test_bit() and queue_work()
fs: dlm: handle -EBUSY first in lock arg validation
HID: multitouch: Add memory barriers
quota: Check next/prev free block number after reading from quota file
platform/chrome: cros_ec_proto: Update version on GET_NEXT_EVENT failure
ASoC: wcd9335: fix order of Slimbus unprepare/disable
ASoC: wcd934x: fix order of Slimbus unprepare/disable
hwmon: (gsc-hwmon) Call of_node_get() before of_find_xxx API
net: thunderbolt: Enable DMA paths only after rings are enabled
regulator: qcom_rpm: Fix circular deferral regression
arm64: topology: move store_cpu_topology() to shared code
riscv: topology: fix default topology reporting
RISC-V: Make port I/O string accessors actually work
parisc: fbdev/stifb: Align graphics memory size to 4MB
riscv: Allow PROT_WRITE-only mmap()
riscv: Make VM_WRITE imply VM_READ
riscv: always honor the CONFIG_CMDLINE_FORCE when parsing dtb
riscv: Pass -mno-relax only on lld < 15.0.0
UM: cpuinfo: Fix a warning for CONFIG_CPUMASK_OFFSTACK
nvmem: core: Fix memleak in nvmem_register()
nvme-multipath: fix possible hang in live ns resize with ANA access
nvme-pci: set min_align_mask before calculating max_hw_sectors
Revert "drm/amdgpu: use dirty framebuffer helper"
dmaengine: mxs: use platform_driver_register
drm/virtio: Check whether transferred 2D BO is shmem
drm/virtio: Unlock reservations on virtio_gpu_object_shmem_init() error
drm/virtio: Use appropriate atomic state in virtio_gpu_plane_cleanup_fb()
drm/udl: Restore display mode on resume
arm64: errata: Add Cortex-A55 to the repeat tlbi list
mm/damon: validate if the pmd entry is present before accessing
mm/mmap: undo ->mmap() when arch_validate_flags() fails
xen/gntdev: Prevent leaking grants
xen/gntdev: Accommodate VMA splitting
PCI: Sanitise firmware BAR assignments behind a PCI-PCI bridge
serial: 8250: Let drivers request full 16550A feature probing
serial: 8250: Request full 16550A feature probing for OxSemi PCIe devices
NFSD: Protect against send buffer overflow in NFSv3 READDIR
NFSD: Protect against send buffer overflow in NFSv2 READ
NFSD: Protect against send buffer overflow in NFSv3 READ
powercap: intel_rapl: Use standard Energy Unit for SPR Dram RAPL domain
powerpc/boot: Explicitly disable usage of SPE instructions
slimbus: qcom-ngd: use correct error in message of pdr_add_lookup() failure
slimbus: qcom-ngd: cleanup in probe error path
scsi: qedf: Populate sysfs attributes for vport
gpio: rockchip: request GPIO mux to pinctrl when setting direction
pinctrl: rockchip: add pinmux_ops.gpio_set_direction callback
fbdev: smscufx: Fix use-after-free in ufx_ops_open()
ksmbd: fix endless loop when encryption for response fails
ksmbd: Fix wrong return value and message length check in smb2_ioctl()
ksmbd: Fix user namespace mapping
fs: record I_DIRTY_TIME even if inode already has I_DIRTY_INODE
btrfs: fix race between quota enable and quota rescan ioctl
btrfs: set generation before calling btrfs_clean_tree_block in btrfs_init_new_buffer
f2fs: complete checkpoints during remount
f2fs: flush pending checkpoints when freezing super
f2fs: increase the limit for reserve_root
f2fs: fix to do sanity check on destination blkaddr during recovery
f2fs: fix to do sanity check on summary info
hardening: Avoid harmless Clang option under CONFIG_INIT_STACK_ALL_ZERO
hardening: Remove Clang's enable flag for -ftrivial-auto-var-init=zero
jbd2: wake up journal waiters in FIFO order, not LIFO
jbd2: fix potential buffer head reference count leak
jbd2: fix potential use-after-free in jbd2_fc_wait_bufs
jbd2: add miss release buffer head in fc_do_one_pass()
ext4: avoid crash when inline data creation follows DIO write
ext4: fix null-ptr-deref in ext4_write_info
ext4: make ext4_lazyinit_thread freezable
ext4: fix check for block being out of directory size
ext4: don't increase iversion counter for ea_inodes
ext4: ext4_read_bh_lock() should submit IO if the buffer isn't uptodate
ext4: place buffer head allocation before handle start
ext4: fix dir corruption when ext4_dx_add_entry() fails
ext4: fix miss release buffer head in ext4_fc_write_inode
ext4: fix potential memory leak in ext4_fc_record_modified_inode()
ext4: fix potential memory leak in ext4_fc_record_regions()
ext4: update 'state->fc_regions_size' after successful memory allocation
livepatch: fix race between fork and KLP transition
ftrace: Properly unset FTRACE_HASH_FL_MOD
ring-buffer: Allow splice to read previous partially read pages
ring-buffer: Have the shortest_full queue be the shortest not longest
ring-buffer: Check pending waiters when doing wake ups as well
ring-buffer: Add ring_buffer_wake_waiters()
ring-buffer: Fix race between reset page and reading page
tracing: Disable interrupt or preemption before acquiring arch_spinlock_t
tracing: Wake up ring buffer waiters on closing of the file
tracing: Wake up waiters when tracing is disabled
tracing: Add ioctl() to force ring buffer waiters to wake up
tracing: Move duplicate code of trace_kprobe/eprobe.c into header
tracing: Add "(fault)" name injection to kernel probes
tracing: Fix reading strings from synthetic events
thunderbolt: Explicitly enable lane adapter hotplug events at startup
efi: libstub: drop pointless get_memory_map() call
media: cedrus: Set the platform driver data earlier
media: cedrus: Fix endless loop in cedrus_h265_skip_bits()
blk-wbt: call rq_qos_add() after wb_normal is initialized
KVM: x86/emulator: Fix handing of POP SS to correctly set interruptibility
KVM: nVMX: Unconditionally purge queued/injected events on nested "exit"
KVM: nVMX: Don't propagate vmcs12's PERF_GLOBAL_CTRL settings to vmcs02
KVM: VMX: Drop bits 31:16 when shoving exception error code into VMCS
staging: greybus: audio_helper: remove unused and wrong debugfs usage
drm/nouveau/kms/nv140-: Disable interlacing
drm/nouveau: fix a use-after-free in nouveau_gem_prime_import_sg_table()
drm/i915: Fix watermark calculations for gen12+ RC CCS modifier
drm/i915: Fix watermark calculations for gen12+ MC CCS modifier
drm/i915: Fix watermark calculations for gen12+ CCS+CC modifier
drm/amd/display: Fix vblank refcount in vrr transition
smb3: must initialize two ACL struct fields to zero
selinux: use "grep -E" instead of "egrep"
ima: fix blocking of security.ima xattrs of unsupported algorithms
userfaultfd: open userfaultfds with O_RDONLY
ntfs3: rework xattr handlers and switch to POSIX ACL VFS helpers
thermal: cpufreq_cooling: Check the policy first in cpufreq_cooling_register()
sh: machvec: Use char[] for section boundaries
MIPS: SGI-IP27: Free some unused memory
MIPS: SGI-IP27: Fix platform-device leak in bridge_platform_create()
ARM: 9244/1: dump: Fix wrong pg_level in walk_pmd()
ARM: 9247/1: mm: set readonly for MT_MEMORY_RO with ARM_LPAE
objtool: Preserve special st_shndx indexes in elf_update_symbol
nfsd: Fix a memory leak in an error handling path
SUNRPC: Fix svcxdr_init_decode's end-of-buffer calculation
SUNRPC: Fix svcxdr_init_encode's buflen calculation
NFSD: Protect against send buffer overflow in NFSv2 READDIR
NFSD: Fix handling of oversized NFSv4 COMPOUND requests
wifi: rtlwifi: 8192de: correct checking of IQK reload
wifi: ath10k: add peer map clean up for peer delete in ath10k_sta_state()
leds: lm3601x: Don't use mutex after it was destroyed
bpf: Fix reference state management for synchronous callbacks
wifi: mac80211: allow bw change during channel switch in mesh
bpftool: Fix a wrong type cast in btf_dumper_int
spi: mt7621: Fix an error message in mt7621_spi_probe()
x86/resctrl: Fix to restore to original value when re-enabling hardware prefetch register
xsk: Fix backpressure mechanism on Tx
bpf: Disable preemption when increasing per-cpu map_locked
bpf: Propagate error from htab_lock_bucket() to userspace
bpf: Use this_cpu_{inc|dec|inc_return} for bpf_task_storage_busy
Bluetooth: btusb: mediatek: fix WMT failure during runtime suspend
wifi: rtl8xxxu: tighten bounds checking in rtl8xxxu_read_efuse()
wifi: rtw88: add missing destroy_workqueue() on error path in rtw_core_init()
selftests/xsk: Avoid use-after-free on ctx
spi: qup: add missing clk_disable_unprepare on error in spi_qup_resume()
spi: qup: add missing clk_disable_unprepare on error in spi_qup_pm_resume_runtime()
wifi: rtl8xxxu: Fix skb misuse in TX queue selection
spi: meson-spicc: do not rely on busy flag in pow2 clk ops
bpf: btf: fix truncated last_member_type_id in btf_struct_resolve
wifi: rtl8xxxu: gen2: Fix mistake in path B IQ calibration
wifi: rtl8xxxu: Remove copy-paste leftover in gen2_update_rate_mask
wifi: mt76: sdio: fix transmitting packet hangs
wifi: mt76: mt7615: add mt7615_mutex_acquire/release in mt7615_sta_set_decap_offload
wifi: mt76: mt7915: do not check state before configuring implicit beamform
Bluetooth: RFCOMM: Fix possible deadlock on socket shutdown/release
net: fs_enet: Fix wrong check in do_pd_setup
bpf: Ensure correct locking around vulnerable function find_vpid()
Bluetooth: hci_{ldisc,serdev}: check percpu_init_rwsem() failure
netfilter: conntrack: fix the gc rescheduling delay
netfilter: conntrack: revisit the gc initial rescheduling bias
wifi: ath11k: fix number of VHT beamformee spatial streams
x86/microcode/AMD: Track patch allocation size explicitly
x86/cpu: Include the header of init_ia32_feat_ctl()'s prototype
spi: dw: Fix PM disable depth imbalance in dw_spi_bt1_probe
spi/omap100k:Fix PM disable depth imbalance in omap1_spi100k_probe
skmsg: Schedule psock work if the cached skb exists on the psock
i2c: mlxbf: support lock mechanism
Bluetooth: hci_core: Fix not handling link timeouts propertly
xfrm: Reinject transport-mode packets through workqueue
netfilter: nft_fib: Fix for rpath check with VRF devices
spi: s3c64xx: Fix large transfers with DMA
wifi: rtl8xxxu: Fix AIFS written to REG_EDCA_*_PARAM
vhost/vsock: Use kvmalloc/kvfree for larger packets.
eth: alx: take rtnl_lock on resume
mISDN: fix use-after-free bugs in l1oip timer handlers
sctp: handle the error returned from sctp_auth_asoc_init_active_key
tcp: fix tcp_cwnd_validate() to not forget is_cwnd_limited
spi: Ensure that sg_table won't be used after being freed
hwmon: (pmbus/mp2888) Fix sensors readouts for MPS Multi-phase mp2888 controller
net: rds: don't hold sock lock when cancelling work from rds_tcp_reset_callbacks()
bnx2x: fix potential memory leak in bnx2x_tpa_stop()
net: wwan: iosm: Call mutex_init before locking it
net/ieee802154: reject zero-sized raw_sendmsg()
once: add DO_ONCE_SLOW() for sleepable contexts
net: mvpp2: fix mvpp2 debugfs leak
drm: bridge: adv7511: fix CEC power down control register offset
drm: bridge: adv7511: unregister cec i2c device after cec adapter
drm/bridge: Avoid uninitialized variable warning
drm/mipi-dsi: Detach devices when removing the host
drm/virtio: Correct drm_gem_shmem_get_sg_table() error handling
drm/bridge: parade-ps8640: Fix regulator supply order
drm/dp_mst: fix drm_dp_dpcd_read return value checks
drm:pl111: Add of_node_put() when breaking out of for_each_available_child_of_node()
ASoC: mt6359: fix tests for platform_get_irq() failure
platform/chrome: fix double-free in chromeos_laptop_prepare()
platform/chrome: fix memory corruption in ioctl
ASoC: tas2764: Allow mono streams
ASoC: tas2764: Drop conflicting set_bias_level power setting
ASoC: tas2764: Fix mute/unmute
platform/x86: msi-laptop: Fix old-ec check for backlight registering
platform/x86: msi-laptop: Fix resource cleanup
platform/chrome: cros_ec_typec: Correct alt mode index
drm/amdgpu: add missing pci_disable_device() in amdgpu_pmops_runtime_resume()
drm/bridge: megachips: Fix a null pointer dereference bug
ASoC: rsnd: Add check for rsnd_mod_power_on
ALSA: hda: beep: Simplify keep-power-at-enable behavior
drm/bochs: fix blanking
drm/omap: dss: Fix refcount leak bugs
drm/amdgpu: Fix memory leak in hpd_rx_irq_create_workqueue()
mmc: au1xmmc: Fix an error handling path in au1xmmc_probe()
ASoC: eureka-tlv320: Hold reference returned from of_find_xxx API
drm/msm/dpu: index dpu_kms->hw_vbif using vbif_idx
drm/msm/dp: correct 1.62G link rate at dp_catalog_ctrl_config_msa()
drm/vmwgfx: Fix memory leak in vmw_mksstat_add_ioctl()
ASoC: codecs: tx-macro: fix kcontrol put
ASoC: da7219: Fix an error handling path in da7219_register_dai_clks()
ALSA: dmaengine: increment buffer pointer atomically
mmc: wmt-sdmmc: Fix an error handling path in wmt_mci_probe()
ASoC: wm8997: Fix PM disable depth imbalance in wm8997_probe
ASoC: wm5110: Fix PM disable depth imbalance in wm5110_probe
ASoC: wm5102: Fix PM disable depth imbalance in wm5102_probe
ASoC: mt6660: Fix PM disable depth imbalance in mt6660_i2c_probe
ALSA: hda/hdmi: Don't skip notification handling during PM operation
memory: pl353-smc: Fix refcount leak bug in pl353_smc_probe()
memory: of: Fix refcount leak bug in of_get_ddr_timings()
memory: of: Fix refcount leak bug in of_lpddr3_get_ddr_timings()
locks: fix TOCTOU race when granting write lease
soc: qcom: smsm: Fix refcount leak bugs in qcom_smsm_probe()
soc: qcom: smem_state: Add refcounting for the 'state->of_node'
ARM: dts: imx6qdl-kontron-samx6i: hook up DDC i2c bus
ARM: dts: turris-omnia: Fix mpp26 pin name and comment
ARM: dts: kirkwood: lsxl: fix serial line
ARM: dts: kirkwood: lsxl: remove first ethernet port
ia64: export memory_add_physaddr_to_nid to fix cxl build error
soc/tegra: fuse: Drop Kconfig dependency on TEGRA20_APB_DMA
arm64: dts: ti: k3-j7200: fix main pinmux range
ARM: dts: exynos: correct s5k6a3 reset polarity on Midas family
ARM: Drop CMDLINE_* dependency on ATAGS
ext4: don't run ext4lazyinit for read-only filesystems
arm64: ftrace: fix module PLTs with mcount
ARM: dts: exynos: fix polarity of VBUS GPIO of Origen
iio: adc: at91-sama5d2_adc: fix AT91_SAMA5D2_MR_TRACKTIM_MAX
iio: adc: at91-sama5d2_adc: check return status for pressure and touch
iio: adc: at91-sama5d2_adc: lock around oversampling and sample freq
iio: adc: at91-sama5d2_adc: disable/prepare buffer on suspend/resume
iio: inkern: only release the device node when done with it
iio: inkern: fix return value in devm_of_iio_channel_get_by_name()
iio: ABI: Fix wrong format of differential capacitance channel ABI.
iio: magnetometer: yas530: Change data type of hard_offsets to signed
RDMA/mlx5: Don't compare mkey tags in DEVX indirect mkey
usb: common: debug: Check non-standard control requests
clk: meson: Hold reference returned by of_get_parent()
clk: oxnas: Hold reference returned by of_get_parent()
clk: qoriq: Hold reference returned by of_get_parent()
clk: berlin: Add of_node_put() for of_get_parent()
clk: sprd: Hold reference returned by of_get_parent()
clk: tegra: Fix refcount leak in tegra210_clock_init
clk: tegra: Fix refcount leak in tegra114_clock_init
clk: tegra20: Fix refcount leak in tegra20_clock_init
HSI: omap_ssi: Fix refcount leak in ssi_probe
HSI: omap_ssi_port: Fix dma_map_sg error check
media: exynos4-is: fimc-is: Add of_node_put() when breaking out of loop
tty: xilinx_uartps: Fix the ignore_status
media: meson: vdec: add missing clk_disable_unprepare on error in vdec_hevc_start()
media: uvcvideo: Fix memory leak in uvc_gpio_parse
media: uvcvideo: Use entity get_cur in uvc_ctrl_set
media: xilinx: vipp: Fix refcount leak in xvip_graph_dma_init
RDMA/rxe: Fix "kernel NULL pointer dereference" error
RDMA/rxe: Fix the error caused by qp->sk
misc: ocxl: fix possible refcount leak in afu_ioctl()
fpga: prevent integer overflow in dfl_feature_ioctl_set_irq()
dmaengine: hisilicon: Disable channels when unregister hisi_dma
dmaengine: hisilicon: Fix CQ head update
dmaengine: hisilicon: Add multi-thread support for a DMA channel
dyndbg: fix static_branch manipulation
dyndbg: fix module.dyndbg handling
dyndbg: let query-modname override actual module name
dyndbg: drop EXPORTed dynamic_debug_exec_queries
clk: qcom: sm6115: Select QCOM_GDSC
mtd: devices: docg3: check the return value of devm_ioremap() in the probe
phy: amlogic: phy-meson-axg-mipi-pcie-analog: Hold reference returned by of_get_parent()
phy: phy-mtk-tphy: fix the phy type setting issue
mtd: rawnand: intel: Read the chip-select line from the correct OF node
mtd: rawnand: intel: Remove undocumented compatible string
mtd: rawnand: fsl_elbc: Fix none ECC mode
RDMA/irdma: Align AE id codes to correct flush code and event
RDMA/srp: Fix srp_abort()
RDMA/siw: Always consume all skbuf data in sk_data_ready() upcall.
RDMA/siw: Fix QP destroy to wait for all references dropped.
ata: fix ata_id_sense_reporting_enabled() and ata_id_has_sense_reporting()
ata: fix ata_id_has_devslp()
ata: fix ata_id_has_ncq_autosense()
ata: fix ata_id_has_dipm()
mtd: rawnand: meson: fix bit map use in meson_nfc_ecc_correct()
md: Replace snprintf with scnprintf
md/raid5: Ensure stripe_fill happens on non-read IO with journal
md/raid5: Remove unnecessary bio_put() in raid5_read_one_chunk()
RDMA/cm: Use SLID in the work completion as the DLID in responder side
IB: Set IOVA/LENGTH on IB_MR in core/uverbs layers
xhci: Don't show warning for reinit on known broken suspend
usb: gadget: function: fix dangling pnp_string in f_printer.c
drivers: serial: jsm: fix some leaks in probe
serial: 8250: Toggle IER bits on only after irq has been set up
tty: serial: fsl_lpuart: disable dma rx/tx use flags in lpuart_dma_shutdown
phy: qualcomm: call clk_disable_unprepare in the error handling
staging: vt6655: fix some erroneous memory clean-up loops
slimbus: qcom-ngd-ctrl: allow compile testing without QCOM_RPROC_COMMON
firmware: google: Test spinlock on panic path to avoid lockups
serial: 8250: Fix restoring termios speed after suspend
scsi: libsas: Fix use-after-free bug in smp_execute_task_sg()
scsi: iscsi: Rename iscsi_conn_queue_work()
scsi: iscsi: Add recv workqueue helpers
scsi: iscsi: Run recv path from workqueue
scsi: iscsi: iscsi_tcp: Fix null-ptr-deref while calling getpeername()
clk: qcom: apss-ipq6018: mark apcs_alias0_core_clk as critical
clk: qcom: gcc-sm6115: Override default Alpha PLL regs
RDMA/rxe: Fix resize_finish() in rxe_queue.c
fsi: core: Check error number after calling ida_simple_get
mfd: intel_soc_pmic: Fix an error handling path in intel_soc_pmic_i2c_probe()
mfd: fsl-imx25: Fix an error handling path in mx25_tsadc_setup_irq()
mfd: lp8788: Fix an error handling path in lp8788_probe()
mfd: lp8788: Fix an error handling path in lp8788_irq_init() and lp8788_irq_init()
mfd: fsl-imx25: Fix check for platform_get_irq() errors
mfd: sm501: Add check for platform_driver_register()
clk: mediatek: mt8183: mfgcfg: Propagate rate changes to parent
dmaengine: ioat: stop mod_timer from resurrecting deleted timer in __cleanup()
usb: mtu3: fix failed runtime suspend in host only mode
spmi: pmic-arb: correct duplicate APID to PPID mapping logic
clk: vc5: Fix 5P49V6901 outputs disabling when enabling FOD
clk: baikal-t1: Fix invalid xGMAC PTP clock divider
clk: baikal-t1: Add shared xGMAC ref/ptp clocks internal parent
clk: baikal-t1: Add SATA internal ref clock buffer
clk: bcm2835: fix bcm2835_clock_rate_from_divisor declaration
clk: imx: scu: fix memleak on platform_device_add() fails
clk: ti: dra7-atl: Fix reference leak in of_dra7_atl_clk_probe
clk: ast2600: BCLK comes from EPLL
mailbox: mpfs: fix handling of the reg property
mailbox: mpfs: account for mbox offsets while sending
mailbox: bcm-ferxrm-mailbox: Fix error check for dma_map_sg
powerpc/configs: Properly enable PAPR_SCM in pseries_defconfig
powerpc/math_emu/efp: Include module.h
powerpc/sysdev/fsl_msi: Add missing of_node_put()
powerpc/pci_dn: Add missing of_node_put()
powerpc/powernv: add missing of_node_put() in opal_export_attrs()
powerpc: Fix fallocate and fadvise64_64 compat parameter combination
x86/hyperv: Fix 'struct hv_enlightened_vmcs' definition
powerpc/64s: Fix GENERIC_CPU build flags for PPC970 / G5
powerpc: Fix SPE Power ISA properties for e500v1 platforms
powerpc/kprobes: Fix null pointer reference in arch_prepare_kprobe()
powerpc/pseries/vas: Pass hw_cpu_id to node associativity HCALL
crypto: sahara - don't sleep when in softirq
crypto: hisilicon/zip - fix mismatch in get/set sgl_sge_nr
hwrng: arm-smccc-trng - fix NO_ENTROPY handling
cgroup: Honor caller's cgroup NS when resolving path
hwrng: imx-rngc - Moving IRQ handler registering after imx_rngc_irq_mask_clear()
crypto: qat - fix default value of WDT timer
crypto: hisilicon/qm - fix missing put dfx access
cgroup/cpuset: Enable update_tasks_cpumask() on top_cpuset
iommu/omap: Fix buffer overflow in debugfs
crypto: akcipher - default implementation for setting a private key
crypto: ccp - Release dma channels before dmaengine unrgister
crypto: inside-secure - Change swab to swab32
crypto: qat - fix DMA transfer direction
cifs: return correct error in ->calc_signature()
iommu/iova: Fix module config properly
tracing: kprobe: Fix kprobe event gen test module on exit
tracing: kprobe: Make gen test module work in arm and riscv
tracing/osnoise: Fix possible recursive locking in stop_per_cpu_kthreads
kbuild: remove the target in signal traps when interrupted
kbuild: rpm-pkg: fix breakage when V=1 is used
crypto: marvell/octeontx - prevent integer overflows
crypto: cavium - prevent integer overflow loading firmware
thermal/drivers/qcom/tsens-v0_1: Fix MSM8939 fourth sensor hw_id
ACPI: APEI: do not add task_work to kernel thread to avoid memory leak
f2fs: fix race condition on setting FI_NO_EXTENT flag
f2fs: fix to account FS_CP_DATA_IO correctly
selftest: tpm2: Add Client.__del__() to close /dev/tpm* handle
fs: dlm: fix race in lowcomms
rcu: Avoid triggering strict-GP irq-work when RCU is idle
rcu: Back off upon fill_page_cache_func() allocation failure
rcu-tasks: Convert RCU_LOCKDEP_WARN() to WARN_ONCE()
ACPI: video: Add Toshiba Satellite/Portege Z830 quirk
ACPI: tables: FPDT: Don't call acpi_os_map_memory() on invalid phys address
cpufreq: intel_pstate: Add Tigerlake support in no-HWP mode
MIPS: BCM47XX: Cast memcmp() of function to (void *)
powercap: intel_rapl: fix UBSAN shift-out-of-bounds issue
thermal: intel_powerclamp: Use get_cpu() instead of smp_processor_id() to avoid crash
ARM: decompressor: Include .data.rel.ro.local
ACPI: x86: Add a quirk for Dell Inspiron 14 2-in-1 for StorageD3Enable
x86/entry: Work around Clang __bdos() bug
NFSD: Return nfserr_serverfault if splice_ok but buf->pages have data
NFSD: fix use-after-free on source server when doing inter-server copy
wifi: brcmfmac: fix invalid address access when enabling SCAN log level
bpftool: Clear errno after libcap's checks
ice: set tx_tstamps when creating new Tx rings via ethtool
net: ethernet: ti: davinci_mdio: Add workaround for errata i2329
openvswitch: Fix double reporting of drops in dropwatch
openvswitch: Fix overreporting of drops in dropwatch
tcp: annotate data-race around tcp_md5sig_pool_populated
x86/mce: Retrieve poison range from hardware
wifi: ath9k: avoid uninit memory read in ath9k_htc_rx_msg()
thunderbolt: Add back Intel Falcon Ridge end-to-end flow control workaround
xfrm: Update ipcomp_scratches with NULL when freed
iavf: Fix race between iavf_close and iavf_reset_task
wifi: brcmfmac: fix use-after-free bug in brcmf_netdev_start_xmit()
Bluetooth: btintel: Mark Intel controller to support LE_STATES quirk
regulator: core: Prevent integer underflow
wifi: mt76: mt7921: reset msta->airtime_ac while clearing up hw value
Bluetooth: L2CAP: initialize delayed works at l2cap_chan_create()
Bluetooth: hci_sysfs: Fix attempting to call device_add multiple times
can: bcm: check the result of can_send() in bcm_can_tx()
wifi: rt2x00: don't run Rt5592 IQ calibration on MT7620
wifi: rt2x00: set correct TX_SW_CFG1 MAC register for MT7620
wifi: rt2x00: set VGC gain for both chains of MT7620
wifi: rt2x00: set SoC wmac clock register
wifi: rt2x00: correctly set BBP register 86 for MT7620
hwmon: (sht4x) do not overflow clamping operation on 32-bit platforms
net: If sock is dead don't access sock's sk_wq in sk_stream_wait_memory
Bluetooth: L2CAP: Fix user-after-free
r8152: Rate limit overflow messages
drm/nouveau/nouveau_bo: fix potential memory leak in nouveau_bo_alloc()
drm: Use size_t type for len variable in drm_copy_field()
drm: Prevent drm_copy_field() to attempt copying a NULL pointer
drm/komeda: Fix handling of atomic commits in the atomic_commit_tail hook
gpu: lontium-lt9611: Fix NULL pointer dereference in lt9611_connector_init()
drm/amd/display: fix overflow on MIN_I64 definition
udmabuf: Set ubuf->sg = NULL if the creation of sg table fails
drm: bridge: dw_hdmi: only trigger hotplug event on link change
ALSA: usb-audio: Register card at the last interface
drm/vc4: vec: Fix timings for VEC modes
drm: panel-orientation-quirks: Add quirk for Anbernic Win600
platform/chrome: cros_ec: Notify the PM of wake events during resume
platform/x86: msi-laptop: Change DMI match / alias strings to fix module autoloading
ASoC: SOF: pci: Change DMI match info to support all Chrome platforms
drm/amdgpu: fix initial connector audio value
drm/meson: reorder driver deinit sequence to fix use-after-free bug
drm/meson: explicitly remove aggregate driver at module unload time
mmc: sdhci-msm: add compatible string check for sdm670
drm/dp: Don't rewrite link config when setting phy test pattern
drm/amd/display: Remove interface for periodic interrupt 1
ARM: dts: imx7d-sdb: config the max pressure for tsc2046
ARM: dts: imx6q: add missing properties for sram
ARM: dts: imx6dl: add missing properties for sram
ARM: dts: imx6qp: add missing properties for sram
ARM: dts: imx6sl: add missing properties for sram
ARM: dts: imx6sll: add missing properties for sram
ARM: dts: imx6sx: add missing properties for sram
kselftest/arm64: Fix validatation termination record after EXTRA_CONTEXT
arm64: dts: imx8mq-librem5: Add bq25895 as max17055's power supply
btrfs: dump extra info if one free space cache has more bitmaps than it should
btrfs: scrub: try to fix super block errors
btrfs: don't print information about space cache or tree every remount
ARM: 9242/1: kasan: Only map modules if CONFIG_KASAN_VMALLOC=n
clk: zynqmp: Fix stack-out-of-bounds in strncpy`
media: cx88: Fix a null-ptr-deref bug in buffer_prepare()
media: platform: fix some double free in meson-ge2d and mtk-jpeg and s5p-mfc
clk: zynqmp: pll: rectify rate rounding in zynqmp_pll_round_rate
usb: host: xhci-plat: suspend and resume clocks
usb: host: xhci-plat: suspend/resume clks for brcm
dmaengine: ti: k3-udma: Reset UDMA_CHAN_RT byte counters to prevent overflow
scsi: 3w-9xxx: Avoid disabling device if failing to enable it
nbd: Fix hung when signal interrupts nbd_start_device_ioctl()
iommu/arm-smmu-v3: Make default domain type of HiSilicon PTT device to identity
power: supply: adp5061: fix out-of-bounds read in adp5061_get_chg_type()
staging: vt6655: fix potential memory leak
blk-throttle: prevent overflow while calculating wait time
ata: libahci_platform: Sanity check the DT child nodes number
bcache: fix set_at_max_writeback_rate() for multiple attached devices
soundwire: cadence: Don't overwrite msg->buf during write commands
soundwire: intel: fix error handling on dai registration issues
HID: roccat: Fix use-after-free in roccat_read()
eventfd: guard wake_up in eventfd fs calls as well
md/raid5: Wait for MD_SB_CHANGE_PENDING in raid5d
usb: host: xhci: Fix potential memory leak in xhci_alloc_stream_info()
usb: musb: Fix musb_gadget.c rxstate overflow bug
arm64: dts: imx8mp: Add snps,gfladj-refclk-lpm-sel quirk to USB nodes
usb: dwc3: core: Enable GUCTL1 bit 10 for fixing termination error after resume bug
Revert "usb: storage: Add quirk for Samsung Fit flash"
staging: rtl8723bs: fix potential memory leak in rtw_init_drv_sw()
staging: rtl8723bs: fix a potential memory leak in rtw_init_cmd_priv()
scsi: tracing: Fix compile error in trace_array calls when TRACING is disabled
ext2: Use kvmalloc() for group descriptor array
nvme: copy firmware_rev on each init
nvmet-tcp: add bounds check on Transfer Tag
usb: idmouse: fix an uninit-value in idmouse_open
clk: bcm2835: Make peripheral PLLC critical
clk: bcm2835: Round UART input clock up
perf intel-pt: Fix segfault in intel_pt_print_info() with uClibc
io_uring/af_unix: defer registered files gc to io_uring release
io_uring: correct pinned_vm accounting
io_uring/rw: fix short rw error handling
io_uring/rw: fix error'ed retry return values
io_uring/rw: fix unexpected link breakage
mm: hugetlb: fix UAF in hugetlb_handle_userfault
net: ieee802154: return -EINVAL for unknown addr type
ALSA: usb-audio: Fix last interface check for registration
blk-wbt: fix that 'rwb->wc' is always set to 1 in wbt_init()
net: ethernet: ti: davinci_mdio: fix build for mdio bitbang uses
Revert "net/ieee802154: reject zero-sized raw_sendmsg()"
net/ieee802154: don't warn zero-sized raw_sendmsg()
drm/amd/display: Fix build breakage with CONFIG_DEBUG_FS=n
Kconfig.debug: simplify the dependency of DEBUG_INFO_DWARF4/5
Kconfig.debug: add toolchain checks for DEBUG_INFO_DWARF_TOOLCHAIN_DEFAULT
lib/Kconfig.debug: Add check for non-constant .{s,u}leb128 support to DWARF5
ext4: continue to expand file system when the target size doesn't reach
thermal: intel_powerclamp: Use first online CPU as control_cpu
gcov: support GCC 12.1 and newer compilers
io-wq: Fix memory leak in worker creation
Linux 5.15.75
Change-Id: I5a3ef9688fb31003940d7e1828f863b9d50f1da9
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
1663 lines
44 KiB
C
1663 lines
44 KiB
C
// SPDX-License-Identifier: GPL-2.0-only
|
|
/*
|
|
* linux/fs/ext2/super.c
|
|
*
|
|
* Copyright (C) 1992, 1993, 1994, 1995
|
|
* Remy Card (card@masi.ibp.fr)
|
|
* Laboratoire MASI - Institut Blaise Pascal
|
|
* Universite Pierre et Marie Curie (Paris VI)
|
|
*
|
|
* from
|
|
*
|
|
* linux/fs/minix/inode.c
|
|
*
|
|
* Copyright (C) 1991, 1992 Linus Torvalds
|
|
*
|
|
* Big-endian to little-endian byte-swapping/bitmaps by
|
|
* David S. Miller (davem@caip.rutgers.edu), 1995
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/string.h>
|
|
#include <linux/fs.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/init.h>
|
|
#include <linux/blkdev.h>
|
|
#include <linux/parser.h>
|
|
#include <linux/random.h>
|
|
#include <linux/buffer_head.h>
|
|
#include <linux/exportfs.h>
|
|
#include <linux/vfs.h>
|
|
#include <linux/seq_file.h>
|
|
#include <linux/mount.h>
|
|
#include <linux/log2.h>
|
|
#include <linux/quotaops.h>
|
|
#include <linux/uaccess.h>
|
|
#include <linux/dax.h>
|
|
#include <linux/iversion.h>
|
|
#include "ext2.h"
|
|
#include "xattr.h"
|
|
#include "acl.h"
|
|
|
|
static void ext2_write_super(struct super_block *sb);
|
|
static int ext2_remount (struct super_block * sb, int * flags, char * data);
|
|
static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf);
|
|
static int ext2_sync_fs(struct super_block *sb, int wait);
|
|
static int ext2_freeze(struct super_block *sb);
|
|
static int ext2_unfreeze(struct super_block *sb);
|
|
|
|
void ext2_error(struct super_block *sb, const char *function,
|
|
const char *fmt, ...)
|
|
{
|
|
struct va_format vaf;
|
|
va_list args;
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
|
struct ext2_super_block *es = sbi->s_es;
|
|
|
|
if (!sb_rdonly(sb)) {
|
|
spin_lock(&sbi->s_lock);
|
|
sbi->s_mount_state |= EXT2_ERROR_FS;
|
|
es->s_state |= cpu_to_le16(EXT2_ERROR_FS);
|
|
spin_unlock(&sbi->s_lock);
|
|
ext2_sync_super(sb, es, 1);
|
|
}
|
|
|
|
va_start(args, fmt);
|
|
|
|
vaf.fmt = fmt;
|
|
vaf.va = &args;
|
|
|
|
printk(KERN_CRIT "EXT2-fs (%s): error: %s: %pV\n",
|
|
sb->s_id, function, &vaf);
|
|
|
|
va_end(args);
|
|
|
|
if (test_opt(sb, ERRORS_PANIC))
|
|
panic("EXT2-fs: panic from previous error\n");
|
|
if (!sb_rdonly(sb) && test_opt(sb, ERRORS_RO)) {
|
|
ext2_msg(sb, KERN_CRIT,
|
|
"error: remounting filesystem read-only");
|
|
sb->s_flags |= SB_RDONLY;
|
|
}
|
|
}
|
|
|
|
void ext2_msg(struct super_block *sb, const char *prefix,
|
|
const char *fmt, ...)
|
|
{
|
|
struct va_format vaf;
|
|
va_list args;
|
|
|
|
va_start(args, fmt);
|
|
|
|
vaf.fmt = fmt;
|
|
vaf.va = &args;
|
|
|
|
printk("%sEXT2-fs (%s): %pV\n", prefix, sb->s_id, &vaf);
|
|
|
|
va_end(args);
|
|
}
|
|
|
|
/*
|
|
* This must be called with sbi->s_lock held.
|
|
*/
|
|
void ext2_update_dynamic_rev(struct super_block *sb)
|
|
{
|
|
struct ext2_super_block *es = EXT2_SB(sb)->s_es;
|
|
|
|
if (le32_to_cpu(es->s_rev_level) > EXT2_GOOD_OLD_REV)
|
|
return;
|
|
|
|
ext2_msg(sb, KERN_WARNING,
|
|
"warning: updating to rev %d because of "
|
|
"new feature flag, running e2fsck is recommended",
|
|
EXT2_DYNAMIC_REV);
|
|
|
|
es->s_first_ino = cpu_to_le32(EXT2_GOOD_OLD_FIRST_INO);
|
|
es->s_inode_size = cpu_to_le16(EXT2_GOOD_OLD_INODE_SIZE);
|
|
es->s_rev_level = cpu_to_le32(EXT2_DYNAMIC_REV);
|
|
/* leave es->s_feature_*compat flags alone */
|
|
/* es->s_uuid will be set by e2fsck if empty */
|
|
|
|
/*
|
|
* The rest of the superblock fields should be zero, and if not it
|
|
* means they are likely already in use, so leave them alone. We
|
|
* can leave it up to e2fsck to clean up any inconsistencies there.
|
|
*/
|
|
}
|
|
|
|
#ifdef CONFIG_QUOTA
|
|
static int ext2_quota_off(struct super_block *sb, int type);
|
|
|
|
static void ext2_quota_off_umount(struct super_block *sb)
|
|
{
|
|
int type;
|
|
|
|
for (type = 0; type < MAXQUOTAS; type++)
|
|
ext2_quota_off(sb, type);
|
|
}
|
|
#else
|
|
static inline void ext2_quota_off_umount(struct super_block *sb)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
static void ext2_put_super (struct super_block * sb)
|
|
{
|
|
int db_count;
|
|
int i;
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
|
|
|
ext2_quota_off_umount(sb);
|
|
|
|
ext2_xattr_destroy_cache(sbi->s_ea_block_cache);
|
|
sbi->s_ea_block_cache = NULL;
|
|
|
|
if (!sb_rdonly(sb)) {
|
|
struct ext2_super_block *es = sbi->s_es;
|
|
|
|
spin_lock(&sbi->s_lock);
|
|
es->s_state = cpu_to_le16(sbi->s_mount_state);
|
|
spin_unlock(&sbi->s_lock);
|
|
ext2_sync_super(sb, es, 1);
|
|
}
|
|
db_count = sbi->s_gdb_count;
|
|
for (i = 0; i < db_count; i++)
|
|
brelse(sbi->s_group_desc[i]);
|
|
kvfree(sbi->s_group_desc);
|
|
kfree(sbi->s_debts);
|
|
percpu_counter_destroy(&sbi->s_freeblocks_counter);
|
|
percpu_counter_destroy(&sbi->s_freeinodes_counter);
|
|
percpu_counter_destroy(&sbi->s_dirs_counter);
|
|
brelse (sbi->s_sbh);
|
|
sb->s_fs_info = NULL;
|
|
kfree(sbi->s_blockgroup_lock);
|
|
fs_put_dax(sbi->s_daxdev);
|
|
kfree(sbi);
|
|
}
|
|
|
|
static struct kmem_cache * ext2_inode_cachep;
|
|
|
|
static struct inode *ext2_alloc_inode(struct super_block *sb)
|
|
{
|
|
struct ext2_inode_info *ei;
|
|
ei = kmem_cache_alloc(ext2_inode_cachep, GFP_KERNEL);
|
|
if (!ei)
|
|
return NULL;
|
|
ei->i_block_alloc_info = NULL;
|
|
inode_set_iversion(&ei->vfs_inode, 1);
|
|
#ifdef CONFIG_QUOTA
|
|
memset(&ei->i_dquot, 0, sizeof(ei->i_dquot));
|
|
#endif
|
|
|
|
return &ei->vfs_inode;
|
|
}
|
|
|
|
static void ext2_free_in_core_inode(struct inode *inode)
|
|
{
|
|
kmem_cache_free(ext2_inode_cachep, EXT2_I(inode));
|
|
}
|
|
|
|
static void init_once(void *foo)
|
|
{
|
|
struct ext2_inode_info *ei = (struct ext2_inode_info *) foo;
|
|
|
|
rwlock_init(&ei->i_meta_lock);
|
|
#ifdef CONFIG_EXT2_FS_XATTR
|
|
init_rwsem(&ei->xattr_sem);
|
|
#endif
|
|
mutex_init(&ei->truncate_mutex);
|
|
inode_init_once(&ei->vfs_inode);
|
|
}
|
|
|
|
static int __init init_inodecache(void)
|
|
{
|
|
ext2_inode_cachep = kmem_cache_create_usercopy("ext2_inode_cache",
|
|
sizeof(struct ext2_inode_info), 0,
|
|
(SLAB_RECLAIM_ACCOUNT|SLAB_MEM_SPREAD|
|
|
SLAB_ACCOUNT),
|
|
offsetof(struct ext2_inode_info, i_data),
|
|
sizeof_field(struct ext2_inode_info, i_data),
|
|
init_once);
|
|
if (ext2_inode_cachep == NULL)
|
|
return -ENOMEM;
|
|
return 0;
|
|
}
|
|
|
|
static void destroy_inodecache(void)
|
|
{
|
|
/*
|
|
* Make sure all delayed rcu free inodes are flushed before we
|
|
* destroy cache.
|
|
*/
|
|
rcu_barrier();
|
|
kmem_cache_destroy(ext2_inode_cachep);
|
|
}
|
|
|
|
static int ext2_show_options(struct seq_file *seq, struct dentry *root)
|
|
{
|
|
struct super_block *sb = root->d_sb;
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
|
struct ext2_super_block *es = sbi->s_es;
|
|
unsigned long def_mount_opts;
|
|
|
|
spin_lock(&sbi->s_lock);
|
|
def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
|
|
|
|
if (sbi->s_sb_block != 1)
|
|
seq_printf(seq, ",sb=%lu", sbi->s_sb_block);
|
|
if (test_opt(sb, MINIX_DF))
|
|
seq_puts(seq, ",minixdf");
|
|
if (test_opt(sb, GRPID))
|
|
seq_puts(seq, ",grpid");
|
|
if (!test_opt(sb, GRPID) && (def_mount_opts & EXT2_DEFM_BSDGROUPS))
|
|
seq_puts(seq, ",nogrpid");
|
|
if (!uid_eq(sbi->s_resuid, make_kuid(&init_user_ns, EXT2_DEF_RESUID)) ||
|
|
le16_to_cpu(es->s_def_resuid) != EXT2_DEF_RESUID) {
|
|
seq_printf(seq, ",resuid=%u",
|
|
from_kuid_munged(&init_user_ns, sbi->s_resuid));
|
|
}
|
|
if (!gid_eq(sbi->s_resgid, make_kgid(&init_user_ns, EXT2_DEF_RESGID)) ||
|
|
le16_to_cpu(es->s_def_resgid) != EXT2_DEF_RESGID) {
|
|
seq_printf(seq, ",resgid=%u",
|
|
from_kgid_munged(&init_user_ns, sbi->s_resgid));
|
|
}
|
|
if (test_opt(sb, ERRORS_RO)) {
|
|
int def_errors = le16_to_cpu(es->s_errors);
|
|
|
|
if (def_errors == EXT2_ERRORS_PANIC ||
|
|
def_errors == EXT2_ERRORS_CONTINUE) {
|
|
seq_puts(seq, ",errors=remount-ro");
|
|
}
|
|
}
|
|
if (test_opt(sb, ERRORS_CONT))
|
|
seq_puts(seq, ",errors=continue");
|
|
if (test_opt(sb, ERRORS_PANIC))
|
|
seq_puts(seq, ",errors=panic");
|
|
if (test_opt(sb, NO_UID32))
|
|
seq_puts(seq, ",nouid32");
|
|
if (test_opt(sb, DEBUG))
|
|
seq_puts(seq, ",debug");
|
|
if (test_opt(sb, OLDALLOC))
|
|
seq_puts(seq, ",oldalloc");
|
|
|
|
#ifdef CONFIG_EXT2_FS_XATTR
|
|
if (test_opt(sb, XATTR_USER))
|
|
seq_puts(seq, ",user_xattr");
|
|
if (!test_opt(sb, XATTR_USER) &&
|
|
(def_mount_opts & EXT2_DEFM_XATTR_USER)) {
|
|
seq_puts(seq, ",nouser_xattr");
|
|
}
|
|
#endif
|
|
|
|
#ifdef CONFIG_EXT2_FS_POSIX_ACL
|
|
if (test_opt(sb, POSIX_ACL))
|
|
seq_puts(seq, ",acl");
|
|
if (!test_opt(sb, POSIX_ACL) && (def_mount_opts & EXT2_DEFM_ACL))
|
|
seq_puts(seq, ",noacl");
|
|
#endif
|
|
|
|
if (test_opt(sb, NOBH))
|
|
seq_puts(seq, ",nobh");
|
|
|
|
if (test_opt(sb, USRQUOTA))
|
|
seq_puts(seq, ",usrquota");
|
|
|
|
if (test_opt(sb, GRPQUOTA))
|
|
seq_puts(seq, ",grpquota");
|
|
|
|
if (test_opt(sb, XIP))
|
|
seq_puts(seq, ",xip");
|
|
|
|
if (test_opt(sb, DAX))
|
|
seq_puts(seq, ",dax");
|
|
|
|
if (!test_opt(sb, RESERVATION))
|
|
seq_puts(seq, ",noreservation");
|
|
|
|
spin_unlock(&sbi->s_lock);
|
|
return 0;
|
|
}
|
|
|
|
#ifdef CONFIG_QUOTA
|
|
static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data, size_t len, loff_t off);
|
|
static ssize_t ext2_quota_write(struct super_block *sb, int type, const char *data, size_t len, loff_t off);
|
|
static int ext2_quota_on(struct super_block *sb, int type, int format_id,
|
|
const struct path *path);
|
|
static struct dquot **ext2_get_dquots(struct inode *inode)
|
|
{
|
|
return EXT2_I(inode)->i_dquot;
|
|
}
|
|
|
|
static const struct quotactl_ops ext2_quotactl_ops = {
|
|
.quota_on = ext2_quota_on,
|
|
.quota_off = ext2_quota_off,
|
|
.quota_sync = dquot_quota_sync,
|
|
.get_state = dquot_get_state,
|
|
.set_info = dquot_set_dqinfo,
|
|
.get_dqblk = dquot_get_dqblk,
|
|
.set_dqblk = dquot_set_dqblk,
|
|
.get_nextdqblk = dquot_get_next_dqblk,
|
|
};
|
|
#endif
|
|
|
|
static const struct super_operations ext2_sops = {
|
|
.alloc_inode = ext2_alloc_inode,
|
|
.free_inode = ext2_free_in_core_inode,
|
|
.write_inode = ext2_write_inode,
|
|
.evict_inode = ext2_evict_inode,
|
|
.put_super = ext2_put_super,
|
|
.sync_fs = ext2_sync_fs,
|
|
.freeze_fs = ext2_freeze,
|
|
.unfreeze_fs = ext2_unfreeze,
|
|
.statfs = ext2_statfs,
|
|
.remount_fs = ext2_remount,
|
|
.show_options = ext2_show_options,
|
|
#ifdef CONFIG_QUOTA
|
|
.quota_read = ext2_quota_read,
|
|
.quota_write = ext2_quota_write,
|
|
.get_dquots = ext2_get_dquots,
|
|
#endif
|
|
};
|
|
|
|
static struct inode *ext2_nfs_get_inode(struct super_block *sb,
|
|
u64 ino, u32 generation)
|
|
{
|
|
struct inode *inode;
|
|
|
|
if (ino < EXT2_FIRST_INO(sb) && ino != EXT2_ROOT_INO)
|
|
return ERR_PTR(-ESTALE);
|
|
if (ino > le32_to_cpu(EXT2_SB(sb)->s_es->s_inodes_count))
|
|
return ERR_PTR(-ESTALE);
|
|
|
|
/*
|
|
* ext2_iget isn't quite right if the inode is currently unallocated!
|
|
* However ext2_iget currently does appropriate checks to handle stale
|
|
* inodes so everything is OK.
|
|
*/
|
|
inode = ext2_iget(sb, ino);
|
|
if (IS_ERR(inode))
|
|
return ERR_CAST(inode);
|
|
if (generation && inode->i_generation != generation) {
|
|
/* we didn't find the right inode.. */
|
|
iput(inode);
|
|
return ERR_PTR(-ESTALE);
|
|
}
|
|
return inode;
|
|
}
|
|
|
|
static struct dentry *ext2_fh_to_dentry(struct super_block *sb, struct fid *fid,
|
|
int fh_len, int fh_type)
|
|
{
|
|
return generic_fh_to_dentry(sb, fid, fh_len, fh_type,
|
|
ext2_nfs_get_inode);
|
|
}
|
|
|
|
static struct dentry *ext2_fh_to_parent(struct super_block *sb, struct fid *fid,
|
|
int fh_len, int fh_type)
|
|
{
|
|
return generic_fh_to_parent(sb, fid, fh_len, fh_type,
|
|
ext2_nfs_get_inode);
|
|
}
|
|
|
|
static const struct export_operations ext2_export_ops = {
|
|
.fh_to_dentry = ext2_fh_to_dentry,
|
|
.fh_to_parent = ext2_fh_to_parent,
|
|
.get_parent = ext2_get_parent,
|
|
};
|
|
|
|
static unsigned long get_sb_block(void **data)
|
|
{
|
|
unsigned long sb_block;
|
|
char *options = (char *) *data;
|
|
|
|
if (!options || strncmp(options, "sb=", 3) != 0)
|
|
return 1; /* Default location */
|
|
options += 3;
|
|
sb_block = simple_strtoul(options, &options, 0);
|
|
if (*options && *options != ',') {
|
|
printk("EXT2-fs: Invalid sb specification: %s\n",
|
|
(char *) *data);
|
|
return 1;
|
|
}
|
|
if (*options == ',')
|
|
options++;
|
|
*data = (void *) options;
|
|
return sb_block;
|
|
}
|
|
|
|
enum {
|
|
Opt_bsd_df, Opt_minix_df, Opt_grpid, Opt_nogrpid,
|
|
Opt_resgid, Opt_resuid, Opt_sb, Opt_err_cont, Opt_err_panic,
|
|
Opt_err_ro, Opt_nouid32, Opt_debug,
|
|
Opt_oldalloc, Opt_orlov, Opt_nobh, Opt_user_xattr, Opt_nouser_xattr,
|
|
Opt_acl, Opt_noacl, Opt_xip, Opt_dax, Opt_ignore, Opt_err, Opt_quota,
|
|
Opt_usrquota, Opt_grpquota, Opt_reservation, Opt_noreservation
|
|
};
|
|
|
|
static const match_table_t tokens = {
|
|
{Opt_bsd_df, "bsddf"},
|
|
{Opt_minix_df, "minixdf"},
|
|
{Opt_grpid, "grpid"},
|
|
{Opt_grpid, "bsdgroups"},
|
|
{Opt_nogrpid, "nogrpid"},
|
|
{Opt_nogrpid, "sysvgroups"},
|
|
{Opt_resgid, "resgid=%u"},
|
|
{Opt_resuid, "resuid=%u"},
|
|
{Opt_sb, "sb=%u"},
|
|
{Opt_err_cont, "errors=continue"},
|
|
{Opt_err_panic, "errors=panic"},
|
|
{Opt_err_ro, "errors=remount-ro"},
|
|
{Opt_nouid32, "nouid32"},
|
|
{Opt_debug, "debug"},
|
|
{Opt_oldalloc, "oldalloc"},
|
|
{Opt_orlov, "orlov"},
|
|
{Opt_nobh, "nobh"},
|
|
{Opt_user_xattr, "user_xattr"},
|
|
{Opt_nouser_xattr, "nouser_xattr"},
|
|
{Opt_acl, "acl"},
|
|
{Opt_noacl, "noacl"},
|
|
{Opt_xip, "xip"},
|
|
{Opt_dax, "dax"},
|
|
{Opt_grpquota, "grpquota"},
|
|
{Opt_ignore, "noquota"},
|
|
{Opt_quota, "quota"},
|
|
{Opt_usrquota, "usrquota"},
|
|
{Opt_reservation, "reservation"},
|
|
{Opt_noreservation, "noreservation"},
|
|
{Opt_err, NULL}
|
|
};
|
|
|
|
static int parse_options(char *options, struct super_block *sb,
|
|
struct ext2_mount_options *opts)
|
|
{
|
|
char *p;
|
|
substring_t args[MAX_OPT_ARGS];
|
|
int option;
|
|
kuid_t uid;
|
|
kgid_t gid;
|
|
|
|
if (!options)
|
|
return 1;
|
|
|
|
while ((p = strsep (&options, ",")) != NULL) {
|
|
int token;
|
|
if (!*p)
|
|
continue;
|
|
|
|
token = match_token(p, tokens, args);
|
|
switch (token) {
|
|
case Opt_bsd_df:
|
|
clear_opt (opts->s_mount_opt, MINIX_DF);
|
|
break;
|
|
case Opt_minix_df:
|
|
set_opt (opts->s_mount_opt, MINIX_DF);
|
|
break;
|
|
case Opt_grpid:
|
|
set_opt (opts->s_mount_opt, GRPID);
|
|
break;
|
|
case Opt_nogrpid:
|
|
clear_opt (opts->s_mount_opt, GRPID);
|
|
break;
|
|
case Opt_resuid:
|
|
if (match_int(&args[0], &option))
|
|
return 0;
|
|
uid = make_kuid(current_user_ns(), option);
|
|
if (!uid_valid(uid)) {
|
|
ext2_msg(sb, KERN_ERR, "Invalid uid value %d", option);
|
|
return 0;
|
|
|
|
}
|
|
opts->s_resuid = uid;
|
|
break;
|
|
case Opt_resgid:
|
|
if (match_int(&args[0], &option))
|
|
return 0;
|
|
gid = make_kgid(current_user_ns(), option);
|
|
if (!gid_valid(gid)) {
|
|
ext2_msg(sb, KERN_ERR, "Invalid gid value %d", option);
|
|
return 0;
|
|
}
|
|
opts->s_resgid = gid;
|
|
break;
|
|
case Opt_sb:
|
|
/* handled by get_sb_block() instead of here */
|
|
/* *sb_block = match_int(&args[0]); */
|
|
break;
|
|
case Opt_err_panic:
|
|
clear_opt (opts->s_mount_opt, ERRORS_CONT);
|
|
clear_opt (opts->s_mount_opt, ERRORS_RO);
|
|
set_opt (opts->s_mount_opt, ERRORS_PANIC);
|
|
break;
|
|
case Opt_err_ro:
|
|
clear_opt (opts->s_mount_opt, ERRORS_CONT);
|
|
clear_opt (opts->s_mount_opt, ERRORS_PANIC);
|
|
set_opt (opts->s_mount_opt, ERRORS_RO);
|
|
break;
|
|
case Opt_err_cont:
|
|
clear_opt (opts->s_mount_opt, ERRORS_RO);
|
|
clear_opt (opts->s_mount_opt, ERRORS_PANIC);
|
|
set_opt (opts->s_mount_opt, ERRORS_CONT);
|
|
break;
|
|
case Opt_nouid32:
|
|
set_opt (opts->s_mount_opt, NO_UID32);
|
|
break;
|
|
case Opt_debug:
|
|
set_opt (opts->s_mount_opt, DEBUG);
|
|
break;
|
|
case Opt_oldalloc:
|
|
set_opt (opts->s_mount_opt, OLDALLOC);
|
|
break;
|
|
case Opt_orlov:
|
|
clear_opt (opts->s_mount_opt, OLDALLOC);
|
|
break;
|
|
case Opt_nobh:
|
|
set_opt (opts->s_mount_opt, NOBH);
|
|
break;
|
|
#ifdef CONFIG_EXT2_FS_XATTR
|
|
case Opt_user_xattr:
|
|
set_opt (opts->s_mount_opt, XATTR_USER);
|
|
break;
|
|
case Opt_nouser_xattr:
|
|
clear_opt (opts->s_mount_opt, XATTR_USER);
|
|
break;
|
|
#else
|
|
case Opt_user_xattr:
|
|
case Opt_nouser_xattr:
|
|
ext2_msg(sb, KERN_INFO, "(no)user_xattr options"
|
|
"not supported");
|
|
break;
|
|
#endif
|
|
#ifdef CONFIG_EXT2_FS_POSIX_ACL
|
|
case Opt_acl:
|
|
set_opt(opts->s_mount_opt, POSIX_ACL);
|
|
break;
|
|
case Opt_noacl:
|
|
clear_opt(opts->s_mount_opt, POSIX_ACL);
|
|
break;
|
|
#else
|
|
case Opt_acl:
|
|
case Opt_noacl:
|
|
ext2_msg(sb, KERN_INFO,
|
|
"(no)acl options not supported");
|
|
break;
|
|
#endif
|
|
case Opt_xip:
|
|
ext2_msg(sb, KERN_INFO, "use dax instead of xip");
|
|
set_opt(opts->s_mount_opt, XIP);
|
|
fallthrough;
|
|
case Opt_dax:
|
|
#ifdef CONFIG_FS_DAX
|
|
ext2_msg(sb, KERN_WARNING,
|
|
"DAX enabled. Warning: EXPERIMENTAL, use at your own risk");
|
|
set_opt(opts->s_mount_opt, DAX);
|
|
#else
|
|
ext2_msg(sb, KERN_INFO, "dax option not supported");
|
|
#endif
|
|
break;
|
|
|
|
#if defined(CONFIG_QUOTA)
|
|
case Opt_quota:
|
|
case Opt_usrquota:
|
|
set_opt(opts->s_mount_opt, USRQUOTA);
|
|
break;
|
|
|
|
case Opt_grpquota:
|
|
set_opt(opts->s_mount_opt, GRPQUOTA);
|
|
break;
|
|
#else
|
|
case Opt_quota:
|
|
case Opt_usrquota:
|
|
case Opt_grpquota:
|
|
ext2_msg(sb, KERN_INFO,
|
|
"quota operations not supported");
|
|
break;
|
|
#endif
|
|
|
|
case Opt_reservation:
|
|
set_opt(opts->s_mount_opt, RESERVATION);
|
|
ext2_msg(sb, KERN_INFO, "reservations ON");
|
|
break;
|
|
case Opt_noreservation:
|
|
clear_opt(opts->s_mount_opt, RESERVATION);
|
|
ext2_msg(sb, KERN_INFO, "reservations OFF");
|
|
break;
|
|
case Opt_ignore:
|
|
break;
|
|
default:
|
|
return 0;
|
|
}
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
static int ext2_setup_super (struct super_block * sb,
|
|
struct ext2_super_block * es,
|
|
int read_only)
|
|
{
|
|
int res = 0;
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
|
|
|
if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) {
|
|
ext2_msg(sb, KERN_ERR,
|
|
"error: revision level too high, "
|
|
"forcing read-only mode");
|
|
res = SB_RDONLY;
|
|
}
|
|
if (read_only)
|
|
return res;
|
|
if (!(sbi->s_mount_state & EXT2_VALID_FS))
|
|
ext2_msg(sb, KERN_WARNING,
|
|
"warning: mounting unchecked fs, "
|
|
"running e2fsck is recommended");
|
|
else if ((sbi->s_mount_state & EXT2_ERROR_FS))
|
|
ext2_msg(sb, KERN_WARNING,
|
|
"warning: mounting fs with errors, "
|
|
"running e2fsck is recommended");
|
|
else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
|
|
le16_to_cpu(es->s_mnt_count) >=
|
|
(unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
|
|
ext2_msg(sb, KERN_WARNING,
|
|
"warning: maximal mount count reached, "
|
|
"running e2fsck is recommended");
|
|
else if (le32_to_cpu(es->s_checkinterval) &&
|
|
(le32_to_cpu(es->s_lastcheck) +
|
|
le32_to_cpu(es->s_checkinterval) <=
|
|
ktime_get_real_seconds()))
|
|
ext2_msg(sb, KERN_WARNING,
|
|
"warning: checktime reached, "
|
|
"running e2fsck is recommended");
|
|
if (!le16_to_cpu(es->s_max_mnt_count))
|
|
es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT);
|
|
le16_add_cpu(&es->s_mnt_count, 1);
|
|
if (test_opt (sb, DEBUG))
|
|
ext2_msg(sb, KERN_INFO, "%s, %s, bs=%lu, fs=%lu, gc=%lu, "
|
|
"bpg=%lu, ipg=%lu, mo=%04lx]",
|
|
EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize,
|
|
sbi->s_frag_size,
|
|
sbi->s_groups_count,
|
|
EXT2_BLOCKS_PER_GROUP(sb),
|
|
EXT2_INODES_PER_GROUP(sb),
|
|
sbi->s_mount_opt);
|
|
return res;
|
|
}
|
|
|
|
static int ext2_check_descriptors(struct super_block *sb)
|
|
{
|
|
int i;
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
|
|
|
ext2_debug ("Checking group descriptors");
|
|
|
|
for (i = 0; i < sbi->s_groups_count; i++) {
|
|
struct ext2_group_desc *gdp = ext2_get_group_desc(sb, i, NULL);
|
|
ext2_fsblk_t first_block = ext2_group_first_block_no(sb, i);
|
|
ext2_fsblk_t last_block = ext2_group_last_block_no(sb, i);
|
|
|
|
if (le32_to_cpu(gdp->bg_block_bitmap) < first_block ||
|
|
le32_to_cpu(gdp->bg_block_bitmap) > last_block)
|
|
{
|
|
ext2_error (sb, "ext2_check_descriptors",
|
|
"Block bitmap for group %d"
|
|
" not in group (block %lu)!",
|
|
i, (unsigned long) le32_to_cpu(gdp->bg_block_bitmap));
|
|
return 0;
|
|
}
|
|
if (le32_to_cpu(gdp->bg_inode_bitmap) < first_block ||
|
|
le32_to_cpu(gdp->bg_inode_bitmap) > last_block)
|
|
{
|
|
ext2_error (sb, "ext2_check_descriptors",
|
|
"Inode bitmap for group %d"
|
|
" not in group (block %lu)!",
|
|
i, (unsigned long) le32_to_cpu(gdp->bg_inode_bitmap));
|
|
return 0;
|
|
}
|
|
if (le32_to_cpu(gdp->bg_inode_table) < first_block ||
|
|
le32_to_cpu(gdp->bg_inode_table) + sbi->s_itb_per_group - 1 >
|
|
last_block)
|
|
{
|
|
ext2_error (sb, "ext2_check_descriptors",
|
|
"Inode table for group %d"
|
|
" not in group (block %lu)!",
|
|
i, (unsigned long) le32_to_cpu(gdp->bg_inode_table));
|
|
return 0;
|
|
}
|
|
}
|
|
return 1;
|
|
}
|
|
|
|
/*
|
|
* Maximal file size. There is a direct, and {,double-,triple-}indirect
|
|
* block limit, and also a limit of (2^32 - 1) 512-byte sectors in i_blocks.
|
|
* We need to be 1 filesystem block less than the 2^32 sector limit.
|
|
*/
|
|
static loff_t ext2_max_size(int bits)
|
|
{
|
|
loff_t res = EXT2_NDIR_BLOCKS;
|
|
int meta_blocks;
|
|
unsigned int upper_limit;
|
|
unsigned int ppb = 1 << (bits-2);
|
|
|
|
/* This is calculated to be the largest file size for a
|
|
* dense, file such that the total number of
|
|
* sectors in the file, including data and all indirect blocks,
|
|
* does not exceed 2^32 -1
|
|
* __u32 i_blocks representing the total number of
|
|
* 512 bytes blocks of the file
|
|
*/
|
|
upper_limit = (1LL << 32) - 1;
|
|
|
|
/* total blocks in file system block size */
|
|
upper_limit >>= (bits - 9);
|
|
|
|
/* Compute how many blocks we can address by block tree */
|
|
res += 1LL << (bits-2);
|
|
res += 1LL << (2*(bits-2));
|
|
res += 1LL << (3*(bits-2));
|
|
/* Compute how many metadata blocks are needed */
|
|
meta_blocks = 1;
|
|
meta_blocks += 1 + ppb;
|
|
meta_blocks += 1 + ppb + ppb * ppb;
|
|
/* Does block tree limit file size? */
|
|
if (res + meta_blocks <= upper_limit)
|
|
goto check_lfs;
|
|
|
|
res = upper_limit;
|
|
/* How many metadata blocks are needed for addressing upper_limit? */
|
|
upper_limit -= EXT2_NDIR_BLOCKS;
|
|
/* indirect blocks */
|
|
meta_blocks = 1;
|
|
upper_limit -= ppb;
|
|
/* double indirect blocks */
|
|
if (upper_limit < ppb * ppb) {
|
|
meta_blocks += 1 + DIV_ROUND_UP(upper_limit, ppb);
|
|
res -= meta_blocks;
|
|
goto check_lfs;
|
|
}
|
|
meta_blocks += 1 + ppb;
|
|
upper_limit -= ppb * ppb;
|
|
/* tripple indirect blocks for the rest */
|
|
meta_blocks += 1 + DIV_ROUND_UP(upper_limit, ppb) +
|
|
DIV_ROUND_UP(upper_limit, ppb*ppb);
|
|
res -= meta_blocks;
|
|
check_lfs:
|
|
res <<= bits;
|
|
if (res > MAX_LFS_FILESIZE)
|
|
res = MAX_LFS_FILESIZE;
|
|
|
|
return res;
|
|
}
|
|
|
|
static unsigned long descriptor_loc(struct super_block *sb,
|
|
unsigned long logic_sb_block,
|
|
int nr)
|
|
{
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
|
unsigned long bg, first_meta_bg;
|
|
|
|
first_meta_bg = le32_to_cpu(sbi->s_es->s_first_meta_bg);
|
|
|
|
if (!EXT2_HAS_INCOMPAT_FEATURE(sb, EXT2_FEATURE_INCOMPAT_META_BG) ||
|
|
nr < first_meta_bg)
|
|
return (logic_sb_block + nr + 1);
|
|
bg = sbi->s_desc_per_block * nr;
|
|
|
|
return ext2_group_first_block_no(sb, bg) + ext2_bg_has_super(sb, bg);
|
|
}
|
|
|
|
static int ext2_fill_super(struct super_block *sb, void *data, int silent)
|
|
{
|
|
struct dax_device *dax_dev = fs_dax_get_by_bdev(sb->s_bdev);
|
|
struct buffer_head * bh;
|
|
struct ext2_sb_info * sbi;
|
|
struct ext2_super_block * es;
|
|
struct inode *root;
|
|
unsigned long block;
|
|
unsigned long sb_block = get_sb_block(&data);
|
|
unsigned long logic_sb_block;
|
|
unsigned long offset = 0;
|
|
unsigned long def_mount_opts;
|
|
long ret = -ENOMEM;
|
|
int blocksize = BLOCK_SIZE;
|
|
int db_count;
|
|
int i, j;
|
|
__le32 features;
|
|
int err;
|
|
struct ext2_mount_options opts;
|
|
|
|
sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
|
|
if (!sbi)
|
|
goto failed;
|
|
|
|
sbi->s_blockgroup_lock =
|
|
kzalloc(sizeof(struct blockgroup_lock), GFP_KERNEL);
|
|
if (!sbi->s_blockgroup_lock) {
|
|
kfree(sbi);
|
|
goto failed;
|
|
}
|
|
sb->s_fs_info = sbi;
|
|
sbi->s_sb_block = sb_block;
|
|
sbi->s_daxdev = dax_dev;
|
|
|
|
spin_lock_init(&sbi->s_lock);
|
|
ret = -EINVAL;
|
|
|
|
/*
|
|
* See what the current blocksize for the device is, and
|
|
* use that as the blocksize. Otherwise (or if the blocksize
|
|
* is smaller than the default) use the default.
|
|
* This is important for devices that have a hardware
|
|
* sectorsize that is larger than the default.
|
|
*/
|
|
blocksize = sb_min_blocksize(sb, BLOCK_SIZE);
|
|
if (!blocksize) {
|
|
ext2_msg(sb, KERN_ERR, "error: unable to set blocksize");
|
|
goto failed_sbi;
|
|
}
|
|
|
|
/*
|
|
* If the superblock doesn't start on a hardware sector boundary,
|
|
* calculate the offset.
|
|
*/
|
|
if (blocksize != BLOCK_SIZE) {
|
|
logic_sb_block = (sb_block*BLOCK_SIZE) / blocksize;
|
|
offset = (sb_block*BLOCK_SIZE) % blocksize;
|
|
} else {
|
|
logic_sb_block = sb_block;
|
|
}
|
|
|
|
if (!(bh = sb_bread(sb, logic_sb_block))) {
|
|
ext2_msg(sb, KERN_ERR, "error: unable to read superblock");
|
|
goto failed_sbi;
|
|
}
|
|
/*
|
|
* Note: s_es must be initialized as soon as possible because
|
|
* some ext2 macro-instructions depend on its value
|
|
*/
|
|
es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
|
|
sbi->s_es = es;
|
|
sb->s_magic = le16_to_cpu(es->s_magic);
|
|
|
|
if (sb->s_magic != EXT2_SUPER_MAGIC)
|
|
goto cantfind_ext2;
|
|
|
|
opts.s_mount_opt = 0;
|
|
/* Set defaults before we parse the mount options */
|
|
def_mount_opts = le32_to_cpu(es->s_default_mount_opts);
|
|
if (def_mount_opts & EXT2_DEFM_DEBUG)
|
|
set_opt(opts.s_mount_opt, DEBUG);
|
|
if (def_mount_opts & EXT2_DEFM_BSDGROUPS)
|
|
set_opt(opts.s_mount_opt, GRPID);
|
|
if (def_mount_opts & EXT2_DEFM_UID16)
|
|
set_opt(opts.s_mount_opt, NO_UID32);
|
|
#ifdef CONFIG_EXT2_FS_XATTR
|
|
if (def_mount_opts & EXT2_DEFM_XATTR_USER)
|
|
set_opt(opts.s_mount_opt, XATTR_USER);
|
|
#endif
|
|
#ifdef CONFIG_EXT2_FS_POSIX_ACL
|
|
if (def_mount_opts & EXT2_DEFM_ACL)
|
|
set_opt(opts.s_mount_opt, POSIX_ACL);
|
|
#endif
|
|
|
|
if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_PANIC)
|
|
set_opt(opts.s_mount_opt, ERRORS_PANIC);
|
|
else if (le16_to_cpu(sbi->s_es->s_errors) == EXT2_ERRORS_CONTINUE)
|
|
set_opt(opts.s_mount_opt, ERRORS_CONT);
|
|
else
|
|
set_opt(opts.s_mount_opt, ERRORS_RO);
|
|
|
|
opts.s_resuid = make_kuid(&init_user_ns, le16_to_cpu(es->s_def_resuid));
|
|
opts.s_resgid = make_kgid(&init_user_ns, le16_to_cpu(es->s_def_resgid));
|
|
|
|
set_opt(opts.s_mount_opt, RESERVATION);
|
|
|
|
if (!parse_options((char *) data, sb, &opts))
|
|
goto failed_mount;
|
|
|
|
sbi->s_mount_opt = opts.s_mount_opt;
|
|
sbi->s_resuid = opts.s_resuid;
|
|
sbi->s_resgid = opts.s_resgid;
|
|
|
|
sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
|
|
(test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0);
|
|
sb->s_iflags |= SB_I_CGROUPWB;
|
|
|
|
if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV &&
|
|
(EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
|
|
EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
|
|
EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U)))
|
|
ext2_msg(sb, KERN_WARNING,
|
|
"warning: feature flags set on rev 0 fs, "
|
|
"running e2fsck is recommended");
|
|
/*
|
|
* Check feature flags regardless of the revision level, since we
|
|
* previously didn't change the revision level when setting the flags,
|
|
* so there is a chance incompat flags are set on a rev 0 filesystem.
|
|
*/
|
|
features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP);
|
|
if (features) {
|
|
ext2_msg(sb, KERN_ERR, "error: couldn't mount because of "
|
|
"unsupported optional features (%x)",
|
|
le32_to_cpu(features));
|
|
goto failed_mount;
|
|
}
|
|
if (!sb_rdonly(sb) && (features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){
|
|
ext2_msg(sb, KERN_ERR, "error: couldn't mount RDWR because of "
|
|
"unsupported optional features (%x)",
|
|
le32_to_cpu(features));
|
|
goto failed_mount;
|
|
}
|
|
|
|
blocksize = BLOCK_SIZE << le32_to_cpu(sbi->s_es->s_log_block_size);
|
|
|
|
if (test_opt(sb, DAX)) {
|
|
if (!dax_supported(dax_dev, sb->s_bdev, blocksize, 0,
|
|
bdev_nr_sectors(sb->s_bdev))) {
|
|
ext2_msg(sb, KERN_ERR,
|
|
"DAX unsupported by block device. Turning off DAX.");
|
|
clear_opt(sbi->s_mount_opt, DAX);
|
|
}
|
|
}
|
|
|
|
/* If the blocksize doesn't match, re-read the thing.. */
|
|
if (sb->s_blocksize != blocksize) {
|
|
brelse(bh);
|
|
|
|
if (!sb_set_blocksize(sb, blocksize)) {
|
|
ext2_msg(sb, KERN_ERR,
|
|
"error: bad blocksize %d", blocksize);
|
|
goto failed_sbi;
|
|
}
|
|
|
|
logic_sb_block = (sb_block*BLOCK_SIZE) / blocksize;
|
|
offset = (sb_block*BLOCK_SIZE) % blocksize;
|
|
bh = sb_bread(sb, logic_sb_block);
|
|
if(!bh) {
|
|
ext2_msg(sb, KERN_ERR, "error: couldn't read"
|
|
"superblock on 2nd try");
|
|
goto failed_sbi;
|
|
}
|
|
es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
|
|
sbi->s_es = es;
|
|
if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) {
|
|
ext2_msg(sb, KERN_ERR, "error: magic mismatch");
|
|
goto failed_mount;
|
|
}
|
|
}
|
|
|
|
sb->s_maxbytes = ext2_max_size(sb->s_blocksize_bits);
|
|
sb->s_max_links = EXT2_LINK_MAX;
|
|
sb->s_time_min = S32_MIN;
|
|
sb->s_time_max = S32_MAX;
|
|
|
|
if (le32_to_cpu(es->s_rev_level) == EXT2_GOOD_OLD_REV) {
|
|
sbi->s_inode_size = EXT2_GOOD_OLD_INODE_SIZE;
|
|
sbi->s_first_ino = EXT2_GOOD_OLD_FIRST_INO;
|
|
} else {
|
|
sbi->s_inode_size = le16_to_cpu(es->s_inode_size);
|
|
sbi->s_first_ino = le32_to_cpu(es->s_first_ino);
|
|
if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) ||
|
|
!is_power_of_2(sbi->s_inode_size) ||
|
|
(sbi->s_inode_size > blocksize)) {
|
|
ext2_msg(sb, KERN_ERR,
|
|
"error: unsupported inode size: %d",
|
|
sbi->s_inode_size);
|
|
goto failed_mount;
|
|
}
|
|
}
|
|
|
|
sbi->s_frag_size = EXT2_MIN_FRAG_SIZE <<
|
|
le32_to_cpu(es->s_log_frag_size);
|
|
if (sbi->s_frag_size == 0)
|
|
goto cantfind_ext2;
|
|
sbi->s_frags_per_block = sb->s_blocksize / sbi->s_frag_size;
|
|
|
|
sbi->s_blocks_per_group = le32_to_cpu(es->s_blocks_per_group);
|
|
sbi->s_frags_per_group = le32_to_cpu(es->s_frags_per_group);
|
|
sbi->s_inodes_per_group = le32_to_cpu(es->s_inodes_per_group);
|
|
|
|
sbi->s_inodes_per_block = sb->s_blocksize / EXT2_INODE_SIZE(sb);
|
|
if (sbi->s_inodes_per_block == 0 || sbi->s_inodes_per_group == 0)
|
|
goto cantfind_ext2;
|
|
sbi->s_itb_per_group = sbi->s_inodes_per_group /
|
|
sbi->s_inodes_per_block;
|
|
sbi->s_desc_per_block = sb->s_blocksize /
|
|
sizeof (struct ext2_group_desc);
|
|
sbi->s_sbh = bh;
|
|
sbi->s_mount_state = le16_to_cpu(es->s_state);
|
|
sbi->s_addr_per_block_bits =
|
|
ilog2 (EXT2_ADDR_PER_BLOCK(sb));
|
|
sbi->s_desc_per_block_bits =
|
|
ilog2 (EXT2_DESC_PER_BLOCK(sb));
|
|
|
|
if (sb->s_magic != EXT2_SUPER_MAGIC)
|
|
goto cantfind_ext2;
|
|
|
|
if (sb->s_blocksize != bh->b_size) {
|
|
if (!silent)
|
|
ext2_msg(sb, KERN_ERR, "error: unsupported blocksize");
|
|
goto failed_mount;
|
|
}
|
|
|
|
if (sb->s_blocksize != sbi->s_frag_size) {
|
|
ext2_msg(sb, KERN_ERR,
|
|
"error: fragsize %lu != blocksize %lu"
|
|
"(not supported yet)",
|
|
sbi->s_frag_size, sb->s_blocksize);
|
|
goto failed_mount;
|
|
}
|
|
|
|
if (sbi->s_blocks_per_group > sb->s_blocksize * 8) {
|
|
ext2_msg(sb, KERN_ERR,
|
|
"error: #blocks per group too big: %lu",
|
|
sbi->s_blocks_per_group);
|
|
goto failed_mount;
|
|
}
|
|
if (sbi->s_frags_per_group > sb->s_blocksize * 8) {
|
|
ext2_msg(sb, KERN_ERR,
|
|
"error: #fragments per group too big: %lu",
|
|
sbi->s_frags_per_group);
|
|
goto failed_mount;
|
|
}
|
|
if (sbi->s_inodes_per_group < sbi->s_inodes_per_block ||
|
|
sbi->s_inodes_per_group > sb->s_blocksize * 8) {
|
|
ext2_msg(sb, KERN_ERR,
|
|
"error: invalid #inodes per group: %lu",
|
|
sbi->s_inodes_per_group);
|
|
goto failed_mount;
|
|
}
|
|
|
|
if (EXT2_BLOCKS_PER_GROUP(sb) == 0)
|
|
goto cantfind_ext2;
|
|
sbi->s_groups_count = ((le32_to_cpu(es->s_blocks_count) -
|
|
le32_to_cpu(es->s_first_data_block) - 1)
|
|
/ EXT2_BLOCKS_PER_GROUP(sb)) + 1;
|
|
if ((u64)sbi->s_groups_count * sbi->s_inodes_per_group !=
|
|
le32_to_cpu(es->s_inodes_count)) {
|
|
ext2_msg(sb, KERN_ERR, "error: invalid #inodes: %u vs computed %llu",
|
|
le32_to_cpu(es->s_inodes_count),
|
|
(u64)sbi->s_groups_count * sbi->s_inodes_per_group);
|
|
goto failed_mount;
|
|
}
|
|
db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) /
|
|
EXT2_DESC_PER_BLOCK(sb);
|
|
sbi->s_group_desc = kvmalloc_array(db_count,
|
|
sizeof(struct buffer_head *),
|
|
GFP_KERNEL);
|
|
if (sbi->s_group_desc == NULL) {
|
|
ret = -ENOMEM;
|
|
ext2_msg(sb, KERN_ERR, "error: not enough memory");
|
|
goto failed_mount;
|
|
}
|
|
bgl_lock_init(sbi->s_blockgroup_lock);
|
|
sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL);
|
|
if (!sbi->s_debts) {
|
|
ret = -ENOMEM;
|
|
ext2_msg(sb, KERN_ERR, "error: not enough memory");
|
|
goto failed_mount_group_desc;
|
|
}
|
|
for (i = 0; i < db_count; i++) {
|
|
block = descriptor_loc(sb, logic_sb_block, i);
|
|
sbi->s_group_desc[i] = sb_bread(sb, block);
|
|
if (!sbi->s_group_desc[i]) {
|
|
for (j = 0; j < i; j++)
|
|
brelse (sbi->s_group_desc[j]);
|
|
ext2_msg(sb, KERN_ERR,
|
|
"error: unable to read group descriptors");
|
|
goto failed_mount_group_desc;
|
|
}
|
|
}
|
|
if (!ext2_check_descriptors (sb)) {
|
|
ext2_msg(sb, KERN_ERR, "group descriptors corrupted");
|
|
goto failed_mount2;
|
|
}
|
|
sbi->s_gdb_count = db_count;
|
|
get_random_bytes(&sbi->s_next_generation, sizeof(u32));
|
|
spin_lock_init(&sbi->s_next_gen_lock);
|
|
|
|
/* per filesystem reservation list head & lock */
|
|
spin_lock_init(&sbi->s_rsv_window_lock);
|
|
sbi->s_rsv_window_root = RB_ROOT;
|
|
/*
|
|
* Add a single, static dummy reservation to the start of the
|
|
* reservation window list --- it gives us a placeholder for
|
|
* append-at-start-of-list which makes the allocation logic
|
|
* _much_ simpler.
|
|
*/
|
|
sbi->s_rsv_window_head.rsv_start = EXT2_RESERVE_WINDOW_NOT_ALLOCATED;
|
|
sbi->s_rsv_window_head.rsv_end = EXT2_RESERVE_WINDOW_NOT_ALLOCATED;
|
|
sbi->s_rsv_window_head.rsv_alloc_hit = 0;
|
|
sbi->s_rsv_window_head.rsv_goal_size = 0;
|
|
ext2_rsv_window_add(sb, &sbi->s_rsv_window_head);
|
|
|
|
err = percpu_counter_init(&sbi->s_freeblocks_counter,
|
|
ext2_count_free_blocks(sb), GFP_KERNEL);
|
|
if (!err) {
|
|
err = percpu_counter_init(&sbi->s_freeinodes_counter,
|
|
ext2_count_free_inodes(sb), GFP_KERNEL);
|
|
}
|
|
if (!err) {
|
|
err = percpu_counter_init(&sbi->s_dirs_counter,
|
|
ext2_count_dirs(sb), GFP_KERNEL);
|
|
}
|
|
if (err) {
|
|
ret = err;
|
|
ext2_msg(sb, KERN_ERR, "error: insufficient memory");
|
|
goto failed_mount3;
|
|
}
|
|
|
|
#ifdef CONFIG_EXT2_FS_XATTR
|
|
sbi->s_ea_block_cache = ext2_xattr_create_cache();
|
|
if (!sbi->s_ea_block_cache) {
|
|
ret = -ENOMEM;
|
|
ext2_msg(sb, KERN_ERR, "Failed to create ea_block_cache");
|
|
goto failed_mount3;
|
|
}
|
|
#endif
|
|
/*
|
|
* set up enough so that it can read an inode
|
|
*/
|
|
sb->s_op = &ext2_sops;
|
|
sb->s_export_op = &ext2_export_ops;
|
|
sb->s_xattr = ext2_xattr_handlers;
|
|
|
|
#ifdef CONFIG_QUOTA
|
|
sb->dq_op = &dquot_operations;
|
|
sb->s_qcop = &ext2_quotactl_ops;
|
|
sb->s_quota_types = QTYPE_MASK_USR | QTYPE_MASK_GRP;
|
|
#endif
|
|
|
|
root = ext2_iget(sb, EXT2_ROOT_INO);
|
|
if (IS_ERR(root)) {
|
|
ret = PTR_ERR(root);
|
|
goto failed_mount3;
|
|
}
|
|
if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
|
|
iput(root);
|
|
ext2_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck");
|
|
goto failed_mount3;
|
|
}
|
|
|
|
sb->s_root = d_make_root(root);
|
|
if (!sb->s_root) {
|
|
ext2_msg(sb, KERN_ERR, "error: get root inode failed");
|
|
ret = -ENOMEM;
|
|
goto failed_mount3;
|
|
}
|
|
if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL))
|
|
ext2_msg(sb, KERN_WARNING,
|
|
"warning: mounting ext3 filesystem as ext2");
|
|
if (ext2_setup_super (sb, es, sb_rdonly(sb)))
|
|
sb->s_flags |= SB_RDONLY;
|
|
ext2_write_super(sb);
|
|
return 0;
|
|
|
|
cantfind_ext2:
|
|
if (!silent)
|
|
ext2_msg(sb, KERN_ERR,
|
|
"error: can't find an ext2 filesystem on dev %s.",
|
|
sb->s_id);
|
|
goto failed_mount;
|
|
failed_mount3:
|
|
ext2_xattr_destroy_cache(sbi->s_ea_block_cache);
|
|
percpu_counter_destroy(&sbi->s_freeblocks_counter);
|
|
percpu_counter_destroy(&sbi->s_freeinodes_counter);
|
|
percpu_counter_destroy(&sbi->s_dirs_counter);
|
|
failed_mount2:
|
|
for (i = 0; i < db_count; i++)
|
|
brelse(sbi->s_group_desc[i]);
|
|
failed_mount_group_desc:
|
|
kvfree(sbi->s_group_desc);
|
|
kfree(sbi->s_debts);
|
|
failed_mount:
|
|
brelse(bh);
|
|
failed_sbi:
|
|
sb->s_fs_info = NULL;
|
|
kfree(sbi->s_blockgroup_lock);
|
|
kfree(sbi);
|
|
failed:
|
|
fs_put_dax(dax_dev);
|
|
return ret;
|
|
}
|
|
|
|
static void ext2_clear_super_error(struct super_block *sb)
|
|
{
|
|
struct buffer_head *sbh = EXT2_SB(sb)->s_sbh;
|
|
|
|
if (buffer_write_io_error(sbh)) {
|
|
/*
|
|
* Oh, dear. A previous attempt to write the
|
|
* superblock failed. This could happen because the
|
|
* USB device was yanked out. Or it could happen to
|
|
* be a transient write error and maybe the block will
|
|
* be remapped. Nothing we can do but to retry the
|
|
* write and hope for the best.
|
|
*/
|
|
ext2_msg(sb, KERN_ERR,
|
|
"previous I/O error to superblock detected");
|
|
clear_buffer_write_io_error(sbh);
|
|
set_buffer_uptodate(sbh);
|
|
}
|
|
}
|
|
|
|
void ext2_sync_super(struct super_block *sb, struct ext2_super_block *es,
|
|
int wait)
|
|
{
|
|
ext2_clear_super_error(sb);
|
|
spin_lock(&EXT2_SB(sb)->s_lock);
|
|
es->s_free_blocks_count = cpu_to_le32(ext2_count_free_blocks(sb));
|
|
es->s_free_inodes_count = cpu_to_le32(ext2_count_free_inodes(sb));
|
|
es->s_wtime = cpu_to_le32(ktime_get_real_seconds());
|
|
/* unlock before we do IO */
|
|
spin_unlock(&EXT2_SB(sb)->s_lock);
|
|
mark_buffer_dirty(EXT2_SB(sb)->s_sbh);
|
|
if (wait)
|
|
sync_dirty_buffer(EXT2_SB(sb)->s_sbh);
|
|
}
|
|
|
|
/*
|
|
* In the second extended file system, it is not necessary to
|
|
* write the super block since we use a mapping of the
|
|
* disk super block in a buffer.
|
|
*
|
|
* However, this function is still used to set the fs valid
|
|
* flags to 0. We need to set this flag to 0 since the fs
|
|
* may have been checked while mounted and e2fsck may have
|
|
* set s_state to EXT2_VALID_FS after some corrections.
|
|
*/
|
|
static int ext2_sync_fs(struct super_block *sb, int wait)
|
|
{
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
|
struct ext2_super_block *es = EXT2_SB(sb)->s_es;
|
|
|
|
/*
|
|
* Write quota structures to quota file, sync_blockdev() will write
|
|
* them to disk later
|
|
*/
|
|
dquot_writeback_dquots(sb, -1);
|
|
|
|
spin_lock(&sbi->s_lock);
|
|
if (es->s_state & cpu_to_le16(EXT2_VALID_FS)) {
|
|
ext2_debug("setting valid to 0\n");
|
|
es->s_state &= cpu_to_le16(~EXT2_VALID_FS);
|
|
}
|
|
spin_unlock(&sbi->s_lock);
|
|
ext2_sync_super(sb, es, wait);
|
|
return 0;
|
|
}
|
|
|
|
static int ext2_freeze(struct super_block *sb)
|
|
{
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
|
|
|
/*
|
|
* Open but unlinked files present? Keep EXT2_VALID_FS flag cleared
|
|
* because we have unattached inodes and thus filesystem is not fully
|
|
* consistent.
|
|
*/
|
|
if (atomic_long_read(&sb->s_remove_count)) {
|
|
ext2_sync_fs(sb, 1);
|
|
return 0;
|
|
}
|
|
/* Set EXT2_FS_VALID flag */
|
|
spin_lock(&sbi->s_lock);
|
|
sbi->s_es->s_state = cpu_to_le16(sbi->s_mount_state);
|
|
spin_unlock(&sbi->s_lock);
|
|
ext2_sync_super(sb, sbi->s_es, 1);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int ext2_unfreeze(struct super_block *sb)
|
|
{
|
|
/* Just write sb to clear EXT2_VALID_FS flag */
|
|
ext2_write_super(sb);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void ext2_write_super(struct super_block *sb)
|
|
{
|
|
if (!sb_rdonly(sb))
|
|
ext2_sync_fs(sb, 1);
|
|
}
|
|
|
|
static int ext2_remount (struct super_block * sb, int * flags, char * data)
|
|
{
|
|
struct ext2_sb_info * sbi = EXT2_SB(sb);
|
|
struct ext2_super_block * es;
|
|
struct ext2_mount_options new_opts;
|
|
int err;
|
|
|
|
sync_filesystem(sb);
|
|
|
|
spin_lock(&sbi->s_lock);
|
|
new_opts.s_mount_opt = sbi->s_mount_opt;
|
|
new_opts.s_resuid = sbi->s_resuid;
|
|
new_opts.s_resgid = sbi->s_resgid;
|
|
spin_unlock(&sbi->s_lock);
|
|
|
|
if (!parse_options(data, sb, &new_opts))
|
|
return -EINVAL;
|
|
|
|
spin_lock(&sbi->s_lock);
|
|
es = sbi->s_es;
|
|
if ((sbi->s_mount_opt ^ new_opts.s_mount_opt) & EXT2_MOUNT_DAX) {
|
|
ext2_msg(sb, KERN_WARNING, "warning: refusing change of "
|
|
"dax flag with busy inodes while remounting");
|
|
new_opts.s_mount_opt ^= EXT2_MOUNT_DAX;
|
|
}
|
|
if ((bool)(*flags & SB_RDONLY) == sb_rdonly(sb))
|
|
goto out_set;
|
|
if (*flags & SB_RDONLY) {
|
|
if (le16_to_cpu(es->s_state) & EXT2_VALID_FS ||
|
|
!(sbi->s_mount_state & EXT2_VALID_FS))
|
|
goto out_set;
|
|
|
|
/*
|
|
* OK, we are remounting a valid rw partition rdonly, so set
|
|
* the rdonly flag and then mark the partition as valid again.
|
|
*/
|
|
es->s_state = cpu_to_le16(sbi->s_mount_state);
|
|
es->s_mtime = cpu_to_le32(ktime_get_real_seconds());
|
|
spin_unlock(&sbi->s_lock);
|
|
|
|
err = dquot_suspend(sb, -1);
|
|
if (err < 0)
|
|
return err;
|
|
|
|
ext2_sync_super(sb, es, 1);
|
|
} else {
|
|
__le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb,
|
|
~EXT2_FEATURE_RO_COMPAT_SUPP);
|
|
if (ret) {
|
|
spin_unlock(&sbi->s_lock);
|
|
ext2_msg(sb, KERN_WARNING,
|
|
"warning: couldn't remount RDWR because of "
|
|
"unsupported optional features (%x).",
|
|
le32_to_cpu(ret));
|
|
return -EROFS;
|
|
}
|
|
/*
|
|
* Mounting a RDONLY partition read-write, so reread and
|
|
* store the current valid flag. (It may have been changed
|
|
* by e2fsck since we originally mounted the partition.)
|
|
*/
|
|
sbi->s_mount_state = le16_to_cpu(es->s_state);
|
|
if (!ext2_setup_super (sb, es, 0))
|
|
sb->s_flags &= ~SB_RDONLY;
|
|
spin_unlock(&sbi->s_lock);
|
|
|
|
ext2_write_super(sb);
|
|
|
|
dquot_resume(sb, -1);
|
|
}
|
|
|
|
spin_lock(&sbi->s_lock);
|
|
out_set:
|
|
sbi->s_mount_opt = new_opts.s_mount_opt;
|
|
sbi->s_resuid = new_opts.s_resuid;
|
|
sbi->s_resgid = new_opts.s_resgid;
|
|
sb->s_flags = (sb->s_flags & ~SB_POSIXACL) |
|
|
(test_opt(sb, POSIX_ACL) ? SB_POSIXACL : 0);
|
|
spin_unlock(&sbi->s_lock);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int ext2_statfs (struct dentry * dentry, struct kstatfs * buf)
|
|
{
|
|
struct super_block *sb = dentry->d_sb;
|
|
struct ext2_sb_info *sbi = EXT2_SB(sb);
|
|
struct ext2_super_block *es = sbi->s_es;
|
|
|
|
spin_lock(&sbi->s_lock);
|
|
|
|
if (test_opt (sb, MINIX_DF))
|
|
sbi->s_overhead_last = 0;
|
|
else if (sbi->s_blocks_last != le32_to_cpu(es->s_blocks_count)) {
|
|
unsigned long i, overhead = 0;
|
|
smp_rmb();
|
|
|
|
/*
|
|
* Compute the overhead (FS structures). This is constant
|
|
* for a given filesystem unless the number of block groups
|
|
* changes so we cache the previous value until it does.
|
|
*/
|
|
|
|
/*
|
|
* All of the blocks before first_data_block are
|
|
* overhead
|
|
*/
|
|
overhead = le32_to_cpu(es->s_first_data_block);
|
|
|
|
/*
|
|
* Add the overhead attributed to the superblock and
|
|
* block group descriptors. If the sparse superblocks
|
|
* feature is turned on, then not all groups have this.
|
|
*/
|
|
for (i = 0; i < sbi->s_groups_count; i++)
|
|
overhead += ext2_bg_has_super(sb, i) +
|
|
ext2_bg_num_gdb(sb, i);
|
|
|
|
/*
|
|
* Every block group has an inode bitmap, a block
|
|
* bitmap, and an inode table.
|
|
*/
|
|
overhead += (sbi->s_groups_count *
|
|
(2 + sbi->s_itb_per_group));
|
|
sbi->s_overhead_last = overhead;
|
|
smp_wmb();
|
|
sbi->s_blocks_last = le32_to_cpu(es->s_blocks_count);
|
|
}
|
|
|
|
buf->f_type = EXT2_SUPER_MAGIC;
|
|
buf->f_bsize = sb->s_blocksize;
|
|
buf->f_blocks = le32_to_cpu(es->s_blocks_count) - sbi->s_overhead_last;
|
|
buf->f_bfree = ext2_count_free_blocks(sb);
|
|
es->s_free_blocks_count = cpu_to_le32(buf->f_bfree);
|
|
buf->f_bavail = buf->f_bfree - le32_to_cpu(es->s_r_blocks_count);
|
|
if (buf->f_bfree < le32_to_cpu(es->s_r_blocks_count))
|
|
buf->f_bavail = 0;
|
|
buf->f_files = le32_to_cpu(es->s_inodes_count);
|
|
buf->f_ffree = ext2_count_free_inodes(sb);
|
|
es->s_free_inodes_count = cpu_to_le32(buf->f_ffree);
|
|
buf->f_namelen = EXT2_NAME_LEN;
|
|
buf->f_fsid = uuid_to_fsid(es->s_uuid);
|
|
spin_unlock(&sbi->s_lock);
|
|
return 0;
|
|
}
|
|
|
|
static struct dentry *ext2_mount(struct file_system_type *fs_type,
|
|
int flags, const char *dev_name, void *data)
|
|
{
|
|
return mount_bdev(fs_type, flags, dev_name, data, ext2_fill_super);
|
|
}
|
|
|
|
#ifdef CONFIG_QUOTA
|
|
|
|
/* Read data from quotafile - avoid pagecache and such because we cannot afford
|
|
* acquiring the locks... As quota files are never truncated and quota code
|
|
* itself serializes the operations (and no one else should touch the files)
|
|
* we don't have to be afraid of races */
|
|
static ssize_t ext2_quota_read(struct super_block *sb, int type, char *data,
|
|
size_t len, loff_t off)
|
|
{
|
|
struct inode *inode = sb_dqopt(sb)->files[type];
|
|
sector_t blk = off >> EXT2_BLOCK_SIZE_BITS(sb);
|
|
int err = 0;
|
|
int offset = off & (sb->s_blocksize - 1);
|
|
int tocopy;
|
|
size_t toread;
|
|
struct buffer_head tmp_bh;
|
|
struct buffer_head *bh;
|
|
loff_t i_size = i_size_read(inode);
|
|
|
|
if (off > i_size)
|
|
return 0;
|
|
if (off+len > i_size)
|
|
len = i_size-off;
|
|
toread = len;
|
|
while (toread > 0) {
|
|
tocopy = sb->s_blocksize - offset < toread ?
|
|
sb->s_blocksize - offset : toread;
|
|
|
|
tmp_bh.b_state = 0;
|
|
tmp_bh.b_size = sb->s_blocksize;
|
|
err = ext2_get_block(inode, blk, &tmp_bh, 0);
|
|
if (err < 0)
|
|
return err;
|
|
if (!buffer_mapped(&tmp_bh)) /* A hole? */
|
|
memset(data, 0, tocopy);
|
|
else {
|
|
bh = sb_bread(sb, tmp_bh.b_blocknr);
|
|
if (!bh)
|
|
return -EIO;
|
|
memcpy(data, bh->b_data+offset, tocopy);
|
|
brelse(bh);
|
|
}
|
|
offset = 0;
|
|
toread -= tocopy;
|
|
data += tocopy;
|
|
blk++;
|
|
}
|
|
return len;
|
|
}
|
|
|
|
/* Write to quotafile */
|
|
static ssize_t ext2_quota_write(struct super_block *sb, int type,
|
|
const char *data, size_t len, loff_t off)
|
|
{
|
|
struct inode *inode = sb_dqopt(sb)->files[type];
|
|
sector_t blk = off >> EXT2_BLOCK_SIZE_BITS(sb);
|
|
int err = 0;
|
|
int offset = off & (sb->s_blocksize - 1);
|
|
int tocopy;
|
|
size_t towrite = len;
|
|
struct buffer_head tmp_bh;
|
|
struct buffer_head *bh;
|
|
|
|
while (towrite > 0) {
|
|
tocopy = sb->s_blocksize - offset < towrite ?
|
|
sb->s_blocksize - offset : towrite;
|
|
|
|
tmp_bh.b_state = 0;
|
|
tmp_bh.b_size = sb->s_blocksize;
|
|
err = ext2_get_block(inode, blk, &tmp_bh, 1);
|
|
if (err < 0)
|
|
goto out;
|
|
if (offset || tocopy != EXT2_BLOCK_SIZE(sb))
|
|
bh = sb_bread(sb, tmp_bh.b_blocknr);
|
|
else
|
|
bh = sb_getblk(sb, tmp_bh.b_blocknr);
|
|
if (unlikely(!bh)) {
|
|
err = -EIO;
|
|
goto out;
|
|
}
|
|
lock_buffer(bh);
|
|
memcpy(bh->b_data+offset, data, tocopy);
|
|
flush_dcache_page(bh->b_page);
|
|
set_buffer_uptodate(bh);
|
|
mark_buffer_dirty(bh);
|
|
unlock_buffer(bh);
|
|
brelse(bh);
|
|
offset = 0;
|
|
towrite -= tocopy;
|
|
data += tocopy;
|
|
blk++;
|
|
}
|
|
out:
|
|
if (len == towrite)
|
|
return err;
|
|
if (inode->i_size < off+len-towrite)
|
|
i_size_write(inode, off+len-towrite);
|
|
inode_inc_iversion(inode);
|
|
inode->i_mtime = inode->i_ctime = current_time(inode);
|
|
mark_inode_dirty(inode);
|
|
return len - towrite;
|
|
}
|
|
|
|
static int ext2_quota_on(struct super_block *sb, int type, int format_id,
|
|
const struct path *path)
|
|
{
|
|
int err;
|
|
struct inode *inode;
|
|
|
|
err = dquot_quota_on(sb, type, format_id, path);
|
|
if (err)
|
|
return err;
|
|
|
|
inode = d_inode(path->dentry);
|
|
inode_lock(inode);
|
|
EXT2_I(inode)->i_flags |= EXT2_NOATIME_FL | EXT2_IMMUTABLE_FL;
|
|
inode_set_flags(inode, S_NOATIME | S_IMMUTABLE,
|
|
S_NOATIME | S_IMMUTABLE);
|
|
inode_unlock(inode);
|
|
mark_inode_dirty(inode);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int ext2_quota_off(struct super_block *sb, int type)
|
|
{
|
|
struct inode *inode = sb_dqopt(sb)->files[type];
|
|
int err;
|
|
|
|
if (!inode || !igrab(inode))
|
|
goto out;
|
|
|
|
err = dquot_quota_off(sb, type);
|
|
if (err)
|
|
goto out_put;
|
|
|
|
inode_lock(inode);
|
|
EXT2_I(inode)->i_flags &= ~(EXT2_NOATIME_FL | EXT2_IMMUTABLE_FL);
|
|
inode_set_flags(inode, 0, S_NOATIME | S_IMMUTABLE);
|
|
inode_unlock(inode);
|
|
mark_inode_dirty(inode);
|
|
out_put:
|
|
iput(inode);
|
|
return err;
|
|
out:
|
|
return dquot_quota_off(sb, type);
|
|
}
|
|
|
|
#endif
|
|
|
|
static struct file_system_type ext2_fs_type = {
|
|
.owner = THIS_MODULE,
|
|
.name = "ext2",
|
|
.mount = ext2_mount,
|
|
.kill_sb = kill_block_super,
|
|
.fs_flags = FS_REQUIRES_DEV,
|
|
};
|
|
MODULE_ALIAS_FS("ext2");
|
|
|
|
static int __init init_ext2_fs(void)
|
|
{
|
|
int err;
|
|
|
|
err = init_inodecache();
|
|
if (err)
|
|
return err;
|
|
err = register_filesystem(&ext2_fs_type);
|
|
if (err)
|
|
goto out;
|
|
return 0;
|
|
out:
|
|
destroy_inodecache();
|
|
return err;
|
|
}
|
|
|
|
static void __exit exit_ext2_fs(void)
|
|
{
|
|
unregister_filesystem(&ext2_fs_type);
|
|
destroy_inodecache();
|
|
}
|
|
|
|
MODULE_AUTHOR("Remy Card and others");
|
|
MODULE_DESCRIPTION("Second Extended Filesystem");
|
|
MODULE_LICENSE("GPL");
|
|
MODULE_IMPORT_NS(ANDROID_GKI_VFS_EXPORT_ONLY);
|
|
module_init(init_ext2_fs)
|
|
module_exit(exit_ext2_fs)
|