Bug 1306264 - glfs_lseek returns incorrect offset for SEEK_SET and SEEK_CUR flags
Summary: glfs_lseek returns incorrect offset for SEEK_SET and SEEK_CUR flags
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: GlusterFS
Classification: Community
Component: libgfapi
Version: mainline
Hardware: All
OS: All
high
high
Target Milestone: ---
Assignee: Anoop C S
QA Contact: Sudhir D
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2016-02-10 12:40 UTC by Anoop C S
Modified: 2016-06-16 13:57 UTC (History)
2 users (show)

Fixed In Version: glusterfs-3.8rc2
Doc Type: Bug Fix
Doc Text:
Clone Of:
Environment:
Last Closed: 2016-06-16 13:57:29 UTC
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Embargoed:


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

Description Anoop C S 2016-02-10 12:40:07 UTC
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 12:44:07 UTC
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)

Comment 2 Vijay Bellur 2016-02-11 10:59:48 UTC
COMMIT: http://review.gluster.org/13423 committed in master by Niels de Vos (ndevos) 
------
commit 095e2c48271a5248c8711a4e6a34bcb4d44c440e
Author: Anoop C S <anoopcs>
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>
    Reviewed-on: http://review.gluster.org/13423
    Smoke: Gluster Build System <jenkins.com>
    NetBSD-regression: NetBSD Build System <jenkins.org>
    CentOS-regression: Gluster Build System <jenkins.com>
    Reviewed-by: jiffin tony Thottan <jthottan>
    Reviewed-by: Niels de Vos <ndevos>

Comment 3 Niels de Vos 2016-06-16 13:57:29 UTC
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.