Bug 1793990

Summary: lseek SEEK_DATA - File descriptor in bad state
Product: [Community] GlusterFS Reporter: Tomáš Mózes <hydrapolic>
Component: open-behindAssignee: Pranith Kumar K <pkarampu>
Status: CLOSED UPSTREAM QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 6CC: bugs, pasik, ravishankar, zmedico
Target Milestone: ---Keywords: Triaged
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-12 12:29:23 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Tomáš Mózes 2020-01-22 13:08:48 UTC
Description of problem:


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


How reproducible:


Steps to Reproduce:
1.
2.
3.

Actual results:


Expected results:


Additional info:

Comment 1 Tomáš Mózes 2020-01-22 13:09:39 UTC
In Gentoo Linux we use portage to install software. That software is usually built from source so it's a good candidate for a shared storage if used by hundreds of systems to avoid re-downloading on multiple systems. While installing some packages in Gentoo (having the source repository on Glusterfs) we discovered that lseek SEEK_DATA isn't working properly on Glusterfs.

A working example on ext4:
# dd if=/dev/zero of=/tmp/sparse bs=1M count=0 seek=1
# echo hi >> /tmp/sparse
# python3 ./lseek-seek-data.py /tmp/sparse
1048576

A failure on glusterfs volume (/usr/portage/distfiles):
# dd if=/dev/zero of=/usr/portage/distfiles/sparse bs=1M count=0 seek=1
# echo hi >> /usr/portage/distfiles/sparse
# python3 ./lseek-seek-data.py /usr/portage/distfiles/sparse
Traceback (most recent call last):
  File "./lseek-seek-data.py", line 19, in <module>
    main()
  File "./lseek-seek-data.py", line 15, in main
    print(os.lseek(input_file.fileno(), offset, os.SEEK_DATA))
OSError: [Errno 77] File descriptor in bad state

lseek-seek-data.py:
#!/usr/bin/env python3

import argparse
import os


def main():
	parser = argparse.ArgumentParser()
	parser.add_argument('input_file')
	args = parser.parse_args()

	offset = 0

	with open(args.input_file, 'rb', 0) as input_file:
		print(os.lseek(input_file.fileno(), offset, os.SEEK_DATA))


if __name__ == '__main__':
	main()

Discussion in Gentoo:
https://bugs.gentoo.org/705536
https://github.com/gentoo/portage/pull/498

The glusterfs volume is simple running default settings on version 6.7.

Comment 2 Ravishankar N 2020-01-27 05:27:46 UTC
Looks like https://review.gluster.org/#/c/23530/ needs to be backported to the release-{6/7} branches. Assigning the bug to Pranith.

@Tomas, for now, a workaround is to disable the open-behind translator: `gluster v set volname open-behind off`. Things will then work as expected.

Comment 3 Tomáš Mózes 2020-01-27 06:59:02 UTC
Thanks @Ravishankar, the patch https://github.com/gluster/glusterfs/commit/9dd57ff963d4d0dde7f3ad0ff230837ff2f4b1df works fine with 6.7/7.2.

Comment 4 Worker Ant 2020-03-12 12:29:23 UTC
This bug is moved to https://github.com/gluster/glusterfs/issues/894, and will be tracked there from now on. Visit GitHub issues URL for further details