Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757324AbcDAHhx (ORCPT ); Fri, 1 Apr 2016 03:37:53 -0400 Received: from out5-smtp.messagingengine.com ([66.111.4.29]:58107 "EHLO out5-smtp.messagingengine.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751947AbcDAHhw (ORCPT ); Fri, 1 Apr 2016 03:37:52 -0400 X-Sasl-enc: 6A5USgveyf8kgKPmV0HWafsgTvi3jbCEkvi3QPenCz7C 1459496271 Message-ID: <1459496266.2974.1.camel@themaw.net> Subject: Re: [PATCH] autofs: don't stuck in a loop if vfs_write returns an error From: Ian Kent To: Andrey Vagin Cc: autofs@vger.kernel.org, linux-kernel@vger.kernel.org, Andrey Vagin Date: Fri, 01 Apr 2016 15:37:46 +0800 In-Reply-To: <1459487558-21258-1-git-send-email-avagin@gmail.com> References: <1459487558-21258-1-git-send-email-avagin@gmail.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.16.5 (3.16.5-3.fc22) Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1028 Lines: 36 On Thu, 2016-03-31 at 22:12 -0700, Andrey Vagin wrote: > From: Andrey Vagin > > __vfs_write() returns a negative value in a error case. Ha, right, I'll send this along to Andrew with my next series which should be soon. > > Cc: Ian Kent > Signed-off-by: Andrey Vagin > --- > fs/autofs4/waitq.c | 7 ++++--- > 1 file changed, 4 insertions(+), 3 deletions(-) > > diff --git a/fs/autofs4/waitq.c b/fs/autofs4/waitq.c > index 0146d91..631f155 100644 > --- a/fs/autofs4/waitq.c > +++ b/fs/autofs4/waitq.c > @@ -66,11 +66,12 @@ static int autofs4_write(struct autofs_sb_info > *sbi, > set_fs(KERNEL_DS); > > mutex_lock(&sbi->pipe_mutex); > - wr = __vfs_write(file, data, bytes, &file->f_pos); > - while (bytes && wr) { > + while (bytes) { > + wr = __vfs_write(file, data, bytes, &file->f_pos); > + if (wr <= 0) > + break; > data += wr; > bytes -= wr; > - wr = __vfs_write(file, data, bytes, &file->f_pos); > } > mutex_unlock(&sbi->pipe_mutex); >