netfs_write_begin(9)
πΈ NAME πΈ
netfs_write_begin β a helper to prepare for writing, bestieβ¦ but it is [DEPRECATED] π« (more on that in a sec). This page lives in the Kernel API Manual, so you know it's serious kernel business with a side of chaos. π
β¨ SYNOPSIS β¨
int netfs_write_begin (struct netfs_inode *ctx , struct file *file ,
struct address_space *mapping , loff_t pos , unsigned int len , struct
folio **_folio , void **_fsdata );
π ARGUMENTS π
ctxβ the netfs context, aka the vibe container for this whole operation πfileβ the file to read from. yes, read from, even though we're beginning a write, iykyk πmappingβ the mapping to read from πposβ the file position at which the write will begin πlenβ the length of the write, and lowkey it may extend beyond the end of the folio chosen π_folioβ where to put the resultant folio π_fsdataβ the place for the netfs to store a cookie πͺ
π§ DESCRIPTION π§
Okay so here's the tea: this helper pre-reads data for a write-begin request by drawing data from the cache if possible, or from the netfs if not. Space beyond the EOF is zero-filled. And multiple I/O requests from different sources will get munged together β yes, literally munged together π.
The calling netfs must provide a table of operations, and only one of them, issue_read, is mandatory. Periodt.
The check_write_begin operation can be provided to check for and flush conflicting writes once the folio is grabbed and locked. It is passed a pointer to the fsdata cookie that gets returned to the VM to be passed to write_end. It is permitted to sleep π΄. It should return 0 if the request should go ahead, or it may return an error. It may also unlock and put the folio, provided it sets *foliop to NULL β in which case a return of 0 will cause the folio to be re-got and the process to be retried. Iconic retry behavior, honestly π.
The calling netfs must initialise a netfs context contiguous to the vfs inode before calling this. No skipping that step, bestie π«Ά.
This is usable whether or not caching is enabled. Flexible queen behavior β¨.
β οΈ Note that this should be considered deprecated and netfs_perform_write used instead. Like, for real for real β use the other one π.
π₯ SEE ALSO π₯
- Kernel file
./fs/netfs/buffered_read.c netfs_readahead(9)netfs_read_folio(9)netfs_buffered_read_iter(9)netfs_file_read_iter(9)
xoxo, your kernel bestie π β source/version: ./fs/netfs, dated October 2026 πβ¨
π¦ where this page comes from
- nixpkgs unstable: linux-manual 7.3.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms