From patchwork Wed Apr 17 12:52:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13633271 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 89DB7132803 for ; Wed, 17 Apr 2024 12:53:02 +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=1713358383; cv=none; b=ljHxgc7R0GtFRNGN15c1lvpTqmCaFUIykdTlBqP5P8oRof44tKO+xaYfVRsgPLIm/YJ2joNIMyTwTwStoOjNO1rStnBD8/GU3KZV4zgDiG1H1Ohlcy4YlxgLVE6dSd2L7KfvBCFJPFqqfYGDpEBOHAPBHBir6kqR+MKaM5v5zsc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713358383; c=relaxed/simple; bh=BXFADOllrM1UVBKYRuTMUGphNwRYGkcECWf3FM7Nekk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=YrTpPP3i//OeECtF7oQfg4DqvCy1NVTvnC6/7N2PZRIubM4fVh23AEM2fBKyVN0T6FDxMKEU2mFpa4RbW+/b+a3sc7HIkSDZLIutm0xcQ2Xrl7ePoa3D3dvan5cV0HpXkZ/reCyiZaY0JuVjYNUuzV+RxjVlPcwpXF8S3yx2wCE= 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=SbzVZQQl; 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="SbzVZQQl" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713358381; 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=5lSe+S7OK8mtqrgnzypf5LaiZywQ+Xf+tz3DhSkUCjo=; b=SbzVZQQlim5s58VScOtVsgWtULL5R5QupndoNbx6EeT7by89OFw0DylfaSzTFsVxSCVEbQ vYp9RJY2px4SlUzb2JXXbzcgiFhBXRxhL03yjEnxoCfhiuznzZRAwPJvPKdWQHvcBVr3Ea 4vL5id6Rrr0tm6N7LtQVZ6/uMHg9aRc= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-132-WZrgp7irMziG9I4NguEhjA-1; Wed, 17 Apr 2024 08:53:00 -0400 X-MC-Unique: WZrgp7irMziG9I4NguEhjA-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-516d6c879c5so3133091e87.3 for ; Wed, 17 Apr 2024 05:52:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713358378; x=1713963178; 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=5lSe+S7OK8mtqrgnzypf5LaiZywQ+Xf+tz3DhSkUCjo=; b=OrSKdrtuLTGccP5TL0QshHg12eLo0FBYq4m43D6XL8dXoANa81AcEDsrsplWh1NWuT eUqR2j+/vpYk8K+spOKh9t7jxPMAOK4M2AndAMsAd8u3eDVIhY8pCBt3IUJ/l0hqOHgY VqWClSwXSp4ZIbhs68+gR4Xv1E/mFa1TuN9inXtDY2Nv5uvD1gOo3KmFGMSLILKSC0vh CaM/YZ08j4+MGfRxm8NOC2nY49+2PIsqw/je4XAlZBAHPgT5wi8l4ijO/cM1P3P9eh1j VewkobF6ISimvzgGlgkFUtRiP2+jxJLCZys7XbpayZoW1ZUsiZSwYV4nLj2o7bFxpGuM BOjQ== X-Forwarded-Encrypted: i=1; AJvYcCVu9aVIK9XZjAzkNNjqCRlgORIh3KQAYcZStXJoGUqJEYI/JomJ7iu5SUwph1C0XYL4r2YLYTxpgTCbCfc3Jz5BdxbAgTI5CagJ X-Gm-Message-State: AOJu0YzP8R93O+S/0aWpnEwYZCJnXFpudpDsEbfA5ESPHrst3+rcyR1V o5DHJ0jOHWCDIc+ntXdsOdIwa0THvvxOxujhpmvkdPwJ4/IjcSH2Or+FnGggi43VUARCl53O+y7 uB+JnlgHcpYfkM/MrVxKRaFjxY+SNkkIoLZ1Z9/M9w1ultEGyFeUw/tiNrJAsZCKx X-Received: by 2002:a19:740b:0:b0:516:bea2:5931 with SMTP id v11-20020a19740b000000b00516bea25931mr10263698lfe.23.1713358378274; Wed, 17 Apr 2024 05:52:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFRScuA2VAP7ngevppA1bCXvDvhNpTMhkk2Oams0lo/+fWB3VtzFnlY8GdAlsDUJLArpl73aQ== X-Received: by 2002:a19:740b:0:b0:516:bea2:5931 with SMTP id v11-20020a19740b000000b00516bea25931mr10263678lfe.23.1713358377697; Wed, 17 Apr 2024 05:52:57 -0700 (PDT) Received: from thinky.redhat.com ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id en8-20020a056402528800b0056e2432d10bsm7258169edb.70.2024.04.17.05.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 05:52:57 -0700 (PDT) From: Andrey Albershteyn To: cem@kernel.org, linux-xfs@vger.kernel.org Cc: djwong@kernel.org, Andrey Albershteyn , Bill O'Donnell Subject: [PATCH v3 1/4] xfs_db: fix leak in flist_find_ftyp() Date: Wed, 17 Apr 2024 14:52:25 +0200 Message-ID: <20240417125227.916015-3-aalbersh@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240417125227.916015-2-aalbersh@redhat.com> References: <20240417125227.916015-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") 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 12:52:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13633272 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 89DFE13CFA6 for ; Wed, 17 Apr 2024 12:53:02 +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=1713358384; cv=none; b=fkeWm/Fj3/UVL15XHys3H1RdIayJxPM9WG4aEMvGdU5+/Bbb19fbKXvLwtkKV7GZeZsaJRlq3fEjQYDci4/Y4HFmDetegKLi+/ZYNBzSVnMU+ATC9TTn4aubuSRDoi3gSy3haTwbYGJabvEltTXKqGwr+tNzyzH2DoihT+kmtBM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713358384; c=relaxed/simple; bh=C5+iz15Iw2env74n4pq0MNv1b4Sz+flYCAOmRifMWCQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dCEWVdu6lKwgqiBCZc98x7GNNTsxXh3FEot9mJMj4NaHsHE7nr+pP5tthMJqpBd9+B85eFOJUkgn1A+G2fgYZJrMVwfBdEfsQGgASceXQSxXGDuv4Ui0pte72qFy69hhnLBWtXQUwHRurOFlCzl7uaPX+014vtPSwvpTslMx/Jo= 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=AiXcxQkg; 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="AiXcxQkg" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713358381; 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=5tUSmPSFguzDZMGlK6GyurAr+DFBgPGYwHDlJ6OTWto=; b=AiXcxQkgXkDsnkU+pyVmrxJg8IBuh/X8azMgLePbUqm+4UcAcL0mVDM9WV46E1jixViwp1 9X8quZKtHunVZvPp8OJkDFzDuHZKRsVVIRAJg4LG+vDGOsZvjuyVyPM+HCXd7LFSLrTfbN /Bmb9aGm87WWzYir0dZ7kgkTulR5e+c= 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-516-QnrTqCucNAWsogLr7zl_Iw-1; Wed, 17 Apr 2024 08:53:00 -0400 X-MC-Unique: QnrTqCucNAWsogLr7zl_Iw-1 Received: by mail-ej1-f70.google.com with SMTP id a640c23a62f3a-a524b774e39so101502966b.1 for ; Wed, 17 Apr 2024 05:52:59 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713358379; x=1713963179; 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=5tUSmPSFguzDZMGlK6GyurAr+DFBgPGYwHDlJ6OTWto=; b=hX+gyXBVTIZNwdqk98Uhp3uOjhri0SmU4tByhKVcLPqoT2BdXym2nYjjNiRy0yTOeQ by2Df+VNsc7L5/SfkiEOFcz+bdYjeuICnc8wz5+0OVzO/pdw5xrguWTLPLxxObyPbaTl yLvolYwDdVzbposiRkqxIWmQJVAJ79X+T0iIpkwBS5M30Fv0DUjgQWGU4T+6ti9AErTI HN6v9okG+qhc3JDbQn3u1ojckbB+2QN3d/VwdlaxbPr/TdZYdQg84Xtvd8L0DgHOaunc EVQm0fbGPTtclkyWdFom8SzZrYvJIKU4A4OTGKa2PCXI0SPjYnIj3LV67TbKXTOqPhMU SfWQ== X-Forwarded-Encrypted: i=1; AJvYcCUJp/788bKruAWPsNuG9bVDqR655d481T79Rn0atkudpRcClEUGk0d0Yql95XLMGuo0dPjIYt1U5+9e+wtIgAAcKKFlUPMdcYmw X-Gm-Message-State: AOJu0YyweLlEr3N4HR44hhfgTmPTGyDz4v8tcq4ZevFue7q44YHNP7hI mbsEObIZUd9cozxLejY0I5KbuDMbTf7qXxGjlqP/okeLw/7uJvlkAd9NLOMb+iVX6AAFJLZXYWo d36u+n/zekTJfRC0hiVBLoqaPVLV1vlMkhgiAKY2+ZiXfDxCCicbiI8iU X-Received: by 2002:a17:907:320a:b0:a55:58f0:5684 with SMTP id xg10-20020a170907320a00b00a5558f05684mr1669742ejb.28.1713358378821; Wed, 17 Apr 2024 05:52:58 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGpg4qHDB3hZFz/VNSl/YyH53PUBFMXK7paNr9sNEVr5/V0EWo8s/RwMvSWOwB1TlM/RJhdPQ== X-Received: by 2002:a17:907:320a:b0:a55:58f0:5684 with SMTP id xg10-20020a170907320a00b00a5558f05684mr1669729ejb.28.1713358378345; Wed, 17 Apr 2024 05:52:58 -0700 (PDT) Received: from thinky.redhat.com ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id en8-20020a056402528800b0056e2432d10bsm7258169edb.70.2024.04.17.05.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 05:52:58 -0700 (PDT) From: Andrey Albershteyn To: cem@kernel.org, linux-xfs@vger.kernel.org Cc: djwong@kernel.org, Andrey Albershteyn Subject: [PATCH v3 2/4] xfs_repair: make duration take time_t Date: Wed, 17 Apr 2024 14:52:26 +0200 Message-ID: <20240417125227.916015-4-aalbersh@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240417125227.916015-2-aalbersh@redhat.com> References: <20240417125227.916015-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'. Signed-off-by: Andrey Albershteyn Reviewed-by: Darrick J. Wong --- 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..5f80fb68ddfd 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); + (int) (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 12:52:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13633274 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 54D7213D53C for ; Wed, 17 Apr 2024 12:53:03 +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=1713358386; cv=none; b=LVIDaGfz0pgnrwb9kZv7KcH78fhZkxvTFqH+2ahnPnfbE6dF53Cq2IkzO6Vl7k4MzrKhyzYuJRU61HWofkyw7R5ViGfU1ral4jtAZdZbBiENh7kh7s62SQ246Pf9XjaDPOQ9lXTVYqG1bwhWdUQe5izPiUs1u6jyeatJM8jYcvc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713358386; c=relaxed/simple; bh=QHbXu60hIYPcu2upLEJCNpbT4ZuJuUjUD2HLvj70emw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=S3yajnfStMDEc/azesdp42pSKeJ1GpfH7yktIfTF/Sz4g329q+1k6MDuGUCobTrYt3ltz3RQWChoSIdBX8bRLwo3rb16UobMhelXgrA2OyL1+YBGwOPyjUlbJUA294pZJM5/Ne0yRB5LNnQmKj7pE1kOizRfHZaebenR7vpqXiM= 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=hLC2oV5d; 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="hLC2oV5d" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713358383; 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=hLC2oV5dDY74t6GIkQtaFhwm+o7xTcUiIo8APx96iBATklSomG4EBf649kpnMNPR+IlWOL h/QU/V4qe9q9qVlat9lVmGPbYnzbyBGP82CAXeyMYsgnh161HWdpy1M2tZf9KCCyL7S26g lqUj+8Y8ry+N9sGHD/ZLkhIadWAbOkA= Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-139-ShBpjzFWP6qd7pTchlf9fQ-1; Wed, 17 Apr 2024 08:53:02 -0400 X-MC-Unique: ShBpjzFWP6qd7pTchlf9fQ-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-516d6407352so5280907e87.0 for ; Wed, 17 Apr 2024 05:53:01 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713358380; x=1713963180; 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=GE2Cmh4EJA3oURG/ipV1t9hg0VOEPggJT5PB+t2d2IVDAqxwkUjVRhqffFflaIahrK WBaFwYN0O9DX8LXOz4CyvWqIeiA5Wf4XRYDzaSOVyxT1w7O30qyb67Tls1/0AloiS71p FzAZKf2MhU5ZeKanCVyN0KtyIMnqrL5oDdX2xttdurmVBmPGq35LJuSnSyE8HgcaXsu/ bK1gzTFTXNM6AnVANUD+YqNZpq+f63cD3B9o5n9roMh7mE/HkzN14lPOSWWnWM/M878u XHdJt3Tso5LbRDUnCtgddKxP1EUTcg7OUEtRbxGm+ZkjRJyBRxmzQhuOv/RRvrq+WIlt r/MQ== X-Forwarded-Encrypted: i=1; AJvYcCV+FKtHEx//BsHS+Ba1HA0JHvWmtUT3tolzmbcRzFxPlO9ErLXFchAw1YCWnnXPSCViXcTCmNDN+OvGKs0tqQMDgbi7zJIXOVXx X-Gm-Message-State: AOJu0Yzym2p9aMxcAzepjqlGdTMclzDwixLebQzaMexaYXw+DNKqqE9Z nC+6wDZEnrkmg4jRP0011KuZwSBa/hsC7gTZrqWgwcF5BdRChmxVnNaNpDF1JkLc/GpTXAhZsxQ rSTH176lgGhBVMONoVZA4mO08wb6IwNWnWCTBg1+XWEl/sljUcVhO4JXr X-Received: by 2002:a05:6512:1103:b0:519:3a8d:2ecb with SMTP id l3-20020a056512110300b005193a8d2ecbmr2554668lfg.5.1713358379610; Wed, 17 Apr 2024 05:52:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHXT44ukteBDsX7n+bqEUtNqS/qQTWUdPLqsaRmxP5LoZ/jQ4FqydUmt1/Koy2eD2eLvi7FFw== X-Received: by 2002:a05:6512:1103:b0:519:3a8d:2ecb with SMTP id l3-20020a056512110300b005193a8d2ecbmr2554656lfg.5.1713358379140; Wed, 17 Apr 2024 05:52:59 -0700 (PDT) Received: from thinky.redhat.com ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id en8-20020a056402528800b0056e2432d10bsm7258169edb.70.2024.04.17.05.52.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 05:52:58 -0700 (PDT) From: Andrey Albershteyn To: cem@kernel.org, linux-xfs@vger.kernel.org Cc: djwong@kernel.org, Andrey Albershteyn , Bill O'Donnell Subject: [PATCH v3 3/4] xfs_scrub: don't call phase_end if phase_rusage was not initialized Date: Wed, 17 Apr 2024 14:52:27 +0200 Message-ID: <20240417125227.916015-5-aalbersh@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240417125227.916015-2-aalbersh@redhat.com> References: <20240417125227.916015-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). Signed-off-by: Andrey Albershteyn Reviewed-by: Darrick J. Wong Reviewed-by: Bill O'Donnell --- 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 12:52:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13633273 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 9D38D84E01 for ; Wed, 17 Apr 2024 12:53:04 +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=1713358386; cv=none; b=I+Jm/iEhnoOtP+MdEmqoSkVtMw80zxlr374BpuPu1BUfA3uBvg4AD1utvTNRRKJGcllYg7zc+sNOvj9tZJ8boh4vGrKtwyQuQuWpOhsChCwS/iStzjMajDFCC0lu7MqWe95uomp4uqFF2nz+6k9So3HwlaX19fOKMRQr8e8cDOs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713358386; c=relaxed/simple; bh=86mJc4MtN/5Es3MhvKn42tq2qsn+xpUDzaPuadYgpBo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=AHGujbW+mgCimJR8eVVmC+Co46DxapPYetX9D2WsyTih+MUxSP0S5gczl5u/tCk2RnIgweDdJr9Wfqcuo8DNPkxypQAuuAL3/CxUQ+1bvrpZP2TspHJ7J2V/eGvFa6N829Ide1kQOHoE9Wpnec5NjxojZLOxsWt78LEVl+Ufk7w= 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=eEgiJUpp; 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="eEgiJUpp" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713358383; 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=pt1/JfZbYOQg6CpN4sXdw/WCUEY0WgJs4WPpgQycX/M=; b=eEgiJUppSSTIkLagGZDKLRCs/uza+8Gh34E3v82kc7AH+PDVq4/Pfm/5TKpbjaVY6ELvez Knw4Otfr6+z3ktg+7toQ2J+bjnfenjj5QwV5wl5Q1jhgIYHuLaDbg8OboXhIjyLlofsbX+ GYaNBiQ7w+zj+Rj5t8g7A7MoM1fg+9M= Received: from mail-ej1-f72.google.com (mail-ej1-f72.google.com [209.85.218.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-612-76rp_6lNOSuOSCBNteZT5A-1; Wed, 17 Apr 2024 08:53:02 -0400 X-MC-Unique: 76rp_6lNOSuOSCBNteZT5A-1 Received: by mail-ej1-f72.google.com with SMTP id a640c23a62f3a-a51beadf204so304427566b.1 for ; Wed, 17 Apr 2024 05:53:02 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713358381; x=1713963181; 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=pt1/JfZbYOQg6CpN4sXdw/WCUEY0WgJs4WPpgQycX/M=; b=dJXsMQUt9UHoH107/iN3OPW0KX7KExDeTxxtRVip36fC+lPlZliAxm2bigCADlIRB1 rKhqJap1Kxy/XRxzC3qGUOZBTOerQ6RxQbFpD7zAgX1fZtpsZaP9Nip1MFEDpqfilE+z VRLtLLIglkkFoV886eGKd6YOpJ2rOpAi6E7i9BK7DRg5R3ybPYUMjCiRRiiXc6XqkJeK 6a6YQrSm8av2EF197hfuzAvmjrfClpDpWeFkD+Qf4QlnYgfE+piL4R5awR/ku6JNNCNo k0EKEYlENmt1pE/oFkBRCbdUee38Dh8PFiIdD4zu3G61meViLYvZbH1iVmlaDpN3eyfn j4pQ== X-Forwarded-Encrypted: i=1; AJvYcCXF5oS+rUQhkt6m5ThSXpKsolsXTyp0/v8CsAYYolgQoNgu/1tsJnK2ANKvVQWWSR2xnZs5EUWnrRY/YDGsRKG3R/teDrYg+HrH X-Gm-Message-State: AOJu0YzhwM9+gE163wGdc9F6vUio0VBDWFI4mCtMZJDJa/G+PAem0nrl oMQA5Vb11v2WmleZ7JIFQK8eoipscrvNF8Bj1ernHufU9Zo/IyDemQDPgaDN2N4qyqPSnkTR4P6 Yy63/HPtE2BK5jduVkH3gmgDH5y85ops6X2ajRQWb5bY8VZ7rj6QUP4w2LqvLmaFW X-Received: by 2002:a50:a6d2:0:b0:56e:f64:aaf6 with SMTP id f18-20020a50a6d2000000b0056e0f64aaf6mr10376570edc.5.1713358380576; Wed, 17 Apr 2024 05:53:00 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFfiSgXLAOmcyYmGpyFJXPBoMLge1tXqtd/lQNPUXiAhyJrJ+lWjQzC6zl/nuCWhZWrffshIw== X-Received: by 2002:a50:a6d2:0:b0:56e:f64:aaf6 with SMTP id f18-20020a50a6d2000000b0056e0f64aaf6mr10376552edc.5.1713358379842; Wed, 17 Apr 2024 05:52:59 -0700 (PDT) Received: from thinky.redhat.com ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id en8-20020a056402528800b0056e2432d10bsm7258169edb.70.2024.04.17.05.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Apr 2024 05:52:59 -0700 (PDT) From: Andrey Albershteyn To: cem@kernel.org, linux-xfs@vger.kernel.org Cc: djwong@kernel.org, Andrey Albershteyn Subject: [PATCH v3 4/4] xfs_fsr: convert fsrallfs to use time_t instead of int Date: Wed, 17 Apr 2024 14:52:28 +0200 Message-ID: <20240417125227.916015-6-aalbersh@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240417125227.916015-2-aalbersh@redhat.com> References: <20240417125227.916015-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. Signed-off-by: Andrey Albershteyn Reviewed-by: Darrick J. Wong --- 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;