From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4239CC433EF for ; Wed, 23 Feb 2022 00:17:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231773AbiBWARU (ORCPT ); Tue, 22 Feb 2022 19:17:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54058 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229544AbiBWARS (ORCPT ); Tue, 22 Feb 2022 19:17:18 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 498BA4C42F for ; Tue, 22 Feb 2022 16:16:51 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D879761295 for ; Wed, 23 Feb 2022 00:16:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 24416C340E8; Wed, 23 Feb 2022 00:16:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1645575410; bh=IfJ0A6W4odMqfWAuTFyGgLeQeK9RTCZE2nzukCzpgwo=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Gx5LL5tQelWrgwB2WtG/RWMgFJ6juCb2GtefL38y00ZaDrqkxQGO0NWPfYb/EpuRD t1BukWyurJtUPd8fppnYYwnARQW0FJwcX/IYgeKnYLKBYTOJY3Ky5vtg6F7JWF2pza AJu6wpXJKauUAdZWDlmCsR+2fHBbdJ9ouRjar68VHASBhWy6hhDXbuArX5do0zwumf xyEXcARS0giq18hKfJdJJYlvGWFd+4uEtI0Yein5AM/G/ORn7aOE/Iw5syyFt62L0C bmcFwl1RkK5brtLC1MjZwq81Y7ySNDpoZMH5iprAs2qX+/D7PGgAu2xSd0RKyEFHr7 LPF1l76LZyZbQ== Received: by quaco.ghostprotocols.net (Postfix, from userid 1000) id 932AB400FE; Tue, 22 Feb 2022 21:16:47 -0300 (-03) Date: Tue, 22 Feb 2022 21:16:47 -0300 From: Arnaldo Carvalho de Melo To: Jiri Olsa Cc: Alexey Bayduraev , Jiri Olsa , Namhyung Kim , Alexander Shishkin , Peter Zijlstra , Ingo Molnar , linux-kernel , Adrian Hunter , Alexander Antonov , Alexei Budankov Subject: Re: [PATCH core v2] perf data: Adding error message if perf_data__create_dir fails Message-ID: References: <20220222091417.11020-1-alexey.v.bayduraev@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Url: http://acmel.wordpress.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Em Tue, Feb 22, 2022 at 11:06:02PM +0100, Jiri Olsa escreveu: > On Tue, Feb 22, 2022 at 12:14:17PM +0300, Alexey Bayduraev wrote: > > Adding proper return codes for all cases of data directory creation > > failure and adding error message output based on these codes. > > > > Signed-off-by: Alexey Bayduraev > > Acked-by: Jiri Olsa Thanks, applied. - Arnaldo > thanks, > jirka > > > --- > > tools/perf/builtin-record.c | 4 +++- > > tools/perf/util/data.c | 8 ++++++-- > > 2 files changed, 9 insertions(+), 3 deletions(-) > > > > diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c > > index 0bc6529814b2..0b4abed555d8 100644 > > --- a/tools/perf/builtin-record.c > > +++ b/tools/perf/builtin-record.c > > @@ -1186,8 +1186,10 @@ static int record__mmap_evlist(struct record *rec, > > > > if (record__threads_enabled(rec)) { > > ret = perf_data__create_dir(&rec->data, evlist->core.nr_mmaps); > > - if (ret) > > + if (ret) { > > + pr_err("Failed to create data directory: %s\n", strerror(-ret)); > > return ret; > > + } > > for (i = 0; i < evlist->core.nr_mmaps; i++) { > > if (evlist->mmap) > > evlist->mmap[i].file = &rec->data.dir.files[i]; > > diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c > > index f5d260b1df4d..dc5d82ea1c30 100644 > > --- a/tools/perf/util/data.c > > +++ b/tools/perf/util/data.c > > @@ -52,12 +52,16 @@ int perf_data__create_dir(struct perf_data *data, int nr) > > struct perf_data_file *file = &files[i]; > > > > ret = asprintf(&file->path, "%s/data.%d", data->path, i); > > - if (ret < 0) > > + if (ret < 0) { > > + ret = -ENOMEM; > > goto out_err; > > + } > > > > ret = open(file->path, O_RDWR|O_CREAT|O_TRUNC, S_IRUSR|S_IWUSR); > > - if (ret < 0) > > + if (ret < 0) { > > + ret = -errno; > > goto out_err; > > + } > > > > file->fd = ret; > > } > > -- > > 2.19.0 > > -- - Arnaldo