From patchwork Mon Mar 25 10:33:07 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 10868771 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6E86D1390 for ; Mon, 25 Mar 2019 10:31:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B2DC2931A for ; Mon, 25 Mar 2019 10:31:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FA79292F0; Mon, 25 Mar 2019 10:31:49 +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=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 DC88C2931A for ; Mon, 25 Mar 2019 10:31:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730571AbfCYKbr (ORCPT ); Mon, 25 Mar 2019 06:31:47 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:36364 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730491AbfCYKbr (ORCPT ); Mon, 25 Mar 2019 06:31:47 -0400 Received: by mail-wr1-f65.google.com with SMTP id y13so9480958wrd.3 for ; Mon, 25 Mar 2019 03:31:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=7QA4Q7hVkb5ZNglXBPwujz9azAwTsex6yHnxvn3mcLg=; b=GURZIeHlk4OWD0ZXSihjBweMQDA571rdjiomeLEK8RR1tnFkHRYf+IwUBIT2VVWDfF 8EpLq7aLbQW6Ud1FbSIwm+cqTzYv/q4LU+wg0h39nD8DHxNxA/3jh42A+9MCwI4bNy8m wWxKhzdjphSnqPwLOPZE73KRVualZp4KOo2bc57qyyHFkcKetsJy2CjAwMJT/G2eQ+qd tqhfNRiM7UJ05utYL5Rem71Y5odjqbpgL6mcgtXLjtYa+GDbQKXpR5BPRF7l7T6Nw1qF KlB1vEg+Q4TZHIImQ1Q9Zr+XZLUh4BogzmBox653OEo8OEFIdYSxrqGG98AROGyA3b9O e2cg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=7QA4Q7hVkb5ZNglXBPwujz9azAwTsex6yHnxvn3mcLg=; b=NB27Yhk0Ihk9nwP0Zxnv6VEYvMpv3oboOzrcmzNBY1zE8RyaS77sANCAfxW1NIDfTP QGCxrZADs9kifKc1EJ7fO4j1IYwVHAPunQKcQu0dqoTdDhmqBDn5yDpEG7ftwx6mZOI5 elTpKGDsUlpc/OCeLX12ltHkC9briyKHSAfN75o3bS2l9s6PbF55Q4oWJ4Vp77Sypn1H bTqH9nPVNdaVxAkhG36gRxtEYjg+VTL7+C2UX/+L/9jBIqMXUVboNBcEGehty/9vEFNm qCM7kExPzqBtq+GLrqZLlabcoKJZ75lIaiqgmk//T41MCZptl+wnkM10VG08idl/H8L7 z2aQ== X-Gm-Message-State: APjAAAUWB5HQvnQx3WAzdFzh6+54av9BgE0GYYFyeLO6ExD5amNKf8+p DaU0+ljQ9r+bcB2lHbrzFrVZFscL X-Google-Smtp-Source: APXvYqwrXzYDFhNRpOzdD3+jzK2WvOhOr7UlRGwpBONRFELF+WHYe7V+NAzyXESzzQoy2REQop252Q== X-Received: by 2002:adf:f8c1:: with SMTP id f1mr15982945wrq.151.1553509905165; Mon, 25 Mar 2019 03:31:45 -0700 (PDT) Received: from kwango.redhat.com (ip-89-102-68-132.net.upcbroadband.cz. [89.102.68.132]) by smtp.gmail.com with ESMTPSA id o10sm11786339wru.54.2019.03.25.03.31.43 for (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2019 03:31:44 -0700 (PDT) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Subject: [PATCH] libceph: fix breakage caused by multipage bvecs Date: Mon, 25 Mar 2019 11:33:07 +0100 Message-Id: <20190325103307.4314-1-idryomov@gmail.com> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 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 A bvec can now consist of multiple physically contiguous pages. This means that bvec_iter_advance() can move to a different page while staying in the same bvec (i.e. ->bi_bvec_done != 0). The messenger works in terms of segments which can now be defined as the smaller of a bvec and a page. The "more bytes to process in this segment" condition holds only if bvec_iter_advance() leaves us in the same bvec _and_ in the same page. On next bvec (possibly in the same page) and on next page (possibly in the same bvec) we may need to set ->last_piece. Signed-off-by: Ilya Dryomov --- net/ceph/messenger.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 7e71b0df1fbc..3083988ce729 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -840,6 +840,7 @@ static bool ceph_msg_data_bio_advance(struct ceph_msg_data_cursor *cursor, size_t bytes) { struct ceph_bio_iter *it = &cursor->bio_iter; + struct page *page = bio_iter_page(it->bio, it->iter); BUG_ON(bytes > cursor->resid); BUG_ON(bytes > bio_iter_len(it->bio, it->iter)); @@ -851,7 +852,8 @@ static bool ceph_msg_data_bio_advance(struct ceph_msg_data_cursor *cursor, return false; /* no more data */ } - if (!bytes || (it->iter.bi_size && it->iter.bi_bvec_done)) + if (!bytes || (it->iter.bi_size && it->iter.bi_bvec_done && + page == bio_iter_page(it->bio, it->iter))) return false; /* more bytes to process in this segment */ if (!it->iter.bi_size) { @@ -899,6 +901,7 @@ static bool ceph_msg_data_bvecs_advance(struct ceph_msg_data_cursor *cursor, size_t bytes) { struct bio_vec *bvecs = cursor->data->bvec_pos.bvecs; + struct page *page = bvec_iter_page(bvecs, cursor->bvec_iter); BUG_ON(bytes > cursor->resid); BUG_ON(bytes > bvec_iter_len(bvecs, cursor->bvec_iter)); @@ -910,7 +913,8 @@ static bool ceph_msg_data_bvecs_advance(struct ceph_msg_data_cursor *cursor, return false; /* no more data */ } - if (!bytes || cursor->bvec_iter.bi_bvec_done) + if (!bytes || (cursor->bvec_iter.bi_bvec_done && + page == bvec_iter_page(bvecs, cursor->bvec_iter))) return false; /* more bytes to process in this segment */ BUG_ON(cursor->last_piece);