From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753702AbcCWHCa (ORCPT ); Wed, 23 Mar 2016 03:02:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34502 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752518AbcCWHCZ (ORCPT ); Wed, 23 Mar 2016 03:02:25 -0400 Date: Wed, 23 Mar 2016 15:02:16 +0800 From: Peter Xu To: Steven Rostedt Cc: linux-kernel@vger.kernel.org Subject: Re: [PATCH trace-cmd 2/2] trace-recorder: better error handling during copy Message-ID: <20160323070216.GN28183@pxdev.xzpeter.org> References: <1458632442-6878-1-git-send-email-peterx@redhat.com> <1458632442-6878-3-git-send-email-peterx@redhat.com> <20160322091956.2c42eefe@gandalf.local.home> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20160322091956.2c42eefe@gandalf.local.home> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 22, 2016 at 09:19:56AM -0400, Steven Rostedt wrote: > On Tue, 22 Mar 2016 09:14:33 -0400 > Peter Xu wrote: > > > Currently we have two ways to copy data, one is splice, one is read + > > write. For both, dump more information when we got errors during the > > copy. Also, when we update_fd(), we should make sure all bytes written, > > and update written bytes only. > > > > These information might be important to better diagnose when the copy > > got wrong, like no space error, or connection error when copying data to > > remote sockets. In the past, we just got silence errors without notice. > > > > Signed-off-by: Peter Xu > > --- > > trace-recorder.c | 34 ++++++++++++++++++++++++---------- > > 1 file changed, 24 insertions(+), 10 deletions(-) > > > > diff --git a/trace-recorder.c b/trace-recorder.c > > index 49b04ea..7d6feb0 100644 > > --- a/trace-recorder.c > > +++ b/trace-recorder.c > > @@ -334,13 +334,14 @@ static inline void update_fd(struct tracecmd_recorder *recorder, int size) > > */ > > static long splice_data(struct tracecmd_recorder *recorder) > > { > > - long ret; > > + long ret, written; > > > > ret = splice(recorder->trace_fd, NULL, recorder->brass[1], NULL, > > recorder->page_size, 1 /* SPLICE_F_MOVE */); > > if (ret < 0) { > > if (errno != EAGAIN && errno != EINTR) { > > - warning("recorder error in splice input"); > > + warning("recorder error in splice input: %s", > > + strerror(errno)); > > I'm wondering if we should add a "pwarning()" helper function that will > do the stderror(error) for us. Ah, I just found that __vwarning() will dump errno string, and warning() is calling that. So it explained why I got one more line when got errors... ;) How about remove all the strerror() things, and just keep capturing the written size? Let me send a v2 for this patch. Thanks. -- peterx