Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1207783pxu; Mon, 23 Nov 2020 14:40:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJyNxSh2q9oTAyf+DiQNPgUxEvzaIvdccOw7hQebf2ulHHW+TVC/pFR6sX9AHlgXnFJVuIrl X-Received: by 2002:a05:6402:7ce:: with SMTP id u14mr1335019edy.19.1606171252610; Mon, 23 Nov 2020 14:40:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606171252; cv=none; d=google.com; s=arc-20160816; b=yRbmsKs/pOX3ayJhEMAhZlCv0CnC8ifwNyO3HTa9WvpOBxaaU3Q6LnA02FyvzI8g7o 9mzVvZ786H+TrAKLsV2LgqppNcKye4hD8IsteA6x1cUwbcoy8J6NpMAM5xcfm4ZwobYH JNbwae5sMM6LJKNRWa/h2FB42j031MIgaXkALdcvbrO3faJHKS4SKIOQ2vIEakP3KhSv rrrw1X+eju/AV0QenSNSiM8iPWcque6wmkGdNzyhL7XR/Yq/5FIojlIJkNatE9zFT94X HYN1uzcOX2xYVdnDVYKbdbxq/pjxSgQzF0srsngrJGtDPQF2/4hmZrHFQp52JrkkSNvz t+cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=LY0bzFRGu7oiZNapt1VC4XPkEBaWNg3Ib4HcYIflwcE=; b=BLXj+dD8XBYfmbs6AturZw3cuHBo4d9sLoR653kdSaab41Hwmo/q//b0/dyrhwz0b8 u+TazK7vKP3cz/KXmHJ3sItRYK3AB6HvLVodEDaQDQxY/dZr/52MR5M2+ooX5FJYgEyw c693OJSVXf4+Udycdkf+gvB/oFL+Gdchqh0sOHFMDtLHxWMXxaAZjrcM2F5QwKAouwVS tOAIPk9zmzsD0JIYeg+KFwrP/pbGdpBks0c7i5H1N5Y2zxfBc459mFsN/LapclE7AD8Z 171l8RfFmeWKkdAT0DaFTvB5wAmRrLW1GO7uvxjwBwoKBtMK4KBLwyYbywJGR+aFpGUx +W4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e18si7284901ejq.261.2020.11.23.14.40.28; Mon, 23 Nov 2020 14:40:52 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731256AbgKWWjG (ORCPT + 99 others); Mon, 23 Nov 2020 17:39:06 -0500 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:37474 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731007AbgKWWjG (ORCPT ); Mon, 23 Nov 2020 17:39:06 -0500 Received: from callcc.thunk.org (pool-72-74-133-215.bstnma.fios.verizon.net [72.74.133.215]) (authenticated bits=0) (User authenticated as tytso@ATHENA.MIT.EDU) by outgoing.mit.edu (8.14.7/8.12.4) with ESMTP id 0ANMcuSH003238 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 23 Nov 2020 17:38:57 -0500 Received: by callcc.thunk.org (Postfix, from userid 15806) id 90E97420136; Mon, 23 Nov 2020 17:38:56 -0500 (EST) Date: Mon, 23 Nov 2020 17:38:56 -0500 From: "Theodore Y. Ts'o" To: Saranya Muruganandam Cc: linux-ext4@vger.kernel.org, adilger.kernel@dilger.ca, Li Xi , Wang Shilong Subject: Re: [RFC PATCH v3 08/61] e2fsck: open io-channel when copying fs Message-ID: <20201123223856.GH132317@mit.edu> References: <20201118153947.3394530-1-saranyamohan@google.com> <20201118153947.3394530-9-saranyamohan@google.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201118153947.3394530-9-saranyamohan@google.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Wed, Nov 18, 2020 at 07:38:54AM -0800, Saranya Muruganandam wrote: > From: Li Xi > > This patch also add writethrough flag to the thread io-channel. > When multiple threads write the same disk, we don't want the > data being saved in memory cache. This will be useful in the > future, but even without that flag, the tests can be passed too. > > This patch also cleanup the io channel cache of the global > context. Otherwise, after pass1 step, the next steps would use > old data saved in the cache. And the cached data might have > already been overwritten in pass1. See my previous comments about why io_managers will almost certainly need to be thread-aware. This commit modifies undo_io.c, but it can't possibly work as-is, since you can't have multiple copies of the undo manager from different threads trying to update a single undo file. So these changes, by themselves, can't possibly be sufficient. Instead of doing things incrementally, my suggestion is that we figure out how to make io_managers thread-safe and we get it right *first*, instead of making incremental changes throughout the patch series. I'd also suggest that we figure out some kind of test framework so we can test io_managers in isolation, so we can do stress tests, as well as functional correctness tests as unit tests. Once we have that, let's merge these changes in incrementally into e2fsprogs, so we can have clean, well-designed and well-tested low-level infrastructure, which will be easier for us to review. > diff --git a/lib/ext2fs/ext2_io.h b/lib/ext2fs/ext2_io.h > index 5540900a..4ad2fec8 100644 > --- a/lib/ext2fs/ext2_io.h > +++ b/lib/ext2fs/ext2_io.h > @@ -81,6 +81,7 @@ struct struct_io_manager { > errcode_t (*write_blk)(io_channel channel, unsigned long block, > int count, const void *data); > errcode_t (*flush)(io_channel channel); > + errcode_t (*flush_cleanup)(io_channel channel); > errcode_t (*write_byte)(io_channel channel, unsigned long offset, > int count, const void *data); > errcode_t (*set_option)(io_channel channel, const char *option, Please don't add new functions into the middle of struct_io_manager. There is a long reserved[14] to add padding to the structure for a reason. Add a new function pointer just before the reserved[] array, and then decrement the padding count. The reason for this is that it's technically allowed for applications to provide their own io_manager to the library, which may be stacked on top of an some other io_manager (as is the case for undo iomanager). Or it might because the userspace application is providing their own io manager to interface with some other OS --- maybe Windows, or Fuschia in the future, who knows? So if we add a new function pointer to the middle of struct_io_manager, this breaks the ABI, and that's a Bad Thing, as it may cause surprises in the future for applications which are using shared libraries and we update with a newer version of the shared library without doing a major version bump of the shared library. - Ted