From nobody Tue Dec 2 02:37:43 2025 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 771F033EB11 for ; Tue, 18 Nov 2025 16:08:54 +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=1763482136; cv=none; b=K4fEz+fYHbw1KgSBVXNSjsIvUhA4by9g77URkC8l8UYCxY3z8Zy/2HU08ddcnl28LIH/BasmkN1bMg5+ynQfgXDcvk9skq2umNvCUGjLo8iv3ZEn8GRvw56G+8+tw8qAnFnsSTadzOKCDLjVEflVuB43u88q94+4vEJTTIv2/Nk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763482136; c=relaxed/simple; bh=KzcnPuDVRPDSGspCYIRm0yZinGIPqiO/J0SVT7JpdTA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Wf2wPGZjDLhIUi87fg29CLwN6ipGZUcci5NVfFifsvZ0tEtay/Byki75S9q0KmdA2hFP67/foCJY4uv42anzRTupsLI0VSp5ALMIDjraeeG1HZ926MhfxyjRMTx5zo0d1SpmoUzE0FfG4bWd1/tYUX+RUXur0+wImanpm44qY+w= 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 CC35F2126D; Tue, 18 Nov 2025 16:08:52 +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 B1F6C3EA61; Tue, 18 Nov 2025 16:08:52 +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 ePPhKhSaHGlnYQAAD6G6ig (envelope-from ); Tue, 18 Nov 2025 16:08:52 +0000 From: Daniel Vacek To: Chris Mason , Josef Bacik , David Sterba Cc: Daniel Vacek , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Omar Sandoval , Sweet Tea Dorminy Subject: [PATCH v7 1/6] btrfs: disable various operations on encrypted inodes Date: Tue, 18 Nov 2025 17:08:38 +0100 Message-ID: <20251118160845.3006733-2-neelx@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118160845.3006733-1-neelx@suse.com> References: <20251118160845.3006733-1-neelx@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Queue-Id: CC35F2126D X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -4.00 X-Spam-Level: X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] Content-Type: text/plain; charset="utf-8" From: Omar Sandoval Initially, only normal data extents will be encrypted. This change forbids various other bits: - allows reflinking only if both inodes have the same encryption status - disable inline data on encrypted inodes Signed-off-by: Omar Sandoval Signed-off-by: Sweet Tea Dorminy Signed-off-by: Josef Bacik Signed-off-by: Daniel Vacek --- v5 was 'Reviewed-by: Boris Burkov ' but the rebase changed the code a bit so dropping. https://lore.kernel.org/linux-btrfs/20240124195303.GC1789919@zen.localdomai= n/ --- fs/btrfs/inode.c | 4 ++++ fs/btrfs/reflink.c | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/fs/btrfs/inode.c b/fs/btrfs/inode.c index f71a5f7f55b9..8e13117eca16 100644 --- a/fs/btrfs/inode.c +++ b/fs/btrfs/inode.c @@ -592,6 +592,10 @@ static bool can_cow_file_range_inline(struct btrfs_ino= de *inode, if (size < i_size_read(&inode->vfs_inode)) return false; =20 + /* Encrypted file cannot be inlined. */ + if (IS_ENCRYPTED(&inode->vfs_inode)) + return false; + return true; } =20 diff --git a/fs/btrfs/reflink.c b/fs/btrfs/reflink.c index 775a32a7953a..3c9c570d6493 100644 --- a/fs/btrfs/reflink.c +++ b/fs/btrfs/reflink.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0 =20 #include +#include #include #include "ctree.h" #include "fs.h" @@ -789,6 +790,12 @@ static int btrfs_remap_file_range_prep(struct file *fi= le_in, loff_t pos_in, ASSERT(inode_in->vfs_inode.i_sb =3D=3D inode_out->vfs_inode.i_sb); } =20 + /* + * Can only reflink encrypted files if both files are encrypted. + */ + if (IS_ENCRYPTED(&inode_in->vfs_inode) !=3D IS_ENCRYPTED(&inode_out->vfs_= inode)) + return -EINVAL; + /* Don't make the dst file partly checksummed */ if ((inode_in->flags & BTRFS_INODE_NODATASUM) !=3D (inode_out->flags & BTRFS_INODE_NODATASUM)) { --=20 2.51.0 From nobody Tue Dec 2 02:37:43 2025 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 43368364033 for ; Tue, 18 Nov 2025 16:09:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763482141; cv=none; b=n2ZuKTIJ8xJ1RuAqZByIYVKj2tZj9Ohag8TsDl1d+xKDL5zXUW47e9/Mijx7tBnK2x+MAV0UN8tzAW4nISsELw5X4qls6pwJVR3+OXfpeeYeCjlz2UjTnR4aCbjYCLulF5YurhXNIRybznCdULqE8VeIZyXH6B07Cg3a+nk+r9M= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763482141; c=relaxed/simple; bh=lYbAgki+AHw1EkZ3Vrf/4jsw/2G6zfphnrCQRXzU8qY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hM5LzUsKahXsGLXBJmElPyVPECPlUgXNxJ7C/1Tdt0nds4nfKywDyrSPqsOJODC/gEtB5/TjSfHX83UB8WNNpZeoLYPx1ebwSgOYpKMug0QAnZZzjeTg/201lIvwb1ZewdfHs2Mb1QH6XbUCh13iWxTh/Ewic8GVT2/iaVBplro= 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; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=Ra6lQnWY; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=Ra6lQnWY; arc=none smtp.client-ip=195.135.223.131 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="Ra6lQnWY"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="Ra6lQnWY" Received: from imap1.dmz-prg2.suse.org (unknown [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-out2.suse.de (Postfix) with ESMTPS id 384771FF8A; Tue, 18 Nov 2025 16:08:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1763482133; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oMdqlW5MqclqolugCJ1CKZKHU2hFqToPTNe/MUSR8Wg=; b=Ra6lQnWYB8oPs2JrgEyEDIajBJJAOHg5wPowSkk1hYzdeRWeuYSfYUqOkyXuWYbZSW40M4 my1Hpc5XJwlAYlvILx3WW8QNeZIW3nQY/R/JmtE8s/w+jH2L2nRo1WjVpdGNDTXFN7+aCL y1VDx3IgrpQK0ySQifpAev8fC5cmpJU= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1763482133; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=oMdqlW5MqclqolugCJ1CKZKHU2hFqToPTNe/MUSR8Wg=; b=Ra6lQnWYB8oPs2JrgEyEDIajBJJAOHg5wPowSkk1hYzdeRWeuYSfYUqOkyXuWYbZSW40M4 my1Hpc5XJwlAYlvILx3WW8QNeZIW3nQY/R/JmtE8s/w+jH2L2nRo1WjVpdGNDTXFN7+aCL y1VDx3IgrpQK0ySQifpAev8fC5cmpJU= 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 1E1E53EA61; Tue, 18 Nov 2025 16:08:53 +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 WCfUBhWaHGlnYQAAD6G6ig (envelope-from ); Tue, 18 Nov 2025 16:08:53 +0000 From: Daniel Vacek To: Chris Mason , Josef Bacik , David Sterba Cc: Daniel Vacek , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Sweet Tea Dorminy , Boris Burkov Subject: [PATCH v7 2/6] btrfs: disable verity on encrypted inodes Date: Tue, 18 Nov 2025 17:08:39 +0100 Message-ID: <20251118160845.3006733-3-neelx@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118160845.3006733-1-neelx@suse.com> References: <20251118160845.3006733-1-neelx@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo,suse.com:mid]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FROM_EQ_ENVFROM(0.00)[]; TO_DN_SOME(0.00)[]; RCPT_COUNT_SEVEN(0.00)[8]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -6.80 Content-Type: text/plain; charset="utf-8" From: Sweet Tea Dorminy Right now there isn't a way to encrypt things that aren't either filenames in directories or data on blocks on disk with extent encryption, so for now, disable verity usage with encryption on btrfs. fscrypt with fsverity should be possible and it can be implemented in the future. Signed-off-by: Sweet Tea Dorminy Signed-off-by: Josef Bacik Reviewed-by: Boris Burkov --- fs/btrfs/verity.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/btrfs/verity.c b/fs/btrfs/verity.c index 16f5580cba55..06dfcb461f53 100644 --- a/fs/btrfs/verity.c +++ b/fs/btrfs/verity.c @@ -578,6 +578,9 @@ static int btrfs_begin_enable_verity(struct file *filp) =20 btrfs_assert_inode_locked(inode); =20 + if (IS_ENCRYPTED(&inode->vfs_inode)) + return -EOPNOTSUPP; + if (test_bit(BTRFS_INODE_VERITY_IN_PROGRESS, &inode->runtime_flags)) return -EBUSY; =20 --=20 2.51.0 From nobody Tue Dec 2 02:37:43 2025 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 C2C4336A013 for ; Tue, 18 Nov 2025 16:09:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763482149; cv=none; b=dv2cDM+WJ63+BhszoevKlghRBfRxX27+/Qxo2HcWk37hD5D2qiCbHtBFxRLayEiz60f0DdZ9x5712h44X0vC236YNys+g//j8gZlU4+k5I/nWmp8H1/SBoDomAYNKSfYOcKQE2str/QZesAm+hNiCjyi89k9iERJ1rKCyRkLmQQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763482149; c=relaxed/simple; bh=H09kXkzCHjshIOsBvxrpbDVneOhMeKZ4DakgDGkO498=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ekQWU4OTqmLq+ilZORCMBBJkcwxKwfW+0IBxiTh7NTJkmZuoea9EzowdN6k88//LctVGAk0GHuHXssp5MXFS8MAqua/QSU1Sm3S2KXs5C5alBAZIBidwyeMhcrauosN0RB2ZFHBy/mc5rRJptIC3crABMZ3QOXLgC1bSFKolKPo= 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; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=rWeRhXbc; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=rWeRhXbc; arc=none smtp.client-ip=195.135.223.131 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="rWeRhXbc"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="rWeRhXbc" Received: from imap1.dmz-prg2.suse.org (unknown [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-out2.suse.de (Postfix) with ESMTPS id BB8791FF8B; Tue, 18 Nov 2025 16:08:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1763482133; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=izpK1ZO+0JeJl4swc++dI5OHKibxqNBLEWwV3CvwziQ=; b=rWeRhXbcmaeroHmZG4GZU5coA/btSey/IEb6usvfnVxEgsyRrSaqOKhotd3O72suVQU91P u01UCI6fw+0JJxxe7mijKHWgfJPuF2kzqrBxmVRXyoL2UQeTTQp9iop5o6C6ulqfBLCoCP yD/Fsm6RXBamilIJBuEj+lZTnz3gSQs= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1763482133; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=izpK1ZO+0JeJl4swc++dI5OHKibxqNBLEWwV3CvwziQ=; b=rWeRhXbcmaeroHmZG4GZU5coA/btSey/IEb6usvfnVxEgsyRrSaqOKhotd3O72suVQU91P u01UCI6fw+0JJxxe7mijKHWgfJPuF2kzqrBxmVRXyoL2UQeTTQp9iop5o6C6ulqfBLCoCP yD/Fsm6RXBamilIJBuEj+lZTnz3gSQs= 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 A655C3EA61; Tue, 18 Nov 2025 16:08:53 +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 QNIBKBWaHGlnYQAAD6G6ig (envelope-from ); Tue, 18 Nov 2025 16:08:53 +0000 From: Daniel Vacek To: Chris Mason , Josef Bacik , David Sterba Cc: Daniel Vacek , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 3/6] btrfs: add orig_logical to btrfs_bio Date: Tue, 18 Nov 2025 17:08:40 +0100 Message-ID: <20251118160845.3006733-4-neelx@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118160845.3006733-1-neelx@suse.com> References: <20251118160845.3006733-1-neelx@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_FIVE(0.00)[6]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -6.80 Content-Type: text/plain; charset="utf-8" From: Josef Bacik When checksumming the encrypted bio on writes we need to know which logical address this checksum is for. At the point where we get the encrypted bio the bi_sector is the physical location on the target disk, so we need to save the original logical offset in the btrfs_bio. Then we can use this when csum'ing the bio instead of the bio->iter.bi_sector. Signed-off-by: Josef Bacik --- fs/btrfs/bio.c | 10 ++++++++++ fs/btrfs/bio.h | 2 ++ fs/btrfs/file-item.c | 2 +- 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/fs/btrfs/bio.c b/fs/btrfs/bio.c index 1b38e3ee0a33..4a7bef895b97 100644 --- a/fs/btrfs/bio.c +++ b/fs/btrfs/bio.c @@ -94,6 +94,8 @@ static struct btrfs_bio *btrfs_split_bio(struct btrfs_fs_= info *fs_info, if (bbio_has_ordered_extent(bbio)) { refcount_inc(&orig_bbio->ordered->refs); bbio->ordered =3D orig_bbio->ordered; + bbio->orig_logical =3D orig_bbio->orig_logical; + orig_bbio->orig_logical +=3D map_length; } bbio->csum_search_commit_root =3D orig_bbio->csum_search_commit_root; atomic_inc(&orig_bbio->pending_ios); @@ -765,6 +767,14 @@ static bool btrfs_submit_chunk(struct btrfs_bio *bbio,= int mirror_num) goto end_bbio; } =20 + /* + * For fscrypt writes we will get the encrypted bio after we've + * remapped our bio to the physical disk location, so we need to + * save the original bytenr so we know what we're checksumming. + */ + if (bio_op(bio) =3D=3D REQ_OP_WRITE && is_data_bbio(bbio)) + bbio->orig_logical =3D logical; + map_length =3D min(map_length, length); if (use_append) map_length =3D btrfs_append_map_length(bbio, map_length); diff --git a/fs/btrfs/bio.h b/fs/btrfs/bio.h index 035145909b00..56279b7f3b2a 100644 --- a/fs/btrfs/bio.h +++ b/fs/btrfs/bio.h @@ -52,6 +52,7 @@ struct btrfs_bio { * - pointer to the checksums for this bio * - original physical address from the allocator * (for zone append only) + * - original logical address, used for checksumming fscrypt bios. */ struct { struct btrfs_ordered_extent *ordered; @@ -60,6 +61,7 @@ struct btrfs_bio { struct completion csum_done; struct bvec_iter csum_saved_iter; u64 orig_physical; + u64 orig_logical; }; =20 /* For metadata reads: parentness verification. */ diff --git a/fs/btrfs/file-item.c b/fs/btrfs/file-item.c index b17632ea085f..14e5257f0f04 100644 --- a/fs/btrfs/file-item.c +++ b/fs/btrfs/file-item.c @@ -824,7 +824,7 @@ int btrfs_csum_one_bio(struct btrfs_bio *bbio, bool asy= nc) if (!sums) return -ENOMEM; =20 - sums->logical =3D bio->bi_iter.bi_sector << SECTOR_SHIFT; + sums->logical =3D bbio->orig_logical; sums->len =3D bio->bi_iter.bi_size; INIT_LIST_HEAD(&sums->list); bbio->sums =3D sums; --=20 2.51.0 From nobody Tue Dec 2 02:37:43 2025 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 B4DD2377E8A for ; Tue, 18 Nov 2025 16:09:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763482155; cv=none; b=G/XJ4Odpg69TyTN/tUkEuXGTwH75tCSfj1yLk64iTDECDAqURO2kb0QTYPzQhtZXSw5j7UrYWQBFMMFLlVrIs/JIwKqflrwf7ytOnmXhKNGLzruoIp9petxp4itnpwKWTYjl/mi+vW6XO0L2eSN31HLTUb3cbphQPpS5cGIrTbM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763482155; c=relaxed/simple; bh=9oUVPZXb839YHlhJsKwAl4wHIictHBrmkJfSVFYDhYA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=DAP+RswnjKJvuPgdIBPAsb5iNKYv+02q7T4kAaBI9CIk0au1QRZ/mxAtAWkUpp9OrMo0V3IfYxPrQptvTd/Gc0wgcWtnmtDPM0OqX/cqeJcfJDH0XHdqg3BCZATO+VrB//gDcwBknNFUr3uMm3sBqHkLwKflVG70clhhlfVH98Y= 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.131 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-out2.suse.de (Postfix) with ESMTPS id 23E041FF8C; Tue, 18 Nov 2025 16:08:54 +0000 (UTC) Authentication-Results: smtp-out2.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 0EE3A3EA61; Tue, 18 Nov 2025 16:08:54 +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 MPAYAxaaHGlnYQAAD6G6ig (envelope-from ); Tue, 18 Nov 2025 16:08:54 +0000 From: Daniel Vacek To: Chris Mason , Josef Bacik , David Sterba Cc: Daniel Vacek , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 4/6] btrfs: don't rewrite ret from inode_permission Date: Tue, 18 Nov 2025 17:08:41 +0100 Message-ID: <20251118160845.3006733-5-neelx@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118160845.3006733-1-neelx@suse.com> References: <20251118160845.3006733-1-neelx@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: 23E041FF8C X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -4.00 Content-Type: text/plain; charset="utf-8" From: Josef Bacik In our user safe ino resolve ioctl we'll just turn any ret into -EACCES from inode_permission. This is redundant, and could potentially be wrong if we had an ENOMEM in the security layer or some such other error, so simply return the actual return value. Signed-off-by: Josef Bacik Reviewed-by: Johannes Thumshirn --- fs/btrfs/ioctl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index 1920caf8d308..c2d992f5ce7d 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1910,10 +1910,8 @@ static int btrfs_search_path_in_tree_user(struct mnt= _idmap *idmap, ret =3D inode_permission(idmap, &temp_inode->vfs_inode, MAY_READ | MAY_EXEC); iput(&temp_inode->vfs_inode); - if (ret) { - ret =3D -EACCES; + if (ret) goto out_put; - } =20 if (key.offset =3D=3D upper_limit) break; --=20 2.51.0 From nobody Tue Dec 2 02:37:43 2025 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 3723136C5B1 for ; Tue, 18 Nov 2025 16:09:01 +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=1763482143; cv=none; b=lUFJy7MFRVsfJ4o10SMuTIwOsKbM05euch3Q8s2ivBEYK+gXpEUizJDgM3hcfrv9MavvkLnGDZ/giPixGLharbzUl1URVn5UBv3cHJ2u7cvGeDxEWw3jJdRcvSX2qYpTl9n9ELFmKuhRFerksV3YHzGn3KRxbBecMc17M6e8gdM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763482143; c=relaxed/simple; bh=a4EeTFdOmh5nbZ+a7Uyi1ZCNfwYSq1mywHIrl7yJSOc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ptujEOoiYHD03xeg8NtKp+VrLYkPyV6LG274n6KkcA4QAnpH1husxK2I5T2XD7x7gHkggRwTG6aQT6bcN+p/ib07Cz4u/h8kX59nMkFnwd7qE3iRQ8oJArBcExvAB77XpwERBLI3OxlNax0LbinpZSMtnEoJhWwh/W5ZpPiyY1k= 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 8836B211F6; Tue, 18 Nov 2025 16:08:54 +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 716293EA61; Tue, 18 Nov 2025 16:08:54 +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 EHchGxaaHGlnYQAAD6G6ig (envelope-from ); Tue, 18 Nov 2025 16:08:54 +0000 From: Daniel Vacek To: Chris Mason , Josef Bacik , David Sterba Cc: Daniel Vacek , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 5/6] btrfs: move inode_to_path higher in backref.c Date: Tue, 18 Nov 2025 17:08:42 +0100 Message-ID: <20251118160845.3006733-6-neelx@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118160845.3006733-1-neelx@suse.com> References: <20251118160845.3006733-1-neelx@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spam-Level: X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Queue-Id: 8836B211F6 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action X-Spam-Flag: NO X-Spam-Score: -4.00 Content-Type: text/plain; charset="utf-8" From: Josef Bacik We have a prototype and then the definition lower below, we don't need to do this, simply move the function to where the prototype is. Signed-off-by: Josef Bacik Reviewed-by: Johannes Thumshirn --- fs/btrfs/backref.c | 68 ++++++++++++++++++++++------------------------ 1 file changed, 32 insertions(+), 36 deletions(-) diff --git a/fs/btrfs/backref.c b/fs/btrfs/backref.c index 78da47a3d00e..bd913e3c356f 100644 --- a/fs/btrfs/backref.c +++ b/fs/btrfs/backref.c @@ -2574,8 +2574,39 @@ int iterate_inodes_from_logical(u64 logical, struct = btrfs_fs_info *fs_info, return iterate_extent_inodes(&walk_ctx, false, build_ino_list, ctx); } =20 +/* + * returns 0 if the path could be dumped (probably truncated) + * returns <0 in case of an error + */ static int inode_to_path(u64 inum, u32 name_len, unsigned long name_off, - struct extent_buffer *eb, struct inode_fs_paths *ipath); + struct extent_buffer *eb, struct inode_fs_paths *ipath) +{ + char *fspath; + char *fspath_min; + int i =3D ipath->fspath->elem_cnt; + const int s_ptr =3D sizeof(char *); + u32 bytes_left; + + bytes_left =3D ipath->fspath->bytes_left > s_ptr ? ipath->fspath->bytes_l= eft - s_ptr : 0; + + fspath_min =3D (char *)ipath->fspath->val + (i + 1) * s_ptr; + fspath =3D btrfs_ref_to_path(ipath->fs_root, ipath->btrfs_path, name_len, + name_off, eb, inum, fspath_min, bytes_left); + if (IS_ERR(fspath)) + return PTR_ERR(fspath); + + if (fspath > fspath_min) { + ipath->fspath->val[i] =3D (u64)(unsigned long)fspath; + ++ipath->fspath->elem_cnt; + ipath->fspath->bytes_left =3D fspath - fspath_min; + } else { + ++ipath->fspath->elem_missed; + ipath->fspath->bytes_missing +=3D fspath_min - fspath; + ipath->fspath->bytes_left =3D 0; + } + + return 0; +} =20 static int iterate_inode_refs(u64 inum, struct inode_fs_paths *ipath) { @@ -2700,41 +2731,6 @@ static int iterate_inode_extrefs(u64 inum, struct in= ode_fs_paths *ipath) return ret; } =20 -/* - * returns 0 if the path could be dumped (probably truncated) - * returns <0 in case of an error - */ -static int inode_to_path(u64 inum, u32 name_len, unsigned long name_off, - struct extent_buffer *eb, struct inode_fs_paths *ipath) -{ - char *fspath; - char *fspath_min; - int i =3D ipath->fspath->elem_cnt; - const int s_ptr =3D sizeof(char *); - u32 bytes_left; - - bytes_left =3D ipath->fspath->bytes_left > s_ptr ? - ipath->fspath->bytes_left - s_ptr : 0; - - fspath_min =3D (char *)ipath->fspath->val + (i + 1) * s_ptr; - fspath =3D btrfs_ref_to_path(ipath->fs_root, ipath->btrfs_path, name_len, - name_off, eb, inum, fspath_min, bytes_left); - if (IS_ERR(fspath)) - return PTR_ERR(fspath); - - if (fspath > fspath_min) { - ipath->fspath->val[i] =3D (u64)(unsigned long)fspath; - ++ipath->fspath->elem_cnt; - ipath->fspath->bytes_left =3D fspath - fspath_min; - } else { - ++ipath->fspath->elem_missed; - ipath->fspath->bytes_missing +=3D fspath_min - fspath; - ipath->fspath->bytes_left =3D 0; - } - - return 0; -} - /* * this dumps all file system paths to the inode into the ipath struct, pr= ovided * is has been created large enough. each path is zero-terminated and acce= ssed --=20 2.51.0 From nobody Tue Dec 2 02:37:43 2025 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 30ADF36B050 for ; Tue, 18 Nov 2025 16:09:07 +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=1763482150; cv=none; b=KPj5weenthDNSFqagWJD7HdkFt2m0bSbwn9AnvNIq+mm7T/Y1LAXL1bm/Da6m8DlHxOvy1rYVGyqqUM+ED9+/0YTObA+gA6gpaROJfF8Jyvp1Y4b0YY6C7dolgeB+1seWpO+5SmPAqitDXPjNqiYI8fzV3/LNTtfzht5PJRdsHI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763482150; c=relaxed/simple; bh=EqBXRxLaT5bXn9isFY1BGIkHkrg2gtWCsErmndXmkfQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Gb9lcOb4DMrt2RZmGmJypfgJNq+GErM1SZVvh6HEkXo0VO4ZgBcGEVOPUWnAqVYqYw/fMfB6CX8KkuLI6p7X5vqEIZEgKlu63dP2s4G40E0xAspDglaNG5QasOa+oOKO/EXhOy46ZfoPRaP7Rfq5uBA1Is2ue0S2JEWxqYFwAX4= 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; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=XDR1rTrw; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=tbtVxzrG; 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="XDR1rTrw"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="tbtVxzrG" Received: from imap1.dmz-prg2.suse.org (unknown [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 E64052126E; Tue, 18 Nov 2025 16:08:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1763482135; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rGiyHM236mKp4HMdnwwzVRNs3LJ5NzSkeXvprHlui7E=; b=XDR1rTrw9UICaG8Gyc/NWxVpJ2akZ7338YXWmJgyiwb+yrNeDIdnBOLP0uMxvBIw+TK8+6 OBNrNIP9WOEV0ol6FQHcZk65EQ6OQtIRmPBPElsKp1uvKqOFP1Ro9P7G8GYppd5ukgj2cQ W+kIsnJ0aED8wwmt1bOJiaE0IOVZ3eM= Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1763482134; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=rGiyHM236mKp4HMdnwwzVRNs3LJ5NzSkeXvprHlui7E=; b=tbtVxzrGcvbSvS+Jp/kA0lL1MmQUjWCxMxJahubj7//pS3zITOaA08MVEGes00iRlxuTLT Y8kjdkQj5IbrAS9n1RPt8fTWtA5W9jdFVykY1te8+Ytosi+cWmXSO2ginZh6BdxKjAac7D RgTnxrVK72Q7MBN0V0gtOwFmm6yqiLs= 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 D2BD83EA61; Tue, 18 Nov 2025 16:08:54 +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 qNjJMhaaHGlnYQAAD6G6ig (envelope-from ); Tue, 18 Nov 2025 16:08:54 +0000 From: Daniel Vacek To: Chris Mason , Josef Bacik , David Sterba Cc: Daniel Vacek , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v7 6/6] btrfs: don't search back for dir inode item in INO_LOOKUP_USER Date: Tue, 18 Nov 2025 17:08:43 +0100 Message-ID: <20251118160845.3006733-7-neelx@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118160845.3006733-1-neelx@suse.com> References: <20251118160845.3006733-1-neelx@suse.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Spam-Level: X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; NEURAL_HAM_LONG(-1.00)[-1.000]; MID_CONTAINS_FROM(1.00)[]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_COUNT_TWO(0.00)[2]; FROM_HAS_DN(0.00)[]; ARC_NA(0.00)[]; MIME_TRACE(0.00)[0:+]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCPT_COUNT_FIVE(0.00)[6]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid,imap1.dmz-prg2.suse.org:helo]; RCVD_TLS_ALL(0.00)[] X-Spam-Flag: NO X-Spam-Score: -6.80 Content-Type: text/plain; charset="utf-8" From: Josef Bacik We don't need to search back to the inode item, the directory inode number is in key.offset, so simply use that. If we can't find the directory we'll get an ENOENT at the iget. Signed-off-by: Josef Bacik Reviewed-by: Johannes Thumshirn --- fs/btrfs/ioctl.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c index c2d992f5ce7d..69df5765acfa 100644 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@ -1822,7 +1822,7 @@ static int btrfs_search_path_in_tree_user(struct mnt_= idmap *idmap, struct btrfs_root_ref *rref; struct btrfs_root *root =3D NULL; struct btrfs_path *path; - struct btrfs_key key, key2; + struct btrfs_key key; struct extent_buffer *leaf; char *ptr; int slot; @@ -1877,24 +1877,6 @@ static int btrfs_search_path_in_tree_user(struct mnt= _idmap *idmap, read_extent_buffer(leaf, ptr, (unsigned long)(iref + 1), len); =20 - /* Check the read+exec permission of this directory */ - ret =3D btrfs_previous_item(root, path, dirid, - BTRFS_INODE_ITEM_KEY); - if (ret < 0) { - goto out_put; - } else if (ret > 0) { - ret =3D -ENOENT; - goto out_put; - } - - leaf =3D path->nodes[0]; - slot =3D path->slots[0]; - btrfs_item_key_to_cpu(leaf, &key2, slot); - if (key2.objectid !=3D dirid) { - ret =3D -ENOENT; - goto out_put; - } - /* * We don't need the path anymore, so release it and * avoid deadlocks and lockdep warnings in case @@ -1902,11 +1884,12 @@ static int btrfs_search_path_in_tree_user(struct mn= t_idmap *idmap, * btree and lock the same leaf. */ btrfs_release_path(path); - temp_inode =3D btrfs_iget(key2.objectid, root); + temp_inode =3D btrfs_iget(key.offset, root); if (IS_ERR(temp_inode)) { ret =3D PTR_ERR(temp_inode); goto out_put; } + /* Check the read+exec permission of this directory */ ret =3D inode_permission(idmap, &temp_inode->vfs_inode, MAY_READ | MAY_EXEC); iput(&temp_inode->vfs_inode); --=20 2.51.0