fs/iomap/ioend.c
Source file repositories/reference/linux-study-clean/fs/iomap/ioend.c
File Facts
- System
- Linux kernel
- Corpus path
fs/iomap/ioend.c- Extension
.c- Size
- 15153 bytes
- Lines
- 513
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/bio-integrity.hlinux/iomap.hlinux/list_sort.hlinux/pagemap.hlinux/writeback.hlinux/fserror.hinternal.htrace.h
Detected Declarations
function iomap_finish_ioend_buffered_writefunction iomap_fail_ioendsfunction iomap_fail_ioend_bufferedfunction ioend_writeback_end_biofunction iomap_ioend_writeback_submitfunction iomap_can_add_to_ioendfunction iomap_add_to_ioendfunction iomap_finish_ioendfunction iomap_finish_ioendsfunction iomap_ioend_can_mergefunction iomap_ioend_try_mergefunction iomap_ioend_comparefunction iomap_sort_ioendsfunction iomap_ioend_initmodule init iomap_ioend_initexport iomap_ioend_biosetexport iomap_init_ioendexport iomap_ioend_writeback_submitexport iomap_add_to_ioendexport iomap_finish_ioendsexport iomap_ioend_try_mergeexport iomap_sort_ioendsexport iomap_split_ioend
Annotated Snippet
if (!bio_flagged(bio, BIO_QUIET)) {
pr_err_ratelimited(
"%s: writeback error on inode %llu, offset %lld, sector %llu",
inode->i_sb->s_id, inode->i_ino,
ioend->io_offset, ioend->io_sector);
}
}
/* walk all folios in bio, ending page IO on them */
bio_for_each_folio_all(fi, bio) {
if (ioend->io_error)
fserror_report_io(inode, FSERR_BUFFERED_WRITE,
folio_pos(fi.folio) + fi.offset,
fi.length, ioend->io_error,
GFP_ATOMIC);
iomap_finish_folio_write(inode, fi.folio, fi.length);
folio_count++;
}
if (bio_integrity(bio))
fs_bio_integrity_free(bio);
bio_put(bio); /* frees the ioend */
return folio_count;
}
static DEFINE_SPINLOCK(failed_ioend_lock);
static LIST_HEAD(failed_ioend_list);
static void
iomap_fail_ioends(
struct work_struct *work)
{
struct iomap_ioend *ioend;
struct list_head tmp;
unsigned long flags;
spin_lock_irqsave(&failed_ioend_lock, flags);
list_replace_init(&failed_ioend_list, &tmp);
spin_unlock_irqrestore(&failed_ioend_lock, flags);
while ((ioend = list_first_entry_or_null(&tmp, struct iomap_ioend,
io_list))) {
list_del_init(&ioend->io_list);
iomap_finish_ioend_buffered_write(ioend);
cond_resched();
}
}
static DECLARE_WORK(failed_ioend_work, iomap_fail_ioends);
static void iomap_fail_ioend_buffered(struct iomap_ioend *ioend)
{
unsigned long flags;
/*
* Bounce I/O errors to a workqueue to avoid nested i_lock acquisitions
* in the fserror code. The caller no longer owns the ioend reference
* after the spinlock drops.
*/
spin_lock_irqsave(&failed_ioend_lock, flags);
if (list_empty(&failed_ioend_list))
WARN_ON_ONCE(!schedule_work(&failed_ioend_work));
list_add_tail(&ioend->io_list, &failed_ioend_list);
spin_unlock_irqrestore(&failed_ioend_lock, flags);
}
static void ioend_writeback_end_bio(struct bio *bio)
{
struct iomap_ioend *ioend = iomap_ioend_from_bio(bio);
ioend->io_error = blk_status_to_errno(bio->bi_status);
if (ioend->io_error) {
iomap_fail_ioend_buffered(ioend);
return;
}
iomap_finish_ioend_buffered_write(ioend);
}
/*
* We cannot cancel the ioend directly in case of an error, so call the bio end
* I/O handler with the error status here to run the normal I/O completion
* handler.
*/
int iomap_ioend_writeback_submit(struct iomap_writepage_ctx *wpc, int error)
{
struct iomap_ioend *ioend = wpc->wb_ctx;
if (!ioend->io_bio.bi_end_io)
ioend->io_bio.bi_end_io = ioend_writeback_end_bio;
Annotation
- Immediate include surface: `linux/bio-integrity.h`, `linux/iomap.h`, `linux/list_sort.h`, `linux/pagemap.h`, `linux/writeback.h`, `linux/fserror.h`, `internal.h`, `trace.h`.
- Detected declarations: `function iomap_finish_ioend_buffered_write`, `function iomap_fail_ioends`, `function iomap_fail_ioend_buffered`, `function ioend_writeback_end_bio`, `function iomap_ioend_writeback_submit`, `function iomap_can_add_to_ioend`, `function iomap_add_to_ioend`, `function iomap_finish_ioend`, `function iomap_finish_ioends`, `function iomap_ioend_can_merge`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.