License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 17:07:57 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0 */
|
2016-06-21 02:22:39 +03:00
|
|
|
#ifndef LINUX_IOMAP_H
|
|
|
|
#define LINUX_IOMAP_H 1
|
|
|
|
|
2018-07-12 08:26:05 +03:00
|
|
|
#include <linux/atomic.h>
|
|
|
|
#include <linux/bitmap.h>
|
2019-10-17 23:12:15 +03:00
|
|
|
#include <linux/blk_types.h>
|
2018-07-12 08:26:05 +03:00
|
|
|
#include <linux/mm.h>
|
2016-06-21 02:22:39 +03:00
|
|
|
#include <linux/types.h>
|
2018-10-27 01:02:59 +03:00
|
|
|
#include <linux/mm_types.h>
|
2019-07-15 18:50:59 +03:00
|
|
|
#include <linux/blkdev.h>
|
2016-06-21 02:22:39 +03:00
|
|
|
|
2018-06-01 19:03:08 +03:00
|
|
|
struct address_space;
|
2016-06-21 02:38:45 +03:00
|
|
|
struct fiemap_extent_info;
|
2016-06-21 02:23:11 +03:00
|
|
|
struct inode;
|
2020-09-28 18:51:08 +03:00
|
|
|
struct iomap_dio;
|
2019-10-17 23:12:15 +03:00
|
|
|
struct iomap_writepage_ctx;
|
2016-06-21 02:23:11 +03:00
|
|
|
struct iov_iter;
|
|
|
|
struct kiocb;
|
2018-06-20 01:10:56 +03:00
|
|
|
struct page;
|
2016-06-21 02:23:11 +03:00
|
|
|
struct vm_area_struct;
|
|
|
|
struct vm_fault;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Types of block ranges for iomap mappings:
|
|
|
|
*/
|
2019-10-19 02:43:08 +03:00
|
|
|
#define IOMAP_HOLE 0 /* no blocks allocated, need allocation */
|
|
|
|
#define IOMAP_DELALLOC 1 /* delayed allocation blocks */
|
|
|
|
#define IOMAP_MAPPED 2 /* blocks allocated at @addr */
|
|
|
|
#define IOMAP_UNWRITTEN 3 /* blocks allocated at @addr in unwritten state */
|
|
|
|
#define IOMAP_INLINE 4 /* data inline in the inode */
|
2016-06-21 02:22:39 +03:00
|
|
|
|
2016-08-29 04:33:58 +03:00
|
|
|
/*
|
2019-10-19 02:40:17 +03:00
|
|
|
* Flags reported by the file system from iomap_begin:
|
|
|
|
*
|
|
|
|
* IOMAP_F_NEW indicates that the blocks have been newly allocated and need
|
|
|
|
* zeroing for areas that no data is copied to.
|
libnvdimm for 4.15
* Introduce MAP_SYNC and MAP_SHARED_VALIDATE, a mechanism to enable
'userspace flush' of persistent memory updates via filesystem-dax
mappings. It arranges for any filesystem metadata updates that may be
required to satisfy a write fault to also be flushed ("on disk") before
the kernel returns to userspace from the fault handler. Effectively
every write-fault that dirties metadata completes an fsync() before
returning from the fault handler. The new MAP_SHARED_VALIDATE mapping
type guarantees that the MAP_SYNC flag is validated as supported by the
filesystem's ->mmap() file operation.
* Add support for the standard ACPI 6.2 label access methods that
replace the NVDIMM_FAMILY_INTEL (vendor specific) label methods. This
enables interoperability with environments that only implement the
standardized methods.
* Add support for the ACPI 6.2 NVDIMM media error injection methods.
* Add support for the NVDIMM_FAMILY_INTEL v1.6 DIMM commands for latch
last shutdown status, firmware update, SMART error injection, and
SMART alarm threshold control.
* Cleanup physical address information disclosures to be root-only.
* Fix revalidation of the DIMM "locked label area" status to support
dynamic unlock of the label area.
* Expand unit test infrastructure to mock the ACPI 6.2 Translate SPA
(system-physical-address) command and error injection commands.
Acknowledgements that came after the commits were pushed to -next:
957ac8c421ad dax: fix PMD faults on zero-length files
Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
a39e596baa07 xfs: support for synchronous DAX faults
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
7b565c9f965b xfs: Implement xfs_filemap_pfn_mkwrite() using __xfs_filemap_fault()
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
-----BEGIN PGP SIGNATURE-----
iQIcBAABAgAGBQJaDfvcAAoJEB7SkWpmfYgCk7sP/2qJhBH+VTTdg2osDnhAdAhI
co/AGEmsHFlUCMBb/Ek7UnMAmhBYiJU2q4ywPsNFBpusXpMlqNy5Iwo7k4/wQHE/
SJcIM0g4zg0ViFuUhwV+C2T0R5UzFR8JLd9EYWj/YS6aJpurtotm5l4UStaM0Hzo
AhxSXJLrBDuqCpbOxbctfiGEmdRL7aRfBEAARTNRKBn/iXxJUcYHlp62rtXQS+t4
I6LC/URCWTNTTMGmzW6TRsgSD9WMfd19xKcGzN3qL6ee0KFccxN4ctFqHA/sFGOh
iYLeR0XJUjJxyp+PkWGteXPVZL0Kj3bD/lSTG+Co5bm/ra8a/sh3TSFfgFyoBZD1
EqMN8Ryf80hGp3FabeH2Iw2SviYPZpHSWgjddjxLD0RA6OmpzINc+Wm8eqApjMME
sbZDTOijiab4QMQ0XamF4GuDHyQtawv5Y/w2Ehhl1tmiqW+5tKhsKqxkQt+/V3Yt
RTVSRe2Pkway66b+cD64IdQ6L2tyonPnmi5IzgkKOhlOEGomy+4/U2Jt2bMbhzq6
ymszKmXp2XI8P06wU8sHrIUeXO5I9qoKn/fZA73Eb8aIzgJe3tBE/5+Ab7RG6HB9
1OVfcMWoXU1gNgNktTs63X1Lsg4aW9kt/K4fPHHcqUcaliEJpJTlAbg9GLF2buoW
nQ+0fTRgMRihE3ZA0Fs3
=h2vZ
-----END PGP SIGNATURE-----
Merge tag 'libnvdimm-for-4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm
Pull libnvdimm and dax updates from Dan Williams:
"Save for a few late fixes, all of these commits have shipped in -next
releases since before the merge window opened, and 0day has given a
build success notification.
The ext4 touches came from Jan, and the xfs touches have Darrick's
reviewed-by. An xfstest for the MAP_SYNC feature has been through
a few round of reviews and is on track to be merged.
- Introduce MAP_SYNC and MAP_SHARED_VALIDATE, a mechanism to enable
'userspace flush' of persistent memory updates via filesystem-dax
mappings. It arranges for any filesystem metadata updates that may
be required to satisfy a write fault to also be flushed ("on disk")
before the kernel returns to userspace from the fault handler.
Effectively every write-fault that dirties metadata completes an
fsync() before returning from the fault handler. The new
MAP_SHARED_VALIDATE mapping type guarantees that the MAP_SYNC flag
is validated as supported by the filesystem's ->mmap() file
operation.
- Add support for the standard ACPI 6.2 label access methods that
replace the NVDIMM_FAMILY_INTEL (vendor specific) label methods.
This enables interoperability with environments that only implement
the standardized methods.
- Add support for the ACPI 6.2 NVDIMM media error injection methods.
- Add support for the NVDIMM_FAMILY_INTEL v1.6 DIMM commands for
latch last shutdown status, firmware update, SMART error injection,
and SMART alarm threshold control.
- Cleanup physical address information disclosures to be root-only.
- Fix revalidation of the DIMM "locked label area" status to support
dynamic unlock of the label area.
- Expand unit test infrastructure to mock the ACPI 6.2 Translate SPA
(system-physical-address) command and error injection commands.
Acknowledgements that came after the commits were pushed to -next:
- 957ac8c421ad ("dax: fix PMD faults on zero-length files"):
Reviewed-by: Ross Zwisler <ross.zwisler@linux.intel.com>
- a39e596baa07 ("xfs: support for synchronous DAX faults") and
7b565c9f965b ("xfs: Implement xfs_filemap_pfn_mkwrite() using __xfs_filemap_fault()")
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>"
* tag 'libnvdimm-for-4.15' of git://git.kernel.org/pub/scm/linux/kernel/git/nvdimm/nvdimm: (49 commits)
acpi, nfit: add 'Enable Latch System Shutdown Status' command support
dax: fix general protection fault in dax_alloc_inode
dax: fix PMD faults on zero-length files
dax: stop requiring a live device for dax_flush()
brd: remove dax support
dax: quiet bdev_dax_supported()
fs, dax: unify IOMAP_F_DIRTY read vs write handling policy in the dax core
tools/testing/nvdimm: unit test clear-error commands
acpi, nfit: validate commands against the device type
tools/testing/nvdimm: stricter bounds checking for error injection commands
xfs: support for synchronous DAX faults
xfs: Implement xfs_filemap_pfn_mkwrite() using __xfs_filemap_fault()
ext4: Support for synchronous DAX faults
ext4: Simplify error handling in ext4_dax_huge_fault()
dax: Implement dax_finish_sync_fault()
dax, iomap: Add support for synchronous faults
mm: Define MAP_SYNC and VM_SYNC flags
dax: Allow tuning whether dax_insert_mapping_entry() dirties entry
dax: Allow dax_iomap_fault() to return pfn
dax: Fix comment describing dax_iomap_fault()
...
2017-11-17 20:51:57 +03:00
|
|
|
*
|
2017-11-01 18:36:42 +03:00
|
|
|
* IOMAP_F_DIRTY indicates the inode has uncommitted metadata needed to access
|
|
|
|
* written data and requires fdatasync to commit them to persistent storage.
|
2019-10-17 23:12:01 +03:00
|
|
|
* This needs to take into account metadata changes that *may* be made at IO
|
|
|
|
* completion, such as file size updates from direct IO.
|
2019-10-19 02:40:17 +03:00
|
|
|
*
|
|
|
|
* IOMAP_F_SHARED indicates that the blocks are shared, and will need to be
|
|
|
|
* unshared as part a write.
|
|
|
|
*
|
|
|
|
* IOMAP_F_MERGED indicates that the iomap contains the merge of multiple block
|
|
|
|
* mappings.
|
|
|
|
*
|
|
|
|
* IOMAP_F_BUFFER_HEAD indicates that the file system requires the use of
|
|
|
|
* buffer heads for this mapping.
|
2016-08-29 04:33:58 +03:00
|
|
|
*/
|
2019-10-19 02:40:17 +03:00
|
|
|
#define IOMAP_F_NEW 0x01
|
|
|
|
#define IOMAP_F_DIRTY 0x02
|
|
|
|
#define IOMAP_F_SHARED 0x04
|
|
|
|
#define IOMAP_F_MERGED 0x08
|
|
|
|
#define IOMAP_F_BUFFER_HEAD 0x10
|
2021-02-04 13:21:41 +03:00
|
|
|
#define IOMAP_F_ZONE_APPEND 0x20
|
2016-10-20 07:51:28 +03:00
|
|
|
|
|
|
|
/*
|
2019-10-19 02:40:17 +03:00
|
|
|
* Flags set by the core iomap code during operations:
|
|
|
|
*
|
|
|
|
* IOMAP_F_SIZE_CHANGED indicates to the iomap_end method that the file size
|
|
|
|
* has changed as the result of this write operation.
|
2016-10-20 07:51:28 +03:00
|
|
|
*/
|
2019-10-19 02:40:17 +03:00
|
|
|
#define IOMAP_F_SIZE_CHANGED 0x100
|
2016-08-29 04:33:58 +03:00
|
|
|
|
2018-06-01 19:03:07 +03:00
|
|
|
/*
|
|
|
|
* Flags from 0x1000 up are for file system specific usage:
|
|
|
|
*/
|
|
|
|
#define IOMAP_F_PRIVATE 0x1000
|
|
|
|
|
|
|
|
|
2016-06-21 02:23:11 +03:00
|
|
|
/*
|
2017-10-02 00:55:54 +03:00
|
|
|
* Magic value for addr:
|
2016-06-21 02:23:11 +03:00
|
|
|
*/
|
2017-10-02 00:55:54 +03:00
|
|
|
#define IOMAP_NULL_ADDR -1ULL /* addr is not valid */
|
2016-06-21 02:22:39 +03:00
|
|
|
|
2019-04-30 18:45:34 +03:00
|
|
|
struct iomap_page_ops;
|
|
|
|
|
2016-06-21 02:22:39 +03:00
|
|
|
struct iomap {
|
2017-10-02 00:55:54 +03:00
|
|
|
u64 addr; /* disk offset of mapping, bytes */
|
2016-06-21 02:23:11 +03:00
|
|
|
loff_t offset; /* file offset of mapping, bytes */
|
|
|
|
u64 length; /* length of mapping, bytes */
|
2016-08-29 04:33:58 +03:00
|
|
|
u16 type; /* type of mapping */
|
|
|
|
u16 flags; /* flags for mapping */
|
2016-06-21 02:23:11 +03:00
|
|
|
struct block_device *bdev; /* block device for I/O */
|
2017-01-27 23:04:59 +03:00
|
|
|
struct dax_device *dax_dev; /* dax_dev for dax operations */
|
2018-06-20 01:10:56 +03:00
|
|
|
void *inline_data;
|
2018-06-20 01:10:57 +03:00
|
|
|
void *private; /* filesystem private */
|
2019-04-30 18:45:34 +03:00
|
|
|
const struct iomap_page_ops *page_ops;
|
|
|
|
};
|
2018-06-20 01:10:56 +03:00
|
|
|
|
2021-08-11 04:33:04 +03:00
|
|
|
static inline sector_t iomap_sector(const struct iomap *iomap, loff_t pos)
|
2019-07-15 18:50:59 +03:00
|
|
|
{
|
|
|
|
return (iomap->addr + pos - iomap->offset) >> SECTOR_SHIFT;
|
|
|
|
}
|
|
|
|
|
2021-08-03 19:38:22 +03:00
|
|
|
/*
|
|
|
|
* Returns the inline data pointer for logical offset @pos.
|
|
|
|
*/
|
2021-08-11 04:33:04 +03:00
|
|
|
static inline void *iomap_inline_data(const struct iomap *iomap, loff_t pos)
|
2021-08-03 19:38:22 +03:00
|
|
|
{
|
|
|
|
return iomap->inline_data + pos - iomap->offset;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Check if the mapping's length is within the valid range for inline data.
|
|
|
|
* This is used to guard against accessing data beyond the page inline_data
|
|
|
|
* points at.
|
|
|
|
*/
|
2021-08-11 04:33:05 +03:00
|
|
|
static inline bool iomap_inline_data_valid(const struct iomap *iomap)
|
2021-08-03 19:38:22 +03:00
|
|
|
{
|
|
|
|
return iomap->length <= PAGE_SIZE - offset_in_page(iomap->inline_data);
|
|
|
|
}
|
|
|
|
|
2019-04-30 18:45:34 +03:00
|
|
|
/*
|
|
|
|
* When a filesystem sets page_ops in an iomap mapping it returns, page_prepare
|
|
|
|
* and page_done will be called for each page written to. This only applies to
|
|
|
|
* buffered writes as unbuffered writes will not typically have pages
|
|
|
|
* associated with them.
|
|
|
|
*
|
|
|
|
* When page_prepare succeeds, page_done will always be called to do any
|
|
|
|
* cleanup work necessary. In that page_done call, @page will be NULL if the
|
|
|
|
* associated page could not be obtained.
|
|
|
|
*/
|
|
|
|
struct iomap_page_ops {
|
2021-08-11 04:33:03 +03:00
|
|
|
int (*page_prepare)(struct inode *inode, loff_t pos, unsigned len);
|
2018-06-20 01:10:56 +03:00
|
|
|
void (*page_done)(struct inode *inode, loff_t pos, unsigned copied,
|
2021-08-11 04:33:03 +03:00
|
|
|
struct page *page);
|
2016-06-21 02:23:11 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Flags for iomap_begin / iomap_end. No flag implies a read.
|
|
|
|
*/
|
2016-10-20 07:51:28 +03:00
|
|
|
#define IOMAP_WRITE (1 << 0) /* writing, must allocate blocks */
|
|
|
|
#define IOMAP_ZERO (1 << 1) /* zeroing operation, may skip holes */
|
|
|
|
#define IOMAP_REPORT (1 << 2) /* report extent status, e.g. FIEMAP */
|
2016-11-10 02:26:50 +03:00
|
|
|
#define IOMAP_FAULT (1 << 3) /* mapping for page fault */
|
2016-11-30 06:36:01 +03:00
|
|
|
#define IOMAP_DIRECT (1 << 4) /* direct I/O */
|
2018-06-01 19:03:07 +03:00
|
|
|
#define IOMAP_NOWAIT (1 << 5) /* do not block */
|
2021-01-23 21:06:10 +03:00
|
|
|
#define IOMAP_OVERWRITE_ONLY (1 << 6) /* only pure overwrites allowed */
|
2021-08-11 04:33:14 +03:00
|
|
|
#define IOMAP_UNSHARE (1 << 7) /* unshare_file_range */
|
2016-06-21 02:23:11 +03:00
|
|
|
|
|
|
|
struct iomap_ops {
|
|
|
|
/*
|
|
|
|
* Return the existing mapping at pos, or reserve space starting at
|
|
|
|
* pos for up to length, as long as we can do it as a single mapping.
|
|
|
|
* The actual length is returned in iomap->length.
|
|
|
|
*/
|
|
|
|
int (*iomap_begin)(struct inode *inode, loff_t pos, loff_t length,
|
2019-10-19 02:44:10 +03:00
|
|
|
unsigned flags, struct iomap *iomap,
|
|
|
|
struct iomap *srcmap);
|
2016-06-21 02:23:11 +03:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Commit and/or unreserve space previous allocated using iomap_begin.
|
|
|
|
* Written indicates the length of the successful write operation which
|
|
|
|
* needs to be commited, while the rest needs to be unreserved.
|
|
|
|
* Written might be zero if no data was written.
|
|
|
|
*/
|
|
|
|
int (*iomap_end)(struct inode *inode, loff_t pos, loff_t length,
|
|
|
|
ssize_t written, unsigned flags, struct iomap *iomap);
|
2016-06-21 02:22:39 +03:00
|
|
|
};
|
|
|
|
|
2021-08-11 04:33:07 +03:00
|
|
|
/**
|
|
|
|
* struct iomap_iter - Iterate through a range of a file
|
|
|
|
* @inode: Set at the start of the iteration and should not change.
|
|
|
|
* @pos: The current file position we are operating on. It is updated by
|
|
|
|
* calls to iomap_iter(). Treat as read-only in the body.
|
|
|
|
* @len: The remaining length of the file segment we're operating on.
|
|
|
|
* It is updated at the same time as @pos.
|
|
|
|
* @processed: The number of bytes processed by the body in the most recent
|
|
|
|
* iteration, or a negative errno. 0 causes the iteration to stop.
|
|
|
|
* @flags: Zero or more of the iomap_begin flags above.
|
|
|
|
* @iomap: Map describing the I/O iteration
|
|
|
|
* @srcmap: Source map for COW operations
|
|
|
|
*/
|
|
|
|
struct iomap_iter {
|
|
|
|
struct inode *inode;
|
|
|
|
loff_t pos;
|
|
|
|
u64 len;
|
|
|
|
s64 processed;
|
|
|
|
unsigned flags;
|
|
|
|
struct iomap iomap;
|
|
|
|
struct iomap srcmap;
|
|
|
|
};
|
|
|
|
|
|
|
|
int iomap_iter(struct iomap_iter *iter, const struct iomap_ops *ops);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* iomap_length - length of the current iomap iteration
|
|
|
|
* @iter: iteration structure
|
|
|
|
*
|
|
|
|
* Returns the length that the operation applies to for the current iteration.
|
|
|
|
*/
|
|
|
|
static inline u64 iomap_length(const struct iomap_iter *iter)
|
|
|
|
{
|
|
|
|
u64 end = iter->iomap.offset + iter->iomap.length;
|
|
|
|
|
|
|
|
if (iter->srcmap.type != IOMAP_HOLE)
|
|
|
|
end = min(end, iter->srcmap.offset + iter->srcmap.length);
|
|
|
|
return min(iter->len, end - iter->pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* iomap_iter_srcmap - return the source map for the current iomap iteration
|
|
|
|
* @i: iteration structure
|
|
|
|
*
|
|
|
|
* Write operations on file systems with reflink support might require a
|
|
|
|
* source and a destination map. This function retourns the source map
|
|
|
|
* for a given operation, which may or may no be identical to the destination
|
|
|
|
* map in &i->iomap.
|
|
|
|
*/
|
2021-08-11 04:33:16 +03:00
|
|
|
static inline const struct iomap *iomap_iter_srcmap(const struct iomap_iter *i)
|
2021-08-11 04:33:07 +03:00
|
|
|
{
|
|
|
|
if (i->srcmap.type != IOMAP_HOLE)
|
|
|
|
return &i->srcmap;
|
|
|
|
return &i->iomap;
|
|
|
|
}
|
|
|
|
|
2016-06-21 02:23:11 +03:00
|
|
|
ssize_t iomap_file_buffered_write(struct kiocb *iocb, struct iov_iter *from,
|
2017-01-28 10:20:26 +03:00
|
|
|
const struct iomap_ops *ops);
|
2018-06-20 01:10:57 +03:00
|
|
|
int iomap_readpage(struct page *page, const struct iomap_ops *ops);
|
2020-06-02 07:47:34 +03:00
|
|
|
void iomap_readahead(struct readahead_control *, const struct iomap_ops *ops);
|
2018-07-12 08:26:05 +03:00
|
|
|
int iomap_is_partially_uptodate(struct page *page, unsigned long from,
|
|
|
|
unsigned long count);
|
|
|
|
int iomap_releasepage(struct page *page, gfp_t gfp_mask);
|
|
|
|
void iomap_invalidatepage(struct page *page, unsigned int offset,
|
|
|
|
unsigned int len);
|
|
|
|
#ifdef CONFIG_MIGRATION
|
|
|
|
int iomap_migrate_page(struct address_space *mapping, struct page *newpage,
|
|
|
|
struct page *page, enum migrate_mode mode);
|
|
|
|
#else
|
|
|
|
#define iomap_migrate_page NULL
|
|
|
|
#endif
|
2019-10-19 02:41:34 +03:00
|
|
|
int iomap_file_unshare(struct inode *inode, loff_t pos, loff_t len,
|
2017-01-28 10:20:26 +03:00
|
|
|
const struct iomap_ops *ops);
|
2016-06-21 02:23:11 +03:00
|
|
|
int iomap_zero_range(struct inode *inode, loff_t pos, loff_t len,
|
2017-01-28 10:20:26 +03:00
|
|
|
bool *did_zero, const struct iomap_ops *ops);
|
2016-06-21 02:23:11 +03:00
|
|
|
int iomap_truncate_page(struct inode *inode, loff_t pos, bool *did_zero,
|
2017-01-28 10:20:26 +03:00
|
|
|
const struct iomap_ops *ops);
|
2018-10-27 01:02:59 +03:00
|
|
|
vm_fault_t iomap_page_mkwrite(struct vm_fault *vmf,
|
|
|
|
const struct iomap_ops *ops);
|
2016-06-21 02:38:45 +03:00
|
|
|
int iomap_fiemap(struct inode *inode, struct fiemap_extent_info *fieinfo,
|
2020-05-23 10:30:12 +03:00
|
|
|
u64 start, u64 len, const struct iomap_ops *ops);
|
2017-06-29 21:43:21 +03:00
|
|
|
loff_t iomap_seek_hole(struct inode *inode, loff_t offset,
|
|
|
|
const struct iomap_ops *ops);
|
|
|
|
loff_t iomap_seek_data(struct inode *inode, loff_t offset,
|
|
|
|
const struct iomap_ops *ops);
|
2018-06-01 19:03:08 +03:00
|
|
|
sector_t iomap_bmap(struct address_space *mapping, sector_t bno,
|
|
|
|
const struct iomap_ops *ops);
|
2016-06-21 02:23:11 +03:00
|
|
|
|
2019-10-17 23:12:15 +03:00
|
|
|
/*
|
|
|
|
* Structure for writeback I/O completions.
|
|
|
|
*/
|
|
|
|
struct iomap_ioend {
|
|
|
|
struct list_head io_list; /* next ioend in chain */
|
|
|
|
u16 io_type;
|
|
|
|
u16 io_flags; /* IOMAP_F_* */
|
|
|
|
struct inode *io_inode; /* file being written to */
|
|
|
|
size_t io_size; /* size of the extent */
|
|
|
|
loff_t io_offset; /* offset in the file */
|
|
|
|
struct bio *io_bio; /* bio being built */
|
|
|
|
struct bio io_inline_bio; /* MUST BE LAST! */
|
|
|
|
};
|
|
|
|
|
|
|
|
struct iomap_writeback_ops {
|
|
|
|
/*
|
|
|
|
* Required, maps the blocks so that writeback can be performed on
|
|
|
|
* the range starting at offset.
|
|
|
|
*/
|
|
|
|
int (*map_blocks)(struct iomap_writepage_ctx *wpc, struct inode *inode,
|
|
|
|
loff_t offset);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Optional, allows the file systems to perform actions just before
|
|
|
|
* submitting the bio and/or override the bio end_io handler for complex
|
|
|
|
* operations like copy on write extent manipulation or unwritten extent
|
|
|
|
* conversions.
|
|
|
|
*/
|
|
|
|
int (*prepare_ioend)(struct iomap_ioend *ioend, int status);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Optional, allows the file system to discard state on a page where
|
|
|
|
* we failed to submit any I/O.
|
|
|
|
*/
|
2020-10-30 00:30:48 +03:00
|
|
|
void (*discard_page)(struct page *page, loff_t fileoff);
|
2019-10-17 23:12:15 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
struct iomap_writepage_ctx {
|
|
|
|
struct iomap iomap;
|
|
|
|
struct iomap_ioend *ioend;
|
|
|
|
const struct iomap_writeback_ops *ops;
|
|
|
|
};
|
|
|
|
|
|
|
|
void iomap_finish_ioends(struct iomap_ioend *ioend, int error);
|
|
|
|
void iomap_ioend_try_merge(struct iomap_ioend *ioend,
|
2021-05-04 18:54:29 +03:00
|
|
|
struct list_head *more_ioends);
|
2019-10-17 23:12:15 +03:00
|
|
|
void iomap_sort_ioends(struct list_head *ioend_list);
|
|
|
|
int iomap_writepage(struct page *page, struct writeback_control *wbc,
|
|
|
|
struct iomap_writepage_ctx *wpc,
|
|
|
|
const struct iomap_writeback_ops *ops);
|
|
|
|
int iomap_writepages(struct address_space *mapping,
|
|
|
|
struct writeback_control *wbc, struct iomap_writepage_ctx *wpc,
|
|
|
|
const struct iomap_writeback_ops *ops);
|
|
|
|
|
2016-11-30 06:36:01 +03:00
|
|
|
/*
|
|
|
|
* Flags for direct I/O ->end_io:
|
|
|
|
*/
|
|
|
|
#define IOMAP_DIO_UNWRITTEN (1 << 0) /* covers unwritten extent(s) */
|
|
|
|
#define IOMAP_DIO_COW (1 << 1) /* covers COW extent(s) */
|
2019-09-20 01:32:45 +03:00
|
|
|
|
|
|
|
struct iomap_dio_ops {
|
|
|
|
int (*end_io)(struct kiocb *iocb, ssize_t size, int error,
|
|
|
|
unsigned flags);
|
2021-08-11 04:33:10 +03:00
|
|
|
blk_qc_t (*submit_io)(const struct iomap_iter *iter, struct bio *bio,
|
|
|
|
loff_t file_offset);
|
2019-09-20 01:32:45 +03:00
|
|
|
};
|
|
|
|
|
2021-01-23 21:06:09 +03:00
|
|
|
/*
|
|
|
|
* Wait for the I/O to complete in iomap_dio_rw even if the kiocb is not
|
|
|
|
* synchronous.
|
|
|
|
*/
|
|
|
|
#define IOMAP_DIO_FORCE_WAIT (1 << 0)
|
|
|
|
|
2021-01-23 21:06:10 +03:00
|
|
|
/*
|
|
|
|
* Do not allocate blocks or zero partial blocks, but instead fall back to
|
|
|
|
* the caller by returning -EAGAIN. Used to optimize direct I/O writes that
|
|
|
|
* are not aligned to the file system block size.
|
|
|
|
*/
|
|
|
|
#define IOMAP_DIO_OVERWRITE_ONLY (1 << 1)
|
|
|
|
|
2022-04-15 01:28:49 +03:00
|
|
|
/*
|
|
|
|
* When a page fault occurs, return a partial synchronous result and allow
|
|
|
|
* the caller to retry the rest of the operation after dealing with the page
|
|
|
|
* fault.
|
|
|
|
*/
|
|
|
|
#define IOMAP_DIO_PARTIAL (1 << 2)
|
|
|
|
|
2016-11-30 06:36:01 +03:00
|
|
|
ssize_t iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
|
2019-10-15 18:43:42 +03:00
|
|
|
const struct iomap_ops *ops, const struct iomap_dio_ops *dops,
|
2022-04-15 01:28:50 +03:00
|
|
|
unsigned int dio_flags, size_t done_before);
|
2020-09-28 18:51:08 +03:00
|
|
|
struct iomap_dio *__iomap_dio_rw(struct kiocb *iocb, struct iov_iter *iter,
|
|
|
|
const struct iomap_ops *ops, const struct iomap_dio_ops *dops,
|
2022-04-15 01:28:50 +03:00
|
|
|
unsigned int dio_flags, size_t done_before);
|
2020-09-28 18:51:08 +03:00
|
|
|
ssize_t iomap_dio_complete(struct iomap_dio *dio);
|
2018-12-04 21:12:08 +03:00
|
|
|
int iomap_dio_iopoll(struct kiocb *kiocb, bool spin);
|
2016-11-30 06:36:01 +03:00
|
|
|
|
2018-05-10 18:38:15 +03:00
|
|
|
#ifdef CONFIG_SWAP
|
|
|
|
struct file;
|
|
|
|
struct swap_info_struct;
|
|
|
|
|
|
|
|
int iomap_swapfile_activate(struct swap_info_struct *sis,
|
|
|
|
struct file *swap_file, sector_t *pagespan,
|
|
|
|
const struct iomap_ops *ops);
|
|
|
|
#else
|
|
|
|
# define iomap_swapfile_activate(sis, swapfile, pagespan, ops) (-EIO)
|
|
|
|
#endif /* CONFIG_SWAP */
|
|
|
|
|
2016-06-21 02:22:39 +03:00
|
|
|
#endif /* LINUX_IOMAP_H */
|