From patchwork Fri Aug 30 22:25:46 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Sterba X-Patchwork-Id: 2852238 Return-Path: X-Original-To: patchwork-linux-btrfs@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 31BA49F313 for ; Fri, 30 Aug 2013 22:26:01 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 3DE8C20166 for ; Fri, 30 Aug 2013 22:26:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 28985200F1 for ; Fri, 30 Aug 2013 22:25:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755991Ab3H3WZz (ORCPT ); Fri, 30 Aug 2013 18:25:55 -0400 Received: from cantor2.suse.de ([195.135.220.15]:58825 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755869Ab3H3WZz (ORCPT ); Fri, 30 Aug 2013 18:25:55 -0400 Received: from relay1.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id D72C7A5211; Sat, 31 Aug 2013 00:25:53 +0200 (CEST) Received: by ds.suse.cz (Postfix, from userid 10065) id 1AE43DAA6D; Sat, 31 Aug 2013 00:25:53 +0200 (CEST) From: David Sterba To: linux-btrfs@vger.kernel.org Cc: chris.mason@fusionio.com, David Sterba , Alex Lyakas , Josef Bacik Subject: [PATCH] btrfs: commit transaction after deleting a subvolume Date: Sat, 31 Aug 2013 00:25:46 +0200 Message-Id: <1377901546-22434-1-git-send-email-dsterba@suse.cz> X-Mailer: git-send-email 1.8.3.1 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org X-Spam-Status: No, score=-9.0 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Alex pointed out the consequences after a transaction is not committed when a subvolume is deleted, so in case of a crash before an actual commit happens will let the subvolume reappear. Original post: http://www.spinics.net/lists/linux-btrfs/msg22088.html Josef's objections: http://www.spinics.net/lists/linux-btrfs/msg22256.html While there's no need to do a full commit for regular files, a subvolume may get a different treatment. http://www.spinics.net/lists/linux-btrfs/msg23087.html: "That a subvol/snapshot may appear after crash if transation commit did not happen does not feel so good. We know that the subvol is only scheduled for deletion and needs to be processed by cleaner. From that point I'd rather see the commit to happen to avoid any unexpected surprises. A subvolume that re-appears still holds the data references and consumes space although the user does not assume that. Automated snapshotting and deleting needs some guarantees about the behaviour and what to do after a crash. So now it has to process the backlog of previously deleted snapshots and verify that they're not there, compared to "deleted -> will never appear, can forget about it". " There is a performance penalty incured by the change, but deleting a subvolume is not a frequent operation and the tradeoff seems justified by getting the guarantee stated above. CC: Alex Lyakas CC: Josef Bacik Signed-off-by: David Sterba --- fs/btrfs/ioctl.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index e407f75..4394632 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -2268,7 +2268,7 @@ static noinline int btrfs_ioctl_snap_destroy(struct file *file, out_end_trans: trans->block_rsv = NULL; trans->bytes_reserved = 0; - ret = btrfs_end_transaction(trans, root); + ret = btrfs_commit_transaction(trans, root); if (ret && !err) err = ret; inode->i_flags |= S_DEAD;