From patchwork Tue Apr 16 20:23:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13632552 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 855D6139D04 for ; Tue, 16 Apr 2024 20:24:19 +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=1713299061; cv=none; b=UTY5eU8DlL86i4HFhO5alR+rZxd1GOnsxDDaK98Ei4iK0H9zU2k/F3AkTBRz3uBF620ZPXxB0BSfgRlcsdyQAkQgvV58NQALw9NXSXROOutytx0RI9aZ0D/OxaFM3ygitiOYNMferBGpEaDK4cBHDXlnMHV5ICcdvxRJRLd1SX0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713299061; c=relaxed/simple; bh=97jwknFT2QGNSM/B8p48WLxBQt5ki5hq6vgfr73ABcc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=B4UWfx1G0WDhMbYfVJ4FVpjYLljvefUalVzRPJWvDgHj1UJX1RpgEaQrBZjI41GyEznYLMw6CnXPm/Z3iFDrOsnNzF8dhJFk+XXoVq5re5pfgh4HIBnb0jXyK2TM0t+Ix23TAVvYzNpTYG4D8n081fKTdHrgCB23AyPiRxD4ry0= 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=SBDO0QRX; 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="SBDO0QRX" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713299058; 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=prY0xi3n/FsFGeqJC4zm+mMUkmD21tId1Sz88Dqht+s=; b=SBDO0QRXeYzWpHbdj/0TBB1zVUwZWoCCOWu3Y/k/5tDhdkeuN1pGzdVdQ+D8JMsV2WGni/ X05qfmS/rJMjwqOV/4PDBQd2oBYTmm7ycRpXWIJ+Vk+B/098qfBdFWAVJFfEst1shAEu9S iB8hsOIZ8E6pV0fq7BUO13dtqhf/vwU= Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-67-K80pkCu2Pg-iSHKlB_tCxA-1; Tue, 16 Apr 2024 16:24:17 -0400 X-MC-Unique: K80pkCu2Pg-iSHKlB_tCxA-1 Received: by mail-ed1-f70.google.com with SMTP id 4fb4d7f45d1cf-56c3dc8d331so3779075a12.2 for ; Tue, 16 Apr 2024 13:24:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713299056; x=1713903856; 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=prY0xi3n/FsFGeqJC4zm+mMUkmD21tId1Sz88Dqht+s=; b=nG2+ozRY5cRSc402lSR6CIKvxhjnhqywimqhdgtGsqWAlK8Gvm3uxUobTvh630GF+7 f23di5qJGFBDbOCEJk2FMkeELyxNZ1282lf2rPP0FGhPrr1iPqzwklSbndk4K80Rgsv6 /ZeAY3w3RPvr0zjKYle8Ls4VjKTMhEU9DsUwWmGZZiiKCiHVKzOdB3vwccsa2sOZQf6m C6djWYDqUt9QVvJ4rEJKOacHh+Q1lk9V3T1jourLEaoUEVRP1BYupC/1Eqvf4hk0+vT6 GIPbMjO1vCKsnfNRPnweGOUNlSWYL1c72+08DT77wRNWw9M9fuvlyqRT9CUJvn75uEzT 4XGQ== X-Forwarded-Encrypted: i=1; AJvYcCXHt9CR6M9CuJbEb+N4mfQ5C7rrpoLJVdWSfZ/dAFbGdLDtwVx8NIW8IUiycm6oknD6RtvQAe2WE7t5jXpobSEL8S9H26Kdivby X-Gm-Message-State: AOJu0YxmoGlR9x7HK4MdHdqKW/TuU7e+czLJe5SE2LdxUn79QZ9RMKO+ paCrPcrRvPpyVMBiRQerVIb0XzqxD/3EaPPYGDey6XWYzFAqfeZ7dlu8UDFtxdPbxVONgSqeHzk jTU8s/z9gylqbvPLKZdC6/2jFNLMba4XopBaFwxW3qX+Q8u3e/wJYy2ap X-Received: by 2002:a50:cd5c:0:b0:56c:5a49:730 with SMTP id d28-20020a50cd5c000000b0056c5a490730mr8938068edj.19.1713299055703; Tue, 16 Apr 2024 13:24:15 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFN04onw7xzoZw2QseyykqfoRq9zAr6de3cxcSVDv6jimvFC0C33/Xddr7mkLXJf+TUpYI7eQ== X-Received: by 2002:a50:cd5c:0:b0:56c:5a49:730 with SMTP id d28-20020a50cd5c000000b0056c5a490730mr8938059edj.19.1713299055198; Tue, 16 Apr 2024 13:24:15 -0700 (PDT) Received: from thinky.redhat.com ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id fe1-20020a056402390100b005701df2ea98sm3655687edb.32.2024.04.16.13.24.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 13:24:14 -0700 (PDT) From: Andrey Albershteyn To: cem@kernel.org, linux-xfs@vger.kernel.org Cc: Andrey Albershteyn , "Darrick J . Wong" Subject: [PATCH v2 1/4] xfs_db: fix leak in flist_find_ftyp() Date: Tue, 16 Apr 2024 22:23:59 +0200 Message-ID: <20240416202402.724492-2-aalbersh@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240416202402.724492-1-aalbersh@redhat.com> References: <20240416202402.724492-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 --- 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 16 20:24:00 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13632554 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 0A0E9139D17 for ; Tue, 16 Apr 2024 20:24:20 +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=1713299062; cv=none; b=ef/qxVC0/uYheFVzLBLZhatRR2qZ27Um0HMfsaOBqnh+2NNzTtq+1ok9FfHYdvdLnpCCe1LCr/oXfl3VT8rOxBR73cRZp7PuBUQycUiKI9UG0xyhOLwXLE99fH9d7PXwP8Y1BXwffDtKOGWVNhz1I/ahxkOOXl1RMXuJWiPU2oc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713299062; c=relaxed/simple; bh=V/tjt0tdFAghHcu3N6R2wKQczfbxfAL6UGZFpH6Ta2M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dC7UbSCgYQvrGGTt4R/yBGchXsT3bpy5weWHLazVVgMUIamj5pzr9QK90RrB78ykae2wCeyzPJrrdLdJ0gwpO6O2T5JoKmJatKekPfkZEs016SHoUmB9sbh6fKeEesB77mb90QNv7mX7eMNa99DiLsAWgEqqxJny/B00j8J2UEo= 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=Z1tdHWei; 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="Z1tdHWei" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713299059; 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=XACU+dctAk7FszI/nYNHcXO931+8urejDikxe9NRQVU=; b=Z1tdHWeiQDyKzcUpiz802usYHAXyTlQBuD26h8U875iebdB4pu1/P5XB9B9fytKHgs8YKc rm9mmpzXGUY7clnLEs4pBz5tb7OkEoszDCOE8XQ88IfPBE1tINB/NF2hT/Z2uM4demPLFT orCtqA9puUiG3sMukFm/8zlmUN2jl98= 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-614-X0Gf3ZHENzaStFX3VTyuNQ-1; Tue, 16 Apr 2024 16:24:18 -0400 X-MC-Unique: X0Gf3ZHENzaStFX3VTyuNQ-1 Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-516de13dd48so3113024e87.0 for ; Tue, 16 Apr 2024 13:24:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713299057; x=1713903857; 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=XACU+dctAk7FszI/nYNHcXO931+8urejDikxe9NRQVU=; b=qkAcKIl2S/czCXPRTH0L2KFW5Skomn8K/5GeZ8RNwZxFjJtA/6BcyaQmjlxVToPDua 30ccD9KOjzmEHOFCbXKLx5JvW9wjzxYzq1iyR5XQlVwCn0ukZ6UXzzcqRVBi/1QIDfPC Sunw22/9O151PFmtv/R8acwnC/dxWmyQ6/oI4iDrcMTzVG7XW9ONGPuNQ8X7gmrDNpss +cgb3bggGU0xdNnAiLyaD8yFolGj+mHezo5bLX0VNQ2Rvsmg6kPHu4nnJNR4AGuC3yCq 25kr7gqdl6vIgAnI5c18eCYxZyjaNuQh5+2m/mkxhkX1dRwy5aS3ub91uFLE7FjoL3lP 1lRw== X-Forwarded-Encrypted: i=1; AJvYcCXBcLgxRG+nA+KznBXjGjD6rreJFRsFTX3l44tdycVyymG0ZstGoliDw3++gveW7SEfLVjIpIa+L8aKNezBvSqSQlmf+S8r4v6r X-Gm-Message-State: AOJu0Yy4FFAbGnZjeKYGvP0pQr+ILYF5G3frTk6VhLZt07h9Q7ffll5p OI4/ANcPqPiWUcr2K9waB2nxiprNnHeSwW0ZHXhAz9thHSFEeWwm7CI2KPlXU1qm2LNCdX7glxA 8a01EWERG5FCcLQTdBjv/Vpro84WdWLnK92Xh9vWtuismj19sSs50MufDqdDIRmtP X-Received: by 2002:ac2:4187:0:b0:518:bdeb:20e1 with SMTP id z7-20020ac24187000000b00518bdeb20e1mr5488855lfh.61.1713299056513; Tue, 16 Apr 2024 13:24:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHTZVLOBZHLFPqI1YfCm4gFfiEE9KaYZ2mZnfEFdAFKwttxNw36W/Rqp+RkRlGCDQNtFbiezw== X-Received: by 2002:ac2:4187:0:b0:518:bdeb:20e1 with SMTP id z7-20020ac24187000000b00518bdeb20e1mr5488842lfh.61.1713299056008; Tue, 16 Apr 2024 13:24:16 -0700 (PDT) Received: from thinky.redhat.com ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id fe1-20020a056402390100b005701df2ea98sm3655687edb.32.2024.04.16.13.24.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 13:24:15 -0700 (PDT) From: Andrey Albershteyn To: cem@kernel.org, linux-xfs@vger.kernel.org Cc: Andrey Albershteyn Subject: [PATCH v2 2/4] xfs_repair: make duration take time_t Date: Tue, 16 Apr 2024 22:24:00 +0200 Message-ID: <20240416202402.724492-3-aalbersh@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240416202402.724492-1-aalbersh@redhat.com> References: <20240416202402.724492-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 --- 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 Tue Apr 16 20:24:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13632553 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 A1C60139D10 for ; Tue, 16 Apr 2024 20:24:20 +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=1713299062; cv=none; b=rMj9qPhkvdSvUDdf+y+qldAbc3QnbSnFPQyJLPpgmyB7zOewtzZ2xImq6kA4IvXAUECrtrXORjf31Wxw8c5ZN7Za2eWkvnm7tzcVC2XMbaVvEAUFL7BlZS8FWe4oMgZFHMqjSgd2et1qObTn8Ifk4HXw4S1V6xERtIcKjtAv0j8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713299062; c=relaxed/simple; bh=/9p8jLxjBvX4RC8/9EQVIoxVTtI4PKoNW7gyJYrNMdc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BbK+VUFEOHXeZxoZbLD0S8O/Zx+T9EYYPfER9w3JLbALOskXOhwMfdAYUkwFC0IE3gM6tP2Fb3fXsgOFSkh3FStMlvjZfSlBgnLPJKecvZdmcheab1pZkBXMY1VvQpj1oJ7OlB2RCH3SRexz2ighSr5frkIJuSMPAk92huXklhs= 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=EffprIyF; 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="EffprIyF" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713299059; 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=5Mo4yrg0kQ03B7AH551uMoxboxf9UooOOFp84HwRh+g=; b=EffprIyFPUQ88I6AtjiGv5e13VmbZYHsG8SjwMAtQupLqMSYrRJxd1U6rmxvm6FkRjN9eT vAXVP4iRz04n8vOoIfPGloPB9Sv8VoI4d8hmJkwtYezAc/Pyciu/KrgV7As26zWzBfiRXt Q/atXnFvd+Cz2tc6zRhBoLiv9s0AtTM= 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-580-91eYyz7YMmy-t70wLdL_qw-1; Tue, 16 Apr 2024 16:24:18 -0400 X-MC-Unique: 91eYyz7YMmy-t70wLdL_qw-1 Received: by mail-ej1-f69.google.com with SMTP id a640c23a62f3a-a51fdbd06c8so392233566b.3 for ; Tue, 16 Apr 2024 13:24:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713299057; x=1713903857; 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=5Mo4yrg0kQ03B7AH551uMoxboxf9UooOOFp84HwRh+g=; b=Tncz565bIo7QiXJ0jL4CMLN2HNw3O+2zk+bRrMw5I+3Ms1OodPb9gko1wnFjrV2eJ8 Vw6k6WeplXGpxBk7vo1bnDOFvtsJqoRVb+T1Dn4UIIDioNeAeEuMFqdmoIvXDHJTCxoT T7kt9/x3ZKDTPPDL7nbN5wDRnobyhwE3ubyQXaQyQKh5NCRQaVmJ24quiGXXgw30IBDr 1v+gXR77ZEMZWbNJhLCXTquCzBLxYK4tz0jA3vFhRBuOqDmfiBO81jzM2OJ9j0W0q9Cl PH/wPmvyAfrGnO430y+Qr+1KnaIPfSS1W4VvoxLnOEvuRAZ4NYNOXCQwbV12+jpdKKcE 6MgA== X-Forwarded-Encrypted: i=1; AJvYcCWvKD0MXyWTh4KGNAR0s6Nq8XsAllXNfAXaFT26VOM+jkGFMOddFnUNCO7GbMGz7gc5I90ixV30KnLUR4c9B9Zx2r0IS4P2tE6k X-Gm-Message-State: AOJu0YwHfqLHA9vhPPRu3sc1BwyngSb8w0rDNlB1Ek7K81pJ0V4Noa6Q EqaApMv72kfr4Z0OmKzDyD7nZRz72alMfwS5SB7Xq8Z7UX7Z8tRRp2GxG+fFhhUFTstgzTEgRQo eghRwEuu1T6hwpizh2jfR7gXddvkAbil1R7LFrilsso7Fwfs5qyETPusS X-Received: by 2002:a50:d75e:0:b0:56b:ed78:f58 with SMTP id i30-20020a50d75e000000b0056bed780f58mr1608942edj.33.1713299056993; Tue, 16 Apr 2024 13:24:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFmo4tzuqSbcGfH0UIulx3m6kCuO61LOXWnLcaBW0JT6ZfPmgxROQ3yI9/E6qupqtBpU4FIWQ== X-Received: by 2002:a50:d75e:0:b0:56b:ed78:f58 with SMTP id i30-20020a50d75e000000b0056bed780f58mr1608936edj.33.1713299056688; Tue, 16 Apr 2024 13:24:16 -0700 (PDT) Received: from thinky.redhat.com ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id fe1-20020a056402390100b005701df2ea98sm3655687edb.32.2024.04.16.13.24.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 13:24:16 -0700 (PDT) From: Andrey Albershteyn To: cem@kernel.org, linux-xfs@vger.kernel.org Cc: Andrey Albershteyn , "Darrick J . Wong" Subject: [PATCH v2 3/4] xfs_scrub: don't call phase_end if phase_rusage was not initialized Date: Tue, 16 Apr 2024 22:24:01 +0200 Message-ID: <20240416202402.724492-4-aalbersh@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240416202402.724492-1-aalbersh@redhat.com> References: <20240416202402.724492-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 --- 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 16 20:24:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrey Albershteyn X-Patchwork-Id: 13632555 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 7860F13A87C for ; Tue, 16 Apr 2024 20:24:21 +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=1713299062; cv=none; b=GSSZX45qt4X+HmN/DtQqzB+xgGzi+zVb4/ijq9fL3JYWApwspy+qajaJPMZKQHYNycf909xF/564CfXvYR4ahcJEg6XGjnhJEa3h2b48DzdjTowznJtd0lrSbvOOdGaMGUC844bygYfMOElGF9Di+j99tUwBc5fCE8eernQLkzs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1713299062; c=relaxed/simple; bh=gle7VWmBPznO5lZOFMUP9sBY5Upvq3wZtt2Re6qobO0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mmBvj8JZUcIfQ8y7cTxz5bxMEKMcUkvJ8/Vi4PXjrHXE8HwuRljAtlB6ri4xmJrLOCapKxtyTth6OpVzZF3fTEoc+mv0zbWnm8jyIlSDYXXehL0cBTz/H4kN8ct5/QMP48Eve7F7NC8FRL7RHgFAgEiSbCLrzuREVS6HSGu01lY= 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=RcZC3Hi0; 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="RcZC3Hi0" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1713299060; 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=r1nUsgIEwvUZY/Y7sKjmmu2jqnXOcwZbDo8j/OXZNko=; b=RcZC3Hi0pB/Zq5gVa1n5N9L0LlPc1cEbv1hw6c64lzWgV5Hd+/c9SddB4zCGhnwArdALhj 9ABdfTy3WJDTYQhc86WdHCFDvCbVIeOnbk0+HEfZbxmYcvtxb0ox8NQywExap7qeFxlwhT CTLdtD+jA7+74RMyX5xRPifATEDB7zM= Received: from mail-ed1-f69.google.com (mail-ed1-f69.google.com [209.85.208.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-385-GtaLcJtCMFiEgPw6Qe_o7A-1; Tue, 16 Apr 2024 16:24:19 -0400 X-MC-Unique: GtaLcJtCMFiEgPw6Qe_o7A-1 Received: by mail-ed1-f69.google.com with SMTP id 4fb4d7f45d1cf-56e573582b9so1597298a12.1 for ; Tue, 16 Apr 2024 13:24:19 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713299058; x=1713903858; 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=r1nUsgIEwvUZY/Y7sKjmmu2jqnXOcwZbDo8j/OXZNko=; b=sRd3Ld0ipwpu05DmHxqCLs6PLpybQNjD2lqhUb7Oj9/8DlcN+o3YUXICO7EBEeN93k K4v4h2MFZbCbnaKMhpVKzimbIXI5pWshZWH9hTisKHXp3+kCofWGcOl+O7YZ2H2tN8rb OVTLX6oF6yvT77Ko4Mr3u5AstBm0ApbhHnK5te91wA9VP5tYFJj/xRzoTn8J9OLfb7wv gKE3x5hqj9Qdvaw6QYuSVK1VXvPYQOG782den/m7b8oN9KpALPqG9c2Gcl/mV9aoK6im wAy/gvu2JOUt3PQJaorfEo120d1oc27ADwzZgEMwHAnjgShFy8p1Hn3wGuN+kCQ+5s1t 7G+g== X-Forwarded-Encrypted: i=1; AJvYcCXUIm8N3r5vLikhhC/PzUoWarnPQrzokXYIgK0+11eVBeqQFjPkjR/fM3mbfvh5+bXsXAMw7h/DF+zSUpL4O0awrIsJHW/6j6Pg X-Gm-Message-State: AOJu0YwNoRzEsWFKTMgLlOodgK3xpljECoHDrMu7XtB4n2ZY2LSqu4g7 GZt7LLvhv/KChxEAymgZqSbnL6NtM3788ANkM6xCuWmFiaMgIS9SgwcG5ya1bMpnif9hV5qDYfT Trx66LtItiDrCLgGutkWFfUC21/b3ZAdABs3I71BhiWf+NCVGKFWx/ZVrBLIfN2QX X-Received: by 2002:a50:8e19:0:b0:56e:2b0b:58 with SMTP id 25-20020a508e19000000b0056e2b0b0058mr9431598edw.10.1713299057799; Tue, 16 Apr 2024 13:24:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGVMbsxmgbfwPflTCr2me7yhQYX1cvv4Zs5Xqd8KJowgpYMfcShyGnZm7swpMdtnq/oet4cZg== X-Received: by 2002:a50:8e19:0:b0:56e:2b0b:58 with SMTP id 25-20020a508e19000000b0056e2b0b0058mr9431587edw.10.1713299057408; Tue, 16 Apr 2024 13:24:17 -0700 (PDT) Received: from thinky.redhat.com ([109.183.6.197]) by smtp.gmail.com with ESMTPSA id fe1-20020a056402390100b005701df2ea98sm3655687edb.32.2024.04.16.13.24.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Apr 2024 13:24:17 -0700 (PDT) From: Andrey Albershteyn To: cem@kernel.org, linux-xfs@vger.kernel.org Cc: Andrey Albershteyn Subject: [PATCH v2 4/4] xfs_fsr: convert fsrallfs to use time_t instead of int Date: Tue, 16 Apr 2024 22:24:02 +0200 Message-ID: <20240416202402.724492-5-aalbersh@redhat.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20240416202402.724492-1-aalbersh@redhat.com> References: <20240416202402.724492-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 --- fsr/xfs_fsr.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/fsr/xfs_fsr.c b/fsr/xfs_fsr.c index 3077d8f4ef46..4e29a8a2c548 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,10 @@ main(int argc, char **argv) break; case 't': howlong = atoi(optarg); + if (howlong > INT_MAX) { + fprintf(stderr, _("%s: too long\n"), progname); + exit(1); + } break; case 'f': leftofffile = optarg; @@ -387,7 +391,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;