Bug 1306264 - glfs_lseek returns incorrect offset for SEEK_SET and SEEK_CUR flags
glfs_lseek returns incorrect offset for SEEK_SET and SEEK_CUR flags
Status: CLOSED CURRENTRELEASE
Product: GlusterFS
Classification: Community
Component: libgfapi (Show other bugs)
mainline
All All
high Severity high
: ---
: ---
Assigned To: Anoop C S
Sudhir D
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-02-10 07:40 EST by Anoop C S
Modified: 2016-06-16 09:57 EDT (History)
2 users (show)

See Also:
Fixed In Version: glusterfs-3.8rc2
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2016-06-16 09:57:29 EDT
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)
Test program (2.08 KB, text/x-csrc)
2016-02-10 07:40 EST, Anoop C S
no flags Details

  None (edit)
Description Anoop C S 2016-02-10 07:40:07 EST
Created attachment 1122783 [details]
Test program

Description of problem:

When glfs_lseek() API is used with SEEK_SET and SEEK_CUR to reposition the open file associated with a fd to the specified offset, even though the operation is success it is not returning the resulting offset location and instead -1 is returned.

Version-Release number of selected component (if applicable):
mainline

How reproducible:
always

Steps to Reproduce:
1. Compile and build glusterfs under /usr/local/.
2. Create and start a simple distribute volume.
3. Download the attached test program and compile it.
# gcc gfapi-test-lseek.c -lgfapi -I /usr/local/include/glusterfs/ -L /usr/local/lib/
4. Export LD_LIBRARY_PATH
# export LD_LIBRARY_PATH=/usr/local/lib
5. Run a.out
# ./a.out <volume-name> <server ip/hostname>

Actual results:
Program produced the following error message:
glfs_lseek with SEEK_SET returned -1, but expected 5
glfs_lseek with SEEK_CUR returned -1, but expected 10

Expected results:
Program should run successfully with out displaying any error message.
Comment 1 Vijay Bellur 2016-02-10 07:44:07 EST
REVIEW: http://review.gluster.org/13423 (api: glfs_lseek must return repositioned offset for SEEK_SET, SEEK_CUR flags) posted (#1) for review on master by Anoop C S (anoopcs@redhat.com)
Comment 2 Vijay Bellur 2016-02-11 05:59:48 EST
COMMIT: http://review.gluster.org/13423 committed in master by Niels de Vos (ndevos@redhat.com) 
------
commit 095e2c48271a5248c8711a4e6a34bcb4d44c440e
Author: Anoop C S <anoopcs@redhat.com>
Date:   Wed Feb 10 17:08:26 2016 +0530

    api: glfs_lseek must return repositioned offset for SEEK_SET, SEEK_CUR flags
    
    On success, glfs_lseek() API is responsible for providing the
    repositioned offset as its return value. But for SEEK_SET and
    SEEK_CUR flags, glfs_lseek() returns -1 on successfully
    repositioning the fd offset. Current change is to set ret to
    0 after glfd->offset is modified correctly so as to return the
    correct offset.
    
    Change-Id: I94d582779a98074cf633289f4b60b3c6a04e4f18
    BUG: 1306264
    Signed-off-by: Anoop C S <anoopcs@redhat.com>
    Reviewed-on: http://review.gluster.org/13423
    Smoke: Gluster Build System <jenkins@build.gluster.com>
    NetBSD-regression: NetBSD Build System <jenkins@build.gluster.org>
    CentOS-regression: Gluster Build System <jenkins@build.gluster.com>
    Reviewed-by: jiffin tony Thottan <jthottan@redhat.com>
    Reviewed-by: Niels de Vos <ndevos@redhat.com>
Comment 3 Niels de Vos 2016-06-16 09:57:29 EDT
This bug is getting closed because a release has been made available that should address the reported issue. In case the problem is still not fixed with glusterfs-3.8.0, please open a new bug report.

glusterfs-3.8.0 has been announced on the Gluster mailinglists [1], packages for several distributions should become available in the near future. Keep an eye on the Gluster Users mailinglist [2] and the update infrastructure for your distribution.

[1] http://blog.gluster.org/2016/06/glusterfs-3-8-released/
[2] http://thread.gmane.org/gmane.comp.file-systems.gluster.user

Note You need to log in before you can comment on or make changes to this bug.