Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp123980pxf; Wed, 31 Mar 2021 18:52:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzh4isnyTDl/9L8G8DZiVANpmg0Fkckt7xPhgQKYaFzZJRupbyDSCxGzsucQLO38OWnt9eC X-Received: by 2002:a17:906:18a1:: with SMTP id c1mr6506121ejf.62.1617241927962; Wed, 31 Mar 2021 18:52:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1617241927; cv=none; d=google.com; s=arc-20160816; b=0zLFpt8Zdm3BeVG+x+Nfp41i4BpoF84JlKiBIlDP8UBjdgW3ul4gLsDuBTVnLDoRNd davwEA1otvqKSZ00qqonKZCYlIGrdrn2duhPWAwZOWws/6JvfOjhirVnw7AfFqTfMJrr ydw7Wm2kVdSW6hrIBsmFBcQbwi4umofhvTUNWwU3Tiv2c4kvcGGULu8JJsCkPe5Jdc3l Irku2Pm+JdwqBz6IS73NWEA8jkkXUNPNOWe+FKxKgb8pvfVDI/2rNb4xAB+8FiYyv0De g0ixQsV97YjLJ63cOJ54gFWydewqD/VLE5x+SMYldAvu8uGfVXryIblrCT5WbgE+6yb9 ZgCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=VQyuwHF3WWP+qSjkHaZSx/EjMcX4n0qR7hgwFVZxo9U=; b=vVvZafbNPN2nSi9kBvnZgufxUREeqD8Ry/zjjIL4vP6sKOY4vUj2U2nP1tjfGTIVDi v+bq9hBJHbdUnLkFIfc+LhunisNEVrhFthVXHkNrqVCVkhLCcWyQxKKoTjRHQPI4ePMD Ix9q6sRH4HPuWMeENa1QGbo40ULylhw99xCQbbewHLULLGMxBOKsEGbcwjTcUBYvOK1p cLrak3mKzjHhXmcLuCM082IDup2QJPBwrSB8rilH2egwDPXLkIGc/Tm26aoRdgxqEu/y TL8a1oO54IuFdmzmyKPhZQkf5kYhlW2+8bbv6qGtr2r/GrSK7WtuGstL7PPii/Vn7JMb 3OEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=C7uXcwNu; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id i13si3173582edq.522.2021.03.31.18.51.34; Wed, 31 Mar 2021 18:52:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=C7uXcwNu; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232207AbhDABvC (ORCPT + 99 others); Wed, 31 Mar 2021 21:51:02 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:44126 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233236AbhDABup (ORCPT ); Wed, 31 Mar 2021 21:50:45 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617241844; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=VQyuwHF3WWP+qSjkHaZSx/EjMcX4n0qR7hgwFVZxo9U=; b=C7uXcwNusHHKK9JGEjqU3AME7wBLAE32uurG/+PLjzWoMiIy4yNw774Ze9m2N0pOp1uG7o xmRj7yh7gf9qLr7b1fYIdCjK/Jsf9EWvkVynU6C2sSof1CsftDmF1chH6n5jUFGALDEztM CS1Oqs0YFUWYNLIGao6gWPD+pbqq7XI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-384-ap62gtpFN3WlzPKACuB--A-1; Wed, 31 Mar 2021 21:50:41 -0400 X-MC-Unique: ap62gtpFN3WlzPKACuB--A-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C8BD2107ACCD; Thu, 1 Apr 2021 01:50:40 +0000 (UTC) Received: from pick.fieldses.org (ovpn-115-11.rdu2.redhat.com [10.10.115.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A7A1C5D9CA; Thu, 1 Apr 2021 01:50:40 +0000 (UTC) Received: by pick.fieldses.org (Postfix, from userid 2815) id AA8FA12063A; Wed, 31 Mar 2021 21:50:39 -0400 (EDT) Date: Wed, 31 Mar 2021 21:50:39 -0400 From: "J. Bruce Fields" To: Olga Kornievskaia Cc: chuck.lever@oracle.com, linux-nfs@vger.kernel.org Subject: Re: [PATCH 1/1] NFSD fix handling of NFSv4.2 SEEK for data within the last hole Message-ID: References: <20210331192819.25637-1-olga.kornievskaia@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210331192819.25637-1-olga.kornievskaia@gmail.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org On Wed, Mar 31, 2021 at 03:28:19PM -0400, Olga Kornievskaia wrote: > From: Olga Kornievskaia > > According to the RFC 7862, "if the server cannot find a > corresponding sa_what, then the status will still be NFS4_OK, > but sr_eof would be TRUE". If there is a file that ends with > a hole and a SEEK request made for sa_what=SEEK_DATA with > an offset in the middle of the last hole, then the server > has to return OK and set the eof. Currently the linux server > returns ERR_NXIO. Makes sense, but I think you can use the return value from vfs_llseek instead of checking the file size again. E.g.: seek->seek_pos = vfs_llseek(nfs->nf_file, seek->seek_offset, whence); if (seek->seek_pos == -ENXIO) seek->seek_eof = true; else if (seek->seek_pos < 0) status = nfserrno(seek->seek_pos); --b. > > Fixes: 24bab491220fa ("NFSD: Implement SEEK") > Signed-off-by: Olga Kornievskaia > --- > fs/nfsd/nfs4proc.c | 10 +++++++--- > 1 file changed, 7 insertions(+), 3 deletions(-) > > diff --git a/fs/nfsd/nfs4proc.c b/fs/nfsd/nfs4proc.c > index e13c4c81fb89..2e7ceb9f1d5d 100644 > --- a/fs/nfsd/nfs4proc.c > +++ b/fs/nfsd/nfs4proc.c > @@ -1737,9 +1737,13 @@ nfsd4_seek(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, > * should ever file->f_pos. > */ > seek->seek_pos = vfs_llseek(nf->nf_file, seek->seek_offset, whence); > - if (seek->seek_pos < 0) > - status = nfserrno(seek->seek_pos); > - else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file))) > + if (seek->seek_pos < 0) { > + if (whence == SEEK_DATA && > + seek->seek_offset < i_size_read(file_inode(nf->nf_file))) > + seek->seek_eof = true; > + else > + status = nfserrno(seek->seek_pos); > + } else if (seek->seek_pos >= i_size_read(file_inode(nf->nf_file))) > seek->seek_eof = true; > > out: > -- > 2.18.2 >