From patchwork Fri Mar 1 04:13:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Sakai X-Patchwork-Id: 13577981 X-Patchwork-Delegate: snitzer@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 99D37482DF for ; Fri, 1 Mar 2024 04:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709266440; cv=none; b=guU872iKNM1Hn7TAJbz2BgkG3HRDaduCwmaAKA69qpI8b+M+tLF8GCtRtaVTk6IszxmPpdnWPqqizJXhKy865S+W8y4xsV/ZKxJfoIxzNnzRT8aZPOq7ZRdgfIenVRajxZtQSZ4bZdQVKXj5hmF0TyeHVt7olhSSF+pzi3nnTF8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709266440; c=relaxed/simple; bh=su5j70Fl8pBTrXxsvHlMD/rif+lI2k2xu8Vg1+yWCgc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=IKPbQtgUNjgZ/G6xBsbysGtmzo7IJLBYJGWmbBgje4TOFEk9jGu4pRhrL9GeYBXrC8chbXN8TOK7j/oOBJZNystj6+rRrmw+oykcSxQdLMGkkqMbFjSv8TQiVbW82ErarxONn3uhkEwWQnuu4TIoqRgEk+RSnUx0T/d6VpTLtx8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=aAPs8st4; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="aAPs8st4" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709266437; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=F1W7GJP5h2A2Ki7icEEVwIjnZ2VHQmIWdbawJThAoCw=; b=aAPs8st4iJrM1q3LWsl8j63xnUG5jNH7WSwambAlU8HvHL1wY2Tnpppfmw88F6OIUodZ+K aLvOFfMaxBVtZdEWCSJoRLq4mo0jGrNFMnvCfIpO52NLG0rhJZyvuOj1ZepaOuRIVm1MRg +tSeIsYCxbu4vS3uERwdL3QJUgFhPFw= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-340-e1O7sO4NPem6iGmUom3dgA-1; Thu, 29 Feb 2024 23:13:53 -0500 X-MC-Unique: e1O7sO4NPem6iGmUom3dgA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8B7C683B8E8; Fri, 1 Mar 2024 04:13:53 +0000 (UTC) Received: from vdo-builder-msakai.permabit.com (vdo-builder-msakai.permabit.lab.eng.bos.redhat.com [10.0.103.170]) by smtp.corp.redhat.com (Postfix) with ESMTP id 86CB61C060AF; Fri, 1 Mar 2024 04:13:53 +0000 (UTC) Received: by vdo-builder-msakai.permabit.com (Postfix, from userid 1138) id 73421A15B0; Thu, 29 Feb 2024 23:13:53 -0500 (EST) From: Matthew Sakai To: dm-devel@lists.linux.dev Cc: Dan Carpenter , Matthew Sakai Subject: [PATCH 1/5] dm vdo slab-depot: delete unnecessary check in allocate_components Date: Thu, 29 Feb 2024 23:13:49 -0500 Message-ID: In-Reply-To: References: Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Dan Carpenter This is a duplicate check so it can't be true. Delete it. Signed-off-by: Dan Carpenter Signed-off-by: Mike Snitzer Signed-off-by: Susan LeGendre-McGhee Signed-off-by: Matthew Sakai --- drivers/md/dm-vdo/slab-depot.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/md/dm-vdo/slab-depot.c b/drivers/md/dm-vdo/slab-depot.c index 5fa7e0838b32..e10c3db8e665 100644 --- a/drivers/md/dm-vdo/slab-depot.c +++ b/drivers/md/dm-vdo/slab-depot.c @@ -4106,9 +4106,6 @@ static int allocate_components(struct slab_depot *depot, }; } - if (result != VDO_SUCCESS) - return result; - slab_count = vdo_compute_slab_count(depot->first_block, depot->last_block, depot->slab_size_shift); if (thread_config->physical_zone_count > slab_count) { From patchwork Fri Mar 1 04:13:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Sakai X-Patchwork-Id: 13577979 X-Patchwork-Delegate: snitzer@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 4D8B547F73 for ; Fri, 1 Mar 2024 04:13:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709266439; cv=none; b=Oa2rfzpR8o9yGb6XeKEZd3vICMHp11SIiGrxme9OOpiMcXQ9e0QS+u0jzoUeYNXdeptYT5iUoW8wrPbmLu+7U6W5IzqJ3ODHEgRs0RBVTOcllptYWNj8ja1yKq6sv/4kAx422oDXgB5YXd6nZv0wlABqDSYjRqgOsRd4q5w0NDs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709266439; c=relaxed/simple; bh=2YBaBKVowzefXc0vXZUzRawz7zU9i6iuEyfQoyj99YQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OW3tGNzTwz4dpyHJ3SWBm8WqqbC0UCqKRc4tACSNhIJj4RvJ3qj9ulnxaNdsy6ov4B3cW3fDK+6to6J2vdPm25UxOvlj0vHKO/8TFHOqLztjEG4ei8AO7xOcQpGtDxRAKfZpSy8wC9XnVGHbXhxInOfUOmO24Q6tbhSMDuSipbo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Sad0tLK5; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Sad0tLK5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709266436; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7OcQ891uvH24y21bX2hnb6FO6hhmUXQA3Yhpwb6kcfo=; b=Sad0tLK5u273YjT0rqYmSsVqaR5GpQKOZ3Bw5beg4qwvqePROVEbVIxAECyYWIP3XPxPIW bdlnlpvPaEaJiU0DMZxOUfgt9YYDQHq8Pfp3Lamw5xB3yeP//gMMCf8Heci8JazKVnEtEu PLPHOoZKlsyqvsQoECEu5xXeivUf/f8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-62-BQ9ffwFmM32JhaTroKqj3Q-1; Thu, 29 Feb 2024 23:13:53 -0500 X-MC-Unique: BQ9ffwFmM32JhaTroKqj3Q-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 86BE9185A784; Fri, 1 Mar 2024 04:13:53 +0000 (UTC) Received: from vdo-builder-msakai.permabit.com (vdo-builder-msakai.permabit.lab.eng.bos.redhat.com [10.0.103.170]) by smtp.corp.redhat.com (Postfix) with ESMTP id 820C0400D6C9; Fri, 1 Mar 2024 04:13:53 +0000 (UTC) Received: by vdo-builder-msakai.permabit.com (Postfix, from userid 1138) id 7956DA15B2; Thu, 29 Feb 2024 23:13:53 -0500 (EST) From: Matthew Sakai To: dm-devel@lists.linux.dev Cc: Mike Snitzer , Matthew Sakai Subject: [PATCH 2/5] dm vdo flush: initialize return to NULL in allocate_flush Date: Thu, 29 Feb 2024 23:13:50 -0500 Message-ID: <02151fc9e38d9b41a7e36a23816f1b643cdeb4ad.1709265967.git.msakai@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Mike Snitzer Otherwise, error path could result in allocate_flush's subsequent check for flush being non-NULL leading to false positive. Reported-by: Dan Carpenter Signed-off-by: Mike Snitzer Signed-off-by: Susan LeGendre-McGhee Signed-off-by: Matthew Sakai --- drivers/md/dm-vdo/flush.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/dm-vdo/flush.c b/drivers/md/dm-vdo/flush.c index 330b18715027..391b6203efc6 100644 --- a/drivers/md/dm-vdo/flush.c +++ b/drivers/md/dm-vdo/flush.c @@ -100,7 +100,7 @@ static struct vdo_flush *vdo_waiter_as_flush(struct vdo_waiter *waiter) static void *allocate_flush(gfp_t gfp_mask, void *pool_data) { - struct vdo_flush *flush; + struct vdo_flush *flush = NULL; if ((gfp_mask & GFP_NOWAIT) == GFP_NOWAIT) { flush = uds_allocate_memory_nowait(sizeof(struct vdo_flush), __func__); From patchwork Fri Mar 1 04:13:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Sakai X-Patchwork-Id: 13577977 X-Patchwork-Delegate: snitzer@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 86F772AEEE for ; Fri, 1 Mar 2024 04:13:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709266438; cv=none; b=CYFf6f8N864HAApcRKUoqT36RQOuu4tBnekPkZsj8yWQSNlccnyI0xq0bSYeEWhC1Sek+TZU+7z4yiYD52NdfL+VLehf76H+c9wNKRSmqY0KXLKGbcgrRzaRES9ZjJpMiEPc3Uoso65+A1vRMzK+Pe3PzhT4csAX7dTOd3eS5m8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709266438; c=relaxed/simple; bh=4fM1tmuXO7U0//KbMfqGbYCaaL8V1AUtP7y2kLYuTsc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jZ3xjNJX9YeLsg2AG4WA0bMFyRXfTYMvmtwAlZOH1NTeEh4f3mnol2OJxH91gTwHO1hDxt4ImeB+mXjKEWJoCc1OJAkW67B82++ml/F5tIGd7VCDpQiHAeu3tASsjmGOvs6O4aiNJhggF0DsGsyFi1oA3OkBKdpswxzMeH00Rn0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=HMuTOHcc; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="HMuTOHcc" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709266435; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=W9pSXJHatv4ovIgjrzn93fgTY0sX3D9fufrL14lbn/E=; b=HMuTOHcc25EODHx03PlE+yoeZsBtRL0otMxoeDvYP0WLNxlhqmrehoEDD2O63xHVfaA1KY 2GYvyf+V9rXhMkNT0+oW8ruF3n71EhSrS7lnLzAHNZkGWoG5NRiBnpCH5tJTeRrm73bw+q LxGxWPBDpxYhxavVm+G6pCSvQ5X+m1M= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-63-DJEKd003MN-Gi6j4uPG1mQ-1; Thu, 29 Feb 2024 23:13:53 -0500 X-MC-Unique: DJEKd003MN-Gi6j4uPG1mQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 88F5029AC011; Fri, 1 Mar 2024 04:13:53 +0000 (UTC) Received: from vdo-builder-msakai.permabit.com (vdo-builder-msakai.permabit.lab.eng.bos.redhat.com [10.0.103.170]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8247D492BC6; Fri, 1 Mar 2024 04:13:53 +0000 (UTC) Received: by vdo-builder-msakai.permabit.com (Postfix, from userid 1138) id 7F3B5A15B4; Thu, 29 Feb 2024 23:13:53 -0500 (EST) From: Matthew Sakai To: dm-devel@lists.linux.dev Cc: Mike Snitzer , Matthew Sakai Subject: [PATCH 3/5] dm vdo indexer-volume: fix missing mutex_lock in process_entry Date: Thu, 29 Feb 2024 23:13:51 -0500 Message-ID: <90036bb8fdef1cfb0f677465358bab87b53e2ea8.1709265967.git.msakai@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Mike Snitzer Must mutex_lock after dm_bufio_read, before dm_bufio_read error handling, otherwise process_entry error path will return without volume->read_threads_mutex held. This fixes potential double mutex_unlock. Reported-by: Dan Carpenter Signed-off-by: Mike Snitzer Signed-off-by: Susan LeGendre-McGhee Signed-off-by: Matthew Sakai --- drivers/md/dm-vdo/volume.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/md/dm-vdo/volume.c b/drivers/md/dm-vdo/volume.c index 37c2ef0777e5..60416dc8a9d7 100644 --- a/drivers/md/dm-vdo/volume.c +++ b/drivers/md/dm-vdo/volume.c @@ -556,6 +556,7 @@ static int process_entry(struct volume *volume, struct queued_read *entry) mutex_unlock(&volume->read_threads_mutex); page_data = dm_bufio_read(volume->client, page_number, &page->buffer); + mutex_lock(&volume->read_threads_mutex); if (IS_ERR(page_data)) { result = -PTR_ERR(page_data); uds_log_warning_strerror(result, @@ -564,7 +565,6 @@ static int process_entry(struct volume *volume, struct queued_read *entry) cancel_page_in_cache(&volume->page_cache, page_number, page); return result; } - mutex_lock(&volume->read_threads_mutex); if (entry->invalid) { uds_log_warning("Page %u invalidated after read", page_number); From patchwork Fri Mar 1 04:13:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Sakai X-Patchwork-Id: 13577980 X-Patchwork-Delegate: snitzer@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 A45D347F54 for ; Fri, 1 Mar 2024 04:13:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709266439; cv=none; b=ALjOjT5DwQyeP88ORZ6qrO8rLW41xyKA/L0QnF98e5ZiG/1PVfP1WFY2e/12OnzsihDSy6MgU3hR0TmhNnLNyUp2m2FwCCQGpBFBz+cnk8tu/IkqR4LbptaR5IgmGcIPnIxQMidLvQgNoC9u7IjWVk+iciI4+3kDy066Wr1+qT8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709266439; c=relaxed/simple; bh=iMUm7E/VAD4lDyj4N5ceUsNf4IV49ax/Vwm3QEyvnC8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=h+Ps6ZrWQoNDMth+GGUhUFZo6mHtV/6Y5zvS22+oGZiUpZeIith6Ger6HmqF72jOI4nrEw3xIPL5nfxmKA08rc9jRVmFdhJHFru3s1OiDqgui2s/CmUC9m2f4t+iTvZeYHD0fXFvJuLvih93aMeNs5/8+Iy6yxjXNOZVmf9bvpg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Mk/BLNid; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Mk/BLNid" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709266435; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s3xcZyQiRgTawTSR+6yRK9Cfy5kPLB2ahIxpZF/G7nQ=; b=Mk/BLNidAdL77oQL4iz9JWlOMJhjWRNRgnNWbiMpVai3/bNNM7HHK+ft6JDd4go1RpC80W 6TTUNceoYwgLvf4dL/TAJx7mZDng1ATecEv4/uLs27Y+/sYSMYojuPzv3kLQ1/guEx5sbp bEG/x9O/1/RyjAyMLqiL0qFAnjR8HCU= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-271-HqrPXZUMMEiKhu8k2Lqbiw-1; Thu, 29 Feb 2024 23:13:53 -0500 X-MC-Unique: HqrPXZUMMEiKhu8k2Lqbiw-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8BF583C100B1; Fri, 1 Mar 2024 04:13:53 +0000 (UTC) Received: from vdo-builder-msakai.permabit.com (vdo-builder-msakai.permabit.lab.eng.bos.redhat.com [10.0.103.170]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8750F40153A7; Fri, 1 Mar 2024 04:13:53 +0000 (UTC) Received: by vdo-builder-msakai.permabit.com (Postfix, from userid 1138) id 854CAA15B6; Thu, 29 Feb 2024 23:13:53 -0500 (EST) From: Matthew Sakai To: dm-devel@lists.linux.dev Cc: Mike Snitzer , Matthew Sakai Subject: [PATCH 4/5] dm vdo: include to resolve current being undeclared Date: Thu, 29 Feb 2024 23:13:52 -0500 Message-ID: <1c4d4f7abb1eddab683b9826525d2281cd236ccc.1709265967.git.msakai@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Mike Snitzer Reported when building on loongarch. Reported-by: Randy Dunlap Signed-off-by: Mike Snitzer Signed-off-by: Bruce Johnston Signed-off-by: Matthew Sakai --- drivers/md/dm-vdo/logger.c | 1 + drivers/md/dm-vdo/thread-registry.c | 1 + drivers/md/dm-vdo/thread-utils.c | 1 + 3 files changed, 3 insertions(+) diff --git a/drivers/md/dm-vdo/logger.c b/drivers/md/dm-vdo/logger.c index 6ba7e99ee8f9..a50edb0331fc 100644 --- a/drivers/md/dm-vdo/logger.c +++ b/drivers/md/dm-vdo/logger.c @@ -5,6 +5,7 @@ #include "logger.h" +#include #include #include #include diff --git a/drivers/md/dm-vdo/thread-registry.c b/drivers/md/dm-vdo/thread-registry.c index 1314d2b6a26f..03e2f45e8e78 100644 --- a/drivers/md/dm-vdo/thread-registry.c +++ b/drivers/md/dm-vdo/thread-registry.c @@ -5,6 +5,7 @@ #include "thread-registry.h" +#include #include #include "permassert.h" diff --git a/drivers/md/dm-vdo/thread-utils.c b/drivers/md/dm-vdo/thread-utils.c index 160679984d72..aeca14bba852 100644 --- a/drivers/md/dm-vdo/thread-utils.c +++ b/drivers/md/dm-vdo/thread-utils.c @@ -5,6 +5,7 @@ #include "thread-utils.h" +#include #include #include #include From patchwork Fri Mar 1 04:13:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matthew Sakai X-Patchwork-Id: 13577982 X-Patchwork-Delegate: snitzer@redhat.com Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (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 3576347F6F for ; Fri, 1 Mar 2024 04:13:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709266442; cv=none; b=PR8YoCGU7U8cEcfuTJd5WqAgjtv1tN1Me7I7kFNkwY0oPio1MZtl84ivqRs9j7DC7OS2wx0fUvIM0jtORiXR6mwbCPHE/VnSRgl2rsc5NGjikYI8B+/vzIZ4QglTVKlzQJR1n7mEAk5my6u3vj6TBTfbDH9sDpHfz6i3sF1TIm4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709266442; c=relaxed/simple; bh=5w2kwsufb2DD+xGkodrhjy0Yw33HwRG1Lxd395YLt/o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=prMedL5a4FsIM1QlSufFkGnt/AQclMh1r9Phex2i8CEHWiSQlgg1h3UcFvGIlgnF2VD2zpOADYgtB7gj8X5hyA2EuGR1QADKR47G7lVscCE+pJIJUVkl3fisU9ApPiQUbK2X4dj7CIcU0wmpl81NNla/r7NNqcEBY0D6TQ5Ok9Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=Pet8XkVN; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="Pet8XkVN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1709266438; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=8MuWm6a7g1u7W0vhuU8Kes4k9BpNhmWGyid2TBUBEvs=; b=Pet8XkVN9My+/UFdu2+ExiHl985bYSEcEEGWad8jtRt8LlIpoWOHofeqJtVxHKZ5CZKS7Q SC7OUzYRsYKwt8AxrUAhPQxfUTJk+ZjbbW8ftgCijunT76qgquzMV69IjPihBd/PbPikFu oSqhJEYEwJMXK/yR8bL+G/IqVNxW8Hk= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-411--zIWSlziO4mnNU3na3MVzA-1; Thu, 29 Feb 2024 23:13:53 -0500 X-MC-Unique: -zIWSlziO4mnNU3na3MVzA-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9B9291024D05 for ; Fri, 1 Mar 2024 04:13:53 +0000 (UTC) Received: from vdo-builder-msakai.permabit.com (vdo-builder-msakai.permabit.lab.eng.bos.redhat.com [10.0.103.170]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8EAC01C060B1; Fri, 1 Mar 2024 04:13:53 +0000 (UTC) Received: by vdo-builder-msakai.permabit.com (Postfix, from userid 1138) id 8C124A15B8; Thu, 29 Feb 2024 23:13:53 -0500 (EST) From: Matthew Sakai To: dm-devel@lists.linux.dev Cc: Chung Chung , Matthew Sakai Subject: [PATCH 5/5] dm vdo: clean up scnprintf usage Date: Thu, 29 Feb 2024 23:13:53 -0500 Message-ID: <53e9c7e3485c10530918acae89e6ef12b68026c4.1709265967.git.msakai@redhat.com> In-Reply-To: References: Precedence: bulk X-Mailing-List: dm-devel@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com From: Chung Chung Ignore scnprintf return status since it is not necessary. Change write_* functions type from int to void since we no longer return any result. Also, clean up any code that checks or uses any scnprintf return results. Check uds_allocate return code which was previous ignored, return and log error when uds_allocate failed. Reported-by: Dan Carpenter Signed-off-by: Chung Chung Signed-off-by: Matthew Sakai --- drivers/md/dm-vdo/message-stats.c | 818 +++++++++--------------------- 1 file changed, 239 insertions(+), 579 deletions(-) diff --git a/drivers/md/dm-vdo/message-stats.c b/drivers/md/dm-vdo/message-stats.c index af964e55b98c..cac7232f467b 100644 --- a/drivers/md/dm-vdo/message-stats.c +++ b/drivers/md/dm-vdo/message-stats.c @@ -11,749 +11,407 @@ #include "thread-device.h" #include "vdo.h" -static int write_u64(char *prefix, u64 value, char *suffix, char **buf, - unsigned int *maxlen) +static void write_u64(char *prefix, u64 value, char *suffix, char **buf, + unsigned int *maxlen) { - int count = scnprintf(*buf, *maxlen, "%s%llu%s", prefix == NULL ? "" : prefix, - value, suffix == NULL ? "" : suffix); + int count; + + count = scnprintf(*buf, *maxlen, "%s%llu%s", prefix == NULL ? "" : prefix, + value, suffix == NULL ? "" : suffix); *buf += count; *maxlen -= count; - if (count >= *maxlen) - return VDO_UNEXPECTED_EOF; - return VDO_SUCCESS; } -static int write_u32(char *prefix, u32 value, char *suffix, char **buf, - unsigned int *maxlen) +static void write_u32(char *prefix, u32 value, char *suffix, char **buf, + unsigned int *maxlen) { - int count = scnprintf(*buf, *maxlen, "%s%u%s", prefix == NULL ? "" : prefix, - value, suffix == NULL ? "" : suffix); + int count; + + count = scnprintf(*buf, *maxlen, "%s%u%s", prefix == NULL ? "" : prefix, + value, suffix == NULL ? "" : suffix); *buf += count; *maxlen -= count; - if (count >= *maxlen) - return VDO_UNEXPECTED_EOF; - return VDO_SUCCESS; } -static int write_block_count_t(char *prefix, block_count_t value, char *suffix, - char **buf, unsigned int *maxlen) +static void write_block_count_t(char *prefix, block_count_t value, char *suffix, + char **buf, unsigned int *maxlen) { - int count = scnprintf(*buf, *maxlen, "%s%llu%s", prefix == NULL ? "" : prefix, - value, suffix == NULL ? "" : suffix); + int count; + + count = scnprintf(*buf, *maxlen, "%s%llu%s", prefix == NULL ? "" : prefix, + value, suffix == NULL ? "" : suffix); *buf += count; *maxlen -= count; - if (count >= *maxlen) - return VDO_UNEXPECTED_EOF; - return VDO_SUCCESS; } -static int write_string(char *prefix, char *value, char *suffix, char **buf, - unsigned int *maxlen) +static void write_string(char *prefix, char *value, char *suffix, char **buf, + unsigned int *maxlen) { - int count = scnprintf(*buf, *maxlen, "%s%s%s", prefix == NULL ? "" : prefix, - value, suffix == NULL ? "" : suffix); + int count; + + count = scnprintf(*buf, *maxlen, "%s%s%s", prefix == NULL ? "" : prefix, + value, suffix == NULL ? "" : suffix); *buf += count; *maxlen -= count; - if (count >= *maxlen) - return VDO_UNEXPECTED_EOF; - return VDO_SUCCESS; } -static int write_bool(char *prefix, bool value, char *suffix, char **buf, - unsigned int *maxlen) +static void write_bool(char *prefix, bool value, char *suffix, char **buf, + unsigned int *maxlen) { - int count = scnprintf(*buf, *maxlen, "%s%d%s", prefix == NULL ? "" : prefix, - value, suffix == NULL ? "" : suffix); + int count; + + count = scnprintf(*buf, *maxlen, "%s%d%s", prefix == NULL ? "" : prefix, + value, suffix == NULL ? "" : suffix); *buf += count; *maxlen -= count; - if (count >= *maxlen) - return VDO_UNEXPECTED_EOF; - return VDO_SUCCESS; } -static int write_u8(char *prefix, u8 value, char *suffix, char **buf, - unsigned int *maxlen) +static void write_u8(char *prefix, u8 value, char *suffix, char **buf, + unsigned int *maxlen) { - int count = scnprintf(*buf, *maxlen, "%s%u%s", prefix == NULL ? "" : prefix, - value, suffix == NULL ? "" : suffix); + int count; + + count = scnprintf(*buf, *maxlen, "%s%u%s", prefix == NULL ? "" : prefix, + value, suffix == NULL ? "" : suffix); *buf += count; *maxlen -= count; - if (count >= *maxlen) - return VDO_UNEXPECTED_EOF; - return VDO_SUCCESS; } -static int write_block_allocator_statistics(char *prefix, - struct block_allocator_statistics *stats, - char *suffix, char **buf, - unsigned int *maxlen) +static void write_block_allocator_statistics(char *prefix, + struct block_allocator_statistics *stats, + char *suffix, char **buf, + unsigned int *maxlen) { - int result; - - result = write_string(prefix, "{ ", NULL, buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_string(prefix, "{ ", NULL, buf, maxlen); /* The total number of slabs from which blocks may be allocated */ - result = write_u64("slabCount : ", stats->slab_count, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("slabCount : ", stats->slab_count, ", ", buf, maxlen); /* The total number of slabs from which blocks have ever been allocated */ - result = write_u64("slabsOpened : ", stats->slabs_opened, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("slabsOpened : ", stats->slabs_opened, ", ", buf, maxlen); /* The number of times since loading that a slab has been re-opened */ - result = write_u64("slabsReopened : ", stats->slabs_reopened, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_string(NULL, "}", suffix, buf, maxlen); - if (result != VDO_SUCCESS) - return result; - return VDO_SUCCESS; + write_u64("slabsReopened : ", stats->slabs_reopened, ", ", buf, maxlen); + write_string(NULL, "}", suffix, buf, maxlen); } -static int write_commit_statistics(char *prefix, struct commit_statistics *stats, - char *suffix, char **buf, unsigned int *maxlen) +static void write_commit_statistics(char *prefix, struct commit_statistics *stats, + char *suffix, char **buf, unsigned int *maxlen) { - int result; - - result = write_string(prefix, "{ ", NULL, buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_string(prefix, "{ ", NULL, buf, maxlen); /* The total number of items on which processing has started */ - result = write_u64("started : ", stats->started, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("started : ", stats->started, ", ", buf, maxlen); /* The total number of items for which a write operation has been issued */ - result = write_u64("written : ", stats->written, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("written : ", stats->written, ", ", buf, maxlen); /* The total number of items for which a write operation has completed */ - result = write_u64("committed : ", stats->committed, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_string(NULL, "}", suffix, buf, maxlen); - if (result != VDO_SUCCESS) - return result; - return VDO_SUCCESS; + write_u64("committed : ", stats->committed, ", ", buf, maxlen); + write_string(NULL, "}", suffix, buf, maxlen); } -static int write_recovery_journal_statistics(char *prefix, - struct recovery_journal_statistics *stats, - char *suffix, char **buf, - unsigned int *maxlen) +static void write_recovery_journal_statistics(char *prefix, + struct recovery_journal_statistics *stats, + char *suffix, char **buf, + unsigned int *maxlen) { - int result; - - result = write_string(prefix, "{ ", NULL, buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_string(prefix, "{ ", NULL, buf, maxlen); /* Number of times the on-disk journal was full */ - result = write_u64("diskFull : ", stats->disk_full, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("diskFull : ", stats->disk_full, ", ", buf, maxlen); /* Number of times the recovery journal requested slab journal commits. */ - result = write_u64("slabJournalCommitsRequested : ", - stats->slab_journal_commits_requested, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("slabJournalCommitsRequested : ", + stats->slab_journal_commits_requested, ", ", buf, maxlen); /* Write/Commit totals for individual journal entries */ - result = write_commit_statistics("entries : ", &stats->entries, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_commit_statistics("entries : ", &stats->entries, ", ", buf, maxlen); /* Write/Commit totals for journal blocks */ - result = write_commit_statistics("blocks : ", &stats->blocks, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_string(NULL, "}", suffix, buf, maxlen); - if (result != VDO_SUCCESS) - return result; - return VDO_SUCCESS; + write_commit_statistics("blocks : ", &stats->blocks, ", ", buf, maxlen); + write_string(NULL, "}", suffix, buf, maxlen); } -static int write_packer_statistics(char *prefix, struct packer_statistics *stats, - char *suffix, char **buf, unsigned int *maxlen) +static void write_packer_statistics(char *prefix, struct packer_statistics *stats, + char *suffix, char **buf, unsigned int *maxlen) { - int result; - - result = write_string(prefix, "{ ", NULL, buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_string(prefix, "{ ", NULL, buf, maxlen); /* Number of compressed data items written since startup */ - result = write_u64("compressedFragmentsWritten : ", - stats->compressed_fragments_written, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("compressedFragmentsWritten : ", + stats->compressed_fragments_written, ", ", buf, maxlen); /* Number of blocks containing compressed items written since startup */ - result = write_u64("compressedBlocksWritten : ", - stats->compressed_blocks_written, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("compressedBlocksWritten : ", + stats->compressed_blocks_written, ", ", buf, maxlen); /* Number of VIOs that are pending in the packer */ - result = write_u64("compressedFragmentsInPacker : ", - stats->compressed_fragments_in_packer, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_string(NULL, "}", suffix, buf, maxlen); - if (result != VDO_SUCCESS) - return result; - return VDO_SUCCESS; + write_u64("compressedFragmentsInPacker : ", + stats->compressed_fragments_in_packer, ", ", buf, maxlen); + write_string(NULL, "}", suffix, buf, maxlen); } -static int write_slab_journal_statistics(char *prefix, - struct slab_journal_statistics *stats, - char *suffix, char **buf, unsigned int *maxlen) +static void write_slab_journal_statistics(char *prefix, + struct slab_journal_statistics *stats, + char *suffix, char **buf, unsigned int *maxlen) { - int result; - - result = write_string(prefix, "{ ", NULL, buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_string(prefix, "{ ", NULL, buf, maxlen); /* Number of times the on-disk journal was full */ - result = write_u64("diskFullCount : ", stats->disk_full_count, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("diskFullCount : ", stats->disk_full_count, ", ", buf, maxlen); /* Number of times an entry was added over the flush threshold */ - result = write_u64("flushCount : ", stats->flush_count, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("flushCount : ", stats->flush_count, ", ", buf, maxlen); /* Number of times an entry was added over the block threshold */ - result = write_u64("blockedCount : ", stats->blocked_count, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("blockedCount : ", stats->blocked_count, ", ", buf, maxlen); /* Number of times a tail block was written */ - result = write_u64("blocksWritten : ", stats->blocks_written, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("blocksWritten : ", stats->blocks_written, ", ", buf, maxlen); /* Number of times we had to wait for the tail to write */ - result = write_u64("tailBusyCount : ", stats->tail_busy_count, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_string(NULL, "}", suffix, buf, maxlen); - if (result != VDO_SUCCESS) - return result; - return VDO_SUCCESS; + write_u64("tailBusyCount : ", stats->tail_busy_count, ", ", buf, maxlen); + write_string(NULL, "}", suffix, buf, maxlen); } -static int write_slab_summary_statistics(char *prefix, - struct slab_summary_statistics *stats, - char *suffix, char **buf, unsigned int *maxlen) +static void write_slab_summary_statistics(char *prefix, + struct slab_summary_statistics *stats, + char *suffix, char **buf, unsigned int *maxlen) { - int result; - - result = write_string(prefix, "{ ", NULL, buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_string(prefix, "{ ", NULL, buf, maxlen); /* Number of blocks written */ - result = write_u64("blocksWritten : ", stats->blocks_written, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_string(NULL, "}", suffix, buf, maxlen); - if (result != VDO_SUCCESS) - return result; - return VDO_SUCCESS; + write_u64("blocksWritten : ", stats->blocks_written, ", ", buf, maxlen); + write_string(NULL, "}", suffix, buf, maxlen); } -static int write_ref_counts_statistics(char *prefix, struct ref_counts_statistics *stats, - char *suffix, char **buf, unsigned int *maxlen) +static void write_ref_counts_statistics(char *prefix, struct ref_counts_statistics *stats, + char *suffix, char **buf, unsigned int *maxlen) { - int result; - - result = write_string(prefix, "{ ", NULL, buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_string(prefix, "{ ", NULL, buf, maxlen); /* Number of reference blocks written */ - result = write_u64("blocksWritten : ", stats->blocks_written, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_string(NULL, "}", suffix, buf, maxlen); - if (result != VDO_SUCCESS) - return result; - return VDO_SUCCESS; + write_u64("blocksWritten : ", stats->blocks_written, ", ", buf, maxlen); + write_string(NULL, "}", suffix, buf, maxlen); } -static int write_block_map_statistics(char *prefix, struct block_map_statistics *stats, - char *suffix, char **buf, unsigned int *maxlen) +static void write_block_map_statistics(char *prefix, struct block_map_statistics *stats, + char *suffix, char **buf, unsigned int *maxlen) { - int result; - - result = write_string(prefix, "{ ", NULL, buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_string(prefix, "{ ", NULL, buf, maxlen); /* number of dirty (resident) pages */ - result = write_u32("dirtyPages : ", stats->dirty_pages, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u32("dirtyPages : ", stats->dirty_pages, ", ", buf, maxlen); /* number of clean (resident) pages */ - result = write_u32("cleanPages : ", stats->clean_pages, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u32("cleanPages : ", stats->clean_pages, ", ", buf, maxlen); /* number of free pages */ - result = write_u32("freePages : ", stats->free_pages, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u32("freePages : ", stats->free_pages, ", ", buf, maxlen); /* number of pages in failed state */ - result = write_u32("failedPages : ", stats->failed_pages, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u32("failedPages : ", stats->failed_pages, ", ", buf, maxlen); /* number of pages incoming */ - result = write_u32("incomingPages : ", stats->incoming_pages, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u32("incomingPages : ", stats->incoming_pages, ", ", buf, maxlen); /* number of pages outgoing */ - result = write_u32("outgoingPages : ", stats->outgoing_pages, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u32("outgoingPages : ", stats->outgoing_pages, ", ", buf, maxlen); /* how many times free page not avail */ - result = write_u32("cachePressure : ", stats->cache_pressure, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u32("cachePressure : ", stats->cache_pressure, ", ", buf, maxlen); /* number of get_vdo_page() calls for read */ - result = write_u64("readCount : ", stats->read_count, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("readCount : ", stats->read_count, ", ", buf, maxlen); /* number of get_vdo_page() calls for write */ - result = write_u64("writeCount : ", stats->write_count, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("writeCount : ", stats->write_count, ", ", buf, maxlen); /* number of times pages failed to read */ - result = write_u64("failedReads : ", stats->failed_reads, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("failedReads : ", stats->failed_reads, ", ", buf, maxlen); /* number of times pages failed to write */ - result = write_u64("failedWrites : ", stats->failed_writes, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("failedWrites : ", stats->failed_writes, ", ", buf, maxlen); /* number of gets that are reclaimed */ - result = write_u64("reclaimed : ", stats->reclaimed, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("reclaimed : ", stats->reclaimed, ", ", buf, maxlen); /* number of gets for outgoing pages */ - result = write_u64("readOutgoing : ", stats->read_outgoing, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("readOutgoing : ", stats->read_outgoing, ", ", buf, maxlen); /* number of gets that were already there */ - result = write_u64("foundInCache : ", stats->found_in_cache, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("foundInCache : ", stats->found_in_cache, ", ", buf, maxlen); /* number of gets requiring discard */ - result = write_u64("discardRequired : ", stats->discard_required, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("discardRequired : ", stats->discard_required, ", ", buf, maxlen); /* number of gets enqueued for their page */ - result = write_u64("waitForPage : ", stats->wait_for_page, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("waitForPage : ", stats->wait_for_page, ", ", buf, maxlen); /* number of gets that have to fetch */ - result = write_u64("fetchRequired : ", stats->fetch_required, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("fetchRequired : ", stats->fetch_required, ", ", buf, maxlen); /* number of page fetches */ - result = write_u64("pagesLoaded : ", stats->pages_loaded, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("pagesLoaded : ", stats->pages_loaded, ", ", buf, maxlen); /* number of page saves */ - result = write_u64("pagesSaved : ", stats->pages_saved, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("pagesSaved : ", stats->pages_saved, ", ", buf, maxlen); /* the number of flushes issued */ - result = write_u64("flushCount : ", stats->flush_count, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_string(NULL, "}", suffix, buf, maxlen); - if (result != VDO_SUCCESS) - return result; - return VDO_SUCCESS; + write_u64("flushCount : ", stats->flush_count, ", ", buf, maxlen); + write_string(NULL, "}", suffix, buf, maxlen); } -static int write_hash_lock_statistics(char *prefix, struct hash_lock_statistics *stats, - char *suffix, char **buf, unsigned int *maxlen) +static void write_hash_lock_statistics(char *prefix, struct hash_lock_statistics *stats, + char *suffix, char **buf, unsigned int *maxlen) { - int result; - - result = write_string(prefix, "{ ", NULL, buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_string(prefix, "{ ", NULL, buf, maxlen); /* Number of times the UDS advice proved correct */ - result = write_u64("dedupeAdviceValid : ", stats->dedupe_advice_valid, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("dedupeAdviceValid : ", stats->dedupe_advice_valid, ", ", buf, maxlen); /* Number of times the UDS advice proved incorrect */ - result = write_u64("dedupeAdviceStale : ", stats->dedupe_advice_stale, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("dedupeAdviceStale : ", stats->dedupe_advice_stale, ", ", buf, maxlen); /* Number of writes with the same data as another in-flight write */ - result = write_u64("concurrentDataMatches : ", stats->concurrent_data_matches, - ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("concurrentDataMatches : ", stats->concurrent_data_matches, + ", ", buf, maxlen); /* Number of writes whose hash collided with an in-flight write */ - result = write_u64("concurrentHashCollisions : ", - stats->concurrent_hash_collisions, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("concurrentHashCollisions : ", + stats->concurrent_hash_collisions, ", ", buf, maxlen); /* Current number of dedupe queries that are in flight */ - result = write_u32("currDedupeQueries : ", stats->curr_dedupe_queries, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_string(NULL, "}", suffix, buf, maxlen); - if (result != VDO_SUCCESS) - return result; - return VDO_SUCCESS; + write_u32("currDedupeQueries : ", stats->curr_dedupe_queries, ", ", buf, maxlen); + write_string(NULL, "}", suffix, buf, maxlen); } -static int write_error_statistics(char *prefix, struct error_statistics *stats, - char *suffix, char **buf, unsigned int *maxlen) +static void write_error_statistics(char *prefix, struct error_statistics *stats, + char *suffix, char **buf, unsigned int *maxlen) { - int result; - - result = write_string(prefix, "{ ", NULL, buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_string(prefix, "{ ", NULL, buf, maxlen); /* number of times VDO got an invalid dedupe advice PBN from UDS */ - result = write_u64("invalidAdvicePBNCount : ", stats->invalid_advice_pbn_count, - ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("invalidAdvicePBNCount : ", stats->invalid_advice_pbn_count, + ", ", buf, maxlen); /* number of times a VIO completed with a VDO_NO_SPACE error */ - result = write_u64("noSpaceErrorCount : ", stats->no_space_error_count, ", ", - buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("noSpaceErrorCount : ", stats->no_space_error_count, ", ", + buf, maxlen); /* number of times a VIO completed with a VDO_READ_ONLY error */ - result = write_u64("readOnlyErrorCount : ", stats->read_only_error_count, ", ", - buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_string(NULL, "}", suffix, buf, maxlen); - if (result != VDO_SUCCESS) - return result; - return VDO_SUCCESS; + write_u64("readOnlyErrorCount : ", stats->read_only_error_count, ", ", + buf, maxlen); + write_string(NULL, "}", suffix, buf, maxlen); } -static int write_bio_stats(char *prefix, struct bio_stats *stats, char *suffix, - char **buf, unsigned int *maxlen) +static void write_bio_stats(char *prefix, struct bio_stats *stats, char *suffix, + char **buf, unsigned int *maxlen) { - int result; - - result = write_string(prefix, "{ ", NULL, buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_string(prefix, "{ ", NULL, buf, maxlen); /* Number of REQ_OP_READ bios */ - result = write_u64("read : ", stats->read, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("read : ", stats->read, ", ", buf, maxlen); /* Number of REQ_OP_WRITE bios with data */ - result = write_u64("write : ", stats->write, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("write : ", stats->write, ", ", buf, maxlen); /* Number of bios tagged with REQ_PREFLUSH and containing no data */ - result = write_u64("emptyFlush : ", stats->empty_flush, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("emptyFlush : ", stats->empty_flush, ", ", buf, maxlen); /* Number of REQ_OP_DISCARD bios */ - result = write_u64("discard : ", stats->discard, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("discard : ", stats->discard, ", ", buf, maxlen); /* Number of bios tagged with REQ_PREFLUSH */ - result = write_u64("flush : ", stats->flush, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("flush : ", stats->flush, ", ", buf, maxlen); /* Number of bios tagged with REQ_FUA */ - result = write_u64("fua : ", stats->fua, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_string(NULL, "}", suffix, buf, maxlen); - if (result != VDO_SUCCESS) - return result; - return VDO_SUCCESS; + write_u64("fua : ", stats->fua, ", ", buf, maxlen); + write_string(NULL, "}", suffix, buf, maxlen); } -static int write_memory_usage(char *prefix, struct memory_usage *stats, char *suffix, - char **buf, unsigned int *maxlen) +static void write_memory_usage(char *prefix, struct memory_usage *stats, char *suffix, + char **buf, unsigned int *maxlen) { - int result; - - result = write_string(prefix, "{ ", NULL, buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_string(prefix, "{ ", NULL, buf, maxlen); /* Tracked bytes currently allocated. */ - result = write_u64("bytesUsed : ", stats->bytes_used, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("bytesUsed : ", stats->bytes_used, ", ", buf, maxlen); /* Maximum tracked bytes allocated. */ - result = write_u64("peakBytesUsed : ", stats->peak_bytes_used, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_string(NULL, "}", suffix, buf, maxlen); - if (result != VDO_SUCCESS) - return result; - return VDO_SUCCESS; + write_u64("peakBytesUsed : ", stats->peak_bytes_used, ", ", buf, maxlen); + write_string(NULL, "}", suffix, buf, maxlen); } -static int write_index_statistics(char *prefix, struct index_statistics *stats, - char *suffix, char **buf, unsigned int *maxlen) +static void write_index_statistics(char *prefix, struct index_statistics *stats, + char *suffix, char **buf, unsigned int *maxlen) { - int result; - - result = write_string(prefix, "{ ", NULL, buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_string(prefix, "{ ", NULL, buf, maxlen); /* Number of records stored in the index */ - result = write_u64("entriesIndexed : ", stats->entries_indexed, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("entriesIndexed : ", stats->entries_indexed, ", ", buf, maxlen); /* Number of post calls that found an existing entry */ - result = write_u64("postsFound : ", stats->posts_found, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("postsFound : ", stats->posts_found, ", ", buf, maxlen); /* Number of post calls that added a new entry */ - result = write_u64("postsNotFound : ", stats->posts_not_found, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("postsNotFound : ", stats->posts_not_found, ", ", buf, maxlen); /* Number of query calls that found an existing entry */ - result = write_u64("queriesFound : ", stats->queries_found, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("queriesFound : ", stats->queries_found, ", ", buf, maxlen); /* Number of query calls that added a new entry */ - result = write_u64("queriesNotFound : ", stats->queries_not_found, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("queriesNotFound : ", stats->queries_not_found, ", ", buf, maxlen); /* Number of update calls that found an existing entry */ - result = write_u64("updatesFound : ", stats->updates_found, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("updatesFound : ", stats->updates_found, ", ", buf, maxlen); /* Number of update calls that added a new entry */ - result = write_u64("updatesNotFound : ", stats->updates_not_found, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("updatesNotFound : ", stats->updates_not_found, ", ", buf, maxlen); /* Number of entries discarded */ - result = write_u64("entriesDiscarded : ", stats->entries_discarded, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_string(NULL, "}", suffix, buf, maxlen); - if (result != VDO_SUCCESS) - return result; - return VDO_SUCCESS; + write_u64("entriesDiscarded : ", stats->entries_discarded, ", ", buf, maxlen); + write_string(NULL, "}", suffix, buf, maxlen); } -static int write_vdo_statistics(char *prefix, struct vdo_statistics *stats, char *suffix, - char **buf, unsigned int *maxlen) +static void write_vdo_statistics(char *prefix, struct vdo_statistics *stats, char *suffix, + char **buf, unsigned int *maxlen) { - int result; - - result = write_string(prefix, "{ ", NULL, buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_u32("version : ", stats->version, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_string(prefix, "{ ", NULL, buf, maxlen); + write_u32("version : ", stats->version, ", ", buf, maxlen); /* Number of blocks used for data */ - result = write_u64("dataBlocksUsed : ", stats->data_blocks_used, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("dataBlocksUsed : ", stats->data_blocks_used, ", ", buf, maxlen); /* Number of blocks used for VDO metadata */ - result = write_u64("overheadBlocksUsed : ", stats->overhead_blocks_used, ", ", - buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("overheadBlocksUsed : ", stats->overhead_blocks_used, ", ", + buf, maxlen); /* Number of logical blocks that are currently mapped to physical blocks */ - result = write_u64("logicalBlocksUsed : ", stats->logical_blocks_used, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("logicalBlocksUsed : ", stats->logical_blocks_used, ", ", buf, maxlen); /* number of physical blocks */ - result = write_block_count_t("physicalBlocks : ", stats->physical_blocks, ", ", - buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_block_count_t("physicalBlocks : ", stats->physical_blocks, ", ", + buf, maxlen); /* number of logical blocks */ - result = write_block_count_t("logicalBlocks : ", stats->logical_blocks, ", ", - buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_block_count_t("logicalBlocks : ", stats->logical_blocks, ", ", + buf, maxlen); /* Size of the block map page cache, in bytes */ - result = write_u64("blockMapCacheSize : ", stats->block_map_cache_size, ", ", - buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("blockMapCacheSize : ", stats->block_map_cache_size, ", ", + buf, maxlen); /* The physical block size */ - result = write_u64("blockSize : ", stats->block_size, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("blockSize : ", stats->block_size, ", ", buf, maxlen); /* Number of times the VDO has successfully recovered */ - result = write_u64("completeRecoveries : ", stats->complete_recoveries, ", ", - buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("completeRecoveries : ", stats->complete_recoveries, ", ", + buf, maxlen); /* Number of times the VDO has recovered from read-only mode */ - result = write_u64("readOnlyRecoveries : ", stats->read_only_recoveries, ", ", - buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("readOnlyRecoveries : ", stats->read_only_recoveries, ", ", + buf, maxlen); /* String describing the operating mode of the VDO */ - result = write_string("mode : ", stats->mode, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_string("mode : ", stats->mode, ", ", buf, maxlen); /* Whether the VDO is in recovery mode */ - result = write_bool("inRecoveryMode : ", stats->in_recovery_mode, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_bool("inRecoveryMode : ", stats->in_recovery_mode, ", ", buf, maxlen); /* What percentage of recovery mode work has been completed */ - result = write_u8("recoveryPercentage : ", stats->recovery_percentage, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_u8("recoveryPercentage : ", stats->recovery_percentage, ", ", buf, maxlen); /* The statistics for the compressed block packer */ - result = write_packer_statistics("packer : ", &stats->packer, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_packer_statistics("packer : ", &stats->packer, ", ", buf, maxlen); /* Counters for events in the block allocator */ - result = write_block_allocator_statistics("allocator : ", &stats->allocator, - ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_block_allocator_statistics("allocator : ", &stats->allocator, + ", ", buf, maxlen); /* Counters for events in the recovery journal */ - result = write_recovery_journal_statistics("journal : ", &stats->journal, ", ", - buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_recovery_journal_statistics("journal : ", &stats->journal, ", ", + buf, maxlen); /* The statistics for the slab journals */ - result = write_slab_journal_statistics("slabJournal : ", &stats->slab_journal, - ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_slab_journal_statistics("slabJournal : ", &stats->slab_journal, + ", ", buf, maxlen); /* The statistics for the slab summary */ - result = write_slab_summary_statistics("slabSummary : ", &stats->slab_summary, - ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_slab_summary_statistics("slabSummary : ", &stats->slab_summary, + ", ", buf, maxlen); /* The statistics for the reference counts */ - result = write_ref_counts_statistics("refCounts : ", &stats->ref_counts, ", ", - buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_ref_counts_statistics("refCounts : ", &stats->ref_counts, ", ", + buf, maxlen); /* The statistics for the block map */ - result = write_block_map_statistics("blockMap : ", &stats->block_map, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_block_map_statistics("blockMap : ", &stats->block_map, ", ", buf, maxlen); /* The dedupe statistics from hash locks */ - result = write_hash_lock_statistics("hashLock : ", &stats->hash_lock, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_hash_lock_statistics("hashLock : ", &stats->hash_lock, ", ", buf, maxlen); /* Counts of error conditions */ - result = write_error_statistics("errors : ", &stats->errors, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_error_statistics("errors : ", &stats->errors, ", ", buf, maxlen); /* The VDO instance */ - result = write_u32("instance : ", stats->instance, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u32("instance : ", stats->instance, ", ", buf, maxlen); /* Current number of active VIOs */ - result = write_u32("currentVIOsInProgress : ", stats->current_vios_in_progress, - ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u32("currentVIOsInProgress : ", stats->current_vios_in_progress, + ", ", buf, maxlen); /* Maximum number of active VIOs */ - result = write_u32("maxVIOs : ", stats->max_vios, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u32("maxVIOs : ", stats->max_vios, ", ", buf, maxlen); /* Number of times the UDS index was too slow in responding */ - result = write_u64("dedupeAdviceTimeouts : ", stats->dedupe_advice_timeouts, - ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("dedupeAdviceTimeouts : ", stats->dedupe_advice_timeouts, + ", ", buf, maxlen); /* Number of flush requests submitted to the storage device */ - result = write_u64("flushOut : ", stats->flush_out, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("flushOut : ", stats->flush_out, ", ", buf, maxlen); /* Logical block size */ - result = write_u64("logicalBlockSize : ", stats->logical_block_size, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_u64("logicalBlockSize : ", stats->logical_block_size, ", ", buf, maxlen); /* Bios submitted into VDO from above */ - result = write_bio_stats("biosIn : ", &stats->bios_in, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_bio_stats("biosInPartial : ", &stats->bios_in_partial, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_bio_stats("biosIn : ", &stats->bios_in, ", ", buf, maxlen); + write_bio_stats("biosInPartial : ", &stats->bios_in_partial, ", ", buf, maxlen); /* Bios submitted onward for user data */ - result = write_bio_stats("biosOut : ", &stats->bios_out, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_bio_stats("biosOut : ", &stats->bios_out, ", ", buf, maxlen); /* Bios submitted onward for metadata */ - result = write_bio_stats("biosMeta : ", &stats->bios_meta, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_bio_stats("biosJournal : ", &stats->bios_journal, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_bio_stats("biosPageCache : ", &stats->bios_page_cache, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_bio_stats("biosOutCompleted : ", &stats->bios_out_completed, ", ", - buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_bio_stats("biosMetaCompleted : ", &stats->bios_meta_completed, - ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_bio_stats("biosJournalCompleted : ", - &stats->bios_journal_completed, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_bio_stats("biosPageCacheCompleted : ", - &stats->bios_page_cache_completed, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_bio_stats("biosAcknowledged : ", &stats->bios_acknowledged, ", ", - buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_bio_stats("biosAcknowledgedPartial : ", - &stats->bios_acknowledged_partial, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_bio_stats("biosMeta : ", &stats->bios_meta, ", ", buf, maxlen); + write_bio_stats("biosJournal : ", &stats->bios_journal, ", ", buf, maxlen); + write_bio_stats("biosPageCache : ", &stats->bios_page_cache, ", ", buf, maxlen); + write_bio_stats("biosOutCompleted : ", &stats->bios_out_completed, ", ", + buf, maxlen); + write_bio_stats("biosMetaCompleted : ", &stats->bios_meta_completed, + ", ", buf, maxlen); + write_bio_stats("biosJournalCompleted : ", + &stats->bios_journal_completed, ", ", buf, maxlen); + write_bio_stats("biosPageCacheCompleted : ", + &stats->bios_page_cache_completed, ", ", buf, maxlen); + write_bio_stats("biosAcknowledged : ", &stats->bios_acknowledged, ", ", + buf, maxlen); + write_bio_stats("biosAcknowledgedPartial : ", + &stats->bios_acknowledged_partial, ", ", buf, maxlen); /* Current number of bios in progress */ - result = write_bio_stats("biosInProgress : ", &stats->bios_in_progress, ", ", - buf, maxlen); - if (result != VDO_SUCCESS) - return result; + write_bio_stats("biosInProgress : ", &stats->bios_in_progress, ", ", + buf, maxlen); /* Memory usage stats. */ - result = write_memory_usage("memoryUsage : ", &stats->memory_usage, ", ", buf, - maxlen); - if (result != VDO_SUCCESS) - return result; + write_memory_usage("memoryUsage : ", &stats->memory_usage, ", ", buf, maxlen); /* The statistics for the UDS index */ - result = write_index_statistics("index : ", &stats->index, ", ", buf, maxlen); - if (result != VDO_SUCCESS) - return result; - result = write_string(NULL, "}", suffix, buf, maxlen); - if (result != VDO_SUCCESS) - return result; - return VDO_SUCCESS; + write_index_statistics("index : ", &stats->index, ", ", buf, maxlen); + write_string(NULL, "}", suffix, buf, maxlen); } int vdo_write_stats(struct vdo *vdo, char *buf, unsigned int maxlen) @@ -762,11 +420,13 @@ int vdo_write_stats(struct vdo *vdo, char *buf, unsigned int maxlen) int result; result = uds_allocate(1, struct vdo_statistics, __func__, &stats); - if (result != VDO_SUCCESS) + if (result != UDS_SUCCESS) { + uds_log_error("Cannot allocate memory to write VDO statistics"); return result; + } vdo_fetch_statistics(vdo, stats); - result = write_vdo_statistics(NULL, stats, NULL, &buf, &maxlen); + write_vdo_statistics(NULL, stats, NULL, &buf, &maxlen); uds_free(stats); - return result; + return VDO_SUCCESS; }