[PATCH] add pread operation to vfs layer

Cole, Timothy D. t.cole at ngc.com
Wed Dec 17 17:03:13 GMT 2003


> -----Original Message-----
> From: Stefan Metzmacher [mailto:metze at metzemix.de]
> Sent: Wednesday, December 17, 2003 0:56
> To: James Peach
> Cc: Cole, Timothy D.; samba-technical
> Subject: Re: [PATCH] add pread operation to vfs layer
>  >This seems quite complicated and difficult to test. There 
> is already 
> pos and
>  >position_information in files_struct, and adding a third 
> player into this
>  >isn't going to help the clarity of this code.

Well... actually I'm not sure it would require any changes to files_struct.

Thinking about it, assuming sys_pread()/sys_pwrite() return ENOSYS on
systems that don't have the real pread()/pwrite(), things get a LOT simpler.

read_file/real_write_file (in smbd/fileio.c) can just always try the VFS
pread/pwrite first; if that yields ENOSYS, then seek and use normal VFS
read/write.  Always update fsp->pos and fsp->position_information whichever
variant was used.

That means efficient fallback behavior can be implemented without touching
anything outside of smbd/fileio.c -- though maybe it'd be expedient to also
implement vfs_p{read,write}_data() in smbd/vfs.c or something.

The only cost on non-p{read,write} systems is an extra (indirect) function
call.

Depending on the invariants expected by the VFS layer, it may also be
possible to short-circuit the seek when fsp->pos == pos.

Anyone see anything glaringly wrong with this?


More information about the samba-technical mailing list