Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5223208pxj; Tue, 22 Jun 2021 18:39:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyvwKHtWIs8QC3pnACnvb/tLzeM56baV2NedFuaEOh/vz+Ov14BlMA2Y4jmfyy8aZZJenZC X-Received: by 2002:a17:906:57d0:: with SMTP id u16mr3960549ejr.422.1624412369437; Tue, 22 Jun 2021 18:39:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624412369; cv=none; d=google.com; s=arc-20160816; b=eCDME2WutDD8aF27pFBGYBXnXh4ipQluW695Nm/DzQSXAMH/3lswQ50DQ0vJTqImSu cERPDLHDmFM0JGITF4eIy+YBai1ee63UqeAF7VlZXHbVXhvsaApZQyEocPUqPgwAqpTu mZ/kOaGkdVtqLtFGlKuZU8jdMKITkJ3ARm5jDAIlHD3vpV2RoErAjErmo5bGq0sDOknF uO8IAjw4M0n6H3rufwGkkjJApCGcnxuPuVh2z7BN48g7GCRw4CBpMKm2dxrWcHMyxwTP EM8YVx3BnMhw7PCeoEk/mwuq3I0R/pKAz9PBIFrscY64HquKHCNmzhWyf4UCXHmJwes2 agMw== 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=udwzRSIj96L/720unvHyEqwqywUEBnRYqkqaQ4bHO3A=; b=bLA1c1ZA3fqUvtWr3xh/r+IruOntwF0kSKb6/Vcj172cv+oTCo+dNod9Ug3cWTz2ko IYCzmBx7zOw7rkj/Qv8sW52C9So25NaHOfrVRmOJOGWsAJR1msiqVeu9cLkk1Ct1qgkA DK30iwwdcHOJJh+5QUt/CWi+kH4Tt3bHONwIhuMQYsIvW2EgWyNJn0Jy5iP/A5l/qV7l 1OGv+UYIOrqFT27gS0GS52Ljkz6Uq0WIPNIz3/fmjuqgCZO5mpPIp4XbUVn9ezXIdqfD 0zS7+yuo+DCHVPzKmrnUR8anO4bVb2E4v6iiTZizWQUZQlmuXfBKPkb0EyhoHB+quOCz OVmg== 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 j8si22493480edj.124.2021.06.22.18.38.59; Tue, 22 Jun 2021 18:39:29 -0700 (PDT) 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 S229769AbhFWBks (ORCPT + 99 others); Tue, 22 Jun 2021 21:40:48 -0400 Received: from outgoing-auth-1.mit.edu ([18.9.28.11]:49753 "EHLO outgoing.mit.edu" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S229751AbhFWBks (ORCPT ); Tue, 22 Jun 2021 21:40:48 -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 15N1cSFl032416 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 22 Jun 2021 21:38:29 -0400 Received: by cwcc.thunk.org (Postfix, from userid 15806) id CB9E215C3CD6; Tue, 22 Jun 2021 21:38:28 -0400 (EDT) Date: Tue, 22 Jun 2021 21:38:28 -0400 From: "Theodore Ts'o" To: Leah Rumancik Cc: linux-ext4@vger.kernel.org Subject: Re: [PATCH v5 2/3] ext4: add ioctl EXT4_IOC_CHECKPOINT Message-ID: References: <20210518151327.130198-1-leah.rumancik@gmail.com> <20210518151327.130198-2-leah.rumancik@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210518151327.130198-2-leah.rumancik@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On Tue, May 18, 2021 at 03:13:26PM +0000, Leah Rumancik wrote: > ioctl EXT4_IOC_CHECKPOINT checkpoints and flushes the journal. This > includes forcing all the transactions to the log, checkpointing the > transactions, and flushing the log to disk. This ioctl takes u32 "flags" > as an argument. Three flags are supported. EXT4_IOC_CHECKPOINT_FLAG_DRY_RUN > can be used to verify input to the ioctl. It returns error if there is any > invalid input, otherwise it returns success without performing > any checkpointing. The other two flags, EXT4_IOC_CHECKPOINT_FLAG_DISCARD > and EXT4_IOC_CHECKPOINT_FLAG_ZEROOUT, can be used to issue requests to > discard or zeroout the journal logs blocks, respectively. At this > point, EXT4_IOC_CHECKPOINT_FLAG_ZEROOUT is primarily added to enable > testing of this codepath on devices that don't support discard. > EXT4_IOC_CHECKPOINT_FLAG_DISCARD and EXT4_IOC_CHECKPOINT_FLAG_ZEROOUT > cannot both be set. > > Systems that wish to achieve content deletion SLO can set up a daemon > that calls this ioctl at a regular interval such that it matches with the > SLO requirement. Thus, with this patch, the ext4_dir_entry2 wipeout > patch[1], and the Ext4 "-o discard" mount option set, Ext4 can now > guarantee that all file contents, file metatdata, and filenames will not > be accessible through the filesystem and will have had discard or > zeroout requests issued for corresponding device blocks. > > The __jbd2_journal_erase function could also be used to discard or > zero-fill the journal during journal load after recovery. This would > provide a potential solution to a journal replay bug reported earlier this > year[2]. After a successful journal recovery, e2fsck can call this ioctl to > discard the journal as well. > > [1] https://lore.kernel.org/linux-ext4/YIHknqxngB1sUdie@mit.edu/ > [2] https://lore.kernel.org/linux-ext4/YDZoaacIYStFQT8g@mit.edu/ > > Signed-off-by: Leah Rumancik FYI, I've made the following change to this commit in the ext4 tree, in order to fix a test failure of ext4/050 when running on a block device that don't support discard --- for example, when running the ext4/dax test config. Cheers, - Ted diff --git a/fs/ext4/ioctl.c b/fs/ext4/ioctl.c index 1290fbda1399..5730aeca563c 100644 --- a/fs/ext4/ioctl.c +++ b/fs/ext4/ioctl.c @@ -805,6 +805,7 @@ static int ext4_ioctl_checkpoint(struct file *filp, unsigned long arg) __u32 flags = 0; unsigned int flush_flags = 0; struct super_block *sb = file_inode(filp)->i_sb; + struct request_queue *q; if (copy_from_user(&flags, (__u32 __user *)arg, sizeof(__u32))) @@ -822,6 +823,15 @@ static int ext4_ioctl_checkpoint(struct file *filp, unsigned long arg) if (!EXT4_SB(sb)->s_journal) return -ENODEV; + if (flags & ~JBD2_JOURNAL_FLUSH_VALID) + return -EINVAL; + + q = bdev_get_queue(EXT4_SB(sb)->s_journal->j_dev); + if (!q) + return -ENXIO; + if ((flags & JBD2_JOURNAL_FLUSH_DISCARD) && !blk_queue_discard(q)) + return -EOPNOTSUPP; + if (flags & EXT4_IOC_CHECKPOINT_FLAG_DRY_RUN) return 0;