From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752171AbbFUFYs (ORCPT ); Sun, 21 Jun 2015 01:24:48 -0400 Received: from zeniv.linux.org.uk ([195.92.253.2]:34799 "EHLO ZenIV.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751395AbbFUFYk (ORCPT ); Sun, 21 Jun 2015 01:24:40 -0400 Date: Sun, 21 Jun 2015 06:24:30 +0100 From: Al Viro To: John Stultz Cc: Felipe Balbi , Andrzej Pietrasiewicz , Krzysztof Opasiak , Greg Kroah-Hartman , Michal Nazarewicz , Robert Baldyga , lkml , linux-usb@vger.kernel.org Subject: Re: Locking issues w/ functionfs gadget and aio? Message-ID: <20150621052430.GA27824@ZenIV.linux.org.uk> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Jun 12, 2015 at 05:51:12PM -0700, John Stultz wrote: > I'm not super sure what the right fix is, but if do something like the > following (sorry, whitespace corrupted via copy/paste), I don't seem > to run into the problem. Looks sane. Which tree would you prefer it to go through, vfs or usb? BTW, in either case you'd need Signed-off-by: on that patch... > diff --git a/drivers/usb/gadget/function/f_fs.c > b/drivers/usb/gadget/function/f_fs.c > index 3507f88..e322818 100644 > --- a/drivers/usb/gadget/function/f_fs.c > +++ b/drivers/usb/gadget/function/f_fs.c > @@ -924,7 +924,8 @@ static ssize_t ffs_epfile_write_iter(struct kiocb > *kiocb, struct iov_iter *from) > > kiocb->private = p; > > - kiocb_set_cancel_fn(kiocb, ffs_aio_cancel); > + if (p->aio) > + kiocb_set_cancel_fn(kiocb, ffs_aio_cancel); > > res = ffs_epfile_io(kiocb->ki_filp, p); > if (res == -EIOCBQUEUED) > @@ -968,7 +969,8 @@ static ssize_t ffs_epfile_read_iter(struct kiocb > *kiocb, struct iov_iter *to) > > kiocb->private = p; > > - kiocb_set_cancel_fn(kiocb, ffs_aio_cancel); > + if(p->aio) > + kiocb_set_cancel_fn(kiocb, ffs_aio_cancel); > > res = ffs_epfile_io(kiocb->ki_filp, p); > if (res == -EIOCBQUEUED) > > > Is there a better solution here? I'm not sure I see if the > is_sync_kiocb(kiocb) check would ever be false from here, so I'm not > sure if all the p->aio checking is really needed or not. > > This issue seems to have been introduced with 70e60d917e91fff > (gadget/function/f_fs.c: switch to ->{read,write}_iter()) > > thanks > -john > -- > To unsubscribe from this list: send the line "unsubscribe linux-kernel" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html > Please read the FAQ at http://www.tux.org/lkml/ -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in Please read the FAQ at http://www.tux.org/lkml/