From patchwork Wed Apr 17 16:16:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13633577 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 5B264148830 for ; Wed, 17 Apr 2024 16:17:00 +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=1713370621; cv=none; b=papO+OVD7UMtL9TijcwI9tsHuh2n4UHnupGtYkxu1hUQ4liLjN74Lres8rU0dVemyu+rdfv0bFGr08lbIgaHpLUYbYkcNaLF6EistKXgccoiJlcUsdu+M1yEI0qXhqAu2BeUJmY0dNdLnUmceuktzu4YeXXZr35oLZoPraIYXdA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370621; c=relaxed/simple; bh=jmZs/Rr2TbNGy6bBvx9C8vRsEg9yWJsR7UB0d/WoXME=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DHw+4OCiJVYT70tZnys9YKm8CaQz5zLG4IHGNDJ2SWruv7wcvaYF6tzVYYAzJVErm5uo2mU8VHD3fB+5DAlOje7VwVZt5YLgU946ugUBzddBUzvJwY/dp677mwBhfSkG3z9F5rKxhND3VyXJouYNgGtCT5jHIfsXJxq1Ug2/Blk= 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=JPuT2GF3; 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="JPuT2GF3" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713370619; 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=ucrPlEEwO8wLfQcM1iZ0iG+ppc3j8g0VWITOSvUHp3o=; b=JPuT2GF3XudHzzbxqW95KcmDDtS27Te5FmKA1noaYCCLs7NBjUZwbUOJHXRQ+aoX5qsM7O v3zXSSzmRGORTZSbujYhGtoQSE20P11Yvhq91FrW27dOvNd+b+jKDcf0D+JmC/VzjszYAN 9aKnqSOwk04X0T/ULNMQJxCML0Z+H4I= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-492-9s9yLXSOMFyRGmIV3vrm8w-1; Wed, 17 Apr 2024 12:16:57 -0400 X-MC-Unique: 9s9yLXSOMFyRGmIV3vrm8w-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a51eb0c14c8so270008866b.0 for ; Wed, 17 Apr 2024 09:16:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713370616; x=1713975416; 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=ucrPlEEwO8wLfQcM1iZ0iG+ppc3j8g0VWITOSvUHp3o=; b=uBYvE9ksVtClCexJuVPSwWqnvWnkBdrpVdI1ZXWesURB29xeqAwk0E0cVZjweAsxS+ l7A1PPxnkMhb3Ft6pIqBbdEAfUwjNpHT99mdUIJhWIOvjVVetK66tXMSVipCGKQ6YeEG 8CyQqYXFIfkYGdh0SMDfHhFNa5OeOdzChs2Jz/lne8yOBVBaU7rFjriQtpim3bXWftrL ZIXwBd19hTf/WYMagKDja4Y8ej3zxex3PvutQ6sZN2s+hDIprsopfH8Yn969xPbljCtU 3XOREHdnEa0xWt8p2wKdZKLbXoUe4uf6+kMTFFhgxZdiM92i+3omO7ME6Y5py8Vxy6/S X3ng== X-Forwarded-Encrypted: i=1; AJvYcCXisJHTERRKMPACx5ZAUI2aDD9XYFHrEZjL0cHRnxAVJJsAL3s+Dlb34P4wFNKEL+1LzrOD16GIuS9GBuShPRxnxwB4/XuVTPLm X-Gm-Message-State: AOJu0Yw+wVNM33m9JQJHTKtZ85LIHLdZFgUi9Z2fihGjoYneM8rDIMIn bZhFmpp0UjLKC2X7AsfSyyuvA5Htv6lhlGeG4S6M0EG7vWbjo0rgXgguDV3J6Fq5yTtD9rUYxyV xXm3ItUrrHBWM0VVChJ5Tgmz5Eu5UsBEfb95M8Y51ynRZ8azxXB0tOKnf5hhlcNAN X-Received: by 2002:a17:906:369a:b0:a55:5504:6f7c with SMTP id a26-20020a170906369a00b00a5555046f7cmr1546514ejc.20.1713370616065; Wed, 17 Apr 2024 09:16:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEFqS0WkbefE2CShW5ylUzUj5B+6EJs5cK3L/Y9ErakLDFZkWdv8w3XXKDVGLErHuRDPK09IQ== X-Received: by 2002:a17:906:369a:b0:a55:5504:6f7c with SMTP id a26-20020a170906369a00b00a5555046f7cmr1546490ejc.20.1713370615494; Wed, 17 Apr 2024 09:16:55 -0700 (PDT) Received: from thinky.redhat.com ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id p4-20020a17090635c400b00a4a33cfe593sm8272427ejb.39.2024.04.17.09.16.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 09:16:55 -0700 (PDT) From: Andrey Albershteyn To: cem@kernel.org, linux-xfs@vger.kernel.org Cc: djwong@kernel.org, hch@infradead.org, Andrey Albershteyn , Bill O'Donnell , Christoph Hellwig Subject: [PATCH v4 1/4] xfs_db: fix leak in flist_find_ftyp() Date: Wed, 17 Apr 2024 18:16:43 +0200 Message-ID: <20240417161646.963612-2-aalbersh@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240417161646.963612-1-aalbersh@redhat.com> References: <20240417161646.963612-1-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") Signed-off-by: Andrey Albershteyn Reviewed-by: Darrick J. Wong Reviewed-by: Bill O'Donnell Reviewed-by: Christoph Hellwig --- 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 Wed Apr 17 16:16:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13633579 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 802A7147C9E for ; Wed, 17 Apr 2024 16:17: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=1713370622; cv=none; b=kNjeRQVSgw9SAJQbS9L/h2O94gY5evpnWQHH8k2V7fj7oHAYPWf22ewMtlH1LARWNaJXIgHoxR+nFaV8vvqDPIyMcY9vDLZzdFTytA8GFievfXyahiZStS6LKVMuTSjv6Rx6KrWb/Cmr88Pc9DXNzVj2yhRHwee2wCqCZtjqSN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370622; c=relaxed/simple; bh=fV6Ft5BaHumro5racGCNpoSd28ETk+SAa+W4S/Qp7Tw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hkCEph+0ZDo8Ny3/yG9y7cP/cB+ABKrVCieSVOLMcpvfI7HLzYDfYj0mFoHwRZFwRaVFBf0WPF6ZzduOeSeYzxhR8GWsIQiSncd7qvO34yxNl01er2IPcsPJDwfgAQDTRRQLV2SWHv/e6C1nBjTU7s14dE7m6ayXJyVLJgNpGdk= 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=StstT+62; 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="StstT+62" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713370620; 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=pK0mBNkkQbwyPGTqCU/n/p4EAhVFXvPO3aXIVRD95Fw=; b=StstT+62oihaBwaI83mnAYdSE61g4Ewmdysd3Fwj7Vv3cy4V7yJ7ioWFe+KusiOoxn2l1J AV6Herk7ufCXbTICSN1lpROOo8xXFkKdH3TkcXvC0ojHr6zV2TKrZxOaV7HNQeewdKgKds ZkmPVC5+9E12hF6sjW4wiV5nusYCPDM= 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-101-1iywr5M_NWWUl2gcSa-ZlA-1; Wed, 17 Apr 2024 12:16:58 -0400 X-MC-Unique: 1iywr5M_NWWUl2gcSa-ZlA-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a5563ef10d4so31796266b.2 for ; Wed, 17 Apr 2024 09:16:58 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713370617; x=1713975417; 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=pK0mBNkkQbwyPGTqCU/n/p4EAhVFXvPO3aXIVRD95Fw=; b=YgRmLnFRk5BdBuHz0CdXsPGCYucQK/KHkMjKLa/IqnStV8lxfdOe/08HflibZnsVaF 7EKTFB0gYCqHXS/sGnx+83CdiIKfx85IWeqbyDQXgjZJ1CIT3XkE2A+i4rdnILhVOavF YxsDt/w6T0R4q3L3lSChmxSgUFD82O1Ihkdgn1AXRH7W1ZZYoic2nzKWzLTQXj+FQCb4 MzOmtIVElD+qc4yfB3Reyl2RCblSzm+66DBqVeXP1zEEIbmt6+jAlB+0G2OPmx80sp+M 79rr6SPGh1LtfUqwyvRxoKf1DSwbxgvawFVqaHyFybcFrAyKN3mP4YcJnKe6tv3inX9Z W+Zg== X-Forwarded-Encrypted: i=1; AJvYcCX6SWe9r1hHZuAnxBF46KpItAbKzdZeTeUfGuE2N7dmKKaDo6Dzz7Ra1vlIjKop5fvE/jrIi0XOuwe9zNwpXOJPcRhOkyGCoIMb X-Gm-Message-State: AOJu0YwOIaeKOrvZUtkWyXeZn8XUGftASlhdSR4ZhIxRPG112zqgzKae scnoJG8JkMDTcdCivEA9J7AQN5atOBjE+qfUWk2NgHadnrteF9wFrvClw9Ior53oWmYeqaR6rAN oTRKw605oLGmqpDfMrhVRrMqKNp3NN4IKLyAdFZRF6NgzqMgv6qNNYubh X-Received: by 2002:a17:906:d9cb:b0:a55:66d2:95d8 with SMTP id qk11-20020a170906d9cb00b00a5566d295d8mr444980ejb.48.1713370616933; Wed, 17 Apr 2024 09:16:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHbCiF5RC28A3hpiS/QDTvemBc2GDyLulGIChVtCCZuYBLEE/6P5Ki+fYr6wjgJxjUhkkhcoA== X-Received: by 2002:a17:906:d9cb:b0:a55:66d2:95d8 with SMTP id qk11-20020a170906d9cb00b00a5566d295d8mr444956ejb.48.1713370616480; Wed, 17 Apr 2024 09:16:56 -0700 (PDT) Received: from thinky.redhat.com ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id p4-20020a17090635c400b00a4a33cfe593sm8272427ejb.39.2024.04.17.09.16.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 09:16:55 -0700 (PDT) From: Andrey Albershteyn To: cem@kernel.org, linux-xfs@vger.kernel.org Cc: djwong@kernel.org, hch@infradead.org, Andrey Albershteyn Subject: [PATCH v4 2/4] xfs_repair: make duration take time_t Date: Wed, 17 Apr 2024 18:16:44 +0200 Message-ID: <20240417161646.963612-3-aalbersh@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240417161646.963612-1-aalbersh@redhat.com> References: <20240417161646.963612-1-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'. Signed-off-by: Andrey Albershteyn Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- repair/globals.c | 2 +- repair/globals.h | 2 +- repair/progress.c | 7 ++++--- repair/progress.h | 2 +- repair/xfs_repair.c | 2 +- 5 files changed, 8 insertions(+), 7 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..71042fbbfa4c 100644 --- a/repair/progress.c +++ b/repair/progress.c @@ -268,12 +268,13 @@ progress_rpt_thread (void *p) _("\t- %02d:%02d:%02d: Phase %d: elapsed time %s - processed %d %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 Wed Apr 17 16:16:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13633581 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 DAB16147C9E for ; Wed, 17 Apr 2024 16:17:01 +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=1713370625; cv=none; b=CNOgVhWKzWsdS+ImO1boOVyHNUPhmIXOnsaigwJ9c+cigZOUoQiHYqhym0awIPcVayUWCVhw7a6dRsANAs4gHiU7u+jPI2ADdei6krDnUHz2ya9+5Cm9kfP2ZCvWJGd167ZTzUJqDF2MddzyZggLZ0kr5W9kN4FxhTHRI9DFtWY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370625; c=relaxed/simple; bh=QHbXu60hIYPcu2upLEJCNpbT4ZuJuUjUD2HLvj70emw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JaTfELN0vq/Wn9IUxQXCDIRjO7vYZx9u0GQqkPfOTVhaCdedpi1HbhFShF4u5LEDPYSIwcO0RAIo35f65BGnakJhUnPeldRRn/W8ALbRMwytzzLdzPCdHDsBpnhErO+G2u9GncIGdzyD0lGwFDgkM/CuGfW9swrgRBgvtHkWoYg= 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=b/dyuUaA; 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="b/dyuUaA" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713370621; 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=yVo/jy69JZgmk6ipt44yooon16rXmwikx8HeguITUzo=; b=b/dyuUaAoRIVgnGRT+xOi8+YxBxA5K3qdSn4oqf2f0EdYZ2L6OsvR2eW5l6HDjT5Bd6/6s JCzNJwmevc765kZH2NU3Aqx/isNdRVdLrDVBkXZEIgvxRhk2zbUocOBX0PV/qPRAeGarBN e6ToDZEJX/+So1Mx6dvP9hPuxbIZWGE= Received: from mail-ej1-f69.google.com (mail-ej1-f69.google.com [209.85.218.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-526-9nr8PfHwPLuv03GlmVlJqQ-1; Wed, 17 Apr 2024 12:16:59 -0400 X-MC-Unique: 9nr8PfHwPLuv03GlmVlJqQ-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a5190b1453fso436918766b.2 for ; Wed, 17 Apr 2024 09:16:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713370618; x=1713975418; 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=yVo/jy69JZgmk6ipt44yooon16rXmwikx8HeguITUzo=; b=rBU4lfszz7orkt4e1djK4X+SwKBtHpWT+3dlSoSBo/NQe5cZ94o+yUgtpvFV6mHASK Cwk/P8BztWSOlhyIwzwV1PpL99SbsiasKkPgW5QC9cG70eqwGX79tY5XpHoGKJrxEyby S3bvn+UZCJy4FHGUat5L1wQ/+HejhZIDiqptlWw3FEvvOTMV90BRC+6GpMHY5kz1WIKP SZjLSm31maVpduwuEGXnp4aQTT7xsp24LSivN4tzcA2sncKdF5oOBF181r5vUxn9xtmI kn883wIUjXy3aSX0AuYrnc9hyPoNVu0yFZmGC6vUjdnnRTHFSA5RN13PEhqmtpauVcv5 F8cA== X-Forwarded-Encrypted: i=1; AJvYcCWqQUY17T/3ZjgwBW/nNQmWa/RAN/ZwPrqGHxaurxTfnXitZ+Y+TIHGYQAsIJIF+vboZDgGu28JcP5Aw5qEmpBMOtk4S/NseBW/ X-Gm-Message-State: AOJu0YxAlkA1l+EUxTm/H2j6oNzbsOaO3E4e9GMLn0VhkmQUwaLVYSN3 RJOWGLmPpnWqurgMCQ+AisWdcbn9ANdrkDQGj7p0kT3Qtpn6mnKXwyJobF8+mRgYNmy19mNjT0r G6Kq+Haf2Oz+jNCvEGDmPGYCMbRBQvPJbFIl7iGwgaoIGOSiDQ2Czwr0x X-Received: by 2002:a17:906:3c4d:b0:a52:28ba:2ce0 with SMTP id i13-20020a1709063c4d00b00a5228ba2ce0mr9803913ejg.29.1713370618033; Wed, 17 Apr 2024 09:16:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGaK62uD8GPwojt7NXkSkjuz2UK7J5F6Xr2kth4oPykFRYqeD4KDzzTQbNjlCs+orwMaMAL2w== X-Received: by 2002:a17:906:3c4d:b0:a52:28ba:2ce0 with SMTP id i13-20020a1709063c4d00b00a5228ba2ce0mr9803904ejg.29.1713370617655; Wed, 17 Apr 2024 09:16:57 -0700 (PDT) Received: from thinky.redhat.com ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id p4-20020a17090635c400b00a4a33cfe593sm8272427ejb.39.2024.04.17.09.16.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 09:16:57 -0700 (PDT) From: Andrey Albershteyn To: cem@kernel.org, linux-xfs@vger.kernel.org Cc: djwong@kernel.org, hch@infradead.org, Andrey Albershteyn , Bill O'Donnell Subject: [PATCH v4 3/4] xfs_scrub: don't call phase_end if phase_rusage was not initialized Date: Wed, 17 Apr 2024 18:16:45 +0200 Message-ID: <20240417161646.963612-4-aalbersh@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240417161646.963612-1-aalbersh@redhat.com> References: <20240417161646.963612-1-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). Signed-off-by: Andrey Albershteyn Reviewed-by: Darrick J. Wong Reviewed-by: Bill O'Donnell Reviewed-by: Christoph Hellwig --- 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 Wed Apr 17 16:16:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13633580 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 2633C84E14 for ; Wed, 17 Apr 2024 16:17: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=1713370624; cv=none; b=CDI6q8DhRbTJCpGKIi7kf3wHfijbvVZXIw+01JxsxCDiFkJaWkdUamLDh6UCxpr7q3GAu9ZL1NUrLd18/pGXuLaBl9Pt2dhed/7jT00N3AGZDbYF5X5cbfeI/EtZTohobV0S3G0xaitqn+wUSoRXdPOjVcuONra0nT54V38unbQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713370624; c=relaxed/simple; bh=uMgraw5bUVp/cLxtj0YcV8Twzxmbu/wm01VBfpRRFYk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W6BmLUSmAGJi4wpS96n3SSdPPu1XQjZ5jlSRuVtG3X9tdN+RFwpIP9ix11GrnmDV0A81DfncLXpA5MQ2i91z2ocaa5DmdL/TQadX7iDJ1dtNtPLcf8fiB41a0W7QmVMDV2dpj+f2l9oMgI7UAC9A7lDR9xuMQg1ZqoOzv6LmBvk= 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=TkZkWRRt; 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="TkZkWRRt" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713370622; 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=Mz77ZZV+ybkygcmEc8at/ITTnBHjlPSt3K+grgoD21o=; b=TkZkWRRt9t9bShjI7SdILJ+UjsVDXpVdAjhTIOIgV6jWDRUv9omQjbFTr0l0dReLHVduow xAcw5h3sC88uWu5fYwzC9nWoKZy2FZrl8m36DeA1iPaZRO0+87gt3soT1SCmoPi04o6dwL ZY6ifvTFMmHxpB134rB91fhqwn4CoM8= Received: from mail-lf1-f72.google.com (mail-lf1-f72.google.com [209.85.167.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-295-eP2ToRVlMIO0lQinDSnwsw-1; Wed, 17 Apr 2024 12:17:00 -0400 X-MC-Unique: eP2ToRVlMIO0lQinDSnwsw-1 Received: by mail-lf1-f72.google.com with SMTP id 2adb3069b0e04-5195b8410d7so327218e87.2 for ; Wed, 17 Apr 2024 09:17:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713370619; x=1713975419; 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=Mz77ZZV+ybkygcmEc8at/ITTnBHjlPSt3K+grgoD21o=; b=K637G5FWJodUw3YonJPHA5oSJbh6K1HAvf33k3HTNKzy07GOKacfPGwMRFnnaYcDIc xpdJIsV9LPd7jKxyun4NkIfEUHJO9HcIGQfWNhNAHnyTWFLlOWRzUF6rNDdZjufyk5WA CnrAlATyRSuL97TQpYkky7/y73BLXDagd11Yv5NueI9YNca8PJYaZ1zfxsxE7copD1xu XCdJLtKpAKpaxMsvk0E+Ie87s+dvrtFzQWJqFC23Us/XX7N4k+hFL49JhCFU0C3/rlok rlp79QBY71iukq02rrx0v2bMQVSF4uX3er4leeWaI7ax3FiyYt4+zjD2Ccky6Kn5533H Ixjw== X-Forwarded-Encrypted: i=1; AJvYcCWHcS9zgvXxk8BzTpS7HZ5WeLaSbWWUucW18LIvDR6qZeZJhOQa9m+ck2llDhZAj9/m7GvkbX3q/5Q03KVwNCfLVoRxWih3vOwR X-Gm-Message-State: AOJu0YzVFPCpIyP0hSfxN/RUjDpUIlSXEdRenqSppGWhTN71hKBVJ5DW gI0JpzwlwWEwV8GkqQyP4AOSsaFuq5Cd3YMIgH4BpD4tgeFHWi9xdDtSmwSMmdXFbB45fwQqeaq gvbinD9Xpb9PHHUB4a0KE9GDltEaoF9x01n2qGZgifihskq5EnrRtzodt X-Received: by 2002:a05:6512:3f08:b0:513:23be:e924 with SMTP id y8-20020a0565123f0800b0051323bee924mr12732771lfa.59.1713370619042; Wed, 17 Apr 2024 09:16:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGEugluNmslbr8t3BlW+16PH0RxhtFQo8HcOPPO9eDSU5VzzvJbzBxpRuoZAYx3T71IK8ZGlQ== X-Received: by 2002:a05:6512:3f08:b0:513:23be:e924 with SMTP id y8-20020a0565123f0800b0051323bee924mr12732746lfa.59.1713370618473; Wed, 17 Apr 2024 09:16:58 -0700 (PDT) Received: from thinky.redhat.com ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id p4-20020a17090635c400b00a4a33cfe593sm8272427ejb.39.2024.04.17.09.16.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 09:16:58 -0700 (PDT) From: Andrey Albershteyn To: cem@kernel.org, linux-xfs@vger.kernel.org Cc: djwong@kernel.org, hch@infradead.org, Andrey Albershteyn Subject: [PATCH v4 4/4] xfs_fsr: convert fsrallfs to use time_t instead of int Date: Wed, 17 Apr 2024 18:16:46 +0200 Message-ID: <20240417161646.963612-5-aalbersh@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240417161646.963612-1-aalbersh@redhat.com> References: <20240417161646.963612-1-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. Signed-off-by: Andrey Albershteyn Reviewed-by: Darrick J. Wong Reviewed-by: Christoph Hellwig --- 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;