From patchwork Tue Jun 23 11:51:56 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peng Tao X-Patchwork-Id: 6659851 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 92CD99F46A for ; Tue, 23 Jun 2015 11:52:34 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B3CFC2063C for ; Tue, 23 Jun 2015 11:52:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id BBD7B20651 for ; Tue, 23 Jun 2015 11:52:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754601AbbFWLwb (ORCPT ); Tue, 23 Jun 2015 07:52:31 -0400 Received: from mail-pd0-f175.google.com ([209.85.192.175]:35357 "EHLO mail-pd0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754634AbbFWLwb (ORCPT ); Tue, 23 Jun 2015 07:52:31 -0400 Received: by pdbci14 with SMTP id ci14so5860234pdb.2 for ; Tue, 23 Jun 2015 04:52:30 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=StpHBFJC/VYcRbNITuxkIvWILo3bszLYK7DGKtAkxb4=; b=UwzYYW+0N1ryFi7dSTWrLZP6nZpaG+zALTlDNUPuIUuIw7Qi/7jpQthHIiF6LHS5/U p/A+qPy6od5RAZ4EwQVTFbHlKoLUv8gQMGuOAbloAbCbiSRX8FiTdGojMHEcUKLPjrnu OOV+QAPFAdQrA2dPrpoFnJ+KV524PNmsiTXoljXnlLZ6tsf1iRdURYdjTRdPKfhmB2AL cSv9xWAFzTwUVbVjQqXdALZAKFr8iCm33ZnmOLqLKn0yEwsZ7QjYRzo/TaqcFGR90fGP gTGDtsqc4srnsso6yRMSX4Co/+nKCFaxFLvM0cHk5iqRdBRFFuckqXeA5x3ssG1d6nXq UMog== X-Gm-Message-State: ALoCoQl4RSmvKZUWBRgsXPWtDXDgrtXScRnaDB1Uds9W8S4r2+rtDvgJwX+a2AOT4EzzVCONtcL6 X-Received: by 10.66.184.133 with SMTP id eu5mr67171126pac.75.1435060350877; Tue, 23 Jun 2015 04:52:30 -0700 (PDT) Received: from lear.localdomain (ec2-54-65-164-9.ap-northeast-1.compute.amazonaws.com. [54.65.164.9]) by mx.google.com with ESMTPSA id kh6sm22995755pbc.50.2015.06.23.04.52.28 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 23 Jun 2015 04:52:30 -0700 (PDT) From: Peng Tao To: linux-nfs Cc: Trond Myklebust , Peng Tao Subject: [PATCH-v2 02/10] pNFS: fill in nfs42_layoutstat_ops Date: Tue, 23 Jun 2015 19:51:56 +0800 Message-Id: <1435060324-13279-3-git-send-email-tao.peng@primarydata.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1435060324-13279-1-git-send-email-tao.peng@primarydata.com> References: <1435060324-13279-1-git-send-email-tao.peng@primarydata.com> 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.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham 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 Reviewed-by: Jeff Layton Signed-off-by: Peng Tao --- fs/nfs/nfs42proc.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/fs/nfs/nfs42proc.c b/fs/nfs/nfs42proc.c index ac92968..a053041 100644 --- a/fs/nfs/nfs42proc.c +++ b/fs/nfs/nfs42proc.c @@ -10,6 +10,11 @@ #include #include "nfs4_fs.h" #include "nfs42.h" +#include "iostat.h" +#include "pnfs.h" +#include "internal.h" + +#define NFSDBG_FACILITY NFSDBG_PNFS static int nfs42_set_rw_stateid(nfs4_stateid *dst, struct file *file, fmode_t fmode) @@ -166,7 +171,44 @@ loff_t nfs42_proc_llseek(struct file *filep, loff_t offset, int whence) return vfs_setpos(filep, res.sr_offset, inode->i_sb->s_maxbytes); } +static void +nfs42_layoutstat_prepare(struct rpc_task *task, void *calldata) +{ + struct nfs42_layoutstat_data *data = calldata; + struct nfs_server *server = NFS_SERVER(data->args.inode); + + nfs41_setup_sequence(nfs4_get_session(server), &data->args.seq_args, + &data->res.seq_res, task); +} + +static void +nfs42_layoutstat_done(struct rpc_task *task, void *calldata) +{ + struct nfs42_layoutstat_data *data = calldata; + + if (!nfs4_sequence_done(task, &data->res.seq_res)) + return; + + /* well, we don't care about errors at all! */ + if (task->tk_status) + dprintk("%s server returns %d\n", __func__, task->tk_status); +} + +static void +nfs42_layoutstat_release(void *calldata) +{ + struct nfs42_layoutstat_data *data = calldata; + + pnfs_put_layout_hdr(NFS_I(data->args.inode)->layout); + nfs_iput_and_deactive(data->inode); + kfree(data->args.devinfo); + kfree(data); +} + static const struct rpc_call_ops nfs42_layoutstat_ops = { + .rpc_call_prepare = nfs42_layoutstat_prepare, + .rpc_call_done = nfs42_layoutstat_done, + .rpc_release = nfs42_layoutstat_release, }; int nfs42_proc_layoutstats_generic(struct nfs_server *server, @@ -186,6 +228,11 @@ int nfs42_proc_layoutstats_generic(struct nfs_server *server, }; struct rpc_task *task; + data->inode = nfs_igrab_and_active(data->args.inode); + if (!data->inode) { + nfs42_layoutstat_release(data); + return -EAGAIN; + } nfs4_init_sequence(&data->args.seq_args, &data->res.seq_res, 0); task = rpc_run_task(&task_setup); if (IS_ERR(task))