From patchwork Sun Jun 14 21:35:05 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Coddington X-Patchwork-Id: 6605441 Return-Path: X-Original-To: patchwork-linux-nfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 31A319F1C1 for ; Sun, 14 Jun 2015 21:35:11 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 53B7220588 for ; Sun, 14 Jun 2015 21:35:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 307B920570 for ; Sun, 14 Jun 2015 21:35:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751569AbbFNVfH (ORCPT ); Sun, 14 Jun 2015 17:35:07 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56307 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751797AbbFNVfG (ORCPT ); Sun, 14 Jun 2015 17:35:06 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (Postfix) with ESMTPS id DFAF7BACB7 for ; Sun, 14 Jun 2015 21:35:05 +0000 (UTC) Received: from bcodding-csb.redhat.com (vpn-54-165.rdu2.redhat.com [10.10.54.165]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t5ELZ5Fm006610 for ; Sun, 14 Jun 2015 17:35:05 -0400 Received: by bcodding-csb.redhat.com (Postfix, from userid 24008) id 2B7F7E5082; Sun, 14 Jun 2015 17:35:05 -0400 (EDT) From: Benjamin Coddington To: linux-nfs@vger.kernel.org Subject: [PATCH] NFS: Handle exceptions for SEEK Date: Sun, 14 Jun 2015 17:35:05 -0400 Message-Id: X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Don't pass along NFS4ERR_* exceptions to VFS and do recovery if needed. These exceptions might look like offsets (even though they are negative) and applications that used the previous behavior of seeking to eof for SEEK_HOLE, and current offset for SEEK_DATA may be caught off-guard if the server responds with transient errors such as NFS4ERR_GRACE. Signed-off-by: Benjamin Coddington --- fs/nfs/nfs42proc.c | 23 +++++++++++++++-------- 1 files changed, 15 insertions(+), 8 deletions(-) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index 3a9e752..9c3c9d2 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -146,20 +146,27 @@ loff_t nfs42_proc_llseek(struct file *filep, loff_t offset, int whence) .rpc_resp = &res, }; struct nfs_server *server = NFS_SERVER(inode); + struct nfs4_exception exception = { }; int status; if (!nfs_server_capable(inode, NFS_CAP_SEEK)) return -ENOTSUPP; - status = nfs42_set_rw_stateid(&args.sa_stateid, filep, FMODE_READ); - if (status) - return status; - nfs_wb_all(inode); - status = nfs4_call_sync(server->client, server, &msg, - &args.seq_args, &res.seq_res, 0); - if (status == -ENOTSUPP) - server->caps &= ~NFS_CAP_SEEK; + do { + status = nfs42_set_rw_stateid(&args.sa_stateid, filep, FMODE_READ); + if (status) + return status; + + status = nfs4_call_sync(server->client, server, &msg, + &args.seq_args, &res.seq_res, 0); + if (status == -ENOTSUPP) { + server->caps &= ~NFS_CAP_SEEK; + return status; + } + status = nfs4_handle_exception(server, status, &exception); + } while (exception.retry); + if (status) return status;