From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B2E7C4320A for ; Sat, 31 Jul 2021 02:46:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 462376101C for ; Sat, 31 Jul 2021 02:46:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231527AbhGaCqh (ORCPT ); Fri, 30 Jul 2021 22:46:37 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:40499 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231380AbhGaCqg (ORCPT ); Fri, 30 Jul 2021 22:46:36 -0400 Received: from cwcc.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 16V2kGk7028015 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jul 2021 22:46:17 -0400 Received: by cwcc.thunk.org (Postfix, from userid 15806) id 9B17815C37C0; Fri, 30 Jul 2021 22:46:16 -0400 (EDT) Date: Fri, 30 Jul 2021 22:46:16 -0400 From: "Theodore Ts'o" To: Eric Biggers Cc: linux-f2fs-devel@lists.sourceforge.net, Jaegeuk Kim , Chao Yu , linux-fsdevel@vger.kernel.org, stable@vger.kernel.org Subject: Re: [PATCH] f2fs: remove broken support for allocating DIO writes Message-ID: References: <20210728015154.171507-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.org On Fri, Jul 30, 2021 at 12:17:26PM -0700, Eric Biggers wrote: > > Currently, non-overwrite DIO writes are fundamentally unsafe on f2fs as > > they require preallocating blocks, but f2fs doesn't support unwritten > > blocks and therefore has to preallocate the blocks as regular blocks. > > f2fs has no way to reliably roll back such preallocations, so as a > > result, f2fs will leak uninitialized blocks to users if a DIO write > > doesn't fully complete. There's another way of solving this problem which doesn't require supporting unwritten blocks. What a file system *could* do is to allocate the blocks, but *not* update the on-disk data structures --- so the allocation happens in memory only, so you know that the physical blocks won't get used for another files, and then issue the data block writes. On the block I/O completion, trigger a workqueue function which updates the on-disk metadata to assign physical blocks to the inode. That way if you crash before the data I/O has a chance to complete, the on-disk logical block -> physical block map hasn't been updated yet, and so you don't need to worry about leaking uninitialized blocks. Cheers, - Ted From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E7A31C4338F for ; Sat, 31 Jul 2021 03:00:47 +0000 (UTC) Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9620260E97 for ; Sat, 31 Jul 2021 03:00:47 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 9620260E97 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=mit.edu Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.sourceforge.net Received: from [127.0.0.1] (helo=sfs-ml-2.v29.lw.sourceforge.com) by sfs-ml-2.v29.lw.sourceforge.com with esmtp (Exim 4.92.3) (envelope-from ) id 1m9fF1-0006I1-1z; Sat, 31 Jul 2021 03:00:47 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-2.v29.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) (envelope-from ) id 1m9fEz-0006Ht-Ef for linux-f2fs-devel@lists.sourceforge.net; Sat, 31 Jul 2021 03:00:45 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=In-Reply-To:Content-Type:MIME-Version:References: Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To:Content-Transfer-Encoding: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=9aVbg38nXcEAhukylWn/te6uwKT45ZiVVyn60mu+cRQ=; b=G9P3j9+nP0PhNcs7Ot3sbQS/gy mmHnPklfvOYts48T17PfYfsVai4I1YlHUOVQ3fYvpsWptFpKHzrDQN6i+C7CQWMNRN7VfZDwDLV1j dIhQfOz4fVZlqxaDDUjc/tsug7fotyVYDVq4cIv0lEh+uKHzxvLhadmIEjhjLIH2/PqY=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To :From:Date:Sender:Reply-To:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=9aVbg38nXcEAhukylWn/te6uwKT45ZiVVyn60mu+cRQ=; b=H81mVYz4aeqZn54fXeHw8Jmjgw nBIWJevm5mK2T2J19kwJE3aHWIH4ESvUKE5LTzbowL1LoSaSng/WOY3MKhzBF5aaCBD4SDPhvmn0q FMks0bQiQM+e7b2H+lufATbC74fBNeEYXzHhbzuM7qc3MxUF2ASpzNmFks4wYVpMMdA8=; Received: from outgoing-auth-1.mit.edu ([18.9.28.11] helo=outgoing.mit.edu) by sfi-mx-1.v28.lw.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.92.3) id 1m9fEr-008Hru-Ao for linux-f2fs-devel@lists.sourceforge.net; Sat, 31 Jul 2021 03:00:45 +0000 Received: from cwcc.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 16V2kGk7028015 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 30 Jul 2021 22:46:17 -0400 Received: by cwcc.thunk.org (Postfix, from userid 15806) id 9B17815C37C0; Fri, 30 Jul 2021 22:46:16 -0400 (EDT) Date: Fri, 30 Jul 2021 22:46:16 -0400 From: "Theodore Ts'o" To: Eric Biggers Message-ID: References: <20210728015154.171507-1-ebiggers@kernel.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Headers-End: 1m9fEr-008Hru-Ao Subject: Re: [f2fs-dev] [PATCH] f2fs: remove broken support for allocating DIO writes X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-fsdevel@vger.kernel.org, Jaegeuk Kim , stable@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net On Fri, Jul 30, 2021 at 12:17:26PM -0700, Eric Biggers wrote: > > Currently, non-overwrite DIO writes are fundamentally unsafe on f2fs as > > they require preallocating blocks, but f2fs doesn't support unwritten > > blocks and therefore has to preallocate the blocks as regular blocks. > > f2fs has no way to reliably roll back such preallocations, so as a > > result, f2fs will leak uninitialized blocks to users if a DIO write > > doesn't fully complete. There's another way of solving this problem which doesn't require supporting unwritten blocks. What a file system *could* do is to allocate the blocks, but *not* update the on-disk data structures --- so the allocation happens in memory only, so you know that the physical blocks won't get used for another files, and then issue the data block writes. On the block I/O completion, trigger a workqueue function which updates the on-disk metadata to assign physical blocks to the inode. That way if you crash before the data I/O has a chance to complete, the on-disk logical block -> physical block map hasn't been updated yet, and so you don't need to worry about leaking uninitialized blocks. Cheers, - Ted _______________________________________________ Linux-f2fs-devel mailing list Linux-f2fs-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel