From patchwork Tue Feb 7 13:50:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kinglong Mee X-Patchwork-Id: 9560153 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 35E0960434 for ; Tue, 7 Feb 2017 13:50:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27BFB2818E for ; Tue, 7 Feb 2017 13:50:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CDBB283CA; Tue, 7 Feb 2017 13:50:41 +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=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 CB83E23B24 for ; Tue, 7 Feb 2017 13:50:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754067AbdBGNuk (ORCPT ); Tue, 7 Feb 2017 08:50:40 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:33499 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754059AbdBGNuj (ORCPT ); Tue, 7 Feb 2017 08:50:39 -0500 Received: by mail-io0-f194.google.com with SMTP id 101so12867944iom.0 for ; Tue, 07 Feb 2017 05:50:39 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:cc:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding; bh=c2Of4BvU//5NKb07vH3CAafEPldNGy5BmMdaZg78cEc=; b=eSDOnmpH4mwUPnuTJT5IG3eBhpjnZE1H4fAkWIdjbE9GlEui36BhoWwqZIIQZtKIGd AZhNt+pqGBjoVZKa8kRlKeoKZ1FkkD8GZYzh0ma8Pd+PHlqnRUqPdFubun33Yk9RZMWv IuuYXbxkN4a9bG22o36IYHh5hej6qrv2wrftDbo72p0iqoG6JzqJ4nVviJZqw29m7H30 GHkOd6ZYDkATcT/F5Zp3sITHLyeDEC583k3IeAkJz6aEt187/AxeNEbifzqt4X6+2Ez2 WV7Po2hmXoJ/ZzVKVUHjt5yQTLSd3UE41yvvw4Suyq0gCmuYsdMZyeSuq+cFhdRQD0iC utTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:cc:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=c2Of4BvU//5NKb07vH3CAafEPldNGy5BmMdaZg78cEc=; b=q1E2wZslEXlVtH48lQIAP/1sG7mq18rGtzz7v3HMw9BJxtV5x25JbkxIHSX4wDHPkp jXKnPGtR4ZrLvzaDPj2BwFMEu49ver2KD4f45FLfDwg8AYfujogidNplWsBaEyiNdAwi zbQ6ISd5tJb3jBT8p07c9FDShkA6SIaFen7maz580x7NI/LQz5y5JM/rgQLSookrAlja LO0TmleKEQPZCECbcc5KXMISraE9KfafLzHY075alCwSaobElm0K2JmbnnOLgrAuo1hS QAoQm1csHoHFnhVYW0rhanmyB7HdpIbPS22fHEfgp2prpnDi4Md+S5OldYEjcb7SdgXr Yfew== X-Gm-Message-State: AMke39mgDOipnoeGCN0Pd2rZJO6a71nANf114Hi4ikwWiHy1BiGAa7NRbM/XbY3YscYMKQ== X-Received: by 10.107.15.163 with SMTP id 35mr4022852iop.177.1486475438700; Tue, 07 Feb 2017 05:50:38 -0800 (PST) Received: from [192.168.0.107] ([182.139.118.29]) by smtp.gmail.com with ESMTPSA id j201sm6051572ita.3.2017.02.07.05.50.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Feb 2017 05:50:38 -0800 (PST) Subject: [PATCH 7/7] sunrpc: use simple_read_from_buffer for reading cache flush To: "J. Bruce Fields" , linux-nfs@vger.kernel.org References: <59432847-8e45-4423-c441-0c67ee645f38@gmail.com> Cc: Trond Myklebust , Kinglong Mee From: Kinglong Mee Message-ID: <02295874-6761-724a-ec8c-cc5159bc0d98@gmail.com> Date: Tue, 7 Feb 2017 21:50:32 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: <59432847-8e45-4423-c441-0c67ee645f38@gmail.com> 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 Signed-off-by: Kinglong Mee --- net/sunrpc/cache.c | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index 9e8561d..2f06f51 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c @@ -1427,20 +1427,11 @@ static ssize_t read_flush(struct file *file, char __user *buf, struct cache_detail *cd) { char tbuf[22]; - unsigned long p = *ppos; size_t len; - snprintf(tbuf, sizeof(tbuf), "%lu\n", convert_to_wallclock(cd->flush_time)); - len = strlen(tbuf); - if (p >= len) - return 0; - len -= p; - if (len > count) - len = count; - if (copy_to_user(buf, (void*)(tbuf+p), len)) - return -EFAULT; - *ppos += len; - return len; + len = snprintf(tbuf, sizeof(tbuf), "%lu\n", + convert_to_wallclock(cd->flush_time)); + return simple_read_from_buffer(buf, count, ppos, tbuf, len); } static ssize_t write_flush(struct file *file, const char __user *buf,