nfs_file_direct_write(9)

πŸ“¦ version 7.3.1, in nixpkgs unstable

πŸ’– NAME πŸ’–

okay so bestie, welcome to the nfs_file_direct_write(9) page from the Kernel API Manual β€” it's literally the file direct write operation for NFS files, and we're about to make it make sense 🫢✨

✨ SYNOPSIS ✨

ssize_t nfs_file_direct_write (struct kiocb *iocb , struct iov_iter
       *iter , bool swap );

πŸŽ€ ARGUMENTS πŸŽ€

  • iocb β€” the target I/O control block, aka the thing this direct write is happening on 🎯
  • iter β€” the vector of user buffers from which to write data; think of it as the little stack of source memory we're pulling from πŸ’Œ
  • swap β€” a flag saying this is swap IO, not O_DIRECT IO β€” important distinction, no cap πŸ”₯

πŸ¦‹ DESCRIPTION πŸ¦‹

so why do we use this for direct writes instead of calling generic_file_aio_write? because we're avoiding taking the inode semaphore and updating the i_size, that's why πŸ’… the NFS server is the one that sets the new i_size, and this client must read the updated size back into its cache. we also let the server do the generic write parameter checking and report any problems β€” delegation is the moment πŸ‘‘

we eliminate local atime updates, see direct read above 🧚

and we avoid unnecessary page cache invalidations for normal cached readers of this file, which is highkey thoughtful of us 🌸

ok bestie, important: O_APPEND is not supported for NFS direct writes, because there is no atomic O_APPEND write facility in the NFS protocol. so don't come for that combination, fr fr πŸ’€

🌈 SEE ALSO 🌈

check out the Kernel file ./fs/nfs/direct.c, plus nfs_file_direct_read(9), nfs_init_directcache(9), and nfs_destroy_directcache(9) πŸ¦‹


mwah πŸ’‹ signed off from ./fs/nfs, dated October 2026, on nfs_file_direct_write(9) β€” periodt πŸŽ€

πŸ“¦ where this page comes from