Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp3080167yba; Mon, 22 Apr 2019 19:27:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmRy/ypmgko5cHHki3KNXxQTBwXCehB2Fr9Wo0fJLbJieo9Bst0Xyt5SCPmE1KhxQaqN4x X-Received: by 2002:a17:902:aa5:: with SMTP id 34mr7158637plp.263.1555986444122; Mon, 22 Apr 2019 19:27:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1555986444; cv=none; d=google.com; s=arc-20160816; b=QPeUeSGO56qda/KGGF9LPmbZI5dxARIF1AtGaWUmYq/nwmfbn5bgd2Lp5AeIindIXF 36GyTuv/fytXmwITIL0tpYXkXm+VTYGT22cceb1Sw7rs9xdPZGuLPYBzFmeuGeYnVqs5 b3TkYWdxRkZAR8wCVG35Q+SvqNd55fzxWHL648Y2hfDHqtWmUsutYuzVAYGG+63int1l xlXN9Kb3O1vmKzzhBfc/msc6/A2ISVi8CtX4sSxvKqB6+vEaMVpJqn6/9/d/7xiYe55Q mqr2akC+waUQ+FIzbeS1Q6vsIYcEyicvBMu7qggyFlSKnek4sRqwmgIbKxtbX5nEjOrh 7kFg== 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=vJ9RbMksiEowo7UmGaEkyj2G5qJWgOzLfINCkBTsEVk=; b=SO36XBq3V1s38MBj0wZgt0muNAnTXbKPAo5YUQX9JHlD9i3ldmOKuYGBVw4Wt6PAv/ zfOMw92zrxUmjR1iEkfPPQMzGUcRto6MpOPC0arYQ+WmyJGu/H6ER8S01kU4AnP7Zkka /2mHR0jjRIRwLBS/H0Y5NJH83YxTfan3RBk9ypgq7tTw/4PF7OpDisFGH/6WQmceTdBb fFf5uFv3w4k3poazxillangLuH9KrNNzlbR1TuOsNQ/Clhwl6cmIO8SJ5CIoWqOG5UwU IYf+zmgGbNMnTgYzyU/7tkAzd9oRkvgcyUJxCtzlHAwPDuI1jHJuk+TkUIvhQ0xomwUy 372Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=QtSwxGmw; 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 m63si15047894pld.147.2019.04.22.19.27.08; Mon, 22 Apr 2019 19:27:24 -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=QtSwxGmw; 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 S1731982AbfDVUBb (ORCPT + 99 others); Mon, 22 Apr 2019 16:01:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:49404 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730111AbfDVTqy (ORCPT ); Mon, 22 Apr 2019 15:46:54 -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 225BE21908; Mon, 22 Apr 2019 19:46:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1555962413; bh=NVgqi82qlt2eSBl1Cd9hanYvDzTeWpWbcBOze/nDCsM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=QtSwxGmwzZzL3orSADOQlsEH5T5Qw65hlY8V3t90j5Y2XIa0NSy2QgMGKQbq3uSR4 TgFt4jHc17QekCyQm7yp7jOO3aGdl1MFP7Xrn5fFE/DR8fh7saqc8H6TOe0Ml70p77 GWpsmnVo27n8YeVxu9Dd9Fn63WYxeHo3c4rbJXhs= 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 4.19 48/68] libceph: fix breakage caused by multipage bvecs Date: Mon, 22 Apr 2019 15:44:56 -0400 Message-Id: <20190422194516.11634-48-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190422194516.11634-1-sashal@kernel.org> References: <20190422194516.11634-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 f7d7f32ac673..ef5216206bdf 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -870,6 +870,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)); @@ -881,7 +882,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) { @@ -929,6 +931,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)); @@ -940,7 +943,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