From patchwork Wed Jan 15 00:41:09 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viacheslav Dubeyko X-Patchwork-Id: 13939709 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8F4F7DF58; Wed, 15 Jan 2025 00:41:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=148.163.158.5 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736901677; cv=fail; b=EcOF8PUIftmS+kawsjlhnThRV/sC84Uf7tHeyyLsf50zcxY1l7FgbU18OodmBijkEvGZXkIGpTrbG1Bc+cWvCnl0NGlb7d1UyTcKz+Vl5P9tNQYfZX+Nksk41M6eNUXiAnp0GINgAXMv6Smg4a4G1aumbrd0Fsl8MnJpG/AdYG0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736901677; c=relaxed/simple; bh=D0JiqVDMYQWom96VhdY3ZVFnPacjmhYwiXaB4KEn318=; h=From:To:CC:Subject:Date:Message-ID:Content-Type:MIME-Version; b=bXIvjDQs8H+b6CswJOIv6wpaPp4q9XckemJ5aK52xzevaZQHOymfQ9bqrMxA1brKIvAaAat03/h4dy+/hPe19vS40paoxrYReMXPbMvJG2m127DRDTq7F9l9cH4yB4UmzEN7foXZgC0DgjhcndBZJPxIvSD626mWavFuKi+tnaQ= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ibm.com; spf=pass smtp.mailfrom=ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=d9whdkdT; arc=fail smtp.client-ip=148.163.158.5 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ibm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="d9whdkdT" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 50EIB9oT022731; Wed, 15 Jan 2025 00:41:12 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-id:content-transfer-encoding:content-type:date:from :message-id:mime-version:subject:to; s=pp1; bh=D0JiqVDMYQWom96Vh dY3ZVFnPacjmhYwiXaB4KEn318=; b=d9whdkdTgy2Lp0IcSelo2L7ICriny/nFx tEGH6PDndHQw7/Eqhm1R42j2LIxw7I4lhHs5Z+N+vS3XQCTK//wvmYcqkGvYmQQW zrgsvkXRokGZivVCss9RUlqY0I9tepOwliInPoCpERi80c5xpL3iczMM1IYZrt2e 6MxbP6+60rhMsKlgSDHYXuGOVxUVvHjnmGrffBGnvRgeDWXlCwoeHLvv1IPB8cQ3 GRcuWzIQvoX02bXdc0v4SdUdehBiTkhiwqAnRbTa2y5ppEYJ+FIRayRq05iQKOIJ SaiUeaxzjn9DV3y+qm/SoQHzRxP+U8nbdQC5YkzXvwP1KEiojaB4A== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 445m433ty5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Jan 2025 00:41:12 +0000 (GMT) Received: from m0360072.ppops.net (m0360072.ppops.net [127.0.0.1]) by pps.reinject (8.18.0.8/8.18.0.8) with ESMTP id 50F0fBhH024003; Wed, 15 Jan 2025 00:41:11 GMT Received: from nam12-bn8-obe.outbound.protection.outlook.com (mail-bn8nam12lp2171.outbound.protection.outlook.com [104.47.55.171]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 445m433ty3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 15 Jan 2025 00:41:11 +0000 (GMT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=YN68h1xl14FAvKZXJmj1mRmf6AqSQJsH9/Rz79ewgcBzqUUBimHHpdEOPfP8Je8fw182AuJobEGnfilIubPlmh8YlvsUBvEB1NVchkIy5qW5mq04cb4Nhsekug4vwWidEMKbXfEghaP6VFzc4eZ8dog40q6a6896XXvxlxjHuc6Kabm2Cl9BkaByRba1jVDmjjvkqqlwLJ9ewjTz98nFoLgna01/WpGUdbShBCWBn6UJJSblFiWpg5s2prAnBwtbp9Hh+O3B7rCnz6dEFwuKdxZkDZmC6/lx5LNrassmma7dYBPR0l0Q/LkOMNZ6w2f25pBTG/TNf8u0Mi/DO4SS4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=D0JiqVDMYQWom96VhdY3ZVFnPacjmhYwiXaB4KEn318=; b=KrEjV/M5c8MLyZR2mox7zHi5T4mpP/94tlGH3PH9cQcqML6AkqDe68Aec2q0M5c1q/8NxqvBZJMzYUlhWnx8pXxKdOA3FkKDpm2/AM9NzdqdCXzhTuakUdCVJ/QdoLxMPXfcd1i+cMxK/moYKLGJkKugomKspNo/9x/BhDpk2Bw8mtxotuS4YxqGNlT82fjZZ0G5WEIhFEkCOObIARfhmcnxqyU/+jXNdwhGpBAtzY4h/IfT3q/iVIHpIGw8pmXsVuPtrnEU6560jKP9gkVWLPDLpf8WoZMojwnDcoQoYjktn4jdGK9ToyvZW6yL6H3EK41CJG+SzTqdWTgVr382XA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=ibm.com; dmarc=pass action=none header.from=ibm.com; dkim=pass header.d=ibm.com; arc=none Received: from SA1PR15MB5819.namprd15.prod.outlook.com (2603:10b6:806:338::8) by PH0PR15MB5286.namprd15.prod.outlook.com (2603:10b6:510:144::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8335.18; Wed, 15 Jan 2025 00:41:09 +0000 Received: from SA1PR15MB5819.namprd15.prod.outlook.com ([fe80::6fd6:67be:7178:d89b]) by SA1PR15MB5819.namprd15.prod.outlook.com ([fe80::6fd6:67be:7178:d89b%7]) with mapi id 15.20.8335.017; Wed, 15 Jan 2025 00:41:09 +0000 From: Viacheslav Dubeyko To: "ceph-devel@vger.kernel.org" CC: Alex Markuze , "linux-fsdevel@vger.kernel.org" , "slava@dubeyko.com" , "idryomov@gmail.com" Subject: [PATCH] ceph: Introduce CONFIG_CEPH_LIB_DEBUG and CONFIG_CEPH_FS_DEBUG Thread-Topic: [PATCH] ceph: Introduce CONFIG_CEPH_LIB_DEBUG and CONFIG_CEPH_FS_DEBUG Thread-Index: AQHbZuYrmixXUxLwSkCVdEFmX2XVpQ== Date: Wed, 15 Jan 2025 00:41:09 +0000 Message-ID: <9a168461fc4665edffde6d8606920a34312f8932.camel@ibm.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: SA1PR15MB5819:EE_|PH0PR15MB5286:EE_ x-ms-office365-filtering-correlation-id: 66b2ea4c-3291-4229-f2ac-08dd34fd4e00 x-ld-processed: fcf67057-50c9-4ad4-98f3-ffca64add9e9,ExtAddr x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0;ARA:13230040|366016|10070799003|376014|1800799024|38070700018; x-microsoft-antispam-message-info: =?utf-8?q?DCPMtqzsfyOKkfrATumklKmPwKyGn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LtScpGF0XtK1p1en8PF/nRGao5cHnGe/XvlSLSCq1e/BfDwdgpQY1Zk4zBf+Gf?= =?utf-8?q?+vC4wue0ckdiC9u/BcwC+Y8YRRspUgfaROP01/7YGCKXAzqfKb+OYqkKl3mC4+wxv?= =?utf-8?q?Yu/ReoiG/KDtbj6v7QUmkVQr45Wiy/s2HAjy+/pT+Qidlf+J4QppRB+/R9n/27rbh?= =?utf-8?q?SjiLWf96zNY1FkpaxI5yETPda4sU2eHB3CKWtStWYsoW+hiNyVAjBUDvm8yoV5kY8?= =?utf-8?q?JVfAi+v7xR9cZ/gqhYOb5nMNcsL3RiY3WqWPlLgkNXowFY9NV4DroDifpOZ3qIviU?= =?utf-8?q?mR8uWQ4U0GrcaQrjeHgvChJnEonJ1mhBo+zfH3wwXeNrapYHlVma+b5vm8KwB4omG?= =?utf-8?q?+dolDYlggeQ/kNIrUOpKodpz4/tqyTGrhbnCXYt0l67B1apKZm3FRJgcERT3P0Wn8?= =?utf-8?q?/+M66xoRJn8oZAxrvJkCH6LOfoEvVrbZBdAL/PCTr9U8VDX+WGzYuEcoZucT+9/vk?= =?utf-8?q?evDpR11g3/Z?= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SA1PR15MB5819.namprd15.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(366016)(10070799003)(376014)(1800799024)(38070700018);DIR:OUT;SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?utf-8?q?hPkYcFyodZHZr5QTuoAfjyihWk/B?= =?utf-8?q?6k3efmrLBFlubyYhefm63RkuUhnHsEbuFPBzvMzaqwjuCz0AudVNUCJngmmyRcDkN?= =?utf-8?q?V8RL3flj82H1Nsw4tGK4lyafzoDQLlrkIBPJOd2Qh6RMkpApmJSqxwW5YEkTbU/AH?= =?utf-8?q?csUAxp7e52nBoF+Y/FD29NOrG2NuEI0AEFcW2Y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LQYXmjuPcdch4mOJ7KTnFGhU94?= =?utf-8?q?HpjzTyibb/1ejRHxhTIc41Gna8UU/u7HqnO47QEFEwFN6a8+PjhiEtq3nkuNuOG66?= =?utf-8?q?BZGpG939j5k8FFvBttqYnoESlWkmxlhM0C9gQoAVIMuWtxoU2EZRCiFu6FAJkgnIm?= =?utf-8?q?Mn4Mf21jKUnKN9KCRF64AuJ/UhYDRX5F7KPBrR8n83ni2Ox+2KzOUWFPohu8qKzdy?= =?utf-8?q?UTbMXgrN3+ds6pC5xSDTLpRfFwSvUXN5af2SCxy2b20IxCZ2mkWVX5njpq2AJjcGQ?= =?utf-8?q?RN9+9C/PMGXLJ9jeDjpZVdrqI7UYe/BYhlbN3ecyIojpyp6taqDFyNq3NQWvOm3YT?= =?utf-8?q?Qotg0vhldsW6ZgKgV5I1CL05+oLnM4vJXd7g3L4hiVgTBqdoTKA/nq9+X4Ajsct15?= =?utf-8?q?TywL7gOzZegyZtM8Ou2hL/Z83d3MLpzqRCMIO5F9O5SuE5m+DLoodedTBcWmfoJF5?= =?utf-8?q?x/fsABHojL8UXqsv8lQ5JvwAySqMR0bpXZZ5mNTdHeM7thPYo1HFElo=3D?= Content-ID: <164DE030E4D45240B474A75A7590BE55@namprd15.prod.outlook.com> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-OriginatorOrg: ibm.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: SA1PR15MB5819.namprd15.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 66b2ea4c-3291-4229-f2ac-08dd34fd4e00 X-MS-Exchange-CrossTenant-originalarrivaltime: 15 Jan 2025 00:41:09.6417 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: fcf67057-50c9-4ad4-98f3-ffca64add9e9 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: utuSzJ4hCZ5EXP/uokN9bfjjCd/i+5RneNPO9PvBk7WnyA+X6UYEROieHJY92UbLyuiqWVq9b3l63lEiZPCkmA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR15MB5286 X-Proofpoint-ORIG-GUID: LK7GpOrUQeciyN0dyCLhWx8WPBq7qWJg X-Proofpoint-GUID: P5oT3NZSTESAwm2klPamhkZIuUW0ndJy X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1057,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-01-14_08,2025-01-13_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 lowpriorityscore=0 mlxscore=0 malwarescore=0 impostorscore=0 spamscore=0 bulkscore=0 mlxlogscore=999 phishscore=0 priorityscore=1501 clxscore=1015 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2411120000 definitions=main-2501150001 Hello, There are multiple cases of using BUG_ON() in the main logic of CephFS kernel code. For example, ceph_msg_data_cursor_init() is one of the example: void ceph_msg_data_cursor_init(struct ceph_msg_data_cursor *cursor, struct ceph_msg *msg, size_t length) { BUG_ON(!length); BUG_ON(length > msg->data_length); BUG_ON(!msg->num_data_items); } Such approach is good for the case of debugging an issue. But it is not user friendly approach because returning and processing an error is more preferable than crashing the kernel. This patch introduces a special debug configuration option for CephFS subsystems with the goal of error processing in the case of release build and kernel crash in the case of debug build: if CONFIG_CEPH_LIB_DEBUG BUG_ON(); else return ; endif Signed-off-by: Viacheslav Dubeyko --- fs/ceph/Kconfig | 13 +++++++++++ include/linux/ceph/messenger.h | 2 +- net/ceph/Kconfig | 13 +++++++++++ net/ceph/messenger.c | 16 +++++++++++-- net/ceph/messenger_v1.c | 27 +++++++++++++++------- net/ceph/messenger_v2.c | 41 +++++++++++++++++++++++++--------- 6 files changed, 90 insertions(+), 22 deletions(-) } } @@ -1046,7 +1049,10 @@ static int setup_message_sgs(struct sg_table *sgt, struct ceph_msg *msg, if (pages) { init_sgs_pages(&cur_sg, pages, dpos, dlen, data_pad); } else { - ceph_msg_data_cursor_init(&cursor, msg, dlen); + ret = ceph_msg_data_cursor_init(&cursor, msg, dlen); + if (ret) + return ret; + init_sgs_cursor(&cur_sg, &cursor, data_pad); } } @@ -1860,10 +1866,13 @@ static int prepare_read_control_remainder(struct ceph_connection *con) static int prepare_read_data(struct ceph_connection *con) { struct bio_vec bv; + int ret; con->in_data_crc = -1; - ceph_msg_data_cursor_init(&con->v2.in_cursor, con->in_msg, - data_len(con->in_msg)); + ret = ceph_msg_data_cursor_init(&con->v2.in_cursor, con- >in_msg, + data_len(con->in_msg)); + if (ret) + return ret; get_bvec_at(&con->v2.in_cursor, &bv); if (ceph_test_opt(from_msgr(con->msgr), RXBOUNCE)) { @@ -2025,6 +2034,7 @@ static int prepare_sparse_read_cont(struct ceph_connection *con) static int prepare_sparse_read_data(struct ceph_connection *con) { struct ceph_msg *msg = con->in_msg; + int ret; dout("%s: starting sparse read\n", __func__); @@ -2034,8 +2044,10 @@ static int prepare_sparse_read_data(struct ceph_connection *con) if (!con_secure(con)) con->in_data_crc = -1; - ceph_msg_data_cursor_init(&con->v2.in_cursor, msg, - msg->sparse_read_total); + ret = ceph_msg_data_cursor_init(&con->v2.in_cursor, msg, + msg->sparse_read_total); + if (ret) + return ret; reset_in_kvecs(con); con->v2.in_state = IN_S_PREPARE_SPARSE_DATA_CONT; @@ -3184,17 +3196,21 @@ int ceph_con_v2_try_read(struct ceph_connection *con) } } -static void queue_data(struct ceph_connection *con) +static int queue_data(struct ceph_connection *con) { struct bio_vec bv; + int ret; con->v2.out_epil.data_crc = -1; - ceph_msg_data_cursor_init(&con->v2.out_cursor, con->out_msg, - data_len(con->out_msg)); + ret = ceph_msg_data_cursor_init(&con->v2.out_cursor, con- >out_msg, + data_len(con->out_msg)); + if (ret) + return ret; get_bvec_at(&con->v2.out_cursor, &bv); set_out_bvec(con, &bv, true); con->v2.out_state = OUT_S_QUEUE_DATA_CONT; + return 0; } static void queue_data_cont(struct ceph_connection *con) @@ -3309,8 +3325,11 @@ static int populate_out_iter(struct ceph_connection *con) switch (con->v2.out_state) { case OUT_S_QUEUE_DATA: WARN_ON(!con->out_msg); - queue_data(con); - goto populated; + ret = queue_data(con); + if (ret) + return ret; + else + goto populated; case OUT_S_QUEUE_DATA_CONT: WARN_ON(!con->out_msg); queue_data_cont(con); diff --git a/fs/ceph/Kconfig b/fs/ceph/Kconfig index 7249d70e1a43..203fb5d1cdd4 100644 --- a/fs/ceph/Kconfig +++ b/fs/ceph/Kconfig @@ -50,3 +50,16 @@ config CEPH_FS_SECURITY_LABEL If you are not using a security module that requires using extended attributes for file security labels, say N. + +config CEPH_FS_DEBUG + bool "Ceph client debugging" + depends on CEPH_FS + default n + help + If you say Y here, this option enables additional pre- condition + and post-condition checks in functions. Also it could enable + BUG_ON() instead of returning the error code. This option could + save more messages in system log and execute additional computation. + + If you are going to debug the code, then chose Y here. + If unsure, say N. diff --git a/include/linux/ceph/messenger.h b/include/linux/ceph/messenger.h index 1717cc57cdac..acfab9052046 100644 --- a/include/linux/ceph/messenger.h +++ b/include/linux/ceph/messenger.h @@ -532,7 +532,7 @@ u32 ceph_get_global_seq(struct ceph_messenger *msgr, u32 gt); void ceph_con_discard_sent(struct ceph_connection *con, u64 ack_seq); void ceph_con_discard_requeued(struct ceph_connection *con, u64 reconnect_seq); -void ceph_msg_data_cursor_init(struct ceph_msg_data_cursor *cursor, +int ceph_msg_data_cursor_init(struct ceph_msg_data_cursor *cursor, struct ceph_msg *msg, size_t length); struct page *ceph_msg_data_next(struct ceph_msg_data_cursor *cursor, size_t *page_offset, size_t *length); diff --git a/net/ceph/Kconfig b/net/ceph/Kconfig index c5c4eef3a9ff..4248661669bd 100644 --- a/net/ceph/Kconfig +++ b/net/ceph/Kconfig @@ -45,3 +45,16 @@ config CEPH_LIB_USE_DNS_RESOLVER Documentation/networking/dns_resolver.rst If unsure, say N. + +config CEPH_LIB_DEBUG + bool "Ceph core library debugging" + depends on CEPH_LIB + default n + help + If you say Y here, this option enables additional pre- condition + and post-condition checks in functions. Also it could enable + BUG_ON() instead of returning the error code. This option could + save more messages in system log and execute additional computation. + + If you are going to debug the code, then chose Y here. + If unsure, say N. diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index d1b5705dc0c6..42db34345572 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -1063,18 +1063,30 @@ static void __ceph_msg_data_cursor_init(struct ceph_msg_data_cursor *cursor) cursor->need_crc = true; } -void ceph_msg_data_cursor_init(struct ceph_msg_data_cursor *cursor, - struct ceph_msg *msg, size_t length) +int ceph_msg_data_cursor_init(struct ceph_msg_data_cursor *cursor, + struct ceph_msg *msg, size_t length) { +#ifdef CONFIG_CEPH_LIB_DEBUG BUG_ON(!length); BUG_ON(length > msg->data_length); BUG_ON(!msg->num_data_items); +#else + if (!length) + return -EINVAL; + + if (length > msg->data_length) + return -EINVAL; + + if (!msg->num_data_items) + return -EINVAL; +#endif /* CONFIG_CEPH_LIB_DEBUG */ cursor->total_resid = length; cursor->data = msg->data; cursor->sr_resid = 0; __ceph_msg_data_cursor_init(cursor); + return 0; } /* diff --git a/net/ceph/messenger_v1.c b/net/ceph/messenger_v1.c index 0cb61c76b9b8..bc2f3a43d572 100644 --- a/net/ceph/messenger_v1.c +++ b/net/ceph/messenger_v1.c @@ -157,12 +157,12 @@ static size_t sizeof_footer(struct ceph_connection *con) sizeof(struct ceph_msg_footer_old); } -static void prepare_message_data(struct ceph_msg *msg, u32 data_len) +static int prepare_message_data(struct ceph_msg *msg, u32 data_len) { /* Initialize data cursor if it's not a sparse read */ u64 len = msg->sparse_read_total ? : data_len; - ceph_msg_data_cursor_init(&msg->cursor, msg, len); + return ceph_msg_data_cursor_init(&msg->cursor, msg, len); } /* @@ -192,10 +192,11 @@ static void prepare_write_message_footer(struct ceph_connection *con) /* * Prepare headers for the next outgoing message. */ -static void prepare_write_message(struct ceph_connection *con) +static int prepare_write_message(struct ceph_connection *con) { struct ceph_msg *m; u32 crc; + int ret; con_out_kvec_reset(con); con->v1.out_msg_done = false; @@ -251,7 +252,10 @@ static void prepare_write_message(struct ceph_connection *con) /* is there a data payload? */ con->out_msg->footer.data_crc = 0; if (m->data_length) { - prepare_message_data(con->out_msg, m->data_length); + ret = prepare_message_data(con->out_msg, m- >data_length); + if (ret) + return ret; + con->v1.out_more = 1; /* data + footer will follow */ } else { /* no, queue up footer too and be done */ @@ -259,6 +263,7 @@ static void prepare_write_message(struct ceph_connection *con) } ceph_con_flag_set(con, CEPH_CON_F_WRITE_PENDING); + return 0; } /* @@ -1230,8 +1235,11 @@ static int read_partial_message(struct ceph_connection *con) /* prepare for data payload, if any */ - if (data_len) - prepare_message_data(con->in_msg, data_len); + if (data_len) { + ret = prepare_message_data(con->in_msg, data_len); + if (ret) + return ret; + } } /* front */ @@ -1546,8 +1554,11 @@ int ceph_con_v1_try_write(struct ceph_connection *con) } /* is anything else pending? */ if (!list_empty(&con->out_queue)) { - prepare_write_message(con); - goto more; + ret = prepare_write_message(con); + if (ret) + goto out; + else + goto more; } if (con->in_seq > con->in_seq_acked) { prepare_write_ack(con); diff --git a/net/ceph/messenger_v2.c b/net/ceph/messenger_v2.c index bd608ffa0627..0904821c8dfa 100644 --- a/net/ceph/messenger_v2.c +++ b/net/ceph/messenger_v2.c @@ -1026,7 +1026,10 @@ static int setup_message_sgs(struct sg_table *sgt, struct ceph_msg *msg, if (need_padding(dlen)) sg_cnt++; } else { - ceph_msg_data_cursor_init(&cursor, msg, dlen); + ret = ceph_msg_data_cursor_init(&cursor, msg, dlen); + if (ret) + return ret; + sg_cnt += calc_sg_cnt_cursor(&cursor);