nfs_file_direct_write(9)
π 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, notO_DIRECTIO β 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_APPENDis not supported for NFS direct writes, because there is no atomicO_APPENDwrite 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
- 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