netfs_buffer..._iter_locked(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

netfs_buffer..._iter_locked(9) πŸ’…


🌸 NAME 🌸

netfs_buffered_write_iter_locked β€” write data to a file. Bestie, this is from the Kernel API Manual and it's giving β€œthe actual write-work function” energy ✨

✨ SYNOPSIS ✨

ssize_t netfs_buffered_write_iter_locked (struct kiocb *iocb , struct iov_iter *from , struct netfs_group *netfs_group );

πŸ’– ARGUMENTS πŸ’–

  • iocb β€” IO state structure (file, offset, etc.) 🫢
  • from β€” iov_iter with data to write
  • netfs_group β€” grouping for dirty folios (eg. ceph snaps).

πŸŽ€ DESCRIPTION πŸŽ€

Okay so this function literally does all the work needed for actually writing data to a file. It does all the basic checks, removes SUID from the file, updates modification times, and calls the proper subroutines depending on whether we do direct IO or a standard buffered write. Slay πŸ’…

The caller must hold appropriate locks around this function and have called generic_write_checks already. The caller is also responsible for doing any necessary syncing afterwards. Important bestie note 🫢

This function does not take care of syncing data in case of O_SYNC write. A caller has to handle it. This is mainly due to the fact that we want to avoid syncing under i_rwsem. Periodt πŸ’€

🫢 RETURN 🫢

  • number of bytes written, even for truncated writes
  • negative error code if no data has been written at all

πŸ‘€ SEE ALSO πŸ‘€

Kernel file ./fs/netfs/buffered_write.c netfs_perform_write(9), netfs_file_write_iter(9).


later bestie β€” source/version: ./fs/netfs, date: October 2026 πŸ¦‹πŸ’–

πŸ“¦ where this page comes from