From nobody Tue Dec 2 02:42:55 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 C509C369963 for ; Tue, 18 Nov 2025 16:01:09 +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=1763481671; cv=none; b=ZHg6wWtS9Y8DvFp40PSPYw6KGZWrppaS23O1EYxZIaAQPMAfKSthOKy291++plHjeQz1XjPyl2pWIFMZC1pzoFXI1ww2abjrWsZ3zcCtkPtRXlaR+DmX70vACEev+ujLJvDGefJiCIi0V3wsCrhOnJiZWH9VtMgBQmU4UD7OoMM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1763481671; c=relaxed/simple; bh=PBKpHZfvRe/oRsGhIN731SPaQ8BVsGnktsZpyvKvdkM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=dTFDV4e19nT+WIIB4cNjCKNzmgayCyiuBzYe5ml2IaWLGOJEs/FIzYAN/Yzy/gk76ni+BQaKEeu1qbMwUcD2vdCZ4tq2aU7lM+BmtVA8u77QaBs+npyvZEVmcAd3G4nz9QkCTdh09k1vjz0xQJcEg7Ovc7aU5Bt0U9jp6S/WoNg= 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=mkR/sRj6; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b=mkR/sRj6; 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="mkR/sRj6"; dkim=pass (1024-bit key) header.d=suse.com header.i=@suse.com header.b="mkR/sRj6" 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 808731FF86; Tue, 18 Nov 2025 16:01:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1763481662; 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=1C1DBii4YHQJJuwFv7p2Q8KZq7zRRY0Cp1It30EA3+M=; b=mkR/sRj6uCvCBilV4SevWMxQ/W8MGkxIYgax2m9ri0VcXXNK7fk4zgYf0VIfDavWkFK0EY 4EP30o0g6U3nzBmcIW9JAT9ilU91M3Kdevg7c8lwO0641JOQL3iQDHmdcVD/SOIkNPl7Ah 4eFSF0Hz/NdLrUVavl7MWQm/z7Afwjg= Authentication-Results: smtp-out2.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.com; s=susede1; t=1763481662; 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=1C1DBii4YHQJJuwFv7p2Q8KZq7zRRY0Cp1It30EA3+M=; b=mkR/sRj6uCvCBilV4SevWMxQ/W8MGkxIYgax2m9ri0VcXXNK7fk4zgYf0VIfDavWkFK0EY 4EP30o0g6U3nzBmcIW9JAT9ilU91M3Kdevg7c8lwO0641JOQL3iQDHmdcVD/SOIkNPl7Ah 4eFSF0Hz/NdLrUVavl7MWQm/z7Afwjg= 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 66D0D3EA61; Tue, 18 Nov 2025 16:01:02 +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 EILJFz6YHGkSWgAAD6G6ig (envelope-from ); Tue, 18 Nov 2025 16:01:02 +0000 From: Daniel Vacek To: Chris Mason , Josef Bacik , David Sterba Cc: Daniel Vacek , linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Daniel Vacek Subject: [PATCH v7 5/6] btrfs: move inode_to_path higher in backref.c Date: Tue, 18 Nov 2025 17:00:40 +0100 Message-ID: <20251118160043.3005684-6-neelx@suse.com> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20251118160043.3005684-1-neelx@suse.com> References: <20251118160043.3005684-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-Spamd-Result: default: False [-5.30 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; SUSPICIOUS_RECIPS(1.50)[]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; FUZZY_RATELIMITED(0.00)[rspamd.com]; FREEMAIL_CC(0.00)[suse.com,vger.kernel.org,gmail.com]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TAGGED_RCPT(0.00)[]; FROM_HAS_DN(0.00)[]; RCVD_TLS_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.com:mid]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[]; DKIM_SIGNED(0.00)[suse.com:s=susede1]; RCPT_COUNT_SEVEN(0.00)[7]; TO_DN_SOME(0.00)[]; FREEMAIL_ENVRCPT(0.00)[gmail.com] X-Spam-Flag: NO X-Spam-Score: -5.30 X-Spam-Level: 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 Signed-off-by: Daniel Vacek --- 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