netfs_write_begin(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

🌸 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 πŸ”₯


xoxo, your kernel bestie πŸ’– β€” source/version: ./fs/netfs, dated October 2026 πŸŽ€βœ¨

πŸ“¦ where this page comes from