From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754983AbdDLV4R (ORCPT ); Wed, 12 Apr 2017 17:56:17 -0400 Received: from mx2.suse.de ([195.135.220.15]:37564 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751647AbdDLV4O (ORCPT ); Wed, 12 Apr 2017 17:56:14 -0400 From: NeilBrown To: Jeff Layton , linux-fsdevel@vger.kernel.org Date: Thu, 13 Apr 2017 07:55:32 +1000 Cc: linux-kernel@vger.kernel.org, akpm@linux-foundation.org, tytso@mit.edu, jack@suse.cz, willy@infradead.org, viro@zeniv.linux.org.uk Subject: Re: [PATCH v2 07/17] fs: new infrastructure for writeback error handling and reporting In-Reply-To: <1492022521.2937.18.camel@redhat.com> References: <20170412120614.6111-1-jlayton@redhat.com> <20170412120614.6111-8-jlayton@redhat.com> <1492022521.2937.18.camel@redhat.com> Message-ID: <87inm9uw8b.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="=-=-="; micalg=pgp-sha256; protocol="application/pgp-signature" Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --=-=-= Content-Type: text/plain On Wed, Apr 12 2017, Jeff Layton wrote: > +void __filemap_set_wb_error(struct address_space *mapping, int err) I was really hoping that this would be void __set_wb_error(wb_err_t *wb_err, int err) so Then nfs_context_set_write_error could become static void nfs_context_set_write_error(struct nfs_open_context *ctx, int error) { __set_wb_error(&ctx->wb_err, error); } and filemap_set_sb_error() would be: static inline void filemap_set_wb_error(struct address_space *mapping, int err) { /* Optimize for the common case of no error */ if (unlikely(err)) __set_wb_error(&mapping->f_wb_err, err); } Similarly we would have wb_err_t sample_wb_error(wb_err_t *wb_err) { ... } and wb_err_t filemap_sample_wb_error(struct address_space *mapping) { return sample_wb_error(&mapping->f_wb_err); } so nfs_file_fsync_commit() could have ret = sample_wb_error(&ctx->wb_err); in place of ret = xchg(&ctx->error, 0); int filemap_report_wb_error(struct file *file) would become int filemap_report_wb_error(struct file *file, wb_err_t *err) or something. The address space is just one (obvious) place where the wb error can be stored. The filesystem might have a different place with finer granularity (nfs already does). > +wb_err_t filemap_sample_wb_error(struct address_space *mapping) > +{ > + wb_err_t old = READ_ONCE(mapping->wb_err); > + wb_err_t new = old; > + > + /* > + * For the common case of no errors ever having been set, we can skip > + * marking the SEEN bit. Once an error has been set, the value will > + * never go back to zero. > + */ > + if (old != 0) { > + new |= WB_ERR_SEEN; > + if (old != new) > + cmpxchg(&mapping->wb_err, old, new); > + } > + return new; > +} I do like how the use of cmpxchg work out here - no looping! Thanks NeilBrown --=-=-= Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEG8Yp69OQ2HB7X0l6Oeye3VZigbkFAljuolQACgkQOeye3VZi gbn5Zg//dklhKi/SeTy/WIJrm/3rgMjHImxcVR2gzoZmjo2O4HV+1Da2w0IEgqQ/ 4EBwUtfkYCoBVw1xTc6FGmOU2HEuL6Lb3PXLmCIhlCxIAx/8vxTByVeYTUwElS8y 32Icyaau1OzqfCFbair5ipr4K472oYzfZqlz1HGXJsLFhJ6Xsx+KxxouqP/Ky9GI 1wO57facCzg4EW9NQM0MTpt8HIfWzXiR6tO8ZMzzlMmeqm/hYOWhamrfQnCw0F7W gnHDyO3v+wQQHdpnUzc8SGv0If/RsCnYp/Dcvydg11jhfMw/GcRF0kPuNsnWaeU6 V+EPjfrROzdZI8BXjxNcyKDZvXLViuBhV/coFbxSygC3NFUeIdFz7Im218CxbFof Bc92l/G2jOeTL5QU+i8LnSI7966lrxgwr7kYcbQo6KldYssQMLbLxKXBsFgjzhMu kBYwnJPORMNgBv8UTTQyP8LXa3SHGefVyJEJJlRYJ7QD1IWk0DyAWNL63pe2e+M6 w1TtVhySu1Vza6pmIc65dOstvISGkKJnhvlrLLl+aIbVPQcXr34vdF9kQ3EkifBi df8bZ0bSh35UJ2gsE375iaIszxtg782WqyjplZ2m3bWO2lwT3ESsDghngO1YKCVB 31HGAILgk3l769NaSHoiINQaqd3ZfqeDmQjYAKKoptrmlfLX1cg= =nDC0 -----END PGP SIGNATURE----- --=-=-=--