linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* lseek gets bad offset from nfs client with ganesha/gluster which supports SEEK
@ 2018-09-11 12:29 Kinglong Mee
  2018-09-11 12:57 ` Trond Myklebust
  0 siblings, 1 reply; 9+ messages in thread
From: Kinglong Mee @ 2018-09-11 12:29 UTC (permalink / raw)
  To: devel, linux-nfs; +Cc: kinglongmee

The latest ganesha/gluster supports seek according to,

https://tools.ietf.org/html/draft-ietf-nfsv4-minorversion2-41#section-15.11

   From the given sa_offset, find the next data_content4 of type sa_what
   in the file.  If the server can not find a corresponding sa_what,
   then the status will still be NFS4_OK, but sr_eof would be TRUE.  If
   the server can find the sa_what, then the sr_offset is the start of
   that content.  If the sa_offset is beyond the end of the file, then
   SEEK MUST return NFS4ERR_NXIO.

For a file's filemap as,

Part    1: HOLE 0x0000000000000000 ---> 0x0000000000600000
Part    2: DATA 0x0000000000600000 ---> 0x0000000000700000
Part    3: HOLE 0x0000000000700000 ---> 0x0000000001000000

SEEK(0x700000, SEEK_DATA) gets result (sr_eof:1, sr_offset:0x70000) from ganesha/gluster;
SEEK(0x700000, SEEK_HOLE) gets result (sr_eof:0, sr_offset:0x70000) from ganesha/gluster.

If an application depends the lseek result for data searching, it may enter infinite loop.

        while (1) {
                next_pos = lseek(fd, cur_pos, seek_type);
                if (seek_type == SEEK_DATA) {
                        seek_type = SEEK_HOLE;
                } else {
                        seek_type = SEEK_DATA;
                }

                if (next_pos == -1) {
                        return ;

                cur_pos = next_pos;
        }

The lseek syscall always gets 0x70000 from nfs client for those two cases, 
but, if underlying filesystem is ext4/f2fs, or the nfs server is knfsd,
the lseek(0x700000, SEEK_DATA) gets ENXIO.

I wanna to know,
should I fix the ganesha/gluster as knfsd return ENXIO for the first case?
or should I fix the nfs client to return ENXIO for the first case?

thanks,
Kinglong Mee

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2020-09-14 19:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-09-11 12:29 lseek gets bad offset from nfs client with ganesha/gluster which supports SEEK Kinglong Mee
2018-09-11 12:57 ` Trond Myklebust
2018-09-11 14:47   ` Kinglong Mee
2018-09-11 15:43     ` Anna Schumaker
2018-09-11 23:20       ` [NFS-Ganesha-Devel] " Frank Filz
2018-09-12  1:31         ` Kinglong Mee
2018-09-12 11:58           ` Frank Filz
2018-09-13  0:03             ` Kinglong Mee
2020-09-14 15:02               ` Frank Filz

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).