Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751467AbdFFWPH (ORCPT ); Tue, 6 Jun 2017 18:15:07 -0400 Received: from imap.thunk.org ([74.207.234.97]:51822 "EHLO imap.thunk.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751398AbdFFWPE (ORCPT ); Tue, 6 Jun 2017 18:15:04 -0400 Date: Tue, 6 Jun 2017 18:11:51 -0400 From: "Theodore Ts'o" To: "Luis R. Rodriguez" Cc: Alan Cox , linux-fsdevel@vger.kernel.org, Stephen Boyd , "Li, Yi" , Dmitry Torokhov , Peter Zijlstra , Jonathan Corbet , "Eric W. Biederman" , "Michael Kerrisk (man-pages)" , Andy Lutomirski , Greg KH , "Fuzzey, Martin" , Linux API , Daniel Wagner , David Woodhouse , jewalt@lgsinnovations.com, rafal@milecki.pl, Arend Van Spriel , "Rafael J. Wysocki" , atull@opensource.altera.com, Moritz Fischer , Petr Mladek , Johannes Berg , Emmanuel Grumbach , Luca Coelho , Kalle Valo , Linus Torvalds , Kees Cook , AKASHI Takahiro , David Howells , Peter Jones , Hans de G oede , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v2] firmware: fix sending -ERESTARTSYS due to signal on fallback Message-ID: <20170606221151.ygoxqkwhhjsqw632@thunk.org> Mail-Followup-To: Theodore Ts'o , "Luis R. Rodriguez" , Alan Cox , linux-fsdevel@vger.kernel.org, Stephen Boyd , "Li, Yi" , Dmitry Torokhov , Peter Zijlstra , Jonathan Corbet , "Eric W. Biederman" , "Michael Kerrisk (man-pages)" , Andy Lutomirski , Greg KH , "Fuzzey, Martin" , Linux API , Daniel Wagner , David Woodhouse , jewalt@lgsinnovations.com, rafal@milecki.pl, Arend Van Spriel , "Rafael J. Wysocki" , atull@opensource.altera.com, Moritz Fischer , Petr Mladek , Johannes Berg , Emmanuel Grumbach , Luca Coelho , Kalle Valo , Linus Torvalds , Kees Cook , AKASHI Takahiro , David Howells , Peter Jones , Hans de G oede , "linux-kernel@vger.kernel.org" References: <87fufr3mdy.fsf@xmission.com> <20170526194640.GS8951@wotan.suse.de> <20170526215518.GB40877@dtor-ws> <20170605202410.GQ8951@wotan.suse.de> <1496760796.5682.48.camel@linux.intel.com> <20170606164734.GB27288@wotan.suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20170606164734.GB27288@wotan.suse.de> User-Agent: NeoMutt/20170113 (1.7.2) X-SA-Exim-Connect-IP: X-SA-Exim-Mail-From: tytso@thunk.org X-SA-Exim-Scanned: No (on imap.thunk.org); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1646 Lines: 36 On Tue, Jun 06, 2017 at 06:47:34PM +0200, Luis R. Rodriguez wrote: > On Tue, Jun 06, 2017 at 03:53:16PM +0100, Alan Cox wrote: > > Yep everyone codes > > > > write(disk_file, "foo", 3); > > > > not while(..) blah around it. In general I/O to tty devices and other character mode devices was where you definitely needed to check for EINTR/EAGAIN because that was the place where historically Unix systems would interrupt system calls --- e.g., a user typing control-Z, for example. And in general writes to file systems and block devices in *general* were never interrupted by signals, although that was always a non-portable assumption. So I've always subscribed to the "be liberal in what you accept, conservative in what you send" rule of thumb. Which is to say, any programs *I* write I'll in general always check for EINTR/EAGAIN and check for partial writes, but in general, as a kernel program I try to adhere to the long-standing Unix trandition for disk based files. This does beg the question about whether firmware devices are more like tty devices or block devices or files, though. If before signals never caused them to return EINTR/EAGAIN, then it's probably best to not break backwards compatbility. That being said, not that you also have the option of using -ERESTARTNOINTR (always restart the system call, regardless of how the sighandle flags were set), and -ERESTARTNOHAND (restart the system call always if there was no signal handler and the process was not killed), in addition to -ERESTARTSYS. So that might be another option that's fairly easy to implement or experiment with. - Ted