Red Hat Bugzilla – Bug 1306264
glfs_lseek returns incorrect offset for SEEK_SET and SEEK_CUR flags
Last modified: 2016-06-16 09:57:29 EDT
Created attachment 1122783 [details]
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):
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>
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
Program should run successfully with out displaying any error message.
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 (firstname.lastname@example.org)
COMMIT: http://review.gluster.org/13423 committed in master by Niels de Vos (email@example.com)
Author: Anoop C S <firstname.lastname@example.org>
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
Signed-off-by: Anoop C S <email@example.com>
Smoke: Gluster Build System <firstname.lastname@example.org>
NetBSD-regression: NetBSD Build System <email@example.com>
CentOS-regression: Gluster Build System <firstname.lastname@example.org>
Reviewed-by: jiffin tony Thottan <email@example.com>
Reviewed-by: Niels de Vos <firstname.lastname@example.org>
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 , packages for several distributions should become available in the near future. Keep an eye on the Gluster Users mailinglist  and the update infrastructure for your distribution.