From patchwork Thu May 3 16:23:01 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 10378725 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 1BA7A60159 for ; Thu, 3 May 2018 16:24:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 087632859A for ; Thu, 3 May 2018 16:24:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 05DCD2854A; Thu, 3 May 2018 16:24:33 +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=-7.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, 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 B66E828B89 for ; Thu, 3 May 2018 16:23:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751316AbeECQXZ (ORCPT ); Thu, 3 May 2018 12:23:25 -0400 Received: from mail-wr0-f194.google.com ([209.85.128.194]:38976 "EHLO mail-wr0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751141AbeECQXY (ORCPT ); Thu, 3 May 2018 12:23:24 -0400 Received: by mail-wr0-f194.google.com with SMTP id q3-v6so18238075wrj.6 for ; Thu, 03 May 2018 09:23:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=CkLQHNS1vO4HrMwoBihhcwh22F5eS+jFJP0g8ba0BKA=; b=pvRH1Ql4gRH3DhJ4Zj2c4THctGyoEO0IoEfHI14pngIereDih1CNs+O6F8Lx78CB2D CgFXXlWS+5vvTGuhdhKqQHF7MCX+s8WvTaZDI/N3rGdDoZNqpkvGmGrYbj41KrXin4MN Dmg4q2BsAjZsFgboGStrjHjhk1j8MYIAa7DccZjTRRWajTD74A+TYPh6KUqkvg7Y9/0U dlLel3MJumtgkLxs7RnDY/HewMtVpje29vKvWLpboJbtOA/rUqoQWHH7qrcFcmd/jAb1 qZ2Mvg77WHG2k8TRhvCfwKacX8gSwFxCulig5vKU/So+08T85VhjxRndLaiOkPFl+r1/ tpyg== 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; bh=CkLQHNS1vO4HrMwoBihhcwh22F5eS+jFJP0g8ba0BKA=; b=p6bMM7nBnjJ3goit0lrAZjkcK4WNw8d5Tc+imHsg9dCFTlissHC2f5JkREjvrwdRP8 pxqMPIBVtcbFhsWx7IjJFRPSi256EevrEtnFh4F8kKkt0EIiJ8hLw6u3D7gCw6YXjfur c8+cfD/viLwcL02lMHlDSiLtKiRPoRLUIHkRZyul3iPFdrofIICz0imVA4zKQcrIkaF1 Zm58Xe+eTT9BGgd1+fDfHNm/FO/9BkKIiFGNswYtxeD+lXEvDPCW9pNW8iSJOEARyYEi Hk9qR/wx937t8M12bCY1YpBlL4i0JkV81/vRvuaI1eExLP5GAzaiXz38bGbgHGZwMDek DsYA== X-Gm-Message-State: ALQs6tC0Nt4DxNREUrSKc5T+KJKs9GMfF0aGnV0qlxUmjOxQsSxY7qnj EAdfj67Fut/B86d8ssXZNe2vU0UA X-Google-Smtp-Source: AB8JxZrVWfQ76tUp17fqsgCUD/3x4XY+vHtLcTMi+8JE3v7lkrKWqaqmC7NbW8lriGXbLv/rFmLr6w== X-Received: by 2002:adf:8af0:: with SMTP id z45-v6mr17402806wrz.150.1525364603314; Thu, 03 May 2018 09:23:23 -0700 (PDT) Received: from orange.redhat.com ([213.175.37.12]) by smtp.gmail.com with ESMTPSA id s15-v6sm13212406wrg.70.2018.05.03.09.23.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 03 May 2018 09:23:22 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Cc: Zheng Yan Subject: [PATCH] ceph: fix rsize/wsize capping in ceph_direct_read_write() Date: Thu, 3 May 2018 18:23:01 +0200 Message-Id: <1525364581-27065-1-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 2.4.3 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 rsize/wsize cap should be applied before ceph_osdc_new_request() is called. Otherwise, if the size is limited by the cap instead of the stripe unit, ceph_osdc_new_request() would setup an extent op that is bigger than what dio_get_pages_alloc() would pin and add to the page vector, triggering asserts in the messenger. Cc: stable@vger.kernel.org Fixes: 95cca2b44e54 ("ceph: limit osd write size") Signed-off-by: Ilya Dryomov Reviewed-by: "Yan, Zheng" --- fs/ceph/file.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/ceph/file.c b/fs/ceph/file.c index f85040d73e3d..8ce7849f3fbd 100644 --- a/fs/ceph/file.c +++ b/fs/ceph/file.c @@ -918,6 +918,11 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter, size_t start = 0; ssize_t len; + if (write) + size = min_t(u64, size, fsc->mount_options->wsize); + else + size = min_t(u64, size, fsc->mount_options->rsize); + vino = ceph_vino(inode); req = ceph_osdc_new_request(&fsc->client->osdc, &ci->i_layout, vino, pos, &size, 0, @@ -933,11 +938,6 @@ ceph_direct_read_write(struct kiocb *iocb, struct iov_iter *iter, break; } - if (write) - size = min_t(u64, size, fsc->mount_options->wsize); - else - size = min_t(u64, size, fsc->mount_options->rsize); - len = size; pages = dio_get_pages_alloc(iter, len, &start, &num_pages); if (IS_ERR(pages)) {