Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp2995235yba; Mon, 22 Apr 2019 17:25:22 -0700 (PDT) X-Google-Smtp-Source: APXvYqwsHkSeerlidIP5QNwuc4VFS419/ITo6/ftTc3RqSlVnFF0HgKE2RqrvdBHU2aGLSRobk59 X-Received: by 2002:a17:902:a503:: with SMTP id s3mr19406777plq.16.1555979122201; Mon, 22 Apr 2019 17:25:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555979122; cv=none; d=google.com; s=arc-20160816; b=qTmYL0c2MUHWc3oew4VJjnaHoLCFOxq9lzUY/UhNHxKE0LQdAokBk9heS4+fw4lKBT 60TWoFkMnPNjuvKWEadGrTVCQtjhncASAZJCsQulp6wVafpJgin/DQtN3RFC1vb8IiVq BHj/vQfjJT0NQCpc7Ma9EGtpIa4t73nDxPwTYX/6P83YETczB5UsbtyNkBzb/T6WIMhs D33U0tMkfWo1ArTs2hWIwVx3y+Xh0TO+7O4o2aEr94hn7dhLa0sTB15rUNofmPjPRf63 WLTaGiSn1boOgl59etOshbvrzgAeq80k9z5iQWOTuY9H7qM2n0Z451af+CsOHb3G3MTl IuKg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Jie0nMh20AeAe7WMCQXYXrWHlmjXFriU6NIZ2IcY+Ns=; b=OLHBjEKwYgSlb4OLSV3/FCLCyALPjoZzE1FcvV6NKg90BNcpFgXAZpmXaw7lrp1ihD l1YBvR6xqzfYd5UJDOB8pK5N3pkjNV0mBWvDYkndxoLoAfuBhnkPneoL0ADbesRa1Lkx 9mgP8eGVZeeamufOPxQL1lwVbaQX/LTeVd2rc572/o5BtVdJ4Z8J1TSwTAB4qBJ9SH7M 5y3GAoBrAUGI+b1618G1894QR5Lv2X/tnx5f+FMaU6vy3AvYTBNY78rI/vDIY2/d8ptV 4abhtf5+LNO/ILdCXXKbfcS/mp0dwLNk4jG/ivmiJ2ert6+PVevfWJnj4968KIHMCWOr kNSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="K/o18F/V"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m4si14195622plt.26.2019.04.22.17.25.06; Mon, 22 Apr 2019 17:25:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="K/o18F/V"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732409AbfDVUHw (ORCPT + 99 others); Mon, 22 Apr 2019 16:07:52 -0400 Received: from mail.kernel.org ([198.145.29.99]:45016 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729354AbfDVToG (ORCPT ); Mon, 22 Apr 2019 15:44:06 -0400 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id C15A6218FF; Mon, 22 Apr 2019 19:44:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962245; bh=HflbZPMLIcsquxM6ihd/etysUwhNi6g6wn+UFL0EiwQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=K/o18F/Vm3FWprbXmFFrgodwMPB1Pyl3nO44x+t299v9VsaE2aOp9NXrdfa2HNtEo ISkEzR8XbTc/UnttRHG0sruanXuNaldqf78kEjozvNJWrUlqGhICfelrxiV3Ejo37u zl/OrEiDW2Ol+j1DhtOhdD0F0CLXRnW8XMVrxJyM= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Ilya Dryomov , Sasha Levin , ceph-devel@vger.kernel.org, netdev@vger.kernel.org Subject: [PATCH AUTOSEL 5.0 61/98] libceph: fix breakage caused by multipage bvecs Date: Mon, 22 Apr 2019 15:41:28 -0400 Message-Id: <20190422194205.10404-61-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194205.10404-1-sashal@kernel.org> References: <20190422194205.10404-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Ilya Dryomov [ Upstream commit 187df76325af5d9e12ae9daec1510307797e54f0 ] 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 Signed-off-by: Sasha Levin (Microsoft) --- 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); -- 2.19.1