From patchwork Thu Sep 27 15:40:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 10618161 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1055B112B for ; Thu, 27 Sep 2018 15:41:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1C182BB16 for ; Thu, 27 Sep 2018 15:41:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F01EF2BB25; Thu, 27 Sep 2018 15:41:00 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5F1422BB21 for ; Thu, 27 Sep 2018 15:41:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727828AbeI0V7t (ORCPT ); Thu, 27 Sep 2018 17:59:49 -0400 Received: from mail-it1-f195.google.com ([209.85.166.195]:50969 "EHLO mail-it1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727556AbeI0V7t (ORCPT ); Thu, 27 Sep 2018 17:59:49 -0400 Received: by mail-it1-f195.google.com with SMTP id j81-v6so8492796ite.0 for ; Thu, 27 Sep 2018 08:40:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=E0AMSxaT/9Vmoyew3fky34RjGTjzdikf0GkIf6/BmJc=; b=fCEv6jKNuYxXf8pSE18HnxHJrAOlTB06jQMyq7PLFipPiEKdIVARmc9leD0NOJF7vb djRFKkPIqkfT7WrWjF9LbQpwGcO+cWf1MUuPpBxpVowggMxcbQXgQqGZwPSbrB/JBfzl iFpWPv4GZKnoT1FerKsP2K0PqUyDT6HvyOzBDlUsQdwAqHp4nI0yBucRfzONXtrLG48q oqRikDZuPaPVtl0/OVeNezE+mO6quOxdmHwBJfjyAzzba6F7Lhzoe7ubxXyfx/OIIe+n OXtKrXj4GdVAYOjS7lZeQexJx0gC7Ox1+Ilq1YXIG4IscsnxgqfJj5+g/sYJkSFM9fEo cBrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=E0AMSxaT/9Vmoyew3fky34RjGTjzdikf0GkIf6/BmJc=; b=n3HnoqSQ2f5dpDHlA2kNq7iETAiudnTgaRV9BBpjkIbXYZ9Tu8bY8AjmiyXIEIFDGc NnomZXIhLEN+qJMV15TuR3KwMrbAVwq06R6kpZ1lnbvsOAI8BNKqZHerAFZ/HG/DxCAF K/+plfvHgqXJxXD47I5828UphnLdsDmcu50z99l5k0lULMEUJJP5W0U18YQKlEn5uILK 8Y8IIysZykDdskH1hRQyDGCMCnT1EqMrgHkaBWyjc1yrVtX7K/nmqEHV5TLZAXUTBQlE CRw2JmIcnfioRmCbRUPx7+alz8+CyMIm3sDSt7ZT10e7LTB1KN0krXCB36+D/nFnlo08 JAhQ== X-Gm-Message-State: ABuFfoiIbldO41gA4nUbLzATKnq3e1ieZg8G8nyuV6p8IZEj1hq/w86b Go4gHP2Yti6qWYbfWmw1ncahfQo= X-Google-Smtp-Source: ACcGV60aeb6IZ4sRggofJ8yhUWM8b2O2hrdUlvGEtCjITkoYxc5EmX0IwoA8AOeomm9JbeEcJkj/qQ== X-Received: by 2002:a24:c808:: with SMTP id w8-v6mr1425924itf.20.1538062857965; Thu, 27 Sep 2018 08:40:57 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (c-68-40-195-73.hsd1.mi.comcast.net. [68.40.195.73]) by smtp.gmail.com with ESMTPSA id d11-v6sm689072iok.77.2018.09.27.08.40.57 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Sep 2018 08:40:57 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 1/3] NFSv3: Improve NFSv3 performance when server returns no post-op attributes Date: Thu, 27 Sep 2018 11:40:01 -0400 Message-Id: <20180927154003.11825-1-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.17.1 MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Trond Myklebust When the server fails to return post-op attributes, the client's attempt to place read data directly in the page cache fails, and so we have to do an extra copy in order to realign the data with page borders. This patch attempts to detect servers that don't return post-op attributes on read (e.g. for pNFS) and adjusts the placement calculation accordingly. Signed-off-by: Trond Myklebust --- fs/nfs/nfs3proc.c | 5 +++++ fs/nfs/nfs3xdr.c | 6 +++++- include/linux/nfs_fs_sb.h | 3 +++ include/linux/nfs_xdr.h | 3 ++- 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/fs/nfs/nfs3proc.c b/fs/nfs/nfs3proc.c index ec8a9efa268f..71bc16225b98 100644 --- a/fs/nfs/nfs3proc.c +++ b/fs/nfs/nfs3proc.c @@ -786,6 +786,7 @@ nfs3_proc_pathconf(struct nfs_server *server, struct nfs_fh *fhandle, static int nfs3_read_done(struct rpc_task *task, struct nfs_pgio_header *hdr) { struct inode *inode = hdr->inode; + struct nfs_server *server = NFS_SERVER(inode); if (hdr->pgio_done_cb != NULL) return hdr->pgio_done_cb(task, hdr); @@ -793,6 +794,9 @@ static int nfs3_read_done(struct rpc_task *task, struct nfs_pgio_header *hdr) if (nfs3_async_handle_jukebox(task, inode)) return -EAGAIN; + if (task->tk_status >= 0 && !server->read_hdrsize) + cmpxchg(&server->read_hdrsize, 0, hdr->res.replen); + nfs_invalidate_atime(inode); nfs_refresh_inode(inode, &hdr->fattr); return 0; @@ -802,6 +806,7 @@ static void nfs3_proc_read_setup(struct nfs_pgio_header *hdr, struct rpc_message *msg) { msg->rpc_proc = &nfs3_procedures[NFS3PROC_READ]; + hdr->args.replen = NFS_SERVER(hdr->inode)->read_hdrsize; } static int nfs3_proc_pgio_rpc_prepare(struct rpc_task *task, diff --git a/fs/nfs/nfs3xdr.c b/fs/nfs/nfs3xdr.c index d8c4c10b15f7..78df4eb60f85 100644 --- a/fs/nfs/nfs3xdr.c +++ b/fs/nfs/nfs3xdr.c @@ -983,10 +983,11 @@ static void nfs3_xdr_enc_read3args(struct rpc_rqst *req, const void *data) { const struct nfs_pgio_args *args = data; + unsigned int replen = args->replen ? args->replen : NFS3_readres_sz; encode_read3args(xdr, args); prepare_reply_buffer(req, args->pages, args->pgbase, - args->count, NFS3_readres_sz); + args->count, replen); req->rq_rcv_buf.flags |= XDRBUF_READ; } @@ -1675,9 +1676,11 @@ static int nfs3_xdr_dec_read3res(struct rpc_rqst *req, struct xdr_stream *xdr, void *data) { struct nfs_pgio_res *result = data; + unsigned int pos; enum nfs_stat status; int error; + pos = xdr_stream_pos(xdr); error = decode_nfsstat3(xdr, &status); if (unlikely(error)) goto out; @@ -1687,6 +1690,7 @@ static int nfs3_xdr_dec_read3res(struct rpc_rqst *req, struct xdr_stream *xdr, result->op_status = status; if (status != NFS3_OK) goto out_status; + result->replen = 3 + ((xdr_stream_pos(xdr) - pos) >> 2); error = decode_read3resok(xdr, result); out: return error; diff --git a/include/linux/nfs_fs_sb.h b/include/linux/nfs_fs_sb.h index bf39d9c92201..0fc0b9135d46 100644 --- a/include/linux/nfs_fs_sb.h +++ b/include/linux/nfs_fs_sb.h @@ -228,6 +228,9 @@ struct nfs_server { unsigned short mountd_port; unsigned short mountd_protocol; struct rpc_wait_queue uoc_rpcwaitq; + + /* XDR related information */ + unsigned int read_hdrsize; }; /* Server capabilities */ diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index bd1c889a9ed9..7f5535e5e852 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -608,6 +608,7 @@ struct nfs_pgio_args { __u32 count; unsigned int pgbase; struct page ** pages; + unsigned int replen; /* used by read */ const u32 * bitmask; /* used by write */ enum nfs3_stable_how stable; /* used by write */ }; @@ -618,9 +619,9 @@ struct nfs_pgio_res { __u32 count; __u32 op_status; int eof; /* used by read */ + unsigned int replen; /* used by read */ struct nfs_writeverf * verf; /* used by write */ const struct nfs_server *server; /* used by write */ - }; /* From patchwork Thu Sep 27 15:40:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 10618163 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 436ED1759 for ; Thu, 27 Sep 2018 15:41:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 352742BAE9 for ; Thu, 27 Sep 2018 15:41:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 33C902BB0C; Thu, 27 Sep 2018 15:41:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DA5CE2BB1C for ; Thu, 27 Sep 2018 15:41:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727556AbeI0V7u (ORCPT ); Thu, 27 Sep 2018 17:59:50 -0400 Received: from mail-io1-f66.google.com ([209.85.166.66]:37884 "EHLO mail-io1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727769AbeI0V7t (ORCPT ); Thu, 27 Sep 2018 17:59:49 -0400 Received: by mail-io1-f66.google.com with SMTP id v14-v6so2266589iob.4 for ; Thu, 27 Sep 2018 08:40:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=HsR+Jr5tLfdzCLQtb6nmTooIrxaURPWV5VNP5aQCWTc=; b=YQzx4kw8F0WxXuzuG5YPIRQzNvDxwCqu5j3h39wSFH6w+AUGLaMVopC8oM0YyAPLxQ KX/X10s2P1gemwPZ2doqofxqikKhrQ9RkJls4JoQqyh2SJFcq2m718nXav7l9/3ENnNa hUKEgONp28UqnPaqwevv3G2KH6i8Nt5idYKgbj0vVj5nWnCyDWJV9tLLabRP14AWVXR/ CEuNnFtQnINWBk0W0Qdhd0S2UfjvLBV+m2JT0lYMh96AKZXjoBCiyFv4/2MOv46H0pls ViaW2PmiWe9E5MYq7u7Uy0kEdMBWbtnRACHplFCsCMcfZdgArAY81LpUiXV8ol2csERR 9aaA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=HsR+Jr5tLfdzCLQtb6nmTooIrxaURPWV5VNP5aQCWTc=; b=RScHHOt7gpsc0m+yrLqXCfVlMwa8doCGB/aVTf+A6f76SEMVU/jpGA1vRAPO62gl3y 4Aj63iZw5wS5umdzhDyM7tP/ykd1T12t5CI5i186eIdtVsuGeozNUoqcnTaPL6UYalpf d+Oge8FsErvS7MJRJaItqmX5jJggohRrwMzXCqZd+rXtsOh0y1sv89+j24vGsBMWP5R4 ypEO78hS/UAkSVt3EUPfN948touAf+0yVSpeocVB0WMYo1Whj1vl2rJ7x6/mZRWzVX4o pNmE9rBpvsTm8T6+3syJSiKr71JRy+sENflyI28eDl19LbNzYlYhQCKRyDDW4CqD+5kN BuvQ== X-Gm-Message-State: ABuFfohiXb5G4jszuxfvTtH+y93HgnSUjtMhiLbAjJbtst67uB4mQy+w duKwsz3GoB8GjwkNNiq+OThchhY= X-Google-Smtp-Source: ACcGV62GX8lTg2Nhv+yasmIVvT53W7OSQVG8w3JyVjtSnRbYBhlt2mjg1skajMVWQub6hTC4BbblWw== X-Received: by 2002:a6b:9bd1:: with SMTP id d200-v6mr9884363ioe.147.1538062858638; Thu, 27 Sep 2018 08:40:58 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (c-68-40-195-73.hsd1.mi.comcast.net. [68.40.195.73]) by smtp.gmail.com with ESMTPSA id d11-v6sm689072iok.77.2018.09.27.08.40.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Sep 2018 08:40:58 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 2/3] NFSv4: Save a few bytes in the nfs_pgio_args/res Date: Thu, 27 Sep 2018 11:40:02 -0400 Message-Id: <20180927154003.11825-2-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180927154003.11825-1-trond.myklebust@hammerspace.com> References: <20180927154003.11825-1-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Save a few bytes by allowing the read/write specific fields of the structures to share storage. Signed-off-by: Trond Myklebust --- include/linux/nfs_xdr.h | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 7f5535e5e852..343e44166346 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -608,9 +608,13 @@ struct nfs_pgio_args { __u32 count; unsigned int pgbase; struct page ** pages; - unsigned int replen; /* used by read */ - const u32 * bitmask; /* used by write */ - enum nfs3_stable_how stable; /* used by write */ + union { + unsigned int replen; /* used by read */ + struct { + const u32 * bitmask; /* used by write */ + enum nfs3_stable_how stable; /* used by write */ + }; + }; }; struct nfs_pgio_res { @@ -618,10 +622,16 @@ struct nfs_pgio_res { struct nfs_fattr * fattr; __u32 count; __u32 op_status; - int eof; /* used by read */ - unsigned int replen; /* used by read */ - struct nfs_writeverf * verf; /* used by write */ - const struct nfs_server *server; /* used by write */ + union { + struct { + unsigned int replen; /* used by read */ + int eof; /* used by read */ + }; + struct { + struct nfs_writeverf * verf; /* used by write */ + const struct nfs_server *server; /* used by write */ + }; + }; }; /* From patchwork Thu Sep 27 15:40:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Trond Myklebust X-Patchwork-Id: 10618165 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 36F21112B for ; Thu, 27 Sep 2018 15:41:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 289E92BB06 for ; Thu, 27 Sep 2018 15:41:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 271EA2BB15; Thu, 27 Sep 2018 15:41:02 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BDDC32BB06 for ; Thu, 27 Sep 2018 15:41:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727867AbeI0V7v (ORCPT ); Thu, 27 Sep 2018 17:59:51 -0400 Received: from mail-io1-f65.google.com ([209.85.166.65]:42164 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727769AbeI0V7v (ORCPT ); Thu, 27 Sep 2018 17:59:51 -0400 Received: by mail-io1-f65.google.com with SMTP id n18-v6so2239519ioa.9 for ; Thu, 27 Sep 2018 08:41:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7UG/64AxnudFBUR+XAIUxquB/4cR6YafIoOKqR5CaSA=; b=iITG6pbyNjtQSNr5Wjh0j32ya9cMYDXCGp3a1HXN9jypJcjjjetqzf2JvHkZBUq8Z8 R1ik4tPX75Ac94bKI8h4ig56kTWjdKSgso0XzYifar5dP6/KEzOpB7aBSAqI+7wnWJ7s JGqrSJNSc7SdT/H/zzbhsu45DPhrPD47XJGVB8p/sLgX2hHEAuxX6Tpu3RwXc/Qe1ZqB Cjf/Pj5LxtDVetlEwdN2X3woqiO/8ubuIIEWMWcSZfxWp2uLj/nQC7bHb8jdknP6lp3o eB5rAtQIWMs2dxwZLgSC7Yuu/3MFSeA4dQSSJLJ2BqNd0AJwNB4LcUKFYct3LmmdCXQG k6HQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7UG/64AxnudFBUR+XAIUxquB/4cR6YafIoOKqR5CaSA=; b=K2kOXqRwySaWywZGGtAC6Eo3M0aK8noSxOCIm5R8KusD58QUbyuXvboagoEK1QNGbf KWTtbfLqxhLDTpSQCwavCcZvrDrgGCptrcV11JznQwh5e/D0JekjFe1N4IVXZK29DusA d597hpuAp+Jr4ulvtV4xJAP20u8OFCpPdbEEZCCJh7hVwKVKdzMS+pbQTdndcg+Sq9TQ 36pQqLhGAVy0HQ0tu4IWniN2IiIIReCmgWLSxTgys+k4uF52OGv9vPXY7y7dk40SFyZC ilhw2u7KBBYM/B32BtOwv/b0oUnQq1+DehATp7snCX0j4a4Ywn/DM2aGdwFfZZFc5xla BZrw== X-Gm-Message-State: ABuFfohdV8gRrz39EiwSc3IM6OFQgDksEkqinkjHJVXSZTXEaS1RapGs VjJ4uLj4sDmvJkVNLQXea04/xho= X-Google-Smtp-Source: ACcGV60TNm5dyUPLwI2o/aQZ8oe17mGW4FvbvBzevU8p5yd2uCOlzqn4/TnjHlATPxnNPOkwB0DAkg== X-Received: by 2002:a6b:fc03:: with SMTP id r3-v6mr9567595ioh.288.1538062859631; Thu, 27 Sep 2018 08:40:59 -0700 (PDT) Received: from leira.trondhjem.org.localdomain (c-68-40-195-73.hsd1.mi.comcast.net. [68.40.195.73]) by smtp.gmail.com with ESMTPSA id d11-v6sm689072iok.77.2018.09.27.08.40.58 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 27 Sep 2018 08:40:59 -0700 (PDT) From: Trond Myklebust X-Google-Original-From: Trond Myklebust To: linux-nfs@vger.kernel.org Subject: [PATCH v2 3/3] NFS: Remove private spinlock in struct nfs_pgio_header Date: Thu, 27 Sep 2018 11:40:03 -0400 Message-Id: <20180927154003.11825-3-trond.myklebust@hammerspace.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180927154003.11825-2-trond.myklebust@hammerspace.com> References: <20180927154003.11825-1-trond.myklebust@hammerspace.com> <20180927154003.11825-2-trond.myklebust@hammerspace.com> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that each struct nfs_pgio_header corresponds to one RPC call, we only have one writer to the struct nfs_pgio_header. Signed-off-by: Trond Myklebust --- fs/nfs/pagelist.c | 13 ++++++------- fs/nfs/read.c | 10 ++++------ include/linux/nfs_xdr.h | 5 ++--- 3 files changed, 12 insertions(+), 16 deletions(-) diff --git a/fs/nfs/pagelist.c b/fs/nfs/pagelist.c index bb5476a6d264..f97c455f5734 100644 --- a/fs/nfs/pagelist.c +++ b/fs/nfs/pagelist.c @@ -63,14 +63,14 @@ EXPORT_SYMBOL_GPL(nfs_pgheader_init); void nfs_set_pgio_error(struct nfs_pgio_header *hdr, int error, loff_t pos) { - spin_lock(&hdr->lock); - if (!test_and_set_bit(NFS_IOHDR_ERROR, &hdr->flags) - || pos < hdr->io_start + hdr->good_bytes) { + unsigned int new = pos - hdr->io_start; + + if (hdr->good_bytes > new) { + hdr->good_bytes = new; clear_bit(NFS_IOHDR_EOF, &hdr->flags); - hdr->good_bytes = pos - hdr->io_start; - hdr->error = error; + if (!test_and_set_bit(NFS_IOHDR_ERROR, &hdr->flags)) + hdr->error = error; } - spin_unlock(&hdr->lock); } static inline struct nfs_page * @@ -494,7 +494,6 @@ struct nfs_pgio_header *nfs_pgio_header_alloc(const struct nfs_rw_ops *ops) if (hdr) { INIT_LIST_HEAD(&hdr->pages); - spin_lock_init(&hdr->lock); hdr->rw_ops = ops; } return hdr; diff --git a/fs/nfs/read.c b/fs/nfs/read.c index 48d7277c60a9..f9f19784db82 100644 --- a/fs/nfs/read.c +++ b/fs/nfs/read.c @@ -276,16 +276,14 @@ static void nfs_readpage_result(struct rpc_task *task, struct nfs_pgio_header *hdr) { if (hdr->res.eof) { - loff_t bound; + loff_t pos = hdr->args.offset + hdr->res.count; + unsigned int new = pos - hdr->io_start; - bound = hdr->args.offset + hdr->res.count; - spin_lock(&hdr->lock); - if (bound < hdr->io_start + hdr->good_bytes) { + if (hdr->good_bytes > new) { + hdr->good_bytes = new; set_bit(NFS_IOHDR_EOF, &hdr->flags); clear_bit(NFS_IOHDR_ERROR, &hdr->flags); - hdr->good_bytes = bound - hdr->io_start; } - spin_unlock(&hdr->lock); } else if (hdr->res.count < hdr->args.count) nfs_readpage_retry(task, hdr); } diff --git a/include/linux/nfs_xdr.h b/include/linux/nfs_xdr.h index 343e44166346..0e016252cfc6 100644 --- a/include/linux/nfs_xdr.h +++ b/include/linux/nfs_xdr.h @@ -1482,11 +1482,10 @@ struct nfs_pgio_header { const struct nfs_rw_ops *rw_ops; struct nfs_io_completion *io_completion; struct nfs_direct_req *dreq; - spinlock_t lock; - /* fields protected by lock */ + int pnfs_error; int error; /* merge with pnfs_error */ - unsigned long good_bytes; /* boundary of good data */ + unsigned int good_bytes; /* boundary of good data */ unsigned long flags; /*