From nobody Tue Dec 2 02:49:44 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