From d8060a4cbf8eda08687c165662704d7f27aa8e08 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Fri, 30 Oct 2015 09:50:36 +0100 Subject: stripe: set ENOENT when a READ hits EOF The NFS-server sets EOF only in the READ reply when op_errno is set to ENOENT. Xlators are expected to set op_errno to ENOENT when EOF is reached, op_ret will contain the number of bytes returned by the READ. When an NFS-client (like VMware ESXi) do a READ that exceeds the size of the file, errno should be set to EOF and the return value contains the number of bytes that are read (from the requested offset, until the end of the file). Not setting EOF on a correct short READ, can result in errors on the NFS-client. This is not an issue with the Linux NFS-client (or VFS). Linux is smart enough to not try to read more bytes than the file contains. Cherry picked from commit 2bd2ccf0fdd5390c1c07cb228048f93e5e516512: > BUG: 1209298 > Change-Id: Ib15538744908a6001d729288d3e18a432d19050b > Signed-off-by: Niels de Vos > Reviewed-on: http://review.gluster.org/10142 > Tested-by: Gluster Build System > Reviewed-by: Kaleb KEITHLEY > Reviewed-by: jiffin tony Thottan BUG: 1219399 Change-Id: Ib15538744908a6001d729288d3e18a432d19050b Signed-off-by: Niels de Vos Reviewed-on: http://review.gluster.org/12470 Reviewed-by: jiffin tony Thottan Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/cluster/stripe/src/stripe.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'xlators') diff --git a/xlators/cluster/stripe/src/stripe.c b/xlators/cluster/stripe/src/stripe.c index db363910b56..dbb76c30b38 100644 --- a/xlators/cluster/stripe/src/stripe.c +++ b/xlators/cluster/stripe/src/stripe.c @@ -3256,6 +3256,11 @@ stripe_readv_fstat_cbk (call_frame_t *frame, void *cookie, xlator_t *this, GF_FREE (local->replies[i].vector); } + /* ENOENT signals EOF to the NFS-server */ + if (op_ret != -1 && op_ret < local->readv_size && + (local->offset + op_ret == buf->ia_size)) + op_errno = ENOENT; + /* FIXME: notice that st_ino, and st_dev (gen) will be * different than what inode will have. Make sure this doesn't * cause any bugs at higher levels */ -- cgit