From patchwork Tue Apr 23 12:36:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13639980 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 608DC134CCA for ; Tue, 23 Apr 2024 12:37:01 +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=1713875823; cv=none; b=ZABdtKV6MnRQ8sVKenQSKWVbu46aCZS6jQmK99IjKHfO5/KH5SdOnMf8Mel6ssZT2MpXitInIYjW4BF77wl+gwaiSpHtWvLdxvsavvuIxG/F671/vNgOmEnUfTT20E8mwncVXP4Zk7bZAx3k12wrrUPlQu4EXM0B/rSJZQRMYFk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713875823; c=relaxed/simple; bh=ulMq5NcQJ+Mm4bToiJej1gzpiwB8mC3K7VcZcG9FsKY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=g++PPWkQq0AfXoYUT1zBiKUOqLFg7vdPbCt5RB8GLnwfbExOc5AahGXEwypFT/gDWq+fhI5kjgazj01Hyl7M0Ip4VoAZXci6TefBXBtIvRKWQFJ8qSzgqfjwLSP9SzoxT2SATSKeNnNfIOH7faOmA0MD0yc6LoJhTIb+zi6rHxU= 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=bQIenZ73; 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="bQIenZ73" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713875820; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=FSdLmKVak3TNL+D9ABpWccd8Qslsa3Pvs9zG76WZCUo=; b=bQIenZ739JQr+a2XCX3oEIx5DsRhhTBT1mdWV/fmQg31Zuesoij+Zry+6qMyOU+8IouokV 4PgSZbW5gTS6Xc88IDkHpu3iIyfVVa/dV9d+iNg5/wiSikBzQN9a5xzwortegdOC7am4i8 VPNRdPWIY8clGEq/ubVOWiDfGcqVXVA= Received: from mail-lj1-f199.google.com (mail-lj1-f199.google.com [209.85.208.199]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-625-wArSill0NzCb6H4npsnAlg-1; Tue, 23 Apr 2024 08:36:58 -0400 X-MC-Unique: wArSill0NzCb6H4npsnAlg-1 Received: by mail-lj1-f199.google.com with SMTP id 38308e7fff4ca-2da2f30cb50so40652701fa.2 for ; Tue, 23 Apr 2024 05:36:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713875817; x=1714480617; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=FSdLmKVak3TNL+D9ABpWccd8Qslsa3Pvs9zG76WZCUo=; b=S1U1M8xCeYLD96p39AMdl2L/bRSZVfi63Gb2FfBbDBZT+dar4YvbNCEIrap3rF56UE uVYgkHmT0gGW7mtefd3Y6q3L2p8BMtJKFdcrwTFNE4unV5EtPim6PBeBmJ/SI7PVFvbl x2VqhUNxKA9GvamcyGaS0iE1uRrp1LXe2OFGyCe+rPUpfophrwizj2OvmeUUAE0/o7/a 0/LyCNsAqYH0IgFbShlSYY8MA/AoL8nc3eHlh2+vHUb9TDD/dyb2qkyHXVXRJ9JFCzCk yEbrPH/LrsG2BdrIlWvsIXxKjrok5haINOf5m/nhXi8NXn3AVrzEn9Ezpoeokpp5Ly1g Y4cQ== X-Forwarded-Encrypted: i=1; AJvYcCUG9MT7eBevzzDPmp24C8veDA2RAkFQ+6PuynEaoWQ1MbpXg7pHVLPvBizrPjdQ9HsRWIhVw+wFhl3DnazB+1eOxeqQZYoYJRo4 X-Gm-Message-State: AOJu0Yz7ayyitaER2cLC8wg0Wj61wCfNfog1NOrnkw6LiT6jyFLk2wf4 kTBc9gYI2wnxkMrggs8j8m3OMTUohtbyDi/x6OWtMGORZU95tu4m6PO9lEHOeNuvu6Vn8cZnxKQ S0cj2m8eDoC2QQcoRNrUQpP509RbqZ97zdlZXwyn+7HDrj3P/SvK4tQxK X-Received: by 2002:a2e:7a09:0:b0:2dc:ae40:c797 with SMTP id v9-20020a2e7a09000000b002dcae40c797mr8683306ljc.15.1713875817055; Tue, 23 Apr 2024 05:36:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEIA5yxWSenyzdbd847+b4uxYnxzPsOOYxS1pMneGAQD8bw0T2R2ImOOQJIlTVr5mWrCaPWrg== X-Received: by 2002:a2e:7a09:0:b0:2dc:ae40:c797 with SMTP id v9-20020a2e7a09000000b002dcae40c797mr8683287ljc.15.1713875816560; Tue, 23 Apr 2024 05:36:56 -0700 (PDT) Received: from thinky.redhat.com ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id et3-20020a056402378300b00571d8da8d09sm4783170edb.68.2024.04.23.05.36.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 05:36:56 -0700 (PDT) From: Andrey Albershteyn To: cem@kernel.org, linux-xfs@vger.kernel.org Cc: Andrey Albershteyn , "Darrick J. Wong" , Bill O'Donnell , Christoph Hellwig Subject: [PATCH v5 1/4] xfs_db: fix leak in flist_find_ftyp() Date: Tue, 23 Apr 2024 14:36:14 +0200 Message-ID: <20240423123616.2629570-3-aalbersh@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240423123616.2629570-2-aalbersh@redhat.com> References: <20240423123616.2629570-2-aalbersh@redhat.com> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When count is zero fl reference is lost. Fix it by freeing the list. Fixes: a0d79cb37a36 ("xfs_db: make flist_find_ftyp() to check for field existance on disk") Reviewed-by: "Darrick J. Wong" Reviewed-by: Bill O'Donnell Reviewed-by: Christoph Hellwig Signed-off-by: Andrey Albershteyn --- db/flist.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/db/flist.c b/db/flist.c index c81d229ab99c..0a6cc5fcee43 100644 --- a/db/flist.c +++ b/db/flist.c @@ -424,8 +424,10 @@ flist_find_ftyp( if (f->ftyp == type) return fl; count = fcount(f, obj, startoff); - if (!count) + if (!count) { + flist_free(fl); continue; + } fa = &ftattrtab[f->ftyp]; if (fa->subfld) { flist_t *nfl; From patchwork Tue Apr 23 12:36:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13639979 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 D8E18130AED for ; Tue, 23 Apr 2024 12:37:01 +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=1713875823; cv=none; b=FIS+v8AXZ6CtQcA6w9CdSOdqkVoJC4N6Jfx09A7TeUaSArto2plAy7JWhG3Hk4zVDq1/IeGhCXbw51NHyWXpx5+yeckdU5g/dJ167UxrN9Yq+kFZcuiRbMo83Bh43bzbazXk/z02bIfdqWs0JfUa2PVYQJ3tv/bRTUbSFBT8jCM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713875823; c=relaxed/simple; bh=gphV23+db5+xQxfJ5m43f/Izi9RUhfIHndB2Nzlk5nI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aMdfqTVX6dJ8oicCCJstk7qkFGCcLzi/Eu4lLGVQgyHxcRAmpLEJt8dP7Fxvf9eb7hGcxRrcKYmNZW51Z3mHkAtc3ulHHA/JzVr7BLgYht8DjZVnmLqS/i0RWL5pRtIPZGgwaeC/fd8+ds3Vn15I+cXYE0zC+l6LQHU7P3RPIEs= 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=AcZ3GBVT; 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="AcZ3GBVT" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713875820; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=DkqxvFgqINBe0oqn/LzATlRSjKi9+CINDNl39XwIbm8=; b=AcZ3GBVTFpdsJaJNyh0n3XbKQIQcQeu08Q1l7ecQ9PTB3OBYLNfsTB6mg9bd0ew3ZfGfRE 3QcYy/tAmrs4yR5OxKHBWamO/eTs1FSQns4Sf6OT+77azo/I5/QBvtSb8ttGcWmXAi41MW yUkQ1XC2fA3KBrJm+aamtxCHJ2dtIv4= Received: from mail-ej1-f70.google.com (mail-ej1-f70.google.com [209.85.218.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-623-8q-QD7PQMsCWOk79niNmJQ-1; Tue, 23 Apr 2024 08:36:59 -0400 X-MC-Unique: 8q-QD7PQMsCWOk79niNmJQ-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a587ef3d325so22966566b.2 for ; Tue, 23 Apr 2024 05:36:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713875818; x=1714480618; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=DkqxvFgqINBe0oqn/LzATlRSjKi9+CINDNl39XwIbm8=; b=v1VluAD1ZbandoB/EvKoCsYwAMScXOjPV1gpj21ZWuXIdmxwQ4603/hdn3dhuaLoGt ic6HDEqVXMpGQfREA0jTmCOfv+IfEynZ3UGJJbW37I7yxw03ZC7Tx/8EfMMFg1wCes4m /TDSUXYb/jdUdGN+x1UnmN1SBn1TFz1UMAfC6NsrgJGEqUgkZ/SrXlwuttQ5jXSORP4E 9fF4QBX90zgTy9lwChHVO9Z8gVoJiVDDV5sAQzAmm/LBTAZ9PQnJq3pLRc5OcOsJp7Kn fD7DU+TJxD9UM2hLkAsyEcpMRNSvdiFreDfh2j3oC8gT3jM4Zdg8GEgrBUypvAAPoqSd 8N3g== X-Forwarded-Encrypted: i=1; AJvYcCVvmcwwhwhHbasG9XqF5arlPLDQE7ALTNIywEJjJ/7X83IMh3cxmylfMNH0/SSF8IqjiIwxZ8ImQOjEqLXwIjWVJfhvSVW4jKNV X-Gm-Message-State: AOJu0YwfJT5yl/0iB84JX/zvQWC0gAOz6vJFmI9jZEcbofXE+jYCjzQe 8Z7RgAYqZZ3cYahFXNuqJio8J5wZ97+B9o6rZaCZPSKGJEYAgPVS4jTf/piIStPkuODNbMTF53e Ic0Naf/KdY9KB26vjnGLC/E1nMP9yhHbxouZbi88bimm2J6oiQmMW40Zm X-Received: by 2002:a50:ab04:0:b0:572:20cb:475d with SMTP id s4-20020a50ab04000000b0057220cb475dmr1693141edc.7.1713875817910; Tue, 23 Apr 2024 05:36:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGahSVxNw5BxHtMCyA9Q3fONUXTHi/k20qlW0g39PsblMo7h0wIIAVwhTtvnERfdbj6pTTFlQ== X-Received: by 2002:a50:ab04:0:b0:572:20cb:475d with SMTP id s4-20020a50ab04000000b0057220cb475dmr1693104edc.7.1713875817248; Tue, 23 Apr 2024 05:36:57 -0700 (PDT) Received: from thinky.redhat.com ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id et3-20020a056402378300b00571d8da8d09sm4783170edb.68.2024.04.23.05.36.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 05:36:56 -0700 (PDT) From: Andrey Albershteyn To: cem@kernel.org, linux-xfs@vger.kernel.org Cc: Andrey Albershteyn , "Darrick J. Wong" , Christoph Hellwig Subject: [PATCH v5 2/4] xfs_repair: make duration take time_t Date: Tue, 23 Apr 2024 14:36:15 +0200 Message-ID: <20240423123616.2629570-4-aalbersh@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240423123616.2629570-2-aalbersh@redhat.com> References: <20240423123616.2629570-2-aalbersh@redhat.com> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 In most of the uses of duration() takes time_t instead of int. Convert the rest to use time_t and make duration() take time_t to not truncate it to int. While at it remove unnecessary parentheses around 'elapsed'. Reviewed-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig Signed-off-by: Andrey Albershteyn Reviewed-by: Carlos Maiolino --- repair/globals.c | 2 +- repair/globals.h | 2 +- repair/progress.c | 9 +++++---- repair/progress.h | 2 +- repair/xfs_repair.c | 2 +- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/repair/globals.c b/repair/globals.c index c40849853b8f..7c819d70a0ab 100644 --- a/repair/globals.c +++ b/repair/globals.c @@ -116,7 +116,7 @@ uint32_t sb_width; struct aglock *ag_locks; struct aglock rt_lock; -int report_interval; +time_t report_interval; uint64_t *prog_rpt_done; int ag_stride; diff --git a/repair/globals.h b/repair/globals.h index 89f1b0e078f3..2d05c8b2c00f 100644 --- a/repair/globals.h +++ b/repair/globals.h @@ -160,7 +160,7 @@ struct aglock { extern struct aglock *ag_locks; extern struct aglock rt_lock; -extern int report_interval; +extern time_t report_interval; extern uint64_t *prog_rpt_done; extern int ag_stride; diff --git a/repair/progress.c b/repair/progress.c index f6c4d988444e..2ce36cef0449 100644 --- a/repair/progress.c +++ b/repair/progress.c @@ -265,15 +265,16 @@ progress_rpt_thread (void *p) (current_phase == 7))) { /* for inode phase report % complete */ do_log( - _("\t- %02d:%02d:%02d: Phase %d: elapsed time %s - processed %d %s per minute\n"), + _("\t- %02d:%02d:%02d: Phase %d: elapsed time %s - processed %ld %s per minute\n"), tmp->tm_hour, tmp->tm_min, tmp->tm_sec, current_phase, duration(elapsed, msgbuf), - (int) (60*sum/(elapsed)), *msgp->format->type); + 60 * sum / elapsed, *msgp->format->type); do_log( _("\t- %02d:%02d:%02d: Phase %d: %" PRIu64 "%% done - estimated remaining time %s\n"), tmp->tm_hour, tmp->tm_min, tmp->tm_sec, current_phase, percent, - duration((int) ((*msgp->total - sum) * (elapsed)/sum), msgbuf)); + duration((*msgp->total - sum) * elapsed / sum, + msgbuf)); } if (pthread_mutex_unlock(&msgp->mutex) != 0) { @@ -420,7 +421,7 @@ timestamp(int end, int phase, char *buf) } char * -duration(int length, char *buf) +duration(time_t length, char *buf) { int sum; int weeks; diff --git a/repair/progress.h b/repair/progress.h index 2c1690db1b17..9575df164aa0 100644 --- a/repair/progress.h +++ b/repair/progress.h @@ -38,7 +38,7 @@ extern void summary_report(void); extern int set_progress_msg(int report, uint64_t total); extern uint64_t print_final_rpt(void); extern char *timestamp(int end, int phase, char *buf); -extern char *duration(int val, char *buf); +extern char *duration(time_t val, char *buf); extern int do_parallel; #define PROG_RPT_INC(a,b) if (ag_stride && prog_rpt_done) (a) += (b) diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c index ba9d28330d82..2ceea87dc57d 100644 --- a/repair/xfs_repair.c +++ b/repair/xfs_repair.c @@ -377,7 +377,7 @@ process_args(int argc, char **argv) do_prefetch = 0; break; case 't': - report_interval = (int)strtol(optarg, NULL, 0); + report_interval = strtol(optarg, NULL, 0); break; case 'e': report_corrected = true; From patchwork Tue Apr 23 12:36:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13639982 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 BD0EE130E5B for ; Tue, 23 Apr 2024 12:37:23 +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=1713875845; cv=none; b=TD9ywVJNrP++Vxq6ewzbPZanVUR9Eg1GjCh69zGpBhJ8mxG52awtomk0fzXDndowgDUqHYLsqjqM42pFsr35kSXCD8nY203ZPDkTrr7YG1tgn3NIP5SYSvoIdauU10o8H8QiwCDFgDujGFYgeFx4Bn6/IgFPHRwV2/xcuBU01q4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713875845; c=relaxed/simple; bh=ZjIlsppbSM+2+B8SuNJOGFUPsxt9o9ur2mn9oYk9b5Y=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=MMf7NvO6HO/EumSX7put2iEe8V74KXAG73dxjMT80oZgv9ThOKCqu8eFXD2yZVpg4faEYZEP6HVE6QCoif89WUoKZ3nd2eBlIhXOXPkHzudkufhKpSRbXmC5PLMVptGzKSuBhtv2apFsIhPvQvZvwH7tZlO1VEwbUcUItVUj0u8= 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=XfZLks0E; 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="XfZLks0E" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713875842; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=R0LxgM8QvLELziwrlN72LAzWTDKmOBhsQQZrCdm0rvo=; b=XfZLks0EFeBlT3lyY+MudcLzTFitl4ptyTTB1CJbVFfaION63hmoowJoUD7Je6ibBAOYGP 2jH6Rp1lvCN32Zm0JsyfHY0qh4owzB2PN2XIQ7AHubqWwx178fMHy6etjhU4OnL8oJIrQO dAqReSo7catntHGIh8Ppz8Q8c1rtqMY= Received: from mail-ed1-f71.google.com (mail-ed1-f71.google.com [209.85.208.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-564-ZhQwYkgYOpKW5n0Dl-0cwg-1; Tue, 23 Apr 2024 08:37:10 -0400 X-MC-Unique: ZhQwYkgYOpKW5n0Dl-0cwg-1 Received: by mail-ed1-f71.google.com with SMTP id 4fb4d7f45d1cf-56e67c53f23so2002184a12.2 for ; Tue, 23 Apr 2024 05:37:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713875819; x=1714480619; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R0LxgM8QvLELziwrlN72LAzWTDKmOBhsQQZrCdm0rvo=; b=lgqBRJSShDN3DjoPV8Nznn4ay71ZDFep59c2CJBB/q6Qtbh6IkwXKCc71ywxHk1i9U WqwEwsVVA6AMUhBTJ7V44vQL6Wr/HIYiTWY9/xoaCwLDWMNWIrfSLYuLu55zN5Ezyft5 GLdCb5fhSPH4nsydGCLVf570Ik2oyrJeiskQ+Aq1uRoMBQxtqD7wJ3tdZcRIUzYUtpMQ 9X+ZiP1RsXO5weAs5bMhqNBD6Q7tXQxdmOa6wH+HMwP4CiMm+wNdAF7FCjiCgC0uGieX rNkaWmuIUhaymg2+7Qci9OM2nbuNfBN72uPvWzineKmrZJVIWGWvc1ksZSslUaJKvOpM t7Ng== X-Forwarded-Encrypted: i=1; AJvYcCUyqtSwP3uuSUo6Mvo7nXFUBk8n7iOakl2cPi6/xHsI+DudMZ8R55VukdKQpxVZwRYSCmdThYuTCdIQzSenRhArXkg1Aw1ufGqq X-Gm-Message-State: AOJu0YwgKEocz7/csKnypm7weKCNO/3EsVshI3cRK+lTUX4lfZxjwsso o6ZuA4iZv6LQL7hoWE6YXmpN7Q0BXT3SzAxHIAm9obk7w/nv1BQWZCxyWkf/C6l37ssXLvM1+eB +35yaSKs3O4H0peeRW34BPREoTp+0G6CEkBxeZvRpw9rg5v0vHCbRJKcb X-Received: by 2002:a50:c30d:0:b0:56e:6d9:7bd6 with SMTP id a13-20020a50c30d000000b0056e06d97bd6mr9000645edb.34.1713875818749; Tue, 23 Apr 2024 05:36:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGdc8PXEEu7IPBFWobjoCgVpuInycnus/1iRSGVSOqkjJCKC5wn1z9uy7L9Z1oiv/FM63JtaA== X-Received: by 2002:a50:c30d:0:b0:56e:6d9:7bd6 with SMTP id a13-20020a50c30d000000b0056e06d97bd6mr9000616edb.34.1713875818115; Tue, 23 Apr 2024 05:36:58 -0700 (PDT) Received: from thinky.redhat.com ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id et3-20020a056402378300b00571d8da8d09sm4783170edb.68.2024.04.23.05.36.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 05:36:57 -0700 (PDT) From: Andrey Albershteyn To: cem@kernel.org, linux-xfs@vger.kernel.org Cc: Andrey Albershteyn , "Darrick J. Wong" , Bill O'Donnell , Christoph Hellwig Subject: [PATCH v5 3/4] xfs_scrub: don't call phase_end if phase_rusage was not initialized Date: Tue, 23 Apr 2024 14:36:16 +0200 Message-ID: <20240423123616.2629570-5-aalbersh@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240423123616.2629570-2-aalbersh@redhat.com> References: <20240423123616.2629570-2-aalbersh@redhat.com> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 If unicrash_load() fails, all_pi can be used uninitialized in phase_end(). Fix it by going to the unload: section if unicrash_load fails and just go with unicrash_unload() (the is_service won't be initialized here). Reviewed-by: "Darrick J. Wong" Reviewed-by: Bill O'Donnell Reviewed-by: Christoph Hellwig Signed-off-by: Andrey Albershteyn --- scrub/xfs_scrub.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scrub/xfs_scrub.c b/scrub/xfs_scrub.c index 752180d646ba..50565857ddd8 100644 --- a/scrub/xfs_scrub.c +++ b/scrub/xfs_scrub.c @@ -631,7 +631,7 @@ main( fprintf(stderr, _("%s: couldn't initialize Unicode library.\n"), progname); - goto out; + goto out_unicrash; } pthread_mutex_init(&ctx.lock, NULL); @@ -828,6 +828,7 @@ out: phase_end(&all_pi, 0); if (progress_fp) fclose(progress_fp); +out_unicrash: unicrash_unload(); /* From patchwork Tue Apr 23 12:36:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13639981 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 4CF9F1350F8 for ; Tue, 23 Apr 2024 12:37:02 +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=1713875824; cv=none; b=fRvtwvp/LafRw9rVyE+J3t821I/F+2qt1YMmy5YTDf03B6W/u94pcNquu3PpuECmVFlfbWBH1cM5zF/n89pl0FDYupPTc51mMfTRfYSkITRRPVu7p6dhVBIAj/mHY6UNAjaTRINFFzkrro4QQ2VvZCghiECCR2DAW7MI2Zcidq8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713875824; c=relaxed/simple; bh=M58YW49eqB4hUf/akvPZwjxoJHQcW1zBANFCkx0Oyyc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VvztWg/Tvig+127Z4l1ti2cL043SRwzsh/SVNwxqLxiESLpV6H5m2qSczh/XucQ5Uh7IddVHJPmeYcRZ4fhLLXjPSBGnSqwwBKUF6g+3S+D7RDf84be3XMyBslMKoFMGR/KiPlvsSEWHoleQ4n3stdzeonFLsscUpAiKqkGYXSk= 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=Rwz4P+w5; 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="Rwz4P+w5" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713875822; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=dpVpkDusONxbkM2QhNnBSL8Tf6PN4P83p60GT/ae07w=; b=Rwz4P+w5Od74lVIblNqcFwkzKGpDqNexaqyOrqtkiW69zYsYNz2ElkHRVbg7Sy2A5t11El EXcc0xj9Xd+13qK8yUAMrX9vg/2g3Mi5HH3Uf3LEjlSKt8iHcM9VZpUdoMLmnHvSMqDw51 Cluv7/v+JHaT5FHMmJANRJ2zoY2QK6Y= Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-515-K8zfnhAUOf-pc96-0N45dA-1; Tue, 23 Apr 2024 08:37:00 -0400 X-MC-Unique: K8zfnhAUOf-pc96-0N45dA-1 Received: by mail-ed1-f72.google.com with SMTP id 4fb4d7f45d1cf-56e678f6d81so6404062a12.0 for ; Tue, 23 Apr 2024 05:37:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713875819; x=1714480619; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dpVpkDusONxbkM2QhNnBSL8Tf6PN4P83p60GT/ae07w=; b=Vj+PnTdK+oTrO6Lru+zXxEjxKFAPAKlJTPnkkQ+SYrMlknTxEOkwZ1NmM7/1UwwrEn spBz1+Wtd4lBhcnwb/LFO3A8YQuOn3cECuY8oF2zZrvXYi0uGo0UpJsqKcmJOjHQWlwu NYsJKAAA0qIrZMRWLmUjXgbqqfaTbDdAWwDvJpFqFlAC4oP4xrnl+ARJaBsQyWoBuArU gEeHYiCj4JWxzcC/aCUbDthA9zuLO91ezyDPLstXLH2ci0dKv2lOS0IqpNAU7Le2Eut3 ss42M7IWLl1+RvDb0XNP+lwJXSiQZx2NIjEugEu/jrQfFv0ozycUNx9K13Db6lYBjLNz 8EEw== X-Forwarded-Encrypted: i=1; AJvYcCXXHEpW86gWbd2yB/esZUwAOuno1SretDwZCZtP8SNrOIri45nx3iteZ8DjKyrGXFzhUBZqakl9mvJIB1tG/05cIBYgTgSQsSii X-Gm-Message-State: AOJu0Yzn5PzZDOMIw1pLj8Juhsi2gefQ/X0ANAZd4iVe/eiDsZXL7IEk joeKgdNdczkWqIB8R/b+yO40OzRjhcRn1EH3CC2SsvmiDPY08nk+A3Ldh4QV5jbdbGc1iK8QJV5 X2hnTda2cj2kRVWzcyjpFDAvxve9RDlFZGHxGFRjeaNCLi6IM2z3QsShk X-Received: by 2002:a50:9e8d:0:b0:572:1c21:1937 with SMTP id a13-20020a509e8d000000b005721c211937mr2662199edf.11.1713875819351; Tue, 23 Apr 2024 05:36:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/7MkF0SXqSifaAQkbxR8qkm5vtYzqqmVZCAwNi7LzWk1grJKM6pe0lEfswJ5jejvGOiVUeg== X-Received: by 2002:a50:9e8d:0:b0:572:1c21:1937 with SMTP id a13-20020a509e8d000000b005721c211937mr2662168edf.11.1713875818823; Tue, 23 Apr 2024 05:36:58 -0700 (PDT) Received: from thinky.redhat.com ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id et3-20020a056402378300b00571d8da8d09sm4783170edb.68.2024.04.23.05.36.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 23 Apr 2024 05:36:58 -0700 (PDT) From: Andrey Albershteyn To: cem@kernel.org, linux-xfs@vger.kernel.org Cc: Andrey Albershteyn , "Darrick J. Wong" , Christoph Hellwig Subject: [PATCH v5 4/4] xfs_fsr: convert fsrallfs to use time_t instead of int Date: Tue, 23 Apr 2024 14:36:17 +0200 Message-ID: <20240423123616.2629570-6-aalbersh@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240423123616.2629570-2-aalbersh@redhat.com> References: <20240423123616.2629570-2-aalbersh@redhat.com> Precedence: bulk X-Mailing-List: linux-xfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert howlong argument to a time_t as it's truncated to int, but in practice this is not an issue as duration will never be this big. Add check for howlong to fit into int (printf can use int format specifier). Even longer interval doesn't make much sense. Reviewed-by: "Darrick J. Wong" Reviewed-by: Christoph Hellwig Signed-off-by: Andrey Albershteyn --- fsr/xfs_fsr.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c index 3077d8f4ef46..02d61ef9399a 100644 --- a/fsr/xfs_fsr.c +++ b/fsr/xfs_fsr.c @@ -72,7 +72,7 @@ static int packfile(char *fname, char *tname, int fd, static void fsrdir(char *dirname); static int fsrfs(char *mntdir, xfs_ino_t ino, int targetrange); static void initallfs(char *mtab); -static void fsrallfs(char *mtab, int howlong, char *leftofffile); +static void fsrallfs(char *mtab, time_t howlong, char *leftofffile); static void fsrall_cleanup(int timeout); static int getnextents(int); int xfsrtextsize(int fd); @@ -165,6 +165,12 @@ main(int argc, char **argv) break; case 't': howlong = atoi(optarg); + if (howlong > INT_MAX) { + fprintf(stderr, + _("%s: the maximum runtime is %d seconds.\n"), + optarg, INT_MAX); + exit(1); + } break; case 'f': leftofffile = optarg; @@ -387,7 +393,7 @@ initallfs(char *mtab) } static void -fsrallfs(char *mtab, int howlong, char *leftofffile) +fsrallfs(char *mtab, time_t howlong, char *leftofffile) { int fd; int error;