https://source.android.com/docs/security/bulletin/2024-05-01 CVE-2023-4622 * tag 'ASB-2024-05-05_4.19-stable' of https://android.googlesource.com/kernel/common: Revert "timers: Rename del_timer_sync() to timer_delete_sync()" Revert "geneve: make sure to pull inner header in geneve_rx()" Linux 4.19.312 amdkfd: use calloc instead of kzalloc to avoid integer overflow initramfs: fix populate_initrd_image() section mismatch ip_gre: do not report erspan version on GRE interface erspan: Check IFLA_GRE_ERSPAN_VER is set. VMCI: Fix possible memcpy() run-time warning in vmci_datagram_invoke_guest_handler() Bluetooth: btintel: Fixe build regression x86/mm/pat: fix VM_PAT handling in COW mappings virtio: reenable config if freezing device failed drm/vkms: call drm_atomic_helper_shutdown before drm_dev_put() tty: n_gsm: require CAP_NET_ADMIN to attach N_GSM0710 ldisc fbmon: prevent division by zero in fb_videomode_from_videomode() fbdev: viafb: fix typo in hw_bitblt_1 and hw_bitblt_2 usb: sl811-hcd: only defined function checkdone if QUIRK2 is defined tools: iio: replace seekdir() in iio_generic_buffer ktest: force $buildonly = 1 for 'make_warnings_file' test type Input: allocate keycode for Display refresh rate toggle block: prevent division by zero in blk_rq_stat_sum() SUNRPC: increase size of rpc_wait_queue.qlen from unsigned short to unsigned int drm/amd/display: Fix nanosec stat overflow media: sta2x11: fix irq handler cast isofs: handle CDs with bad root inode but good Joliet root directory scsi: lpfc: Fix possible memory leak in lpfc_rcv_padisc() sysv: don't call sb_bread() with pointers_lock held Input: synaptics-rmi4 - fail probing if memory allocation for "phys" fails Bluetooth: btintel: Fix null ptr deref in btintel_read_version btrfs: send: handle path ref underflow in header iterate_inode_ref() btrfs: export: handle invalid inode or root reference in btrfs_get_parent() btrfs: handle chunk tree lookup error in btrfs_relocate_sys_chunks() tools/power x86_energy_perf_policy: Fix file leak in get_pkg_num() arm64: dts: rockchip: fix rk3399 hdmi ports node VMCI: Fix memcpy() run-time warning in dg_dispatch_as_host() wifi: ath9k: fix LNA selection in ath_ant_try_scan() ALSA: hda/realtek: Update Panasonic CF-SZ6 quirk to support headset with microphone ata: sata_mv: Fix PCI device ID table declaration compilation warning ata: sata_sx4: fix pdc20621_get_from_dimm() on 64-bit ASoC: ops: Fix wraparound for mask in snd_soc_get_volsw erspan: make sure erspan_base_hdr is present in skb->head erspan: Add type I version 0 support. init: open /initrd.image with O_LARGEFILE initramfs: switch initramfs unpacking to struct file based APIs fs: add a vfs_fchmod helper fs: add a vfs_fchown helper initramfs: factor out a helper to populate the initrd image staging: vc04_services: fix information leak in create_component() staging: vc04_services: changen strncpy() to strscpy_pad() staging: mmal-vchiq: Fix client_component for 64 bit kernel staging: mmal-vchiq: Allocate and free components as required staging: mmal-vchiq: Avoid use of bool in structures i40e: fix vf may be used uninitialized in this function warning ipv6: Fix infinite recursion in fib6_dump_done(). selftests: reuseaddr_conflict: add missing new line at the end of the output net: stmmac: fix rx queue priority assignment net/sched: act_skbmod: prevent kernel-infoleak netfilter: nf_tables: Fix potential data-race in __nft_flowtable_type_get() mm, vmscan: prevent infinite loop for costly GFP_NOIO | __GFP_RETRY_MAYFAIL allocations Revert "x86/mm/ident_map: Use gbpages only where full GB page should be mapped." net/rds: fix possible cp null dereference netfilter: nf_tables: disallow timeout for anonymous sets Bluetooth: Fix TOCTOU in HCI debugfs implementation Bluetooth: hci_event: set the conn encrypted before conn establishes r8169: fix issue caused by buggy BIOS on certain boards with RTL8168d tcp: properly terminate timers for kernel sockets mptcp: add sk_stop_timer_sync helper nfc: nci: Fix uninit-value in nci_dev_up and nci_ntf_packet USB: core: Fix deadlock in usb_deauthorize_interface() scsi: lpfc: Correct size for wqe for memset() x86/cpu: Enable STIBP on AMD if Automatic IBRS is enabled scsi: qla2xxx: Fix command flush on cable pull usb: udc: remove warning when queue disabled ep usb: dwc2: gadget: LPM flow fix usb: dwc2: host: Fix ISOC flow in DDMA mode usb: dwc2: host: Fix hibernation flow usb: dwc2: host: Fix remote wakeup from hibernation loop: loop_set_status_from_info() check before assignment loop: Check for overflow while configuring loop loop: Factor out configuring loop from status powerpc: xor_vmx: Add '-mhard-float' to CFLAGS efivarfs: Request at most 512 bytes for variable names perf/core: Fix reentry problem in perf_output_read_group() loop: properly observe rotational flag of underlying device loop: Refactor loop_set_status() size calculation loop: Factor out setting loop device size loop: Remove sector_t truncation checks loop: Call loop_config_discard() only after new config is applied Revert "loop: Check for overflow while configuring loop" btrfs: allocate btrfs_ioctl_defrag_range_args on stack printk: Update @console_may_schedule in console_trylock_spinning() fs/aio: Check IOCB_AIO_RW before the struct aio_kiocb conversion ALSA: sh: aica: reorder cleanup operations to avoid UAF bugs usb: cdc-wdm: close race between read and workqueue exec: Fix NOMMU linux_binprm::exec in transfer_args_to_stack() wifi: mac80211: check/clear fast rx for non-4addr sta VLAN changes mm/migrate: set swap entry values of THP tail pages properly. mm/memory-failure: fix an incorrect use of tail pages vt: fix memory overlapping when deleting chars in the buffer vt: fix unicode buffer corruption when deleting characters tty: serial: fsl_lpuart: avoid idle preamble pending if CTS is enabled usb: port: Don't try to peer unused USB ports based on location usb: gadget: ncm: Fix handling of zero block length packets USB: usb-storage: Prevent divide-by-0 error in isd200_ata_command ALSA: hda/realtek - Fix headset Mic no show at resume back for Lenovo ALC897 platform xfrm: Avoid clang fortify warning in copy_to_user_tmpl() netfilter: nf_tables: reject constant set with timeout netfilter: nf_tables: disallow anonymous set with timeout flag comedi: comedi_test: Prevent timers rescheduling during deletion ahci: asm1064: asm1166: don't limit reported ports ahci: asm1064: correct count of reported ports x86/CPU/AMD: Update the Zenbleed microcode revisions nilfs2: prevent kernel bug at submit_bh_wbc() nilfs2: use a more common logging style nilfs2: fix failure to detect DAT corruption in btree and direct mappings memtest: use {READ,WRITE}_ONCE in memory scanning drm/vc4: hdmi: do not return negative values from .get_modes() drm/imx/ipuv3: do not return negative values from .get_modes() s390/zcrypt: fix reference counting on zcrypt card objects soc: fsl: qbman: Use raw spinlock for cgr_lock soc: fsl: qbman: Add CGR update function soc: fsl: qbman: Add helper for sanity checking cgr ops soc: fsl: qbman: Always disable interrupts when taking cgr_lock vfio/platform: Disable virqfds on cleanup kbuild: Move -Wenum-{compare-conditional,enum-conversion} into W=1 speakup: Fix 8bit characters from direct synth slimbus: core: Remove usage of the deprecated ida_simple_xx() API ext4: fix corruption during on-line resize hwmon: (amc6821) add of_match table mmc: core: Fix switch on gp3 partition dm-raid: fix lockdep waring in "pers->hot_add_disk" Revert "Revert "md/raid5: Wait for MD_SB_CHANGE_PENDING in raid5d"" PCI/PM: Drain runtime-idle callbacks before driver removal PCI: Drop pci_device_remove() test of pci_dev->driver fuse: don't unhash root mmc: tmio: avoid concurrent runs of mmc_request_done() PM: sleep: wakeirq: fix wake irq warning in system suspend USB: serial: cp210x: add pid/vid for TDK NC0110013M and MM0110113M USB: serial: option: add MeiG Smart SLM320 product USB: serial: cp210x: add ID for MGP Instruments PDS100 USB: serial: add device ID for VeriFone adapter USB: serial: ftdi_sio: add support for GMC Z216C Adapter IR-USB powerpc/fsl: Fix mfpmr build errors with newer binutils clk: qcom: mmcc-msm8974: fix terminating of frequency table arrays clk: qcom: mmcc-apq8084: fix terminating of frequency table arrays clk: qcom: gcc-ipq8074: fix terminating of frequency table arrays PM: suspend: Set mem_sleep_current during kernel command line setup parisc: Strip upper 32 bit of sum in csum_ipv6_magic for 64-bit builds parisc: Fix csum_ipv6_magic on 64-bit systems parisc: Fix csum_ipv6_magic on 32-bit systems parisc: Fix ip_fast_csum parisc: Do not hardcode registers in checksum functions ubi: correct the calculation of fastmap size ubi: Check for too small LEB size in VTBL code ubifs: Set page uptodate in the correct place fat: fix uninitialized field in nostale filehandles crypto: qat - resolve race condition during AER recovery crypto: qat - fix double free during reset sparc: vDSO: fix return value of __setup handler sparc64: NMI watchdog: fix return value of __setup handler KVM: Always flush async #PF workqueue when vCPU is being destroyed media: xc4000: Fix atomicity violation in xc4000_get_frequency arm: dts: marvell: Fix maxium->maxim typo in brownstone dts ARM: dts: mmp2-brownstone: Don't redeclare phandle references smack: Handle SMACK64TRANSMUTE in smack_inode_setsecurity() smack: Set SMACK64TRANSMUTE only for dirs in smack_inode_setxattr() wifi: brcmfmac: Fix use-after-free bug in brcmf_cfg80211_detach timers: Rename del_timer_sync() to timer_delete_sync() timers: Use del_timer_sync() even on UP timers: Update kernel-doc for various functions timers: Prepare support for PREEMPT_RT timer/trace: Improve timer tracing timer/trace: Replace deprecated vsprintf pointer extension %pf by %ps x86/bugs: Use sysfs_emit() x86/cpu: Support AMD Automatic IBRS Documentation/hw-vuln: Update spectre doc Linux 4.19.311 crypto: af_alg - Work around empty control messages without MSG_MORE crypto: af_alg - Fix regression on empty requests spi: spi-mt65xx: Fix NULL pointer access in interrupt handler net/bnx2x: Prevent access to a freed page in page_pool hsr: Handle failures in module init rds: introduce acquire/release ordering in acquire/release_in_xmit() hsr: Fix uninit-value access in hsr_get_node() net: hsr: fix placement of logical operator in a multi-line statement usb: gadget: net2272: Use irqflags in the call to net2272_probe_fin staging: greybus: fix get_channel_from_mode() failure path serial: 8250_exar: Don't remove GPIO device on suspend rtc: mt6397: select IRQ_DOMAIN instead of depending on it kconfig: fix infinite loop when expanding a macro at the end of file tty: serial: samsung: fix tx_empty() to return TIOCSER_TEMT serial: max310x: fix syntax error in IRQ error message clk: qcom: gdsc: Add support to update GDSC transition delay NFS: Fix an off by one in root_nfs_cat() net: sunrpc: Fix an off by one in rpc_sockaddr2uaddr() scsi: bfa: Fix function pointer type mismatch for hcb_qe->cbfn scsi: csiostor: Avoid function pointer casts ALSA: usb-audio: Stop parsing channels bits when all channels are found. sparc32: Fix section mismatch in leon_pci_grpci backlight: lp8788: Fully initialize backlight_properties during probe backlight: lm3639: Fully initialize backlight_properties during probe backlight: da9052: Fully initialize backlight_properties during probe backlight: lm3630a: Don't set bl->props.brightness in get_brightness backlight: lm3630a: Initialize backlight_properties on init powerpc/embedded6xx: Fix no previous prototype for avr_uart_send() etc. powerpc/hv-gpci: Fix the H_GET_PERF_COUNTER_INFO hcall return value checks drm/mediatek: Fix a null pointer crash in mtk_drm_crtc_finish_page_flip media: go7007: fix a memleak in go7007_load_encoder media: dvb-frontends: avoid stack overflow warnings with clang media: pvrusb2: fix uaf in pvr2_context_set_notify drm/amdgpu: Fix missing break in ATOM_ARG_IMM Case of atom_get_src_int() ASoC: meson: axg-tdm-interface: fix mclk setup without mclk-fs mtd: rawnand: lpc32xx_mlc: fix irq handler prototype crypto: arm/sha - fix function cast warnings crypto: arm - Rename functions to avoid conflict with crypto/sha256.h mfd: syscon: Call of_node_put() only when of_parse_phandle() takes a ref drm/tegra: put drm_gem_object ref on error in tegra_fb_create clk: hisilicon: hi3519: Release the correct number of gates in hi3519_clk_unregister() PCI: Mark 3ware-9650SE Root Port Extended Tags as broken drm/mediatek: dsi: Fix DSI RGB666 formats and definitions clk: qcom: dispcc-sdm845: Adjust internal GDSC wait times firmware: qcom: scm: Add WLAN VMID for Qualcomm SCM interface media: pvrusb2: fix pvr2_stream_callback casts media: go7007: add check of return value of go7007_read_addr() ALSA: seq: fix function cast warnings drm/radeon/ni: Fix wrong firmware size logging in ni_init_microcode() perf thread_map: Free strlist on normal path in thread_map__new_by_tid_str() quota: Fix rcu annotations of inode dquot pointers quota: Fix potential NULL pointer dereference quota: simplify drop_dquot_ref() quota: check time limit when back out space/inode change fs/quota: erase unused but set variable warning quota: code cleanup for __dquot_alloc_space() clk: qcom: reset: Ensure write completion on reset de/assertion clk: qcom: reset: Commonize the de/assert functions clk: qcom: reset: support resetting multiple bits clk: qcom: reset: Allow specifying custom reset delay media: edia: dvbdev: fix a use-after-free media: dvb-core: Fix use-after-free due to race at dvb_register_device() media: dvbdev: fix error logic at dvb_register_device() media: dvbdev: Fix memleak in dvb_register_device media: media/dvb: Use kmemdup rather than duplicating its implementation media: dvbdev: remove double-unlock media: v4l2-mem2mem: fix a memleak in v4l2_m2m_register_entity media: v4l2-tpg: fix some memleaks in tpg_alloc media: em28xx: annotate unchecked call to media_device_register() ABI: sysfs-bus-pci-devices-aer_stats uses an invalid tag perf evsel: Fix duplicate initialization of data->id in evsel__parse_sample() media: tc358743: register v4l2 async device only after successful setup drm/rockchip: lvds: do not print scary message when probing defer drm/rockchip: lvds: do not overwrite error code drm: Don't treat 0 as -1 in drm_fixp2int_ceil drm/rockchip: inno_hdmi: Fix video timing drm/tegra: dsi: Fix missing pm_runtime_disable() in the error handling path of tegra_dsi_probe() drm/tegra: dsi: Fix some error handling paths in tegra_dsi_probe() drm/tegra: dsi: Make use of the helper function dev_err_probe() gpu: host1x: mipi: Update tegra_mipi_request() to be node based drm/tegra: dsi: Add missing check for of_find_device_by_node dm: call the resume method on internal suspend dm raid: fix false positive for requeue needed during reshape nfp: flower: handle acti_netdevs allocation failure net/x25: fix incorrect parameter validation in the x25_getsockopt() function net: kcm: fix incorrect parameter validation in the kcm_getsockopt) function udp: fix incorrect parameter validation in the udp_lib_getsockopt() function l2tp: fix incorrect parameter validation in the pppol2tp_getsockopt() function tcp: fix incorrect parameter validation in the do_tcp_getsockopt() function ipv6: fib6_rules: flush route cache when rule is changed bpf: Fix stackmap overflow check on 32-bit arches bpf: Fix hashtab overflow check on 32-bit arches sr9800: Add check for usbnet_get_endpoints Bluetooth: hci_core: Fix possible buffer overflow Bluetooth: Remove superfluous call to hci_conn_check_pending() igb: Fix missing time sync events igb: move PEROUT and EXTTS isr logic to separate functions mmc: wmt-sdmmc: remove an incorrect release_mem_region() call in the .remove function SUNRPC: fix some memleaks in gssx_dec_option_array x86, relocs: Ignore relocations in .notes section ACPI: scan: Fix device check notification handling ARM: dts: arm: realview: Fix development chip ROM compatible value wifi: brcmsmac: avoid function pointer casts iommu/amd: Mark interrupt as managed bus: tegra-aconnect: Update dependency to ARCH_TEGRA ACPI: processor_idle: Fix memory leak in acpi_processor_power_exit() wifi: libertas: fix some memleaks in lbs_allocate_cmd_buffer() af_unix: Annotate data-race of gc_in_progress in wait_for_unix_gc(). sock_diag: annotate data-races around sock_diag_handlers[family] wifi: mwifiex: debugfs: Drop unnecessary error check for debugfs_create_dir() wifi: b43: Disable QoS for bcm4331 wifi: b43: Stop correct queue in DMA worker when QoS is disabled b43: main: Fix use true/false for bool type wifi: b43: Stop/wake correct queue in PIO Tx path when QoS is disabled wifi: b43: Stop/wake correct queue in DMA Tx path when QoS is disabled b43: dma: Fix use true/false for bool type variable wifi: ath10k: fix NULL pointer dereference in ath10k_wmi_tlv_op_pull_mgmt_tx_compl_ev() timekeeping: Fix cross-timestamp interpolation for non-x86 timekeeping: Fix cross-timestamp interpolation corner case decision timekeeping: Fix cross-timestamp interpolation on counter wrap aoe: fix the potential use-after-free problem in aoecmd_cfg_pkts md: Don't clear MD_CLOSING when the raid is about to stop md: implement ->set_read_only to hook into BLKROSET processing block: add a new set_read_only method md: switch to ->check_events for media change notifications fs/select: rework stack allocation hack for clang do_sys_name_to_handle(): use kzalloc() to fix kernel-infoleak crypto: algif_aead - Only wake up when ctx->more is zero crypto: af_alg - make some functions static crypto: algif_aead - fix uninitialized ctx->init ASoC: wm8962: Fix up incorrect error message in wm8962_set_fll ASoC: wm8962: Enable both SPKOUTR_ENA and SPKOUTL_ENA in mono mode ASoC: wm8962: Enable oscillator if selecting WM8962_FLL_OSC Input: gpio_keys_polled - suppress deferred probe error for gpio ASoC: Intel: bytcr_rt5640: Add an extra entry for the Chuwi Vi8 tablet firewire: core: use long bus reset on gap count error Bluetooth: rfcomm: Fix null-ptr-deref in rfcomm_check_security scsi: mpt3sas: Prevent sending diag_reset when the controller is ready dm-verity, dm-crypt: align "struct bvec_iter" correctly block: sed-opal: handle empty atoms when parsing response net/iucv: fix the allocation size of iucv_path_table array MIPS: Clear Cause.BD in instruction_pointer_set x86/xen: Add some null pointer checking to smp.c ASoC: rt5645: Make LattePanda board DMI match more precise Linux 4.19.310 selftests/vm: fix map_hugetlb length used for testing read and write selftests/vm: fix display of page size in map_hugetlb getrusage: use sig->stats_lock rather than lock_task_sighand() getrusage: use __for_each_thread() getrusage: move thread_group_cputime_adjusted() outside of lock_task_sighand() getrusage: add the "signal_struct *sig" local variable y2038: rusage: use __kernel_old_timeval hv_netvsc: Register VF in netvsc_probe if NET_DEVICE_REGISTER missed hv_netvsc: use netif_is_bond_master() instead of open code hv_netvsc: Make netvsc/VF binding check both MAC and serial number Input: i8042 - fix strange behavior of touchpad on Clevo NS70PU um: allow not setting extra rpaths in the linux binary selftests: mm: fix map_hugetlb failure on 64K page size systems tools/selftest/vm: allow choosing mem size and page size in map_hugetlb btrfs: ref-verify: free ref cache before clearing mount opt netrom: Fix data-races around sysctl_net_busy_read netrom: Fix a data-race around sysctl_netrom_link_fails_count netrom: Fix a data-race around sysctl_netrom_routing_control netrom: Fix a data-race around sysctl_netrom_transport_no_activity_timeout netrom: Fix a data-race around sysctl_netrom_transport_requested_window_size netrom: Fix a data-race around sysctl_netrom_transport_busy_delay netrom: Fix a data-race around sysctl_netrom_transport_acknowledge_delay netrom: Fix a data-race around sysctl_netrom_transport_maximum_tries netrom: Fix a data-race around sysctl_netrom_transport_timeout netrom: Fix data-races around sysctl_netrom_network_ttl_initialiser netrom: Fix a data-race around sysctl_netrom_obsolescence_count_initialiser netrom: Fix a data-race around sysctl_netrom_default_path_quality netfilter: nf_conntrack_h323: Add protection for bmp length out of range net/rds: fix WARNING in rds_conn_connect_if_down net/ipv6: avoid possible UAF in ip6_route_mpath_notify() geneve: make sure to pull inner header in geneve_rx() net: move definition of pcpu_lstats to header file net: lan78xx: fix runtime PM count underflow on link stop lan78xx: Fix race conditions in suspend/resume handling lan78xx: Fix partial packet errors on suspend/resume lan78xx: Add missing return code checks lan78xx: Fix white space and style issues net: usb: lan78xx: Remove lots of set but unused 'ret' variables Linux 4.19.309 gpio: 74x164: Enable output pins after registers are reset cachefiles: fix memory leak in cachefiles_add_cache() mmc: core: Fix eMMC initialization with 1-bit bus connection btrfs: dev-replace: properly validate device names wifi: nl80211: reject iftype change with mesh ID change gtp: fix use-after-free and null-ptr-deref in gtp_newlink() ALSA: Drop leftover snd-rtctimer stuff from Makefile power: supply: bq27xxx-i2c: Do not free non existing IRQ efi/capsule-loader: fix incorrect allocation size Bluetooth: Enforce validation on max value of connection interval Bluetooth: hci_event: Fix handling of HCI_EV_IO_CAPA_REQUEST Bluetooth: Avoid potential use-after-free in hci_error_reset net: usb: dm9601: fix wrong return value in dm9601_mdio_read lan78xx: enable auto speed configuration for LAN7850 if no EEPROM is detected tun: Fix xdp_rxq_info's queue_index when detaching netlink: Fix kernel-infoleak-after-free in __skb_datagram_iter Linux 4.19.308 scripts/bpf: Fix xdp_md forward declaration typo fs/aio: Restrict kiocb_set_cancel_fn() to I/O submitted via libaio KVM: arm64: vgic-its: Test for valid IRQ in MOVALL handler KVM: arm64: vgic-its: Test for valid IRQ in its_sync_lpi_pending_table() PCI/MSI: Prevent MSI hardware interrupt number truncation s390: use the correct count for __iowrite64_copy() packet: move from strlcpy with unused retval to strscpy ipv6: sr: fix possible use-after-free and null-ptr-deref nouveau: fix function cast warnings scsi: jazz_esp: Only build if SCSI core is builtin bpf, scripts: Correct GPL license name scripts/bpf: teach bpf_helpers_doc.py to dump BPF helper definitions RDMA/srpt: fix function pointer cast warnings RDMA/srpt: Make debug output more detailed RDMA/ulp: Use dev_name instead of ibdev->name RDMA/srpt: Support specifying the srpt_service_guid parameter RDMA/bnxt_re: Return error for SRQ resize IB/hfi1: Fix a memleak in init_credit_return usb: roles: don't get/set_role() when usb_role_switch is unregistered usb: gadget: ncm: Avoid dropping datagrams of properly parsed NTBs ARM: ep93xx: Add terminator to gpiod_lookup_table l2tp: pass correct message length to ip6_append_data gtp: fix use-after-free and null-ptr-deref in gtp_genl_dump_pdp() dm-crypt: don't modify the data when using authenticated encryption mm: memcontrol: switch to rcu protection in drain_all_stock() IB/hfi1: Fix sdma.h tx->num_descs off-by-one error pmdomain: renesas: r8a77980-sysc: CR7 must be always on s390/qeth: Fix potential loss of L3-IP@ in case of network issues virtio-blk: Ensure no requests in virtqueues before deleting vqs. firewire: core: send bus reset promptly on gap count error hwmon: (coretemp) Enlarge per package core count limit regulator: pwm-regulator: Add validity checks in continuous .get_voltage ext4: avoid allocating blocks from corrupted group in ext4_mb_find_by_goal() ext4: avoid allocating blocks from corrupted group in ext4_mb_try_best_found() ahci: asm1166: correct count of reported ports fbdev: sis: Error out if pixclock equals zero fbdev: savage: Error out if pixclock equals zero wifi: mac80211: fix race condition on enabling fast-xmit wifi: cfg80211: fix missing interfaces when dumping dmaengine: shdma: increase size of 'dev_id' scsi: target: core: Add TMF to tmr_list handling sched/rt: Disallow writing invalid values to sched_rt_period_us sched/rt: sysctl_sched_rr_timeslice show default timeslice after reset sched/rt: Fix sysctl_sched_rr_timeslice intial value userfaultfd: fix mmap_changing checking in mfill_atomic_hugetlb nilfs2: replace WARN_ONs for invalid DAT metadata block requests memcg: add refcnt for pcpu stock to avoid UAF problem in drain_all_stock() net: stmmac: fix notifier registration stmmac: no need to check return value of debugfs_create functions net/sched: Retire dsmark qdisc net/sched: Retire ATM qdisc net/sched: Retire CBQ qdisc Linux 4.19.307 netfilter: nf_tables: fix pointer math issue in nft_byteorder_eval() lsm: new security_file_ioctl_compat() hook nilfs2: fix potential bug in end_buffer_async_write sched/membarrier: reduce the ability to hammer on sys_membarrier Revert "md/raid5: Wait for MD_SB_CHANGE_PENDING in raid5d" pmdomain: core: Move the unused cleanup to a _sync initcall irqchip/irq-brcmstb-l2: Add write memory barrier before exit nfp: use correct macro for LengthSelect in BAR config nilfs2: fix hang in nilfs_lookup_dirty_data_buffers() nilfs2: fix data corruption in dsync block recovery for small block sizes ALSA: hda/conexant: Add quirk for SWS JS201D x86/mm/ident_map: Use gbpages only where full GB page should be mapped. x86/Kconfig: Transmeta Crusoe is CPU family 5, not 6 serial: max310x: improve crystal stable clock detection serial: max310x: set default value when reading clock ready bit ring-buffer: Clean ring_buffer_poll_wait() error return staging: iio: ad5933: fix type mismatch regression ext4: fix double-free of blocks due to wrong extents moved_len binder: signal epoll threads of self-work xen-netback: properly sync TX responses nfc: nci: free rx_data_reassembly skb on NCI device cleanup firewire: core: correct documentation of fw_csr_string() kernel API scsi: Revert "scsi: fcoe: Fix potential deadlock on &fip->ctlr_lock" usb: f_mass_storage: forbid async queue when shutdown happen USB: hub: check for alternate port before enabling A_ALT_HNP_SUPPORT HID: wacom: Do not register input devices until after hid_hw_start HID: wacom: generic: Avoid reporting a serial of '0' to userspace mm/writeback: fix possible divide-by-zero in wb_dirty_limits(), again tracing/trigger: Fix to return error if failed to alloc snapshot i40e: Fix waiting for queues of all VSIs to be disabled MIPS: Add 'memory' clobber to csum_ipv6_magic() inline assembler net: sysfs: Fix /sys/class/net/<iface> path for statistics Documentation: net-sysfs: describe missing statistics ASoC: rt5645: Fix deadlock in rt5645_jack_detect_work() spi: ppc4xx: Drop write-only variable btrfs: send: return EOPNOTSUPP on unknown flags btrfs: forbid creating subvol qgroups hrtimer: Report offline hrtimer enqueue vhost: use kzalloc() instead of kmalloc() followed by memset() Input: atkbd - skip ATKBD_CMD_SETLEDS when skipping ATKBD_CMD_GETID USB: serial: cp210x: add ID for IMST iM871A-USB USB: serial: option: add Fibocom FM101-GL variant USB: serial: qcserial: add new usb-id for Dell Wireless DW5826e net/af_iucv: clean up a try_then_request_module() netfilter: nft_compat: restrict match/target protocol to u16 netfilter: nft_compat: reject unused compat flag ppp_async: limit MRU to 64K tipc: Check the bearer type before calling tipc_udp_nl_bearer_add() rxrpc: Fix response to PING RESPONSE ACKs to a dead call inet: read sk->sk_family once in inet_recv_error() hwmon: (coretemp) Fix bogus core_id to attr name mapping hwmon: (coretemp) Fix out-of-bounds memory access hwmon: (aspeed-pwm-tacho) mutex for tach reading atm: idt77252: fix a memleak in open_card_ubr0 phy: ti: phy-omap-usb2: Fix NULL pointer dereference for SRP dmaengine: fix is_slave_direction() return false when DMA_DEV_TO_DEV bonding: remove print in bond_verify_device_path HID: apple: Add 2021 magic keyboard FN key mapping HID: apple: Swap the Fn and Left Control keys on Apple keyboards HID: apple: Add support for the 2021 Magic Keyboard net: sysfs: Fix /sys/class/net/<iface> path af_unix: fix lockdep positive in sk_diag_dump_icons() net: ipv4: fix a memleak in ip_setup_cork netfilter: nf_log: replace BUG_ON by WARN_ON_ONCE when putting logger llc: call sock_orphan() at release time ipv6: Ensure natural alignment of const ipv6 loopback and router addresses ixgbe: Fix an error handling path in ixgbe_read_iosf_sb_reg_x550() ixgbe: Refactor overtemp event handling ixgbe: Refactor returning internal error codes ixgbe: Remove non-inclusive language net: remove unneeded break scsi: isci: Fix an error code problem in isci_io_request_build() wifi: cfg80211: fix RCU dereference in __cfg80211_bss_update drm/amdgpu: Release 'adev->pm.fw' before return in 'amdgpu_device_need_post()' ceph: fix deadlock or deadcode of misusing dget() blk-mq: fix IO hang from sbitmap wakeup race virtio_net: Fix "‘%d’ directive writing between 1 and 11 bytes into a region of size 10" warnings libsubcmd: Fix memory leak in uniq() usb: hub: Replace hardcoded quirk value with BIT() macro PCI: Only override AMD USB controller if required mfd: ti_am335x_tscadc: Fix TI SoC dependencies um: net: Fix return type of uml_net_start_xmit() um: Don't use vfprintf() for os_info() um: Fix naming clash between UML and scheduler leds: trigger: panic: Don't register panic notifier if creating the trigger failed drm/amdgpu: Drop 'fence' check in 'to_amdgpu_amdkfd_fence()' drm/amdgpu: Let KFD sync with VM fences clk: mmp: pxa168: Fix memory leak in pxa168_clk_init() clk: hi3620: Fix memory leak in hi3620_mmc_clk_init() drm/msm/dpu: Ratelimit framedone timeout msgs media: ddbridge: fix an error code problem in ddb_probe IB/ipoib: Fix mcast list locking drm/exynos: Call drm_atomic_helper_shutdown() at shutdown/unbind time ALSA: hda: Intel: add HDA_ARL PCI ID support PCI: add INTEL_HDA_ARL to pci_ids.h media: rockchip: rga: fix swizzling for RGB formats media: stk1160: Fixed high volume of stk1160_dbg messages drm/mipi-dsi: Fix detach call without attach drm/framebuffer: Fix use of uninitialized variable drm/drm_file: fix use of uninitialized variable RDMA/IPoIB: Fix error code return in ipoib_mcast_join fast_dput(): handle underflows gracefully ASoC: doc: Fix undefined SND_SOC_DAPM_NOPM argument f2fs: fix to check return value of f2fs_reserve_new_block() wifi: cfg80211: free beacon_ies when overridden from hidden BSS wifi: rtlwifi: rtl8723{be,ae}: using calculate_bit_shift() wifi: rtl8xxxu: Add additional USB IDs for RTL8192EU devices md: Whenassemble the array, consult the superblock of the freshest device ARM: dts: imx23/28: Fix the DMA controller node name ARM: dts: imx23-sansa: Use preferred i2c-gpios properties ARM: dts: imx27-apf27dev: Fix LED name ARM: dts: imx1: Fix sram node ARM: dts: imx27: Fix sram node ARM: dts: imx: Use flash@0,0 pattern ARM: dts: imx25/27-eukrea: Fix RTC node name ARM: dts: rockchip: fix rk3036 hdmi ports node scsi: libfc: Fix up timeout error in fc_fcp_rec_error() scsi: libfc: Don't schedule abort twice bpf: Add map and need_defer parameters to .map_fd_put_ptr() wifi: ath9k: Fix potential array-index-out-of-bounds read in ath9k_htc_txstatus() ARM: dts: imx7s: Fix nand-controller #size-cells ARM: dts: imx7s: Fix lcdif compatible bonding: return -ENOMEM instead of BUG in alb_upper_dev_walk PCI: Add no PM reset quirk for NVIDIA Spectrum devices scsi: lpfc: Fix possible file string name overflow when updating firmware ext4: avoid online resizing failures due to oversized flex bg ext4: remove unnecessary check from alloc_flex_gd() ext4: unify the type of flexbg_size to unsigned int ext4: fix inconsistent between segment fstrim and full fstrim SUNRPC: Fix a suspicious RCU usage warning KVM: s390: fix setting of fpc register s390/ptrace: handle setting of fpc register correctly jfs: fix array-index-out-of-bounds in diNewExt rxrpc_find_service_conn_rcu: fix the usage of read_seqbegin_or_lock() afs: fix the usage of read_seqbegin_or_lock() in afs_find_server*() crypto: stm32/crc32 - fix parsing list of devices pstore/ram: Fix crash when setting number of cpus to an odd number jfs: fix uaf in jfs_evict_inode jfs: fix array-index-out-of-bounds in dbAdjTree jfs: fix slab-out-of-bounds Read in dtSearch UBSAN: array-index-out-of-bounds in dtSplitRoot FS:JFS:UBSAN:array-index-out-of-bounds in dbAdjTree ACPI: extlog: fix NULL pointer dereference check PNP: ACPI: fix fortify warning ACPI: video: Add quirk for the Colorful X15 AT 23 Laptop audit: Send netlink ACK before setting connection in auditd_set powerpc/lib: Validate size for vector operations powerpc/mm: Fix build failures due to arch_reserved_kernel_pages() powerpc: Fix build error due to is_valid_bugaddr() powerpc/mm: Fix null-pointer dereference in pgtable_cache_add net/sched: cbs: Fix not adding cbs instance to list x86/entry/ia32: Ensure s32 is sign extended to s64 tick/sched: Preserve number of idle sleeps across CPU hotplug events mips: Call lose_fpu(0) before initializing fcr31 in mips_set_personality_nan gpio: eic-sprd: Clear interrupt after set the interrupt type drm/exynos: gsc: minor fix for loop iteration in gsc_runtime_resume drm/bridge: nxp-ptn3460: simplify some error checking drm/bridge: nxp-ptn3460: fix i2c_master_send() error checking drm: Don't unref the same fb many times by mistake due to deadlock handling gpiolib: acpi: Ignore touchpad wakeup on GPD G1619-04 netfilter: nf_tables: reject QUEUE/DROP verdict parameters btrfs: defrag: reject unknown flags of btrfs_ioctl_defrag_range_args btrfs: don't warn if discard range is not aligned to sector net: fec: fix the unhandled context fault from smmu fjes: fix memleaks in fjes_hw_setup netfilter: nf_tables: restrict anonymous set and map names to 16 bytes net/mlx5e: fix a double-free in arfs_create_groups net/mlx5: Use kfree(ft->g) in arfs_create_groups() netlink: fix potential sleeping issue in mqueue_flush_file Conflicts: include/linux/fs.h include/linux/timer.h init/initramfs.c kernel/time/timer.c mm/memory-failure.c mm/page_alloc.c net/core/sock.c scripts/Makefile.extrawarn Change-Id: I0ccfce4c1a43240cfb997b426ef9fc59e61e3c55
2118 lines
61 KiB
C
2118 lines
61 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
#ifndef _LINUX_BLKDEV_H
|
|
#define _LINUX_BLKDEV_H
|
|
|
|
#include <linux/sched.h>
|
|
#include <linux/sched/clock.h>
|
|
|
|
#ifdef CONFIG_BLOCK
|
|
|
|
#include <linux/major.h>
|
|
#include <linux/genhd.h>
|
|
#include <linux/list.h>
|
|
#include <linux/llist.h>
|
|
#include <linux/timer.h>
|
|
#include <linux/workqueue.h>
|
|
#include <linux/pagemap.h>
|
|
#include <linux/backing-dev-defs.h>
|
|
#include <linux/wait.h>
|
|
#include <linux/mempool.h>
|
|
#include <linux/pfn.h>
|
|
#include <linux/bio.h>
|
|
#include <linux/stringify.h>
|
|
#include <linux/gfp.h>
|
|
#include <linux/bsg.h>
|
|
#include <linux/smp.h>
|
|
#include <linux/rcupdate.h>
|
|
#include <linux/percpu-refcount.h>
|
|
#include <linux/scatterlist.h>
|
|
#include <linux/blkzoned.h>
|
|
|
|
struct module;
|
|
struct scsi_ioctl_command;
|
|
|
|
struct request_queue;
|
|
struct elevator_queue;
|
|
struct blk_trace;
|
|
struct request;
|
|
struct sg_io_hdr;
|
|
struct bsg_job;
|
|
struct blkcg_gq;
|
|
struct blk_flush_queue;
|
|
struct pr_ops;
|
|
struct rq_qos;
|
|
struct blk_queue_stats;
|
|
struct blk_stat_callback;
|
|
struct keyslot_manager;
|
|
|
|
#define BLKDEV_MIN_RQ 4
|
|
#define BLKDEV_MAX_RQ 128 /* Default maximum */
|
|
|
|
/* Must be consistent with blk_mq_poll_stats_bkt() */
|
|
#define BLK_MQ_POLL_STATS_BKTS 16
|
|
|
|
/*
|
|
* Maximum number of blkcg policies allowed to be registered concurrently.
|
|
* Defined here to simplify include dependency.
|
|
*/
|
|
#define BLKCG_MAX_POLS 5
|
|
|
|
static inline int blk_validate_block_size(unsigned int bsize)
|
|
{
|
|
if (bsize < 512 || bsize > PAGE_SIZE || !is_power_of_2(bsize))
|
|
return -EINVAL;
|
|
|
|
return 0;
|
|
}
|
|
|
|
typedef void (rq_end_io_fn)(struct request *, blk_status_t);
|
|
|
|
#define BLK_RL_SYNCFULL (1U << 0)
|
|
#define BLK_RL_ASYNCFULL (1U << 1)
|
|
|
|
struct request_list {
|
|
struct request_queue *q; /* the queue this rl belongs to */
|
|
#ifdef CONFIG_BLK_CGROUP
|
|
struct blkcg_gq *blkg; /* blkg this request pool belongs to */
|
|
#endif
|
|
/*
|
|
* count[], starved[], and wait[] are indexed by
|
|
* BLK_RW_SYNC/BLK_RW_ASYNC
|
|
*/
|
|
int count[2];
|
|
int starved[2];
|
|
mempool_t *rq_pool;
|
|
wait_queue_head_t wait[2];
|
|
unsigned int flags;
|
|
};
|
|
|
|
/*
|
|
* request flags */
|
|
typedef __u32 __bitwise req_flags_t;
|
|
|
|
/* elevator knows about this request */
|
|
#define RQF_SORTED ((__force req_flags_t)(1 << 0))
|
|
/* drive already may have started this one */
|
|
#define RQF_STARTED ((__force req_flags_t)(1 << 1))
|
|
/* uses tagged queueing */
|
|
#define RQF_QUEUED ((__force req_flags_t)(1 << 2))
|
|
/* may not be passed by ioscheduler */
|
|
#define RQF_SOFTBARRIER ((__force req_flags_t)(1 << 3))
|
|
/* request for flush sequence */
|
|
#define RQF_FLUSH_SEQ ((__force req_flags_t)(1 << 4))
|
|
/* merge of different types, fail separately */
|
|
#define RQF_MIXED_MERGE ((__force req_flags_t)(1 << 5))
|
|
/* track inflight for MQ */
|
|
#define RQF_MQ_INFLIGHT ((__force req_flags_t)(1 << 6))
|
|
/* don't call prep for this one */
|
|
#define RQF_DONTPREP ((__force req_flags_t)(1 << 7))
|
|
/* set for "ide_preempt" requests and also for requests for which the SCSI
|
|
"quiesce" state must be ignored. */
|
|
#define RQF_PREEMPT ((__force req_flags_t)(1 << 8))
|
|
/* contains copies of user pages */
|
|
#define RQF_COPY_USER ((__force req_flags_t)(1 << 9))
|
|
/* vaguely specified driver internal error. Ignored by the block layer */
|
|
#define RQF_FAILED ((__force req_flags_t)(1 << 10))
|
|
/* don't warn about errors */
|
|
#define RQF_QUIET ((__force req_flags_t)(1 << 11))
|
|
/* elevator private data attached */
|
|
#define RQF_ELVPRIV ((__force req_flags_t)(1 << 12))
|
|
/* account I/O stat */
|
|
#define RQF_IO_STAT ((__force req_flags_t)(1 << 13))
|
|
/* request came from our alloc pool */
|
|
#define RQF_ALLOCED ((__force req_flags_t)(1 << 14))
|
|
/* runtime pm request */
|
|
#define RQF_PM ((__force req_flags_t)(1 << 15))
|
|
/* on IO scheduler merge hash */
|
|
#define RQF_HASHED ((__force req_flags_t)(1 << 16))
|
|
/* IO stats tracking on */
|
|
#define RQF_STATS ((__force req_flags_t)(1 << 17))
|
|
/* Look at ->special_vec for the actual data payload instead of the
|
|
bio chain. */
|
|
#define RQF_SPECIAL_PAYLOAD ((__force req_flags_t)(1 << 18))
|
|
/* The per-zone write lock is held for this request */
|
|
#define RQF_ZONE_WRITE_LOCKED ((__force req_flags_t)(1 << 19))
|
|
/* already slept for hybrid poll */
|
|
#define RQF_MQ_POLL_SLEPT ((__force req_flags_t)(1 << 20))
|
|
/* ->timeout has been called, don't expire again */
|
|
#define RQF_TIMED_OUT ((__force req_flags_t)(1 << 21))
|
|
/* increased nr_pending for this request */
|
|
#define RQF_PM_ADDED ((__force req_flags_t)(1 << 22))
|
|
|
|
/* flags that prevent us from merging requests: */
|
|
#define RQF_NOMERGE_FLAGS \
|
|
(RQF_STARTED | RQF_SOFTBARRIER | RQF_FLUSH_SEQ | RQF_SPECIAL_PAYLOAD)
|
|
|
|
/*
|
|
* Request state for blk-mq.
|
|
*/
|
|
enum mq_rq_state {
|
|
MQ_RQ_IDLE = 0,
|
|
MQ_RQ_IN_FLIGHT = 1,
|
|
MQ_RQ_COMPLETE = 2,
|
|
};
|
|
|
|
/*
|
|
* Try to put the fields that are referenced together in the same cacheline.
|
|
*
|
|
* If you modify this structure, make sure to update blk_rq_init() and
|
|
* especially blk_mq_rq_ctx_init() to take care of the added fields.
|
|
*/
|
|
struct request {
|
|
struct request_queue *q;
|
|
struct blk_mq_ctx *mq_ctx;
|
|
|
|
int cpu;
|
|
unsigned int cmd_flags; /* op and common flags */
|
|
req_flags_t rq_flags;
|
|
|
|
int internal_tag;
|
|
|
|
/* the following two fields are internal, NEVER access directly */
|
|
unsigned int __data_len; /* total data len */
|
|
int tag;
|
|
sector_t __sector; /* sector cursor */
|
|
|
|
struct bio *bio;
|
|
struct bio *biotail;
|
|
|
|
struct list_head queuelist;
|
|
|
|
/*
|
|
* The hash is used inside the scheduler, and killed once the
|
|
* request reaches the dispatch list. The ipi_list is only used
|
|
* to queue the request for softirq completion, which is long
|
|
* after the request has been unhashed (and even removed from
|
|
* the dispatch list).
|
|
*/
|
|
union {
|
|
struct hlist_node hash; /* merge hash */
|
|
struct list_head ipi_list;
|
|
};
|
|
|
|
/*
|
|
* The rb_node is only used inside the io scheduler, requests
|
|
* are pruned when moved to the dispatch queue. So let the
|
|
* completion_data share space with the rb_node.
|
|
*/
|
|
union {
|
|
struct rb_node rb_node; /* sort/lookup */
|
|
struct bio_vec special_vec;
|
|
void *completion_data;
|
|
int error_count; /* for legacy drivers, don't use */
|
|
};
|
|
|
|
/*
|
|
* Three pointers are available for the IO schedulers, if they need
|
|
* more they have to dynamically allocate it. Flush requests are
|
|
* never put on the IO scheduler. So let the flush fields share
|
|
* space with the elevator data.
|
|
*/
|
|
union {
|
|
struct {
|
|
struct io_cq *icq;
|
|
void *priv[2];
|
|
} elv;
|
|
|
|
struct {
|
|
unsigned int seq;
|
|
struct list_head list;
|
|
rq_end_io_fn *saved_end_io;
|
|
} flush;
|
|
};
|
|
|
|
struct gendisk *rq_disk;
|
|
struct hd_struct *part;
|
|
/* Time that I/O was submitted to the kernel. */
|
|
u64 start_time_ns;
|
|
/* Time that I/O was submitted to the device. */
|
|
u64 io_start_time_ns;
|
|
|
|
#ifdef CONFIG_BLK_WBT
|
|
unsigned short wbt_flags;
|
|
#endif
|
|
#ifdef CONFIG_BLK_DEV_THROTTLING_LOW
|
|
unsigned short throtl_size;
|
|
#endif
|
|
|
|
/*
|
|
* Number of scatter-gather DMA addr+len pairs after
|
|
* physical address coalescing is performed.
|
|
*/
|
|
unsigned short nr_phys_segments;
|
|
|
|
#if defined(CONFIG_BLK_DEV_INTEGRITY)
|
|
unsigned short nr_integrity_segments;
|
|
#endif
|
|
|
|
unsigned short write_hint;
|
|
unsigned short ioprio;
|
|
|
|
void *special; /* opaque pointer available for LLD use */
|
|
|
|
unsigned int extra_len; /* length of alignment and padding */
|
|
|
|
enum mq_rq_state state;
|
|
refcount_t ref;
|
|
|
|
unsigned int timeout;
|
|
|
|
/* access through blk_rq_set_deadline, blk_rq_deadline */
|
|
unsigned long __deadline;
|
|
|
|
struct list_head timeout_list;
|
|
|
|
union {
|
|
struct __call_single_data csd;
|
|
u64 fifo_time;
|
|
};
|
|
|
|
/*
|
|
* completion callback.
|
|
*/
|
|
rq_end_io_fn *end_io;
|
|
void *end_io_data;
|
|
|
|
/* for bidi */
|
|
struct request *next_rq;
|
|
|
|
#ifdef CONFIG_BLK_CGROUP
|
|
struct request_list *rl; /* rl this rq is alloced from */
|
|
#endif
|
|
};
|
|
|
|
static inline bool blk_op_is_scsi(unsigned int op)
|
|
{
|
|
return op == REQ_OP_SCSI_IN || op == REQ_OP_SCSI_OUT;
|
|
}
|
|
|
|
static inline bool blk_op_is_private(unsigned int op)
|
|
{
|
|
return op == REQ_OP_DRV_IN || op == REQ_OP_DRV_OUT;
|
|
}
|
|
|
|
static inline bool blk_rq_is_scsi(struct request *rq)
|
|
{
|
|
return blk_op_is_scsi(req_op(rq));
|
|
}
|
|
|
|
static inline bool blk_rq_is_private(struct request *rq)
|
|
{
|
|
return blk_op_is_private(req_op(rq));
|
|
}
|
|
|
|
static inline bool blk_rq_is_passthrough(struct request *rq)
|
|
{
|
|
return blk_rq_is_scsi(rq) || blk_rq_is_private(rq);
|
|
}
|
|
|
|
static inline bool bio_is_passthrough(struct bio *bio)
|
|
{
|
|
unsigned op = bio_op(bio);
|
|
|
|
return blk_op_is_scsi(op) || blk_op_is_private(op);
|
|
}
|
|
|
|
static inline unsigned short req_get_ioprio(struct request *req)
|
|
{
|
|
return req->ioprio;
|
|
}
|
|
|
|
#include <linux/elevator.h>
|
|
|
|
struct blk_queue_ctx;
|
|
|
|
typedef void (request_fn_proc) (struct request_queue *q);
|
|
typedef blk_qc_t (make_request_fn) (struct request_queue *q, struct bio *bio);
|
|
typedef bool (poll_q_fn) (struct request_queue *q, blk_qc_t);
|
|
typedef int (prep_rq_fn) (struct request_queue *, struct request *);
|
|
typedef void (unprep_rq_fn) (struct request_queue *, struct request *);
|
|
|
|
struct bio_vec;
|
|
typedef void (softirq_done_fn)(struct request *);
|
|
typedef int (dma_drain_needed_fn)(struct request *);
|
|
typedef int (lld_busy_fn) (struct request_queue *q);
|
|
typedef int (bsg_job_fn) (struct bsg_job *);
|
|
typedef int (init_rq_fn)(struct request_queue *, struct request *, gfp_t);
|
|
typedef void (exit_rq_fn)(struct request_queue *, struct request *);
|
|
|
|
enum blk_eh_timer_return {
|
|
BLK_EH_DONE, /* drivers has completed the command */
|
|
BLK_EH_RESET_TIMER, /* reset timer and try again */
|
|
};
|
|
|
|
typedef enum blk_eh_timer_return (rq_timed_out_fn)(struct request *);
|
|
|
|
enum blk_queue_state {
|
|
Queue_down,
|
|
Queue_up,
|
|
};
|
|
|
|
struct blk_queue_tag {
|
|
struct request **tag_index; /* map of busy tags */
|
|
unsigned long *tag_map; /* bit map of free/busy tags */
|
|
int max_depth; /* what we will send to device */
|
|
int real_max_depth; /* what the array can hold */
|
|
atomic_t refcnt; /* map can be shared */
|
|
int alloc_policy; /* tag allocation policy */
|
|
int next_tag; /* next tag */
|
|
};
|
|
#define BLK_TAG_ALLOC_FIFO 0 /* allocate starting from 0 */
|
|
#define BLK_TAG_ALLOC_RR 1 /* allocate starting from last allocated tag */
|
|
|
|
#define BLK_SCSI_MAX_CMDS (256)
|
|
#define BLK_SCSI_CMD_PER_LONG (BLK_SCSI_MAX_CMDS / (sizeof(long) * 8))
|
|
|
|
/*
|
|
* Zoned block device models (zoned limit).
|
|
*/
|
|
enum blk_zoned_model {
|
|
BLK_ZONED_NONE, /* Regular block device */
|
|
BLK_ZONED_HA, /* Host-aware zoned block device */
|
|
BLK_ZONED_HM, /* Host-managed zoned block device */
|
|
};
|
|
|
|
struct queue_limits {
|
|
unsigned long bounce_pfn;
|
|
unsigned long seg_boundary_mask;
|
|
unsigned long virt_boundary_mask;
|
|
|
|
unsigned int max_hw_sectors;
|
|
unsigned int max_dev_sectors;
|
|
unsigned int chunk_sectors;
|
|
unsigned int max_sectors;
|
|
unsigned int max_segment_size;
|
|
unsigned int physical_block_size;
|
|
unsigned int logical_block_size;
|
|
unsigned int alignment_offset;
|
|
unsigned int io_min;
|
|
unsigned int io_opt;
|
|
unsigned int max_discard_sectors;
|
|
unsigned int max_hw_discard_sectors;
|
|
unsigned int max_write_same_sectors;
|
|
unsigned int max_write_zeroes_sectors;
|
|
unsigned int discard_granularity;
|
|
unsigned int discard_alignment;
|
|
|
|
unsigned short max_segments;
|
|
unsigned short max_integrity_segments;
|
|
unsigned short max_discard_segments;
|
|
|
|
unsigned char misaligned;
|
|
unsigned char discard_misaligned;
|
|
unsigned char cluster;
|
|
unsigned char raid_partial_stripes_expensive;
|
|
enum blk_zoned_model zoned;
|
|
};
|
|
|
|
#ifdef CONFIG_BLK_DEV_ZONED
|
|
|
|
struct blk_zone_report_hdr {
|
|
unsigned int nr_zones;
|
|
u8 padding[60];
|
|
};
|
|
|
|
extern int blkdev_report_zones(struct block_device *bdev,
|
|
sector_t sector, struct blk_zone *zones,
|
|
unsigned int *nr_zones, gfp_t gfp_mask);
|
|
extern int blkdev_reset_zones(struct block_device *bdev, sector_t sectors,
|
|
sector_t nr_sectors, gfp_t gfp_mask);
|
|
|
|
extern int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode,
|
|
unsigned int cmd, unsigned long arg);
|
|
extern int blkdev_reset_zones_ioctl(struct block_device *bdev, fmode_t mode,
|
|
unsigned int cmd, unsigned long arg);
|
|
|
|
#else /* CONFIG_BLK_DEV_ZONED */
|
|
|
|
static inline int blkdev_report_zones_ioctl(struct block_device *bdev,
|
|
fmode_t mode, unsigned int cmd,
|
|
unsigned long arg)
|
|
{
|
|
return -ENOTTY;
|
|
}
|
|
|
|
static inline int blkdev_reset_zones_ioctl(struct block_device *bdev,
|
|
fmode_t mode, unsigned int cmd,
|
|
unsigned long arg)
|
|
{
|
|
return -ENOTTY;
|
|
}
|
|
|
|
#endif /* CONFIG_BLK_DEV_ZONED */
|
|
|
|
struct request_queue {
|
|
/*
|
|
* Together with queue_head for cacheline sharing
|
|
*/
|
|
struct list_head queue_head;
|
|
struct request *last_merge;
|
|
struct elevator_queue *elevator;
|
|
int nr_rqs[2]; /* # allocated [a]sync rqs */
|
|
int nr_rqs_elvpriv; /* # allocated rqs w/ elvpriv */
|
|
|
|
struct blk_queue_stats *stats;
|
|
struct rq_qos *rq_qos;
|
|
|
|
/*
|
|
* If blkcg is not used, @q->root_rl serves all requests. If blkcg
|
|
* is used, root blkg allocates from @q->root_rl and all other
|
|
* blkgs from their own blkg->rl. Which one to use should be
|
|
* determined using bio_request_list().
|
|
*/
|
|
struct request_list root_rl;
|
|
|
|
request_fn_proc *request_fn;
|
|
make_request_fn *make_request_fn;
|
|
poll_q_fn *poll_fn;
|
|
prep_rq_fn *prep_rq_fn;
|
|
unprep_rq_fn *unprep_rq_fn;
|
|
softirq_done_fn *softirq_done_fn;
|
|
rq_timed_out_fn *rq_timed_out_fn;
|
|
dma_drain_needed_fn *dma_drain_needed;
|
|
lld_busy_fn *lld_busy_fn;
|
|
/* Called just after a request is allocated */
|
|
init_rq_fn *init_rq_fn;
|
|
/* Called just before a request is freed */
|
|
exit_rq_fn *exit_rq_fn;
|
|
/* Called from inside blk_get_request() */
|
|
void (*initialize_rq_fn)(struct request *rq);
|
|
|
|
const struct blk_mq_ops *mq_ops;
|
|
|
|
unsigned int *mq_map;
|
|
|
|
/* sw queues */
|
|
struct blk_mq_ctx __percpu *queue_ctx;
|
|
unsigned int nr_queues;
|
|
|
|
unsigned int queue_depth;
|
|
|
|
/* hw dispatch queues */
|
|
struct blk_mq_hw_ctx **queue_hw_ctx;
|
|
unsigned int nr_hw_queues;
|
|
|
|
/*
|
|
* Dispatch queue sorting
|
|
*/
|
|
sector_t end_sector;
|
|
struct request *boundary_rq;
|
|
|
|
/*
|
|
* Delayed queue handling
|
|
*/
|
|
struct delayed_work delay_work;
|
|
|
|
struct backing_dev_info *backing_dev_info;
|
|
|
|
/*
|
|
* The queue owner gets to use this for whatever they like.
|
|
* ll_rw_blk doesn't touch it.
|
|
*/
|
|
void *queuedata;
|
|
|
|
/*
|
|
* various queue flags, see QUEUE_* below
|
|
*/
|
|
unsigned long queue_flags;
|
|
/*
|
|
* Number of contexts that have called blk_set_pm_only(). If this
|
|
* counter is above zero then only RQF_PM and RQF_PREEMPT requests are
|
|
* processed.
|
|
*/
|
|
atomic_t pm_only;
|
|
|
|
/*
|
|
* ida allocated id for this queue. Used to index queues from
|
|
* ioctx.
|
|
*/
|
|
int id;
|
|
|
|
/*
|
|
* queue needs bounce pages for pages above this limit
|
|
*/
|
|
gfp_t bounce_gfp;
|
|
|
|
/*
|
|
* protects queue structures from reentrancy. ->__queue_lock should
|
|
* _never_ be used directly, it is queue private. always use
|
|
* ->queue_lock.
|
|
*/
|
|
spinlock_t __queue_lock;
|
|
spinlock_t *queue_lock;
|
|
|
|
/*
|
|
* queue kobject
|
|
*/
|
|
struct kobject kobj;
|
|
|
|
/*
|
|
* mq queue kobject
|
|
*/
|
|
struct kobject mq_kobj;
|
|
|
|
#ifdef CONFIG_BLK_DEV_INTEGRITY
|
|
struct blk_integrity integrity;
|
|
#endif /* CONFIG_BLK_DEV_INTEGRITY */
|
|
|
|
#ifdef CONFIG_PM
|
|
struct device *dev;
|
|
int rpm_status;
|
|
unsigned int nr_pending;
|
|
#endif
|
|
|
|
/*
|
|
* queue settings
|
|
*/
|
|
unsigned long nr_requests; /* Max # of requests */
|
|
unsigned int nr_congestion_on;
|
|
unsigned int nr_congestion_off;
|
|
unsigned int nr_batching;
|
|
|
|
unsigned int dma_drain_size;
|
|
void *dma_drain_buffer;
|
|
unsigned int dma_pad_mask;
|
|
unsigned int dma_alignment;
|
|
|
|
struct blk_queue_tag *queue_tags;
|
|
|
|
unsigned int nr_sorted;
|
|
unsigned int in_flight[2];
|
|
|
|
/*
|
|
* Number of active block driver functions for which blk_drain_queue()
|
|
* must wait. Must be incremented around functions that unlock the
|
|
* queue_lock internally, e.g. scsi_request_fn().
|
|
*/
|
|
unsigned int request_fn_active;
|
|
#ifdef CONFIG_BLK_INLINE_ENCRYPTION
|
|
/* Inline crypto capabilities */
|
|
struct keyslot_manager *ksm;
|
|
#endif
|
|
|
|
unsigned int rq_timeout;
|
|
int poll_nsec;
|
|
|
|
struct blk_stat_callback *poll_cb;
|
|
struct blk_rq_stat poll_stat[BLK_MQ_POLL_STATS_BKTS];
|
|
|
|
struct timer_list timeout;
|
|
struct work_struct timeout_work;
|
|
struct list_head timeout_list;
|
|
|
|
struct list_head icq_list;
|
|
#ifdef CONFIG_BLK_CGROUP
|
|
DECLARE_BITMAP (blkcg_pols, BLKCG_MAX_POLS);
|
|
struct blkcg_gq *root_blkg;
|
|
struct list_head blkg_list;
|
|
#endif
|
|
|
|
struct queue_limits limits;
|
|
|
|
#ifdef CONFIG_BLK_DEV_ZONED
|
|
/*
|
|
* Zoned block device information for request dispatch control.
|
|
* nr_zones is the total number of zones of the device. This is always
|
|
* 0 for regular block devices. seq_zones_bitmap is a bitmap of nr_zones
|
|
* bits which indicates if a zone is conventional (bit clear) or
|
|
* sequential (bit set). seq_zones_wlock is a bitmap of nr_zones
|
|
* bits which indicates if a zone is write locked, that is, if a write
|
|
* request targeting the zone was dispatched. All three fields are
|
|
* initialized by the low level device driver (e.g. scsi/sd.c).
|
|
* Stacking drivers (device mappers) may or may not initialize
|
|
* these fields.
|
|
*
|
|
* Reads of this information must be protected with blk_queue_enter() /
|
|
* blk_queue_exit(). Modifying this information is only allowed while
|
|
* no requests are being processed. See also blk_mq_freeze_queue() and
|
|
* blk_mq_unfreeze_queue().
|
|
*/
|
|
unsigned int nr_zones;
|
|
unsigned long *seq_zones_bitmap;
|
|
unsigned long *seq_zones_wlock;
|
|
#endif /* CONFIG_BLK_DEV_ZONED */
|
|
|
|
/*
|
|
* sg stuff
|
|
*/
|
|
unsigned int sg_timeout;
|
|
unsigned int sg_reserved_size;
|
|
int node;
|
|
#ifdef CONFIG_BLK_DEV_IO_TRACE
|
|
struct blk_trace __rcu *blk_trace;
|
|
struct mutex blk_trace_mutex;
|
|
#endif
|
|
/*
|
|
* for flush operations
|
|
*/
|
|
struct blk_flush_queue *fq;
|
|
|
|
struct list_head requeue_list;
|
|
spinlock_t requeue_lock;
|
|
struct delayed_work requeue_work;
|
|
|
|
struct mutex sysfs_lock;
|
|
|
|
int bypass_depth;
|
|
atomic_t mq_freeze_depth;
|
|
|
|
bsg_job_fn *bsg_job_fn;
|
|
struct bsg_class_device bsg_dev;
|
|
|
|
#ifdef CONFIG_BLK_DEV_THROTTLING
|
|
/* Throttle data */
|
|
struct throtl_data *td;
|
|
#endif
|
|
struct rcu_head rcu_head;
|
|
wait_queue_head_t mq_freeze_wq;
|
|
struct percpu_ref q_usage_counter;
|
|
struct list_head all_q_node;
|
|
|
|
struct blk_mq_tag_set *tag_set;
|
|
struct list_head tag_set_list;
|
|
struct bio_set bio_split;
|
|
|
|
#ifdef CONFIG_BLK_DEBUG_FS
|
|
struct dentry *debugfs_dir;
|
|
struct dentry *sched_debugfs_dir;
|
|
#endif
|
|
|
|
bool mq_sysfs_init_done;
|
|
|
|
size_t cmd_size;
|
|
void *rq_alloc_data;
|
|
|
|
struct work_struct release_work;
|
|
|
|
#define BLK_MAX_WRITE_HINTS 5
|
|
u64 write_hints[BLK_MAX_WRITE_HINTS];
|
|
};
|
|
|
|
#define QUEUE_FLAG_QUEUED 0 /* uses generic tag queueing */
|
|
#define QUEUE_FLAG_STOPPED 1 /* queue is stopped */
|
|
#define QUEUE_FLAG_DYING 2 /* queue being torn down */
|
|
#define QUEUE_FLAG_BYPASS 3 /* act as dumb FIFO queue */
|
|
#define QUEUE_FLAG_BIDI 4 /* queue supports bidi requests */
|
|
#define QUEUE_FLAG_NOMERGES 5 /* disable merge attempts */
|
|
#define QUEUE_FLAG_SAME_COMP 6 /* complete on same CPU-group */
|
|
#define QUEUE_FLAG_FAIL_IO 7 /* fake timeout */
|
|
#define QUEUE_FLAG_NONROT 9 /* non-rotational device (SSD) */
|
|
#define QUEUE_FLAG_VIRT QUEUE_FLAG_NONROT /* paravirt device */
|
|
#define QUEUE_FLAG_IO_STAT 10 /* do IO stats */
|
|
#define QUEUE_FLAG_DISCARD 11 /* supports DISCARD */
|
|
#define QUEUE_FLAG_NOXMERGES 12 /* No extended merges */
|
|
#define QUEUE_FLAG_ADD_RANDOM 13 /* Contributes to random pool */
|
|
#define QUEUE_FLAG_SECERASE 14 /* supports secure erase */
|
|
#define QUEUE_FLAG_SAME_FORCE 15 /* force complete on same CPU */
|
|
#define QUEUE_FLAG_DEAD 16 /* queue tear-down finished */
|
|
#define QUEUE_FLAG_INIT_DONE 17 /* queue is initialized */
|
|
#define QUEUE_FLAG_NO_SG_MERGE 18 /* don't attempt to merge SG segments*/
|
|
#define QUEUE_FLAG_POLL 19 /* IO polling enabled if set */
|
|
#define QUEUE_FLAG_WC 20 /* Write back caching */
|
|
#define QUEUE_FLAG_FUA 21 /* device supports FUA writes */
|
|
#define QUEUE_FLAG_FLUSH_NQ 22 /* flush not queueuable */
|
|
#define QUEUE_FLAG_DAX 23 /* device supports DAX */
|
|
#define QUEUE_FLAG_STATS 24 /* track rq completion times */
|
|
#define QUEUE_FLAG_POLL_STATS 25 /* collecting stats for hybrid polling */
|
|
#define QUEUE_FLAG_REGISTERED 26 /* queue has been registered to a disk */
|
|
#define QUEUE_FLAG_SCSI_PASSTHROUGH 27 /* queue supports SCSI commands */
|
|
#define QUEUE_FLAG_QUIESCED 28 /* queue has been quiesced */
|
|
|
|
#define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \
|
|
(1 << QUEUE_FLAG_SAME_COMP) | \
|
|
(1 << QUEUE_FLAG_ADD_RANDOM))
|
|
|
|
#define QUEUE_FLAG_MQ_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \
|
|
(1 << QUEUE_FLAG_SAME_COMP) | \
|
|
(1 << QUEUE_FLAG_POLL))
|
|
|
|
void blk_queue_flag_set(unsigned int flag, struct request_queue *q);
|
|
void blk_queue_flag_clear(unsigned int flag, struct request_queue *q);
|
|
bool blk_queue_flag_test_and_set(unsigned int flag, struct request_queue *q);
|
|
bool blk_queue_flag_test_and_clear(unsigned int flag, struct request_queue *q);
|
|
|
|
#define blk_queue_tagged(q) test_bit(QUEUE_FLAG_QUEUED, &(q)->queue_flags)
|
|
#define blk_queue_stopped(q) test_bit(QUEUE_FLAG_STOPPED, &(q)->queue_flags)
|
|
#define blk_queue_dying(q) test_bit(QUEUE_FLAG_DYING, &(q)->queue_flags)
|
|
#define blk_queue_dead(q) test_bit(QUEUE_FLAG_DEAD, &(q)->queue_flags)
|
|
#define blk_queue_bypass(q) test_bit(QUEUE_FLAG_BYPASS, &(q)->queue_flags)
|
|
#define blk_queue_init_done(q) test_bit(QUEUE_FLAG_INIT_DONE, &(q)->queue_flags)
|
|
#define blk_queue_nomerges(q) test_bit(QUEUE_FLAG_NOMERGES, &(q)->queue_flags)
|
|
#define blk_queue_noxmerges(q) \
|
|
test_bit(QUEUE_FLAG_NOXMERGES, &(q)->queue_flags)
|
|
#define blk_queue_nonrot(q) test_bit(QUEUE_FLAG_NONROT, &(q)->queue_flags)
|
|
#define blk_queue_io_stat(q) test_bit(QUEUE_FLAG_IO_STAT, &(q)->queue_flags)
|
|
#define blk_queue_add_random(q) test_bit(QUEUE_FLAG_ADD_RANDOM, &(q)->queue_flags)
|
|
#define blk_queue_discard(q) test_bit(QUEUE_FLAG_DISCARD, &(q)->queue_flags)
|
|
#define blk_queue_secure_erase(q) \
|
|
(test_bit(QUEUE_FLAG_SECERASE, &(q)->queue_flags))
|
|
#define blk_queue_dax(q) test_bit(QUEUE_FLAG_DAX, &(q)->queue_flags)
|
|
#define blk_queue_scsi_passthrough(q) \
|
|
test_bit(QUEUE_FLAG_SCSI_PASSTHROUGH, &(q)->queue_flags)
|
|
|
|
#define blk_noretry_request(rq) \
|
|
((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \
|
|
REQ_FAILFAST_DRIVER))
|
|
#define blk_queue_quiesced(q) test_bit(QUEUE_FLAG_QUIESCED, &(q)->queue_flags)
|
|
#define blk_queue_pm_only(q) atomic_read(&(q)->pm_only)
|
|
#define blk_queue_fua(q) test_bit(QUEUE_FLAG_FUA, &(q)->queue_flags)
|
|
#define blk_queue_registered(q) test_bit(QUEUE_FLAG_REGISTERED, &(q)->queue_flags)
|
|
|
|
extern void blk_set_pm_only(struct request_queue *q);
|
|
extern void blk_clear_pm_only(struct request_queue *q);
|
|
|
|
static inline int queue_in_flight(struct request_queue *q)
|
|
{
|
|
return q->in_flight[0] + q->in_flight[1];
|
|
}
|
|
|
|
static inline bool blk_account_rq(struct request *rq)
|
|
{
|
|
return (rq->rq_flags & RQF_STARTED) && !blk_rq_is_passthrough(rq);
|
|
}
|
|
|
|
#define blk_rq_cpu_valid(rq) ((rq)->cpu != -1)
|
|
#define blk_bidi_rq(rq) ((rq)->next_rq != NULL)
|
|
/* rq->queuelist of dequeued request must be list_empty() */
|
|
#define blk_queued_rq(rq) (!list_empty(&(rq)->queuelist))
|
|
|
|
#define list_entry_rq(ptr) list_entry((ptr), struct request, queuelist)
|
|
|
|
#define rq_data_dir(rq) (op_is_write(req_op(rq)) ? WRITE : READ)
|
|
|
|
/*
|
|
* Driver can handle struct request, if it either has an old style
|
|
* request_fn defined, or is blk-mq based.
|
|
*/
|
|
static inline bool queue_is_rq_based(struct request_queue *q)
|
|
{
|
|
return q->request_fn || q->mq_ops;
|
|
}
|
|
|
|
static inline unsigned int blk_queue_cluster(struct request_queue *q)
|
|
{
|
|
return q->limits.cluster;
|
|
}
|
|
|
|
static inline enum blk_zoned_model
|
|
blk_queue_zoned_model(struct request_queue *q)
|
|
{
|
|
return q->limits.zoned;
|
|
}
|
|
|
|
static inline bool blk_queue_is_zoned(struct request_queue *q)
|
|
{
|
|
switch (blk_queue_zoned_model(q)) {
|
|
case BLK_ZONED_HA:
|
|
case BLK_ZONED_HM:
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
|
|
static inline unsigned int blk_queue_zone_sectors(struct request_queue *q)
|
|
{
|
|
return blk_queue_is_zoned(q) ? q->limits.chunk_sectors : 0;
|
|
}
|
|
|
|
#ifdef CONFIG_BLK_DEV_ZONED
|
|
static inline unsigned int blk_queue_zone_no(struct request_queue *q,
|
|
sector_t sector)
|
|
{
|
|
if (!blk_queue_is_zoned(q))
|
|
return 0;
|
|
return sector >> ilog2(q->limits.chunk_sectors);
|
|
}
|
|
|
|
static inline bool blk_queue_zone_is_seq(struct request_queue *q,
|
|
sector_t sector)
|
|
{
|
|
if (!blk_queue_is_zoned(q) || !q->seq_zones_bitmap)
|
|
return false;
|
|
return test_bit(blk_queue_zone_no(q, sector), q->seq_zones_bitmap);
|
|
}
|
|
#endif /* CONFIG_BLK_DEV_ZONED */
|
|
|
|
static inline bool rq_is_sync(struct request *rq)
|
|
{
|
|
return op_is_sync(rq->cmd_flags);
|
|
}
|
|
|
|
static inline bool blk_rl_full(struct request_list *rl, bool sync)
|
|
{
|
|
unsigned int flag = sync ? BLK_RL_SYNCFULL : BLK_RL_ASYNCFULL;
|
|
|
|
return rl->flags & flag;
|
|
}
|
|
|
|
static inline void blk_set_rl_full(struct request_list *rl, bool sync)
|
|
{
|
|
unsigned int flag = sync ? BLK_RL_SYNCFULL : BLK_RL_ASYNCFULL;
|
|
|
|
rl->flags |= flag;
|
|
}
|
|
|
|
static inline void blk_clear_rl_full(struct request_list *rl, bool sync)
|
|
{
|
|
unsigned int flag = sync ? BLK_RL_SYNCFULL : BLK_RL_ASYNCFULL;
|
|
|
|
rl->flags &= ~flag;
|
|
}
|
|
|
|
static inline bool rq_mergeable(struct request *rq)
|
|
{
|
|
if (blk_rq_is_passthrough(rq))
|
|
return false;
|
|
|
|
if (req_op(rq) == REQ_OP_FLUSH)
|
|
return false;
|
|
|
|
if (req_op(rq) == REQ_OP_WRITE_ZEROES)
|
|
return false;
|
|
|
|
if (rq->cmd_flags & REQ_NOMERGE_FLAGS)
|
|
return false;
|
|
if (rq->rq_flags & RQF_NOMERGE_FLAGS)
|
|
return false;
|
|
|
|
return true;
|
|
}
|
|
|
|
static inline bool blk_write_same_mergeable(struct bio *a, struct bio *b)
|
|
{
|
|
if (bio_page(a) == bio_page(b) &&
|
|
bio_offset(a) == bio_offset(b))
|
|
return true;
|
|
|
|
return false;
|
|
}
|
|
|
|
static inline unsigned int blk_queue_depth(struct request_queue *q)
|
|
{
|
|
if (q->queue_depth)
|
|
return q->queue_depth;
|
|
|
|
return q->nr_requests;
|
|
}
|
|
|
|
/*
|
|
* q->prep_rq_fn return values
|
|
*/
|
|
enum {
|
|
BLKPREP_OK, /* serve it */
|
|
BLKPREP_KILL, /* fatal error, kill, return -EIO */
|
|
BLKPREP_DEFER, /* leave on queue */
|
|
BLKPREP_INVALID, /* invalid command, kill, return -EREMOTEIO */
|
|
};
|
|
|
|
extern unsigned long blk_max_low_pfn, blk_max_pfn;
|
|
|
|
/*
|
|
* standard bounce addresses:
|
|
*
|
|
* BLK_BOUNCE_HIGH : bounce all highmem pages
|
|
* BLK_BOUNCE_ANY : don't bounce anything
|
|
* BLK_BOUNCE_ISA : bounce pages above ISA DMA boundary
|
|
*/
|
|
|
|
#if BITS_PER_LONG == 32
|
|
#define BLK_BOUNCE_HIGH ((u64)blk_max_low_pfn << PAGE_SHIFT)
|
|
#else
|
|
#define BLK_BOUNCE_HIGH -1ULL
|
|
#endif
|
|
#define BLK_BOUNCE_ANY (-1ULL)
|
|
#define BLK_BOUNCE_ISA (DMA_BIT_MASK(24))
|
|
|
|
/*
|
|
* default timeout for SG_IO if none specified
|
|
*/
|
|
#define BLK_DEFAULT_SG_TIMEOUT (60 * HZ)
|
|
#define BLK_MIN_SG_TIMEOUT (7 * HZ)
|
|
|
|
struct rq_map_data {
|
|
struct page **pages;
|
|
int page_order;
|
|
int nr_entries;
|
|
unsigned long offset;
|
|
int null_mapped;
|
|
int from_user;
|
|
};
|
|
|
|
struct req_iterator {
|
|
struct bvec_iter iter;
|
|
struct bio *bio;
|
|
};
|
|
|
|
/* This should not be used directly - use rq_for_each_segment */
|
|
#define for_each_bio(_bio) \
|
|
for (; _bio; _bio = _bio->bi_next)
|
|
#define __rq_for_each_bio(_bio, rq) \
|
|
if ((rq->bio)) \
|
|
for (_bio = (rq)->bio; _bio; _bio = _bio->bi_next)
|
|
|
|
#define rq_for_each_segment(bvl, _rq, _iter) \
|
|
__rq_for_each_bio(_iter.bio, _rq) \
|
|
bio_for_each_segment(bvl, _iter.bio, _iter.iter)
|
|
|
|
#define rq_iter_last(bvec, _iter) \
|
|
(_iter.bio->bi_next == NULL && \
|
|
bio_iter_last(bvec, _iter.iter))
|
|
|
|
#ifndef ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
|
|
# error "You should define ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE for your platform"
|
|
#endif
|
|
#if ARCH_IMPLEMENTS_FLUSH_DCACHE_PAGE
|
|
extern void rq_flush_dcache_pages(struct request *rq);
|
|
#else
|
|
static inline void rq_flush_dcache_pages(struct request *rq)
|
|
{
|
|
}
|
|
#endif
|
|
|
|
extern int blk_register_queue(struct gendisk *disk);
|
|
extern void blk_unregister_queue(struct gendisk *disk);
|
|
extern blk_qc_t generic_make_request(struct bio *bio);
|
|
extern blk_qc_t direct_make_request(struct bio *bio);
|
|
extern void blk_rq_init(struct request_queue *q, struct request *rq);
|
|
extern void blk_init_request_from_bio(struct request *req, struct bio *bio);
|
|
extern void blk_put_request(struct request *);
|
|
extern void __blk_put_request(struct request_queue *, struct request *);
|
|
extern struct request *blk_get_request(struct request_queue *, unsigned int op,
|
|
blk_mq_req_flags_t flags);
|
|
extern void blk_requeue_request(struct request_queue *, struct request *);
|
|
extern int blk_lld_busy(struct request_queue *q);
|
|
extern int blk_rq_prep_clone(struct request *rq, struct request *rq_src,
|
|
struct bio_set *bs, gfp_t gfp_mask,
|
|
int (*bio_ctr)(struct bio *, struct bio *, void *),
|
|
void *data);
|
|
extern void blk_rq_unprep_clone(struct request *rq);
|
|
extern blk_status_t blk_insert_cloned_request(struct request_queue *q,
|
|
struct request *rq);
|
|
extern int blk_rq_append_bio(struct request *rq, struct bio **bio);
|
|
extern void blk_delay_queue(struct request_queue *, unsigned long);
|
|
extern void blk_queue_split(struct request_queue *, struct bio **);
|
|
extern void blk_recount_segments(struct request_queue *, struct bio *);
|
|
extern int scsi_verify_blk_ioctl(struct block_device *, unsigned int);
|
|
extern int scsi_cmd_blk_ioctl(struct block_device *, fmode_t,
|
|
unsigned int, void __user *);
|
|
extern int scsi_cmd_ioctl(struct request_queue *, struct gendisk *, fmode_t,
|
|
unsigned int, void __user *);
|
|
extern int sg_scsi_ioctl(struct request_queue *, struct gendisk *, fmode_t,
|
|
struct scsi_ioctl_command __user *);
|
|
|
|
extern int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags);
|
|
extern void blk_queue_exit(struct request_queue *q);
|
|
extern void blk_start_queue(struct request_queue *q);
|
|
extern void blk_start_queue_async(struct request_queue *q);
|
|
extern void blk_stop_queue(struct request_queue *q);
|
|
extern void blk_sync_queue(struct request_queue *q);
|
|
extern void __blk_stop_queue(struct request_queue *q);
|
|
extern void __blk_run_queue(struct request_queue *q);
|
|
extern void __blk_run_queue_uncond(struct request_queue *q);
|
|
extern void blk_run_queue(struct request_queue *);
|
|
extern void blk_run_queue_async(struct request_queue *q);
|
|
extern int blk_rq_map_user(struct request_queue *, struct request *,
|
|
struct rq_map_data *, void __user *, unsigned long,
|
|
gfp_t);
|
|
extern int blk_rq_unmap_user(struct bio *);
|
|
extern int blk_rq_map_kern(struct request_queue *, struct request *, void *, unsigned int, gfp_t);
|
|
extern int blk_rq_map_user_iov(struct request_queue *, struct request *,
|
|
struct rq_map_data *, const struct iov_iter *,
|
|
gfp_t);
|
|
extern void blk_execute_rq(struct request_queue *, struct gendisk *,
|
|
struct request *, int);
|
|
extern void blk_execute_rq_nowait(struct request_queue *, struct gendisk *,
|
|
struct request *, int, rq_end_io_fn *);
|
|
|
|
int blk_status_to_errno(blk_status_t status);
|
|
blk_status_t errno_to_blk_status(int errno);
|
|
|
|
bool blk_poll(struct request_queue *q, blk_qc_t cookie);
|
|
|
|
static inline struct request_queue *bdev_get_queue(struct block_device *bdev)
|
|
{
|
|
return bdev->bd_disk->queue; /* this is never NULL */
|
|
}
|
|
|
|
/*
|
|
* The basic unit of block I/O is a sector. It is used in a number of contexts
|
|
* in Linux (blk, bio, genhd). The size of one sector is 512 = 2**9
|
|
* bytes. Variables of type sector_t represent an offset or size that is a
|
|
* multiple of 512 bytes. Hence these two constants.
|
|
*/
|
|
#ifndef SECTOR_SHIFT
|
|
#define SECTOR_SHIFT 9
|
|
#endif
|
|
#ifndef SECTOR_SIZE
|
|
#define SECTOR_SIZE (1 << SECTOR_SHIFT)
|
|
#endif
|
|
|
|
/*
|
|
* blk_rq_pos() : the current sector
|
|
* blk_rq_bytes() : bytes left in the entire request
|
|
* blk_rq_cur_bytes() : bytes left in the current segment
|
|
* blk_rq_err_bytes() : bytes left till the next error boundary
|
|
* blk_rq_sectors() : sectors left in the entire request
|
|
* blk_rq_cur_sectors() : sectors left in the current segment
|
|
*/
|
|
static inline sector_t blk_rq_pos(const struct request *rq)
|
|
{
|
|
return rq->__sector;
|
|
}
|
|
|
|
static inline unsigned int blk_rq_bytes(const struct request *rq)
|
|
{
|
|
return rq->__data_len;
|
|
}
|
|
|
|
static inline int blk_rq_cur_bytes(const struct request *rq)
|
|
{
|
|
return rq->bio ? bio_cur_bytes(rq->bio) : 0;
|
|
}
|
|
|
|
extern unsigned int blk_rq_err_bytes(const struct request *rq);
|
|
|
|
static inline unsigned int blk_rq_sectors(const struct request *rq)
|
|
{
|
|
return blk_rq_bytes(rq) >> SECTOR_SHIFT;
|
|
}
|
|
|
|
static inline unsigned int blk_rq_cur_sectors(const struct request *rq)
|
|
{
|
|
return blk_rq_cur_bytes(rq) >> SECTOR_SHIFT;
|
|
}
|
|
|
|
#ifdef CONFIG_BLK_DEV_ZONED
|
|
static inline unsigned int blk_rq_zone_no(struct request *rq)
|
|
{
|
|
return blk_queue_zone_no(rq->q, blk_rq_pos(rq));
|
|
}
|
|
|
|
static inline unsigned int blk_rq_zone_is_seq(struct request *rq)
|
|
{
|
|
return blk_queue_zone_is_seq(rq->q, blk_rq_pos(rq));
|
|
}
|
|
#endif /* CONFIG_BLK_DEV_ZONED */
|
|
|
|
/*
|
|
* Some commands like WRITE SAME have a payload or data transfer size which
|
|
* is different from the size of the request. Any driver that supports such
|
|
* commands using the RQF_SPECIAL_PAYLOAD flag needs to use this helper to
|
|
* calculate the data transfer size.
|
|
*/
|
|
static inline unsigned int blk_rq_payload_bytes(struct request *rq)
|
|
{
|
|
if (rq->rq_flags & RQF_SPECIAL_PAYLOAD)
|
|
return rq->special_vec.bv_len;
|
|
return blk_rq_bytes(rq);
|
|
}
|
|
|
|
static inline unsigned int blk_queue_get_max_sectors(struct request_queue *q,
|
|
int op)
|
|
{
|
|
if (unlikely(op == REQ_OP_DISCARD || op == REQ_OP_SECURE_ERASE))
|
|
return min(q->limits.max_discard_sectors,
|
|
UINT_MAX >> SECTOR_SHIFT);
|
|
|
|
if (unlikely(op == REQ_OP_WRITE_SAME))
|
|
return q->limits.max_write_same_sectors;
|
|
|
|
if (unlikely(op == REQ_OP_WRITE_ZEROES))
|
|
return q->limits.max_write_zeroes_sectors;
|
|
|
|
return q->limits.max_sectors;
|
|
}
|
|
|
|
/*
|
|
* Return maximum size of a request at given offset. Only valid for
|
|
* file system requests.
|
|
*/
|
|
static inline unsigned int blk_max_size_offset(struct request_queue *q,
|
|
sector_t offset)
|
|
{
|
|
if (!q->limits.chunk_sectors)
|
|
return q->limits.max_sectors;
|
|
|
|
return min(q->limits.max_sectors, (unsigned int)(q->limits.chunk_sectors -
|
|
(offset & (q->limits.chunk_sectors - 1))));
|
|
}
|
|
|
|
static inline unsigned int blk_rq_get_max_sectors(struct request *rq,
|
|
sector_t offset)
|
|
{
|
|
struct request_queue *q = rq->q;
|
|
|
|
if (blk_rq_is_passthrough(rq))
|
|
return q->limits.max_hw_sectors;
|
|
|
|
if (!q->limits.chunk_sectors ||
|
|
req_op(rq) == REQ_OP_DISCARD ||
|
|
req_op(rq) == REQ_OP_SECURE_ERASE)
|
|
return blk_queue_get_max_sectors(q, req_op(rq));
|
|
|
|
return min(blk_max_size_offset(q, offset),
|
|
blk_queue_get_max_sectors(q, req_op(rq)));
|
|
}
|
|
|
|
static inline unsigned int blk_rq_count_bios(struct request *rq)
|
|
{
|
|
unsigned int nr_bios = 0;
|
|
struct bio *bio;
|
|
|
|
__rq_for_each_bio(bio, rq)
|
|
nr_bios++;
|
|
|
|
return nr_bios;
|
|
}
|
|
|
|
/*
|
|
* Request issue related functions.
|
|
*/
|
|
extern struct request *blk_peek_request(struct request_queue *q);
|
|
extern void blk_start_request(struct request *rq);
|
|
extern struct request *blk_fetch_request(struct request_queue *q);
|
|
|
|
void blk_steal_bios(struct bio_list *list, struct request *rq);
|
|
|
|
/*
|
|
* Request completion related functions.
|
|
*
|
|
* blk_update_request() completes given number of bytes and updates
|
|
* the request without completing it.
|
|
*
|
|
* blk_end_request() and friends. __blk_end_request() must be called
|
|
* with the request queue spinlock acquired.
|
|
*
|
|
* Several drivers define their own end_request and call
|
|
* blk_end_request() for parts of the original function.
|
|
* This prevents code duplication in drivers.
|
|
*/
|
|
extern bool blk_update_request(struct request *rq, blk_status_t error,
|
|
unsigned int nr_bytes);
|
|
extern void blk_finish_request(struct request *rq, blk_status_t error);
|
|
extern bool blk_end_request(struct request *rq, blk_status_t error,
|
|
unsigned int nr_bytes);
|
|
extern void blk_end_request_all(struct request *rq, blk_status_t error);
|
|
extern bool __blk_end_request(struct request *rq, blk_status_t error,
|
|
unsigned int nr_bytes);
|
|
extern void __blk_end_request_all(struct request *rq, blk_status_t error);
|
|
extern bool __blk_end_request_cur(struct request *rq, blk_status_t error);
|
|
|
|
extern void blk_complete_request(struct request *);
|
|
extern void __blk_complete_request(struct request *);
|
|
extern void blk_abort_request(struct request *);
|
|
extern void blk_unprep_request(struct request *);
|
|
|
|
/*
|
|
* Access functions for manipulating queue properties
|
|
*/
|
|
extern struct request_queue *blk_init_queue_node(request_fn_proc *rfn,
|
|
spinlock_t *lock, int node_id);
|
|
extern struct request_queue *blk_init_queue(request_fn_proc *, spinlock_t *);
|
|
extern int blk_init_allocated_queue(struct request_queue *);
|
|
extern void blk_cleanup_queue(struct request_queue *);
|
|
extern void blk_queue_make_request(struct request_queue *, make_request_fn *);
|
|
extern void blk_queue_bounce_limit(struct request_queue *, u64);
|
|
extern void blk_queue_max_hw_sectors(struct request_queue *, unsigned int);
|
|
extern void blk_queue_chunk_sectors(struct request_queue *, unsigned int);
|
|
extern void blk_queue_max_segments(struct request_queue *, unsigned short);
|
|
extern void blk_queue_max_discard_segments(struct request_queue *,
|
|
unsigned short);
|
|
extern void blk_queue_max_segment_size(struct request_queue *, unsigned int);
|
|
extern void blk_queue_max_discard_sectors(struct request_queue *q,
|
|
unsigned int max_discard_sectors);
|
|
extern void blk_queue_max_write_same_sectors(struct request_queue *q,
|
|
unsigned int max_write_same_sectors);
|
|
extern void blk_queue_max_write_zeroes_sectors(struct request_queue *q,
|
|
unsigned int max_write_same_sectors);
|
|
extern void blk_queue_logical_block_size(struct request_queue *, unsigned int);
|
|
extern void blk_queue_physical_block_size(struct request_queue *, unsigned int);
|
|
extern void blk_queue_alignment_offset(struct request_queue *q,
|
|
unsigned int alignment);
|
|
extern void blk_limits_io_min(struct queue_limits *limits, unsigned int min);
|
|
extern void blk_queue_io_min(struct request_queue *q, unsigned int min);
|
|
extern void blk_limits_io_opt(struct queue_limits *limits, unsigned int opt);
|
|
extern void blk_queue_io_opt(struct request_queue *q, unsigned int opt);
|
|
extern void blk_set_queue_depth(struct request_queue *q, unsigned int depth);
|
|
extern void blk_set_default_limits(struct queue_limits *lim);
|
|
extern void blk_set_stacking_limits(struct queue_limits *lim);
|
|
extern int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,
|
|
sector_t offset);
|
|
extern int bdev_stack_limits(struct queue_limits *t, struct block_device *bdev,
|
|
sector_t offset);
|
|
extern void disk_stack_limits(struct gendisk *disk, struct block_device *bdev,
|
|
sector_t offset);
|
|
extern void blk_queue_stack_limits(struct request_queue *t, struct request_queue *b);
|
|
extern void blk_queue_dma_pad(struct request_queue *, unsigned int);
|
|
extern void blk_queue_update_dma_pad(struct request_queue *, unsigned int);
|
|
extern int blk_queue_dma_drain(struct request_queue *q,
|
|
dma_drain_needed_fn *dma_drain_needed,
|
|
void *buf, unsigned int size);
|
|
extern void blk_queue_lld_busy(struct request_queue *q, lld_busy_fn *fn);
|
|
extern void blk_queue_segment_boundary(struct request_queue *, unsigned long);
|
|
extern void blk_queue_virt_boundary(struct request_queue *, unsigned long);
|
|
extern void blk_queue_prep_rq(struct request_queue *, prep_rq_fn *pfn);
|
|
extern void blk_queue_unprep_rq(struct request_queue *, unprep_rq_fn *ufn);
|
|
extern void blk_queue_dma_alignment(struct request_queue *, int);
|
|
extern void blk_queue_update_dma_alignment(struct request_queue *, int);
|
|
extern void blk_queue_softirq_done(struct request_queue *, softirq_done_fn *);
|
|
extern void blk_queue_rq_timed_out(struct request_queue *, rq_timed_out_fn *);
|
|
extern void blk_queue_rq_timeout(struct request_queue *, unsigned int);
|
|
extern void blk_queue_flush_queueable(struct request_queue *q, bool queueable);
|
|
extern void blk_queue_write_cache(struct request_queue *q, bool enabled, bool fua);
|
|
|
|
/*
|
|
* Number of physical segments as sent to the device.
|
|
*
|
|
* Normally this is the number of discontiguous data segments sent by the
|
|
* submitter. But for data-less command like discard we might have no
|
|
* actual data segments submitted, but the driver might have to add it's
|
|
* own special payload. In that case we still return 1 here so that this
|
|
* special payload will be mapped.
|
|
*/
|
|
static inline unsigned short blk_rq_nr_phys_segments(struct request *rq)
|
|
{
|
|
if (rq->rq_flags & RQF_SPECIAL_PAYLOAD)
|
|
return 1;
|
|
return rq->nr_phys_segments;
|
|
}
|
|
|
|
/*
|
|
* Number of discard segments (or ranges) the driver needs to fill in.
|
|
* Each discard bio merged into a request is counted as one segment.
|
|
*/
|
|
static inline unsigned short blk_rq_nr_discard_segments(struct request *rq)
|
|
{
|
|
return max_t(unsigned short, rq->nr_phys_segments, 1);
|
|
}
|
|
|
|
extern int blk_rq_map_sg(struct request_queue *, struct request *, struct scatterlist *);
|
|
extern void blk_dump_rq_flags(struct request *, char *);
|
|
extern long nr_blockdev_pages(void);
|
|
|
|
bool __must_check blk_get_queue(struct request_queue *);
|
|
struct request_queue *blk_alloc_queue(gfp_t);
|
|
struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id,
|
|
spinlock_t *lock);
|
|
extern void blk_put_queue(struct request_queue *);
|
|
extern void blk_set_queue_dying(struct request_queue *);
|
|
|
|
/*
|
|
* block layer runtime pm functions
|
|
*/
|
|
#ifdef CONFIG_PM
|
|
extern void blk_pm_runtime_init(struct request_queue *q, struct device *dev);
|
|
extern int blk_pre_runtime_suspend(struct request_queue *q);
|
|
extern void blk_post_runtime_suspend(struct request_queue *q, int err);
|
|
extern void blk_pre_runtime_resume(struct request_queue *q);
|
|
extern void blk_post_runtime_resume(struct request_queue *q, int err);
|
|
extern void blk_set_runtime_active(struct request_queue *q);
|
|
#else
|
|
static inline void blk_pm_runtime_init(struct request_queue *q,
|
|
struct device *dev) {}
|
|
static inline int blk_pre_runtime_suspend(struct request_queue *q)
|
|
{
|
|
return -ENOSYS;
|
|
}
|
|
static inline void blk_post_runtime_suspend(struct request_queue *q, int err) {}
|
|
static inline void blk_pre_runtime_resume(struct request_queue *q) {}
|
|
static inline void blk_post_runtime_resume(struct request_queue *q, int err) {}
|
|
static inline void blk_set_runtime_active(struct request_queue *q) {}
|
|
#endif
|
|
|
|
/*
|
|
* blk_plug permits building a queue of related requests by holding the I/O
|
|
* fragments for a short period. This allows merging of sequential requests
|
|
* into single larger request. As the requests are moved from a per-task list to
|
|
* the device's request_queue in a batch, this results in improved scalability
|
|
* as the lock contention for request_queue lock is reduced.
|
|
*
|
|
* It is ok not to disable preemption when adding the request to the plug list
|
|
* or when attempting a merge, because blk_schedule_flush_list() will only flush
|
|
* the plug list when the task sleeps by itself. For details, please see
|
|
* schedule() where blk_schedule_flush_plug() is called.
|
|
*/
|
|
struct blk_plug {
|
|
struct list_head list; /* requests */
|
|
struct list_head mq_list; /* blk-mq requests */
|
|
struct list_head cb_list; /* md requires an unplug callback */
|
|
};
|
|
#define BLK_MAX_REQUEST_COUNT 16
|
|
#define BLK_PLUG_FLUSH_SIZE (128 * 1024)
|
|
|
|
struct blk_plug_cb;
|
|
typedef void (*blk_plug_cb_fn)(struct blk_plug_cb *, bool);
|
|
struct blk_plug_cb {
|
|
struct list_head list;
|
|
blk_plug_cb_fn callback;
|
|
void *data;
|
|
};
|
|
extern struct blk_plug_cb *blk_check_plugged(blk_plug_cb_fn unplug,
|
|
void *data, int size);
|
|
extern void blk_start_plug(struct blk_plug *);
|
|
extern void blk_finish_plug(struct blk_plug *);
|
|
extern void blk_flush_plug_list(struct blk_plug *, bool);
|
|
|
|
static inline void blk_flush_plug(struct task_struct *tsk)
|
|
{
|
|
struct blk_plug *plug = tsk->plug;
|
|
|
|
if (plug)
|
|
blk_flush_plug_list(plug, false);
|
|
}
|
|
|
|
static inline void blk_schedule_flush_plug(struct task_struct *tsk)
|
|
{
|
|
struct blk_plug *plug = tsk->plug;
|
|
|
|
if (plug)
|
|
blk_flush_plug_list(plug, true);
|
|
}
|
|
|
|
static inline bool blk_needs_flush_plug(struct task_struct *tsk)
|
|
{
|
|
struct blk_plug *plug = tsk->plug;
|
|
|
|
return plug &&
|
|
(!list_empty(&plug->list) ||
|
|
!list_empty(&plug->mq_list) ||
|
|
!list_empty(&plug->cb_list));
|
|
}
|
|
|
|
/*
|
|
* tag stuff
|
|
*/
|
|
extern int blk_queue_start_tag(struct request_queue *, struct request *);
|
|
extern struct request *blk_queue_find_tag(struct request_queue *, int);
|
|
extern void blk_queue_end_tag(struct request_queue *, struct request *);
|
|
extern int blk_queue_init_tags(struct request_queue *, int, struct blk_queue_tag *, int);
|
|
extern void blk_queue_free_tags(struct request_queue *);
|
|
extern int blk_queue_resize_tags(struct request_queue *, int);
|
|
extern struct blk_queue_tag *blk_init_tags(int, int);
|
|
extern void blk_free_tags(struct blk_queue_tag *);
|
|
|
|
static inline struct request *blk_map_queue_find_tag(struct blk_queue_tag *bqt,
|
|
int tag)
|
|
{
|
|
if (unlikely(bqt == NULL || tag >= bqt->real_max_depth))
|
|
return NULL;
|
|
return bqt->tag_index[tag];
|
|
}
|
|
|
|
extern int blkdev_issue_flush(struct block_device *, gfp_t, sector_t *);
|
|
extern int blkdev_issue_write_same(struct block_device *bdev, sector_t sector,
|
|
sector_t nr_sects, gfp_t gfp_mask, struct page *page);
|
|
|
|
#define BLKDEV_DISCARD_SECURE (1 << 0) /* issue a secure erase */
|
|
|
|
extern int blkdev_issue_discard(struct block_device *bdev, sector_t sector,
|
|
sector_t nr_sects, gfp_t gfp_mask, unsigned long flags);
|
|
extern int __blkdev_issue_discard(struct block_device *bdev, sector_t sector,
|
|
sector_t nr_sects, gfp_t gfp_mask, int flags,
|
|
struct bio **biop);
|
|
|
|
#define BLKDEV_ZERO_NOUNMAP (1 << 0) /* do not free blocks */
|
|
#define BLKDEV_ZERO_NOFALLBACK (1 << 1) /* don't write explicit zeroes */
|
|
|
|
extern int __blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
|
|
sector_t nr_sects, gfp_t gfp_mask, struct bio **biop,
|
|
unsigned flags);
|
|
extern int blkdev_issue_zeroout(struct block_device *bdev, sector_t sector,
|
|
sector_t nr_sects, gfp_t gfp_mask, unsigned flags);
|
|
|
|
static inline int sb_issue_discard(struct super_block *sb, sector_t block,
|
|
sector_t nr_blocks, gfp_t gfp_mask, unsigned long flags)
|
|
{
|
|
return blkdev_issue_discard(sb->s_bdev,
|
|
block << (sb->s_blocksize_bits -
|
|
SECTOR_SHIFT),
|
|
nr_blocks << (sb->s_blocksize_bits -
|
|
SECTOR_SHIFT),
|
|
gfp_mask, flags);
|
|
}
|
|
static inline int sb_issue_zeroout(struct super_block *sb, sector_t block,
|
|
sector_t nr_blocks, gfp_t gfp_mask)
|
|
{
|
|
return blkdev_issue_zeroout(sb->s_bdev,
|
|
block << (sb->s_blocksize_bits -
|
|
SECTOR_SHIFT),
|
|
nr_blocks << (sb->s_blocksize_bits -
|
|
SECTOR_SHIFT),
|
|
gfp_mask, 0);
|
|
}
|
|
|
|
extern int blk_verify_command(unsigned char *cmd, fmode_t mode);
|
|
|
|
enum blk_default_limits {
|
|
BLK_MAX_SEGMENTS = 128,
|
|
BLK_SAFE_MAX_SECTORS = 255,
|
|
BLK_DEF_MAX_SECTORS = 2560,
|
|
BLK_MAX_SEGMENT_SIZE = 65536,
|
|
BLK_SEG_BOUNDARY_MASK = 0xFFFFFFFFUL,
|
|
};
|
|
|
|
static inline unsigned long queue_segment_boundary(struct request_queue *q)
|
|
{
|
|
return q->limits.seg_boundary_mask;
|
|
}
|
|
|
|
static inline unsigned long queue_virt_boundary(struct request_queue *q)
|
|
{
|
|
return q->limits.virt_boundary_mask;
|
|
}
|
|
|
|
static inline unsigned int queue_max_sectors(struct request_queue *q)
|
|
{
|
|
return q->limits.max_sectors;
|
|
}
|
|
|
|
static inline unsigned int queue_max_hw_sectors(struct request_queue *q)
|
|
{
|
|
return q->limits.max_hw_sectors;
|
|
}
|
|
|
|
static inline unsigned short queue_max_segments(struct request_queue *q)
|
|
{
|
|
return q->limits.max_segments;
|
|
}
|
|
|
|
static inline unsigned short queue_max_discard_segments(struct request_queue *q)
|
|
{
|
|
return q->limits.max_discard_segments;
|
|
}
|
|
|
|
static inline unsigned int queue_max_segment_size(struct request_queue *q)
|
|
{
|
|
return q->limits.max_segment_size;
|
|
}
|
|
|
|
static inline unsigned queue_logical_block_size(struct request_queue *q)
|
|
{
|
|
int retval = 512;
|
|
|
|
if (q && q->limits.logical_block_size)
|
|
retval = q->limits.logical_block_size;
|
|
|
|
return retval;
|
|
}
|
|
|
|
static inline unsigned int bdev_logical_block_size(struct block_device *bdev)
|
|
{
|
|
return queue_logical_block_size(bdev_get_queue(bdev));
|
|
}
|
|
|
|
static inline unsigned int queue_physical_block_size(struct request_queue *q)
|
|
{
|
|
return q->limits.physical_block_size;
|
|
}
|
|
|
|
static inline unsigned int bdev_physical_block_size(struct block_device *bdev)
|
|
{
|
|
return queue_physical_block_size(bdev_get_queue(bdev));
|
|
}
|
|
|
|
static inline unsigned int queue_io_min(struct request_queue *q)
|
|
{
|
|
return q->limits.io_min;
|
|
}
|
|
|
|
static inline int bdev_io_min(struct block_device *bdev)
|
|
{
|
|
return queue_io_min(bdev_get_queue(bdev));
|
|
}
|
|
|
|
static inline unsigned int queue_io_opt(struct request_queue *q)
|
|
{
|
|
return q->limits.io_opt;
|
|
}
|
|
|
|
static inline int bdev_io_opt(struct block_device *bdev)
|
|
{
|
|
return queue_io_opt(bdev_get_queue(bdev));
|
|
}
|
|
|
|
static inline int queue_alignment_offset(struct request_queue *q)
|
|
{
|
|
if (q->limits.misaligned)
|
|
return -1;
|
|
|
|
return q->limits.alignment_offset;
|
|
}
|
|
|
|
static inline int queue_limit_alignment_offset(struct queue_limits *lim, sector_t sector)
|
|
{
|
|
unsigned int granularity = max(lim->physical_block_size, lim->io_min);
|
|
unsigned int alignment = sector_div(sector, granularity >> SECTOR_SHIFT)
|
|
<< SECTOR_SHIFT;
|
|
|
|
return (granularity + lim->alignment_offset - alignment) % granularity;
|
|
}
|
|
|
|
static inline int bdev_alignment_offset(struct block_device *bdev)
|
|
{
|
|
struct request_queue *q = bdev_get_queue(bdev);
|
|
|
|
if (q->limits.misaligned)
|
|
return -1;
|
|
|
|
if (bdev != bdev->bd_contains)
|
|
return bdev->bd_part->alignment_offset;
|
|
|
|
return q->limits.alignment_offset;
|
|
}
|
|
|
|
static inline int queue_discard_alignment(struct request_queue *q)
|
|
{
|
|
if (q->limits.discard_misaligned)
|
|
return -1;
|
|
|
|
return q->limits.discard_alignment;
|
|
}
|
|
|
|
static inline int queue_limit_discard_alignment(struct queue_limits *lim, sector_t sector)
|
|
{
|
|
unsigned int alignment, granularity, offset;
|
|
|
|
if (!lim->max_discard_sectors)
|
|
return 0;
|
|
|
|
/* Why are these in bytes, not sectors? */
|
|
alignment = lim->discard_alignment >> SECTOR_SHIFT;
|
|
granularity = lim->discard_granularity >> SECTOR_SHIFT;
|
|
if (!granularity)
|
|
return 0;
|
|
|
|
/* Offset of the partition start in 'granularity' sectors */
|
|
offset = sector_div(sector, granularity);
|
|
|
|
/* And why do we do this modulus *again* in blkdev_issue_discard()? */
|
|
offset = (granularity + alignment - offset) % granularity;
|
|
|
|
/* Turn it back into bytes, gaah */
|
|
return offset << SECTOR_SHIFT;
|
|
}
|
|
|
|
static inline int bdev_discard_alignment(struct block_device *bdev)
|
|
{
|
|
struct request_queue *q = bdev_get_queue(bdev);
|
|
|
|
if (bdev != bdev->bd_contains)
|
|
return bdev->bd_part->discard_alignment;
|
|
|
|
return q->limits.discard_alignment;
|
|
}
|
|
|
|
static inline unsigned int bdev_write_same(struct block_device *bdev)
|
|
{
|
|
struct request_queue *q = bdev_get_queue(bdev);
|
|
|
|
if (q)
|
|
return q->limits.max_write_same_sectors;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static inline unsigned int bdev_write_zeroes_sectors(struct block_device *bdev)
|
|
{
|
|
struct request_queue *q = bdev_get_queue(bdev);
|
|
|
|
if (q)
|
|
return q->limits.max_write_zeroes_sectors;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static inline enum blk_zoned_model bdev_zoned_model(struct block_device *bdev)
|
|
{
|
|
struct request_queue *q = bdev_get_queue(bdev);
|
|
|
|
if (q)
|
|
return blk_queue_zoned_model(q);
|
|
|
|
return BLK_ZONED_NONE;
|
|
}
|
|
|
|
static inline bool bdev_is_zoned(struct block_device *bdev)
|
|
{
|
|
struct request_queue *q = bdev_get_queue(bdev);
|
|
|
|
if (q)
|
|
return blk_queue_is_zoned(q);
|
|
|
|
return false;
|
|
}
|
|
|
|
static inline unsigned int bdev_zone_sectors(struct block_device *bdev)
|
|
{
|
|
struct request_queue *q = bdev_get_queue(bdev);
|
|
|
|
if (q)
|
|
return blk_queue_zone_sectors(q);
|
|
return 0;
|
|
}
|
|
|
|
static inline int queue_dma_alignment(struct request_queue *q)
|
|
{
|
|
return q ? q->dma_alignment : 511;
|
|
}
|
|
|
|
static inline int blk_rq_aligned(struct request_queue *q, unsigned long addr,
|
|
unsigned int len)
|
|
{
|
|
unsigned int alignment = queue_dma_alignment(q) | q->dma_pad_mask;
|
|
return !(addr & alignment) && !(len & alignment);
|
|
}
|
|
|
|
/* assumes size > 256 */
|
|
static inline unsigned int blksize_bits(unsigned int size)
|
|
{
|
|
unsigned int bits = 8;
|
|
do {
|
|
bits++;
|
|
size >>= 1;
|
|
} while (size > 256);
|
|
return bits;
|
|
}
|
|
|
|
static inline unsigned int block_size(struct block_device *bdev)
|
|
{
|
|
return bdev->bd_block_size;
|
|
}
|
|
|
|
static inline bool queue_flush_queueable(struct request_queue *q)
|
|
{
|
|
return !test_bit(QUEUE_FLAG_FLUSH_NQ, &q->queue_flags);
|
|
}
|
|
|
|
typedef struct {struct page *v;} Sector;
|
|
|
|
unsigned char *read_dev_sector(struct block_device *, sector_t, Sector *);
|
|
|
|
static inline void put_dev_sector(Sector p)
|
|
{
|
|
put_page(p.v);
|
|
}
|
|
|
|
static inline bool __bvec_gap_to_prev(struct request_queue *q,
|
|
struct bio_vec *bprv, unsigned int offset)
|
|
{
|
|
return offset ||
|
|
((bprv->bv_offset + bprv->bv_len) & queue_virt_boundary(q));
|
|
}
|
|
|
|
/*
|
|
* Check if adding a bio_vec after bprv with offset would create a gap in
|
|
* the SG list. Most drivers don't care about this, but some do.
|
|
*/
|
|
static inline bool bvec_gap_to_prev(struct request_queue *q,
|
|
struct bio_vec *bprv, unsigned int offset)
|
|
{
|
|
if (!queue_virt_boundary(q))
|
|
return false;
|
|
return __bvec_gap_to_prev(q, bprv, offset);
|
|
}
|
|
|
|
/*
|
|
* Check if the two bvecs from two bios can be merged to one segment.
|
|
* If yes, no need to check gap between the two bios since the 1st bio
|
|
* and the 1st bvec in the 2nd bio can be handled in one segment.
|
|
*/
|
|
static inline bool bios_segs_mergeable(struct request_queue *q,
|
|
struct bio *prev, struct bio_vec *prev_last_bv,
|
|
struct bio_vec *next_first_bv)
|
|
{
|
|
if (!BIOVEC_PHYS_MERGEABLE(prev_last_bv, next_first_bv))
|
|
return false;
|
|
if (!BIOVEC_SEG_BOUNDARY(q, prev_last_bv, next_first_bv))
|
|
return false;
|
|
if (prev->bi_seg_back_size + next_first_bv->bv_len >
|
|
queue_max_segment_size(q))
|
|
return false;
|
|
return true;
|
|
}
|
|
|
|
static inline bool bio_will_gap(struct request_queue *q,
|
|
struct request *prev_rq,
|
|
struct bio *prev,
|
|
struct bio *next)
|
|
{
|
|
if (bio_has_data(prev) && queue_virt_boundary(q)) {
|
|
struct bio_vec pb, nb;
|
|
|
|
/*
|
|
* don't merge if the 1st bio starts with non-zero
|
|
* offset, otherwise it is quite difficult to respect
|
|
* sg gap limit. We work hard to merge a huge number of small
|
|
* single bios in case of mkfs.
|
|
*/
|
|
if (prev_rq)
|
|
bio_get_first_bvec(prev_rq->bio, &pb);
|
|
else
|
|
bio_get_first_bvec(prev, &pb);
|
|
if (pb.bv_offset)
|
|
return true;
|
|
|
|
/*
|
|
* We don't need to worry about the situation that the
|
|
* merged segment ends in unaligned virt boundary:
|
|
*
|
|
* - if 'pb' ends aligned, the merged segment ends aligned
|
|
* - if 'pb' ends unaligned, the next bio must include
|
|
* one single bvec of 'nb', otherwise the 'nb' can't
|
|
* merge with 'pb'
|
|
*/
|
|
bio_get_last_bvec(prev, &pb);
|
|
bio_get_first_bvec(next, &nb);
|
|
|
|
if (!bios_segs_mergeable(q, prev, &pb, &nb))
|
|
return __bvec_gap_to_prev(q, &pb, nb.bv_offset);
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
static inline bool req_gap_back_merge(struct request *req, struct bio *bio)
|
|
{
|
|
return bio_will_gap(req->q, req, req->biotail, bio);
|
|
}
|
|
|
|
static inline bool req_gap_front_merge(struct request *req, struct bio *bio)
|
|
{
|
|
return bio_will_gap(req->q, NULL, bio, req->bio);
|
|
}
|
|
|
|
int kblockd_schedule_work(struct work_struct *work);
|
|
int kblockd_schedule_work_on(int cpu, struct work_struct *work);
|
|
int kblockd_mod_delayed_work_on(int cpu, struct delayed_work *dwork, unsigned long delay);
|
|
|
|
#define MODULE_ALIAS_BLOCKDEV(major,minor) \
|
|
MODULE_ALIAS("block-major-" __stringify(major) "-" __stringify(minor))
|
|
#define MODULE_ALIAS_BLOCKDEV_MAJOR(major) \
|
|
MODULE_ALIAS("block-major-" __stringify(major) "-*")
|
|
|
|
#if defined(CONFIG_BLK_DEV_INTEGRITY)
|
|
|
|
enum blk_integrity_flags {
|
|
BLK_INTEGRITY_VERIFY = 1 << 0,
|
|
BLK_INTEGRITY_GENERATE = 1 << 1,
|
|
BLK_INTEGRITY_DEVICE_CAPABLE = 1 << 2,
|
|
BLK_INTEGRITY_IP_CHECKSUM = 1 << 3,
|
|
};
|
|
|
|
struct blk_integrity_iter {
|
|
void *prot_buf;
|
|
void *data_buf;
|
|
sector_t seed;
|
|
unsigned int data_size;
|
|
unsigned short interval;
|
|
const char *disk_name;
|
|
};
|
|
|
|
typedef blk_status_t (integrity_processing_fn) (struct blk_integrity_iter *);
|
|
|
|
struct blk_integrity_profile {
|
|
integrity_processing_fn *generate_fn;
|
|
integrity_processing_fn *verify_fn;
|
|
const char *name;
|
|
};
|
|
|
|
extern void blk_integrity_register(struct gendisk *, struct blk_integrity *);
|
|
extern void blk_integrity_unregister(struct gendisk *);
|
|
extern int blk_integrity_compare(struct gendisk *, struct gendisk *);
|
|
extern int blk_rq_map_integrity_sg(struct request_queue *, struct bio *,
|
|
struct scatterlist *);
|
|
extern int blk_rq_count_integrity_sg(struct request_queue *, struct bio *);
|
|
extern bool blk_integrity_merge_rq(struct request_queue *, struct request *,
|
|
struct request *);
|
|
extern bool blk_integrity_merge_bio(struct request_queue *, struct request *,
|
|
struct bio *);
|
|
|
|
static inline struct blk_integrity *blk_get_integrity(struct gendisk *disk)
|
|
{
|
|
struct blk_integrity *bi = &disk->queue->integrity;
|
|
|
|
if (!bi->profile)
|
|
return NULL;
|
|
|
|
return bi;
|
|
}
|
|
|
|
static inline
|
|
struct blk_integrity *bdev_get_integrity(struct block_device *bdev)
|
|
{
|
|
return blk_get_integrity(bdev->bd_disk);
|
|
}
|
|
|
|
static inline bool blk_integrity_rq(struct request *rq)
|
|
{
|
|
return rq->cmd_flags & REQ_INTEGRITY;
|
|
}
|
|
|
|
static inline void blk_queue_max_integrity_segments(struct request_queue *q,
|
|
unsigned int segs)
|
|
{
|
|
q->limits.max_integrity_segments = segs;
|
|
}
|
|
|
|
static inline unsigned short
|
|
queue_max_integrity_segments(struct request_queue *q)
|
|
{
|
|
return q->limits.max_integrity_segments;
|
|
}
|
|
|
|
static inline bool integrity_req_gap_back_merge(struct request *req,
|
|
struct bio *next)
|
|
{
|
|
struct bio_integrity_payload *bip = bio_integrity(req->bio);
|
|
struct bio_integrity_payload *bip_next = bio_integrity(next);
|
|
|
|
return bvec_gap_to_prev(req->q, &bip->bip_vec[bip->bip_vcnt - 1],
|
|
bip_next->bip_vec[0].bv_offset);
|
|
}
|
|
|
|
static inline bool integrity_req_gap_front_merge(struct request *req,
|
|
struct bio *bio)
|
|
{
|
|
struct bio_integrity_payload *bip = bio_integrity(bio);
|
|
struct bio_integrity_payload *bip_next = bio_integrity(req->bio);
|
|
|
|
return bvec_gap_to_prev(req->q, &bip->bip_vec[bip->bip_vcnt - 1],
|
|
bip_next->bip_vec[0].bv_offset);
|
|
}
|
|
|
|
/**
|
|
* bio_integrity_intervals - Return number of integrity intervals for a bio
|
|
* @bi: blk_integrity profile for device
|
|
* @sectors: Size of the bio in 512-byte sectors
|
|
*
|
|
* Description: The block layer calculates everything in 512 byte
|
|
* sectors but integrity metadata is done in terms of the data integrity
|
|
* interval size of the storage device. Convert the block layer sectors
|
|
* to the appropriate number of integrity intervals.
|
|
*/
|
|
static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
|
|
unsigned int sectors)
|
|
{
|
|
return sectors >> (bi->interval_exp - 9);
|
|
}
|
|
|
|
static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
|
|
unsigned int sectors)
|
|
{
|
|
return bio_integrity_intervals(bi, sectors) * bi->tuple_size;
|
|
}
|
|
|
|
#else /* CONFIG_BLK_DEV_INTEGRITY */
|
|
|
|
struct bio;
|
|
struct block_device;
|
|
struct gendisk;
|
|
struct blk_integrity;
|
|
|
|
static inline int blk_integrity_rq(struct request *rq)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int blk_rq_count_integrity_sg(struct request_queue *q,
|
|
struct bio *b)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline int blk_rq_map_integrity_sg(struct request_queue *q,
|
|
struct bio *b,
|
|
struct scatterlist *s)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline struct blk_integrity *bdev_get_integrity(struct block_device *b)
|
|
{
|
|
return NULL;
|
|
}
|
|
static inline struct blk_integrity *blk_get_integrity(struct gendisk *disk)
|
|
{
|
|
return NULL;
|
|
}
|
|
static inline int blk_integrity_compare(struct gendisk *a, struct gendisk *b)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline void blk_integrity_register(struct gendisk *d,
|
|
struct blk_integrity *b)
|
|
{
|
|
}
|
|
static inline void blk_integrity_unregister(struct gendisk *d)
|
|
{
|
|
}
|
|
static inline void blk_queue_max_integrity_segments(struct request_queue *q,
|
|
unsigned int segs)
|
|
{
|
|
}
|
|
static inline unsigned short queue_max_integrity_segments(struct request_queue *q)
|
|
{
|
|
return 0;
|
|
}
|
|
static inline bool blk_integrity_merge_rq(struct request_queue *rq,
|
|
struct request *r1,
|
|
struct request *r2)
|
|
{
|
|
return true;
|
|
}
|
|
static inline bool blk_integrity_merge_bio(struct request_queue *rq,
|
|
struct request *r,
|
|
struct bio *b)
|
|
{
|
|
return true;
|
|
}
|
|
|
|
static inline bool integrity_req_gap_back_merge(struct request *req,
|
|
struct bio *next)
|
|
{
|
|
return false;
|
|
}
|
|
static inline bool integrity_req_gap_front_merge(struct request *req,
|
|
struct bio *bio)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline unsigned int bio_integrity_intervals(struct blk_integrity *bi,
|
|
unsigned int sectors)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static inline unsigned int bio_integrity_bytes(struct blk_integrity *bi,
|
|
unsigned int sectors)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
#endif /* CONFIG_BLK_DEV_INTEGRITY */
|
|
|
|
struct block_device_operations {
|
|
int (*open) (struct block_device *, fmode_t);
|
|
void (*release) (struct gendisk *, fmode_t);
|
|
int (*rw_page)(struct block_device *, sector_t, struct page *, unsigned int);
|
|
int (*ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
|
|
int (*compat_ioctl) (struct block_device *, fmode_t, unsigned, unsigned long);
|
|
unsigned int (*check_events) (struct gendisk *disk,
|
|
unsigned int clearing);
|
|
void (*unlock_native_capacity) (struct gendisk *);
|
|
int (*revalidate_disk) (struct gendisk *);
|
|
int (*getgeo)(struct block_device *, struct hd_geometry *);
|
|
int (*set_read_only)(struct block_device *bdev, bool ro);
|
|
/* this callback is with swap_lock and sometimes page table lock held */
|
|
void (*swap_slot_free_notify) (struct block_device *, unsigned long);
|
|
struct module *owner;
|
|
const struct pr_ops *pr_ops;
|
|
};
|
|
|
|
extern int __blkdev_driver_ioctl(struct block_device *, fmode_t, unsigned int,
|
|
unsigned long);
|
|
extern int bdev_read_page(struct block_device *, sector_t, struct page *);
|
|
extern int bdev_write_page(struct block_device *, sector_t, struct page *,
|
|
struct writeback_control *);
|
|
|
|
#ifdef CONFIG_BLK_DEV_ZONED
|
|
bool blk_req_needs_zone_write_lock(struct request *rq);
|
|
void __blk_req_zone_write_lock(struct request *rq);
|
|
void __blk_req_zone_write_unlock(struct request *rq);
|
|
|
|
static inline void blk_req_zone_write_lock(struct request *rq)
|
|
{
|
|
if (blk_req_needs_zone_write_lock(rq))
|
|
__blk_req_zone_write_lock(rq);
|
|
}
|
|
|
|
static inline void blk_req_zone_write_unlock(struct request *rq)
|
|
{
|
|
if (rq->rq_flags & RQF_ZONE_WRITE_LOCKED)
|
|
__blk_req_zone_write_unlock(rq);
|
|
}
|
|
|
|
static inline bool blk_req_zone_is_write_locked(struct request *rq)
|
|
{
|
|
return rq->q->seq_zones_wlock &&
|
|
test_bit(blk_rq_zone_no(rq), rq->q->seq_zones_wlock);
|
|
}
|
|
|
|
static inline bool blk_req_can_dispatch_to_zone(struct request *rq)
|
|
{
|
|
if (!blk_req_needs_zone_write_lock(rq))
|
|
return true;
|
|
return !blk_req_zone_is_write_locked(rq);
|
|
}
|
|
#else
|
|
static inline bool blk_req_needs_zone_write_lock(struct request *rq)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline void blk_req_zone_write_lock(struct request *rq)
|
|
{
|
|
}
|
|
|
|
static inline void blk_req_zone_write_unlock(struct request *rq)
|
|
{
|
|
}
|
|
static inline bool blk_req_zone_is_write_locked(struct request *rq)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline bool blk_req_can_dispatch_to_zone(struct request *rq)
|
|
{
|
|
return true;
|
|
}
|
|
#endif /* CONFIG_BLK_DEV_ZONED */
|
|
|
|
#else /* CONFIG_BLOCK */
|
|
|
|
struct block_device;
|
|
|
|
/*
|
|
* stubs for when the block layer is configured out
|
|
*/
|
|
#define buffer_heads_over_limit 0
|
|
|
|
static inline long nr_blockdev_pages(void)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
struct blk_plug {
|
|
};
|
|
|
|
static inline void blk_start_plug(struct blk_plug *plug)
|
|
{
|
|
}
|
|
|
|
static inline void blk_finish_plug(struct blk_plug *plug)
|
|
{
|
|
}
|
|
|
|
static inline void blk_flush_plug(struct task_struct *task)
|
|
{
|
|
}
|
|
|
|
static inline void blk_schedule_flush_plug(struct task_struct *task)
|
|
{
|
|
}
|
|
|
|
|
|
static inline bool blk_needs_flush_plug(struct task_struct *tsk)
|
|
{
|
|
return false;
|
|
}
|
|
|
|
static inline int blkdev_issue_flush(struct block_device *bdev, gfp_t gfp_mask,
|
|
sector_t *error_sector)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
#endif /* CONFIG_BLOCK */
|
|
|
|
#endif
|