From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id BF99342314F for ; Wed, 13 May 2026 08:56:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778662583; cv=none; b=UPIagaLMVzR1wVmQgdmzCDs2y7JEIyoQFRrma1OgckSD4yJEMchXJvmMf4+EIZLyvFkf56sIZ5SRy7WVPoouy2kQxakgdnBXsobguOLW60e9o89rPgq5v6t34E+XI5Dle4Fci629dy2pMPx8N+NkMiVJzIcraci75UJGbmbAxGc= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778662583; c=relaxed/simple; bh=FeXqo2cfD20WHw55uPZX5zZXnkmMkpxQ2YLl088KrTA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U+AmmxSlMbBu2TQQdGrbEMj/PyYPSlLxwUIh2ZqBd0l3Qyd2NFZm8jBSTKOHT6pNvhy9kP5Yv0afXI/60XloqPeREjdgCstGfUw99/X6+DGIODCeX1huIPP3Y1jTHzUndN1kT7I+DXFbQ1WawFt/e97lKxWe8uVlKk+ptqyUwdA= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com; spf=pass smtp.mailfrom=suse.com; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=suse.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.com Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 672B95C958; Wed, 13 May 2026 08:54:47 +0000 (UTC) Authentication-Results: smtp-out1.suse.de; none Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 3FBD5593A9; Wed, 13 May 2026 08:54:47 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id gJ4TD1c8BGpERwAAD6G6ig (envelope-from ); Wed, 13 May 2026 08:54:47 +0000 From: Daniel Vacek To: Chris Mason , Josef Bacik , Eric Biggers , "Theodore Y. Ts'o" , Jaegeuk Kim , Jens Axboe , David Sterba Cc: linux-block@vger.kernel.org, Daniel Vacek , linux-fscrypt@vger.kernel.org, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 41/43] btrfs: disable auto defrag on encrypted files Date: Wed, 13 May 2026 10:53:15 +0200 Message-ID: <20260513085340.3673127-42-neelx@suse.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260513085340.3673127-1-neelx@suse.com> References: <20260513085340.3673127-1-neelx@suse.com> Precedence: bulk X-Mailing-List: linux-fscrypt@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: 672B95C958 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spam-Score: -4.00 X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Flag: NO X-Rspamd-Action: no action From: Josef Bacik We will drop the inode and re-look it up to do defrag with auto defrag, which means we could lose the encryption policy. Auto defrag needs to be reworked to just hold onto the inode for scheduling later so we don't lose the context. For now just disable it if the file is encrypted. Signed-off-by: Josef Bacik Signed-off-by: Daniel Vacek --- v5: https://lore.kernel.org/linux-btrfs/b717912bf88797b3044a3c2724b59b1ecc17ea78.1706116485.git.josef@toxicpanda.com/ * No changes since. --- fs/btrfs/defrag.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/btrfs/defrag.c b/fs/btrfs/defrag.c index a828ec45bb5f..652b8423f01e 100644 --- a/fs/btrfs/defrag.c +++ b/fs/btrfs/defrag.c @@ -126,6 +126,14 @@ void btrfs_add_inode_defrag(struct btrfs_inode *inode, u32 extent_thresh) if (!need_auto_defrag(fs_info)) return; + /* + * Since we have to read the inode at defrag time disable auto defrag + * for encrypted inodes until we have code to read the parent and load + * the encryption context. + */ + if (IS_ENCRYPTED(&inode->vfs_inode)) + return; + if (test_bit(BTRFS_INODE_IN_DEFRAG, &inode->runtime_flags)) return; -- 2.53.0