On Tue, Jan 14, 2025 at 10:38 PM Anna Schumaker <anna.schumaker@xxxxxxxxxx> wrote: > > I've seen a few requests for implementing the NFS v4.2 WRITE_SAME [1] operation over the last few months [2][3] to accelerate writing patterns of data on the server, so it's been in the back of my mind for a future project. I'll need to write some code somewhere so NFS & NFSD can handle this request. I could keep any implementation internal to NFS / NFSD, but I'd like to find out if local filesystems would find this sort of feature useful and if I should put it in the VFS instead. > > I was thinking I could keep it simple, and model a function call based on write(3) / pwrite(3) to write some pattern N times starting at either the file's current offset or at a user-provide offset. Something like: > write_pattern(int filedes, const void *pattern, size_t nbytes, size_t count); > pwrite_pattern(int filedes, const void *pattern, size_t nbytes, size_t count, offset_t offset); > > I could then construct a WRITE_SAME call in the NFS client using this information. This seems "good enough" to me for what people have asked for, at least as a client-side interface. It wouldn't really help the server, which would still need to do several writes in a loop to be spec-compliant with writing the pattern to an offset inside the "application data block" [4] structure. > > But maybe I'm simplifying this too much, and others would find the additional application data block fields useful? Or should I keep it all inside NFS, and call it with an ioctl instead of putting it into the VFS? API questions: 1. Can WRITE_SAME requests be split up if the adb_pattern (see https://datatracker.ietf.org/doc/html/rfc7862#section-15.12.1) is very large (e.g. 50MB), e.g. turn one WRITE_SAME request into two requests, where each half request writes only 1/2 of the pattern ? 2. Is it possible to write patterns with WRITE_SAME, but skip a number of bytes which is larger than the size of the pattern ? Example: Repeat writing adb_pattern="X" (size=1), start at file position 0, and write four times at every 2nd position, e.g. turn "abcdefghijklm" into "XbXdXfXhijklm" Can the API do that ? ---- Bye, Roland -- __ . . __ (o.\ \/ /.o) roland.mainz@xxxxxxxxxxx \__\/\/__/ MPEG specialist, C&&JAVA&&Sun&&Unix programmer /O /==\ O\ TEL +49 641 3992797 (;O/ \/ \O;)