From patchwork Tue Feb 14 20:11:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9572773 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 71D6260578 for ; Tue, 14 Feb 2017 20:12:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6E0FF271BC for ; Tue, 14 Feb 2017 20:12:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6324F2840E; Tue, 14 Feb 2017 20:12:46 +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 180F5271BC for ; Tue, 14 Feb 2017 20:12:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754967AbdBNUMn (ORCPT ); Tue, 14 Feb 2017 15:12:43 -0500 Received: from mail-qt0-f195.google.com ([209.85.216.195]:35879 "EHLO mail-qt0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754953AbdBNUMk (ORCPT ); Tue, 14 Feb 2017 15:12:40 -0500 Received: by mail-qt0-f195.google.com with SMTP id h53so18733528qth.3 for ; Tue, 14 Feb 2017 12:12:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=URi6C4N0zsgXX3N0+yyyJE/vBPPLoVQaY6Lhklfur2c=; b=Ba7JYuDtKduW8vfnPgPtu3obprLj/JUJFbpGSPPiuay56bJJd73ts4xFlNfft80Tym 2abcph1+rWu9wFKhLlyzop8QuGv+9hsz/wUvt4blD+WoTCXibFkz8COUShtsnUndcbL/ PESY5EGRnQp24ZX9V3XdnS6cjFki8+Z5RpvS6TKW78uP7xKImYiD+gSH7L/Hp4DS+nFO WOBV9kDLmTpG5SD4J+Yv0ThPPYxR7zHndFFLPIfIq05sEMQqAMzFsn4PEVYL9LhtyKb3 2Mg+dATVk7UV8KGQrZatkTOD5xZ1g+KVLoGvlPxtXPzN2p0UfX3dW+rM7MBOvHP46lu+ gApg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=URi6C4N0zsgXX3N0+yyyJE/vBPPLoVQaY6Lhklfur2c=; b=GWZt4sk/PmKFvAA/1KxQKF5ceCCnlxb6zfEMrgP9T3frdXI3ve+Tf284+UCxZHaqcu CA2Rd86N42/eJB41enGC4N0DcXP42zbeigOQ7jFDuGYO46VNE/J802aQgSgkKL5KkxpD Lv8LEhwPAlzesz3APxeNlfGiP0vN4Aa1bmdinBgeiq03Gq3NJ+iZYCMSU8fBDwEJwGO9 NPxd8Mquuz7y/a2l35OJq6xqqXiJDdbPJGU047wO126t+263bCKhc7Ukak0xaVlPVLsI AJ1EC+rlDVV9qXvxyF306hqF0e6uQakj53tYUzbhk7ODIs9cWBW6dvK0BhKGLFWtKEnu Bnog== X-Gm-Message-State: AMke39lrWdcSq146BykK4sxv7ca5m2Jy5ObVRqmpwdfgFJxipjdb3j+EI7/eE+I9zo4omQ== X-Received: by 10.200.36.207 with SMTP id t15mr30523561qtt.84.1487103154372; Tue, 14 Feb 2017 12:12:34 -0800 (PST) Received: from dhcp-1-235.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id w138sm939945qka.27.2017.02.14.12.12.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Feb 2017 12:12:34 -0800 (PST) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Cc: Alex Elder Subject: [PATCH 05/15] libceph: pass reply buffer length through ceph_osdc_call() Date: Tue, 14 Feb 2017 21:11:54 +0100 Message-Id: <1487103124-2974-6-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1487103124-2974-1-git-send-email-idryomov@gmail.com> References: <1487103124-2974-1-git-send-email-idryomov@gmail.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP To spare checking for "this reply fits into a page, but does it fit into my buffer?" in some callers, osd_req_op_cls_response_data_pages() needs to know how big it is. Signed-off-by: Ilya Dryomov --- net/ceph/cls_lock_client.c | 2 +- net/ceph/osd_client.c | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/net/ceph/cls_lock_client.c b/net/ceph/cls_lock_client.c index 50f040fdb2a9..f13a1ea87459 100644 --- a/net/ceph/cls_lock_client.c +++ b/net/ceph/cls_lock_client.c @@ -278,7 +278,7 @@ int ceph_cls_lock_info(struct ceph_osd_client *osdc, int get_info_op_buf_size; int name_len = strlen(lock_name); struct page *get_info_op_page, *reply_page; - size_t reply_len; + size_t reply_len = PAGE_SIZE; void *p, *end; int ret; diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c index 3a2417bb6ff0..ac4753421d0c 100644 --- a/net/ceph/osd_client.c +++ b/net/ceph/osd_client.c @@ -4023,7 +4023,7 @@ EXPORT_SYMBOL(ceph_osdc_maybe_request_map); * Execute an OSD class method on an object. * * @flags: CEPH_OSD_FLAG_* - * @resp_len: out param for reply length + * @resp_len: in/out param for reply length */ int ceph_osdc_call(struct ceph_osd_client *osdc, struct ceph_object_id *oid, @@ -4036,6 +4036,9 @@ int ceph_osdc_call(struct ceph_osd_client *osdc, struct ceph_osd_request *req; int ret; + if (req_len > PAGE_SIZE || (resp_page && *resp_len > PAGE_SIZE)) + return -E2BIG; + req = ceph_osdc_alloc_request(osdc, NULL, 1, false, GFP_NOIO); if (!req) return -ENOMEM; @@ -4054,7 +4057,7 @@ int ceph_osdc_call(struct ceph_osd_client *osdc, 0, false, false); if (resp_page) osd_req_op_cls_response_data_pages(req, 0, &resp_page, - PAGE_SIZE, 0, false, false); + *resp_len, 0, false, false); ceph_osdc_start_request(osdc, req, false); ret = ceph_osdc_wait_request(osdc, req);