From patchwork Wed Sep 3 04:27:58 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 4830441 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.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 9A1239F2ED for ; Wed, 3 Sep 2014 04:25:59 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id DEB6F200ED for ; Wed, 3 Sep 2014 04:25:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1418F200E6 for ; Wed, 3 Sep 2014 04:25:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751146AbaICEZ5 (ORCPT ); Wed, 3 Sep 2014 00:25:57 -0400 Received: from casper.infradead.org ([85.118.1.10]:37589 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751495AbaICEZ4 (ORCPT ); Wed, 3 Sep 2014 00:25:56 -0400 Received: from [64.134.221.109] (helo=localhost) by casper.infradead.org with esmtpsa (Exim 4.80.1 #2 (Red Hat Linux)) id 1XP28p-0003VL-E8 for linux-nfs@vger.kernel.org; Wed, 03 Sep 2014 04:25:55 +0000 From: Christoph Hellwig To: linux-nfs@vger.kernel.org Subject: [PATCH 2/4] pnfs: add a common GETDEVICELIST implementation Date: Tue, 2 Sep 2014 21:27:58 -0700 Message-Id: <1409718480-1529-3-git-send-email-hch@lst.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1409718480-1529-1-git-send-email-hch@lst.de> References: <1409718480-1529-1-git-send-email-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org See http://www.infradead.org/rpr.html Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Spam-Status: No, score=-8.6 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 At a simple helper to issue a GETDEVICELIST operation and pre-load the device id cache based on the result. Signed-off-by: Christoph Hellwig --- fs/nfs/pnfs.h | 2 ++ fs/nfs/pnfs_dev.c | 29 +++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/fs/nfs/pnfs.h b/fs/nfs/pnfs.h index c5f90e7..bf4e87d 100644 --- a/fs/nfs/pnfs.h +++ b/fs/nfs/pnfs.h @@ -276,6 +276,8 @@ bool nfs4_put_deviceid_node(struct nfs4_deviceid_node *); void nfs4_mark_deviceid_unavailable(struct nfs4_deviceid_node *node); bool nfs4_test_deviceid_unavailable(struct nfs4_deviceid_node *node); void nfs4_deviceid_purge_client(const struct nfs_client *); +int nfs4_deviceid_getdevicelist(struct nfs_server *server, + const struct nfs_fh *fh); static inline struct pnfs_layout_segment * pnfs_get_lseg(struct pnfs_layout_segment *lseg) diff --git a/fs/nfs/pnfs_dev.c b/fs/nfs/pnfs_dev.c index 791f8b3..82c2836 100644 --- a/fs/nfs/pnfs_dev.c +++ b/fs/nfs/pnfs_dev.c @@ -359,3 +359,32 @@ nfs4_deviceid_mark_client_invalid(struct nfs_client *clp) rcu_read_unlock(); } +int +nfs4_deviceid_getdevicelist(struct nfs_server *server, + const struct nfs_fh *fh) +{ + struct pnfs_devicelist *dlist; + struct nfs4_deviceid_node *d; + int error = 0, i; + + dlist = kzalloc(sizeof(struct pnfs_devicelist), GFP_NOFS); + if (!dlist) + return -ENOMEM; + + while (!dlist->eof) { + error = nfs4_proc_getdevicelist(server, fh, dlist); + if (error) + break; + + for (i = 0; i < dlist->num_devs; i++) { + d = nfs4_find_get_deviceid(server, &dlist->dev_id[i], + NULL, GFP_NOFS); + if (d) + nfs4_put_deviceid_node(d); + } + } + + kfree(dlist); + return error; +} +EXPORT_SYMBOL_GPL(nfs4_deviceid_getdevicelist);