From patchwork Thu Feb 20 11:04:14 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983750 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2A5561E0B7F for ; Thu, 20 Feb 2025 11:04:48 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049489; cv=none; b=c/AM7tBN0Am6fI041nDSWfGwRhxVo26E4K0C24suCAlgiYmhCFOP+oJG6YrD83OKAaOfocApSQaJZUHi+DZ/mZzNsRRfWOTfA7CFpZ6XfzXdib0tZenCIr4VcNNKn8STLpQB48X+n2qyq+2BDAWNnV4+pqujYvJV9nZhuGoKvjA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049489; c=relaxed/simple; bh=SFoXfHCjtGJFKLXsvz0msUIJ3NMfNEF9czHWurNCZcY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=HoNDZQZuYkXXeFdA1KmCkZok7HHtqTg5lQvjI9LCOXnjYFlfpC2xt+7iGxRJnJBV0w5yr69Esus1mauxHfCD2xu6MYfUrpSMSK7x8d1k6KtTqw6tF+i/XMhjC+MdFJYOmvp3KnEWOecJO2AH68DC83gM79pRtJkaFBxjDdWQe0k= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ijZ0B8eM; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ijZ0B8eM" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0DD8BC4CEE3 for ; Thu, 20 Feb 2025 11:04:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049488; bh=SFoXfHCjtGJFKLXsvz0msUIJ3NMfNEF9czHWurNCZcY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ijZ0B8eM2uWD1Gea15zEflf3SLDY3u8LzYo6I1hzOoHkVVaapX5VhQ6Bn35tfw4Bh XLfI6FfAE0ccP2FGhwm9L0cZY82/fiOLDErC/+IIa6jwqqJnuKmVutz+vARIUdSMvg nWhaQTf01WKnYnmOSwB0R6aY3IAkEWjsmTsbY0PYvLtjjK3HQtZ7i07fz8qF+V3RDs X1rt5oJ1zK/K91eVe/fzWHYiGgF3asVUMrWVz1Dq1iU3RQz0vmji2csI8VIUK0Y0nD 1oRCrJn3ED1WV4FeqVUTfDuH/s8CmN8m4kRNXQOvQEnVvrOsyRCabj1aI0Oggz8OS/ FlkA9RctQtTXw== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 01/30] btrfs: send: remove duplicated logic from fs_path_reset() Date: Thu, 20 Feb 2025 11:04:14 +0000 Message-Id: <11c4195087f7e815a71e9803ad276897df156c83.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There's duplicated logic in both branches of the if statement, so move it outside the branches. This also reduces the object code size. Before this change: $ size fs/btrfs/btrfs.ko text data bss dec hex filename 1746279 163600 16920 1926799 1d668f fs/btrfs/btrfs.ko After this change: $ size fs/btrfs/btrfs.ko text data bss dec hex filename 1746047 163592 16920 1926559 1d659f fs/btrfs/btrfs.ko Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index d513f7fd5fe8..8de561fb1390 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -424,15 +424,13 @@ static int need_send_hole(struct send_ctx *sctx) static void fs_path_reset(struct fs_path *p) { - if (p->reversed) { + if (p->reversed) p->start = p->buf + p->buf_len - 1; - p->end = p->start; - *p->start = 0; - } else { + else p->start = p->buf; - p->end = p->start; - *p->start = 0; - } + + p->end = p->start; + *p->start = 0; } static struct fs_path *fs_path_alloc(void) From patchwork Thu Feb 20 11:04:15 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983751 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 333431F0E2D for ; Thu, 20 Feb 2025 11:04:49 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049490; cv=none; b=Y5NjElTq5ZqKr3Mf3haTf/5zGL/s+BfuO0pEHu0sWf8rQfuvLe9SIdtM/xlb2GnvEXskYxaBjLdczA1a1SYPlU30ns5wlXM1Ea/vhrmy+KhM0uY3lIyxkd0yqbNsaNMEs+olTD2UkmyqRoEB44CPHC0zUXavCnceR3gC/OWrHqA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049490; c=relaxed/simple; bh=VElW5lz5SNietu+keLp8sG3SfJrkP00ZTihTb1ozIFI=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=bRxZ1Vr+aczmmuLZr1Xaxi8g5UYk0KsikkF5MPgMDWbCLfl/DWt0xvaKaWE7rENqngRNEUZHqFpD5OnF6mKaJ1SK3SvPyTyCCXKrd7G7pzfZHgFdlbh/8ZZZeoLvHLABL3ct1fHvGrVsdPYdm1CuH1tLYbzj17gkcNXsqPpuoho= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=fmFOeHlY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="fmFOeHlY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 14C63C4CEDD for ; Thu, 20 Feb 2025 11:04:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049489; bh=VElW5lz5SNietu+keLp8sG3SfJrkP00ZTihTb1ozIFI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fmFOeHlYWIanQJ3xlTdYbgPMInjp3aJwX5oUh51UXGYPF2gQ5/ayZibeCHSXpE1kn mSAAmRIt2xydjMW70qmGocB42c5EyvHRMXmqq7PNqxkFMve45bmsnSjhjD3RRGtpaD jARM8UYngX7o4jV8VZr95Fmi5kEK9ZPXbnuy2sWi7woUVWqCkHnFED5hEcqFK2Ot0Z rLJKVg0kXA+WOmdtmGLOx38+cF52Onz3zmaxNVwGpsWPS5vVfJ2RKgJzR6xwiXJU0A UZrWuGqV5GQxFBd7YvXvJnu8BTXMEUhNjR8lBcq3zL7zJixIpUI8mXLbSjPo5jJrih wU/vE3LgJF8tg== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 02/30] btrfs: send: make fs_path_len() inline and constify its argument Date: Thu, 20 Feb 2025 11:04:15 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana The helper function fs_path_len() is trivial and doesn't need to change its path argument, so make it inline and constify the argument. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 8de561fb1390..4e998bf8d379 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -468,7 +468,7 @@ static void fs_path_free(struct fs_path *p) kfree(p); } -static int fs_path_len(struct fs_path *p) +static inline int fs_path_len(const struct fs_path *p) { return p->end - p->start; } From patchwork Thu Feb 20 11:04:16 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983752 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C90DB1F12E0 for ; Thu, 20 Feb 2025 11:04:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049490; cv=none; b=TBnkE7dszS3c4bHZaZ0OffkEIShwlarXogCiRd/79reCrRYAkBysk94VUAbsA8aaryy1slOLKkD25dCv0fJgazdMTzVWN/MUpRUZZyrOGwyaBGrkIUgMUa8PC18Cw9n+1CkgGQtAamEnDgy9rrLaQZ46bQ6QqXSwhk6A1x+9V7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049490; c=relaxed/simple; bh=qw0g4x9hg7TAw+pEdZ+odymNejfMhtMSkua0gV5gkeQ=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=rwnO9+LwUMVQIcbtTo3GuEsUZ0KJCJagrhHpqkYKcoLepQvqV+QPu3F4Kx5CJNu6Ii8RHLRiiC5a+QL4MJuNTfxdxusqxSTX1sglN3D8muOsaaVRrPARqiDrurE+AhHjCvseZ6YapzrsNQBHUgAeQNUd/P++KpXBaRaAacx1Abk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Pe92Ckb8; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Pe92Ckb8" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 231FCC4CED1 for ; Thu, 20 Feb 2025 11:04:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049490; bh=qw0g4x9hg7TAw+pEdZ+odymNejfMhtMSkua0gV5gkeQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Pe92Ckb8M3fCYF3/wVzV0gijuHoDh2FTQq7jJ0KSDMxyBzCxNzeWzgHBwon04JxRK uJwr4LpLTPBG7t9QnGVXrpRpBbewuGyUEkliAy8ADVh6iCRq6ByEwVYSljFORj+2w8 XuE7DQxMpQCQEWPdmzMieto7f9wT6sVCx++7ITGOrR4GVX/av0yJ6n1kls1pNo7o6K MFxlJDN+Ugy8blFdG84xDfKW2b2FWCr0zoqdrtY854xWujRG4bqZ6U1vCEJcfNIlY7 OUscsg7dydDbubHTGomPcTwBT0ZjmSuEarargGkEezNuSp63ilHd39l34O2fp5373M 0asfJE2Qf9nFw== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 03/30] btrfs: send: always use fs_path_len() to determine a path's length Date: Thu, 20 Feb 2025 11:04:16 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana Several places are hardcoding the path length calculation instead of using the helper fs_path_len() for that. Update all those places to instead use fs_path_len(). Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 4e998bf8d379..9f9885dc1e10 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -489,7 +489,7 @@ static int fs_path_ensure_buf(struct fs_path *p, int len) return -ENOMEM; } - path_len = p->end - p->start; + path_len = fs_path_len(p); old_buf_len = p->buf_len; /* @@ -530,7 +530,7 @@ static int fs_path_prepare_for_add(struct fs_path *p, int name_len, int ret; int new_len; - new_len = p->end - p->start + name_len; + new_len = fs_path_len(p) + name_len; if (p->start != p->end) new_len++; ret = fs_path_ensure_buf(p, new_len); @@ -571,12 +571,13 @@ static int fs_path_add(struct fs_path *p, const char *name, int name_len) static int fs_path_add_path(struct fs_path *p, struct fs_path *p2) { int ret; + const int p2_len = fs_path_len(p2); char *prepared; - ret = fs_path_prepare_for_add(p, p2->end - p2->start, &prepared); + ret = fs_path_prepare_for_add(p, p2_len, &prepared); if (ret < 0) goto out; - memcpy(prepared, p2->start, p2->end - p2->start); + memcpy(prepared, p2->start, p2_len); out: return ret; @@ -616,7 +617,7 @@ static void fs_path_unreverse(struct fs_path *p) return; tmp = p->start; - len = p->end - p->start; + len = fs_path_len(p); p->start = p->buf; p->end = p->start + len; memmove(p->start, tmp, len + 1); @@ -737,7 +738,7 @@ static int tlv_put_btrfs_timespec(struct send_ctx *sctx, u16 attr, #define TLV_PUT_PATH(sctx, attrtype, p) \ do { \ ret = tlv_put_string(sctx, attrtype, p->start, \ - p->end - p->start); \ + fs_path_len((p))); \ if (ret < 0) \ goto tlv_put_failure; \ } while(0) @@ -2364,7 +2365,7 @@ static int __get_cur_name_and_parent(struct send_ctx *sctx, * earlier. If yes, treat as orphan and return 1. */ ret = did_overwrite_ref(sctx, *parent_ino, *parent_gen, ino, gen, - dest->start, dest->end - dest->start); + dest->start, fs_path_len(dest)); if (ret < 0) goto out; if (ret) { From patchwork Thu Feb 20 11:04:17 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983753 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D7A421F152F for ; Thu, 20 Feb 2025 11:04:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049491; cv=none; b=Fmcxxszzp5bUvImwDlpVKNdKFfZ2nrISiRuqfzv+1ObobLtzJboPW234n3AP8ADLIJbM/XyDHtViUvtYjWUAtDyEzLEulOSe/cc2G88/SlIQFD/6v9dRFJMvmisbzNWqKmKu/dXGecxkj1CUnI6U8YlT2Z1XEGI2cMsQznLQOR0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049491; c=relaxed/simple; bh=rdrI5QR7o7YSMAs7It4zSI9Pc91EI1TQvoSr4/qmDNk=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dwNZmQOLZt1/d705jvSjrUvzWM5AFEx9cGtmOBBChjnJjO+yhe1mSPnbavY+kN1byofzQORLTVdvCn8yVFVOfOGXiES5wX/l5i7wNcPIhrpLnPja9BBJdVXfUBUAKuGswlXoZmcEeywpQr+/VlYN+xGKdgoJjr5tcbgtBnYAmDE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=S0dp1OHq; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="S0dp1OHq" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2A3ABC4CED1 for ; Thu, 20 Feb 2025 11:04:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049491; bh=rdrI5QR7o7YSMAs7It4zSI9Pc91EI1TQvoSr4/qmDNk=; h=From:To:Subject:Date:In-Reply-To:References:From; b=S0dp1OHqMZqr5mW/1mh0oUpZvV6M7v07/aLd0W3aYSIZhPeXmP6saIFc/E2C5XJQe eObxS5pqdjwKrZa7RpIPyFG34kvAkAuQwOj9Bk4GRI8HpfiAINF5Bd8rEIEZVkfnA3 H4rRAOFuItTyPkgbHXUw3F+Slqkg4/DKteJA4cQmc/oEB9n+eCBHdOE4w24qylaM02 RkVFfhfgxw4hZu3SDvMlMdXXZJg+DAGEk1MF/LiI8MuR8CMzQZMw+vNeQiK9/0tx8d druRjmy3gNSmUysr287WRW9Fh0jwZCV6v/FjVusiQns0sw0GsEF5jLK5UsGB7tf4c0 tHYEj8Q7RuF5g== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 04/30] btrfs: send: simplify return logic from fs_path_prepare_for_add() Date: Thu, 20 Feb 2025 11:04:17 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There is no need to have an 'out' label and jump into it since there are no resource cleanups to perform (release locks, free memory, etc), so make this simpler by removing the label and goto and instead return directly. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 9f9885dc1e10..535384028cb8 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -535,7 +535,7 @@ static int fs_path_prepare_for_add(struct fs_path *p, int name_len, new_len++; ret = fs_path_ensure_buf(p, new_len); if (ret < 0) - goto out; + return ret; if (p->reversed) { if (p->start != p->end) @@ -550,8 +550,7 @@ static int fs_path_prepare_for_add(struct fs_path *p, int name_len, *p->end = 0; } -out: - return ret; + return 0; } static int fs_path_add(struct fs_path *p, const char *name, int name_len) From patchwork Thu Feb 20 11:04:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983754 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 36FF51D2F53 for ; Thu, 20 Feb 2025 11:04:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049493; cv=none; b=mBPncU5S14FjczLmhmNjlEpTJXKyKEfOiNHgHpl1cVeqY91u+7+e9HOAxuzE4ha89qGTiGO4OfmoVxh+0rdrvhcrHspqXQio9SSzhUB7d4ltr7W4XB2fxVPS3irxtO2R4NgpeCwTQHAuF7+Ce3wk/N/s4ZTWDxoDBz6pEWAxieU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049493; c=relaxed/simple; bh=nLZMehNoN9F5I0XHcpAhnK5JTMMzu8dFugV0exoQdf0=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=e/s9Ol88JhcTjnHT1rj4OLeJ1+NsGZHbamEk/ju7/NH+ei2IlyO6+1AtAnTrjA7suSjIwkrWiEbcvPU+wkZaSNgUmxDYynLTNnYfkGtgtsXnGAjgLM+HuR8gxB12r/QOa3RgTBw3ii3eyU9NX67S8kMh/wIcMUM8miAoiSDueVQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=tTnMJn81; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="tTnMJn81" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 30E18C4CED1 for ; Thu, 20 Feb 2025 11:04:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049492; bh=nLZMehNoN9F5I0XHcpAhnK5JTMMzu8dFugV0exoQdf0=; h=From:To:Subject:Date:In-Reply-To:References:From; b=tTnMJn81DzZJcXXLkpEprckPJiH/7580Fz+QcbUpSzYtZHx2vRehIvBUx7L9NYqOe WiBzOPCKjkqAwusNLg/98ptp6kJ9VOei0iT9Nkz8JG54oXnaSiNDQbi/q5zXea+hiJ IZIdB3VlRprchkrLtbmIFSoboVXuRI1yNj0xvQJ9/mVz6Qdt+0jsMJmnBKZpQe5CXM LpuUQARSNsDKjCgCtDPYQHx7ECwvD4Hc89CRlgK4ekwibd0m5WNaTMTIm7kJeC614O hZyBjgFVpX9rX/7O8PNBlN69sJZapWW4dtCTwCQPh57GzGNgacFf8YuufmguyqBn/O eiTj0/Y46KlNg== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 05/30] btrfs: send: simplify return logic from fs_path_add() Date: Thu, 20 Feb 2025 11:04:18 +0000 Message-Id: <301aafddc69b21853a1b95038cafcb37f9b11588.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There is no need to have an 'out' label and jump into it since there are no resource cleanups to perform (release locks, free memory, etc), so make this simpler by removing the label and goto and instead return directly. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 535384028cb8..2203745569e0 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -560,11 +560,10 @@ static int fs_path_add(struct fs_path *p, const char *name, int name_len) ret = fs_path_prepare_for_add(p, name_len, &prepared); if (ret < 0) - goto out; + return ret; memcpy(prepared, name, name_len); -out: - return ret; + return 0; } static int fs_path_add_path(struct fs_path *p, struct fs_path *p2) From patchwork Thu Feb 20 11:04:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983755 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 50B5E1F2369 for ; Thu, 20 Feb 2025 11:04:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049494; cv=none; b=YTItT1SWLyMHCgTWdLBt+6wx5Zn0aPbtKWLMV3jbVeLEQAEKNEeqeEwa6O+BXQbXWJ+ZoNN7Iozq9aaTUYwcKY6zFS0ocxG5U+5GVSevwVkb+aH7KjsOLe1xXbQVRLsflhp0hr4ALdtg1E1vsAxuav0XzfqQrwC3jfVmDT2icoY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049494; c=relaxed/simple; bh=XxZo2AnDSw5lV1zznAhDaeSUgPufzogr8jT0/2qq8Mo=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qnuZ/Of9uYWCBuFY2BBso4LslMsLQWIbGz7/PSynUmzWpdcghuQ/BpDVR43CXGyU2IPRlpVbfENUiA6fKLe25Dco4iEZdsCaWc7u9v6sJmU+K/OdI7gcEOI1kCNSjmvMwqO52o2zIMBtRy/S/aQJyxqDpYgabINafjnvAsQCM0M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=QbLYiSfr; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="QbLYiSfr" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 37781C4CEE3 for ; Thu, 20 Feb 2025 11:04:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049493; bh=XxZo2AnDSw5lV1zznAhDaeSUgPufzogr8jT0/2qq8Mo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=QbLYiSfr2qfZnmpmT9ooMQrrNbrbDCBeWFra1H06DAltLuGy4O7Qn35c62FWQY4lP Alr5yOEavKDfQmLk8BnHfQBJzRavHMclDqIRDYwkiIqTOvdZB0MM66YXbTXa7GMXF3 /PbBsqa4UmVwcB2Pdtsp1reJXK+2AQbFtlfe+elMy8z0HQNp7wXl+0DEdZhUP389pq jVtMvasjdnfdwi50KUDH9bjN4VmkxR1UrHNIs0bQvfhA95n4XrEMgT04QNkhRQVFJF bb/GerPz7p71I/B4A6OpA1YQHNIv2XyJ3pd3g8/1Ji1fcTvY25kxRiq/8x4NUWce/h 8B+0YltISCj1Q== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 06/30] btrfs: send: implement fs_path_add_path() using fs_path_add() Date: Thu, 20 Feb 2025 11:04:19 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana The helper fs_path_add_path() is basically a copy of fs_path_add() and it can be made a wrapper around fs_path_add(). So do that and also make it inline and constify its second argument. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 2203745569e0..7a75f1d963f9 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -566,19 +566,9 @@ static int fs_path_add(struct fs_path *p, const char *name, int name_len) return 0; } -static int fs_path_add_path(struct fs_path *p, struct fs_path *p2) +static inline int fs_path_add_path(struct fs_path *p, const struct fs_path *p2) { - int ret; - const int p2_len = fs_path_len(p2); - char *prepared; - - ret = fs_path_prepare_for_add(p, p2_len, &prepared); - if (ret < 0) - goto out; - memcpy(prepared, p2->start, p2_len); - -out: - return ret; + return fs_path_add(p, p2->start, fs_path_len(p2)); } static int fs_path_add_from_extent_buffer(struct fs_path *p, From patchwork Thu Feb 20 11:04:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983756 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E20311F2382 for ; Thu, 20 Feb 2025 11:04:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049495; cv=none; b=t2MHD0U1A3mdPKqWalsYt/ZiV1ytMLRNWzeAS/piPJLCrUX2layBPOmvI6UspBn9JNrsxhMCZ/pwRnq1zZmOVIhCr35ifjtL1HOcm/bJfbBpH76UQMqVu5n9enN+RtpXyq1RdCTUhOIsa1VIegR/IhcD7aGiTd66ZSRCdZL8+vY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049495; c=relaxed/simple; bh=TU4XK2ZNfLY7/Ncb2aX2uSF786rE++vnCm1jmieZQ44=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Yj/OlCH2wTtfsZS4dWnFsPLAQ9I72A2QZZteJRyyclb+mghJntlc4yuMQCg1N8CBsX1723Ej7RgnIP6+5gR0IKH7mB9veCghirDIY31UShiBZlmneiLeCYFhoq6XC7n0i9cDjIRdwlBy8ol2Qq+Qjabxau5se5FXWmrFdFkahwA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=adFM72Qk; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="adFM72Qk" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3D3E0C4CEDD for ; Thu, 20 Feb 2025 11:04:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049494; bh=TU4XK2ZNfLY7/Ncb2aX2uSF786rE++vnCm1jmieZQ44=; h=From:To:Subject:Date:In-Reply-To:References:From; b=adFM72Qk1BR9hyN+RB8OOrpj77dztniRZeXif5HewcX6VzGJkjKRn9siSPSblbB7o 66Lj0V25GoADUd8kvZ7TlYtJPaA3vB8kspQg3lJNI7HYxTacGVfUEEiAuUD+n6bEaq 4TGbWpXboAp7r/MWUvrzu7OQpFmnOQ6vEDNptxwd6i6nLzIW62FpX5jv7iFvZl+X05 TF7AQIa+n4SWJsef4UCkgKWYZftrmQuzhk0VPGDADDXsyCqX4xhlj0I/6OaTNeT9El vEn6QVJ/WY8C/mYksSE6Vc7Fns7nTXpXCO0u0tmRdD/pxAVodqEoYntYrFifgadKcY mdTPSoBzNzSNw== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 07/30] btrfs: send: simplify return logic from fs_path_add_from_extent_buffer() Date: Thu, 20 Feb 2025 11:04:20 +0000 Message-Id: <5138a07e83870cb29bb09a340f7ec7abe7eb7d78.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There is no need to have an 'out' label and jump into it since there are no resource cleanups to perform (release locks, free memory, etc), so make this simpler by removing the label and goto and instead return directly. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 7a75f1d963f9..b9de1ab94367 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -580,12 +580,11 @@ static int fs_path_add_from_extent_buffer(struct fs_path *p, ret = fs_path_prepare_for_add(p, len, &prepared); if (ret < 0) - goto out; + return ret; read_extent_buffer(eb, prepared, off, len); -out: - return ret; + return 0; } static int fs_path_copy(struct fs_path *p, struct fs_path *from) From patchwork Thu Feb 20 11:04:21 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983757 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 57AB81F2382 for ; Thu, 20 Feb 2025 11:04:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049496; cv=none; b=HWWHh3p/NOvR+MX003dCtZMK1LVJ29GiLG0Ic6Dc9ph/K1pkeASSGn9r72VJ0a6EEhYhJKuMrW/nd68EG5Inr4zF5esjvh/9v15IF4rY/fZuZ+kaIXWSKnIlVy8RtGz10iTRgpnUqD8tGitW5UN75uOVsv7Xdo/E2b0prRMA5/4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049496; c=relaxed/simple; bh=jyxzL+aBLpb/hFzx7tyDyKjp6IkA5CQDpEEkFLuAiaw=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MWWAR0bYJhYmJFSfyIp5q2ybTwpXSdkzaHQM5w04atvgasIyiiM1qYT0AHiXPeB0h6zINZI71Mdx/1L8sUZtOvZGseMVnXWZhzLkJuSBkmQ447qEHdC40boZ5sLLBCtqwwmlJu/f2zV9PaTZN4AGqw5MTPknBcWyOd4CfTjFtyQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=G2qUcMG4; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="G2qUcMG4" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 44916C4CEDD for ; Thu, 20 Feb 2025 11:04:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049495; bh=jyxzL+aBLpb/hFzx7tyDyKjp6IkA5CQDpEEkFLuAiaw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=G2qUcMG4Rpy3HbXOld58ySMgpAyEbAoV8ELgomAht8lnQ8cYTCa7xw/H/1hTXC0Fm WFqAR+zf41Iahjxml2bESUYy1PZb9MIN+Oxde56Qt7jW/+RZBWroqHjnWT5P6oK8yp 3bLgY9r0DNC1Mdg6HS4pg5XxX5T+IbumTN/6om4ovSu2HP+VgQHjTzkGZxkHLeOxrA gJi54bfaMpFlgdBjjS6AUfS03VUFSQgzyOoVaCF6KpW3MRA/23yqON3CM8hkXsT/fA ATrBR8WSQKdeK+cIbmZ+V9wCFSGaQ6xfpIvQ61MvJG0/rLLv9a/oc0ooz+7TYfZtZh rEfNU40nvF8RQ== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 08/30] btrfs: send: return -ENAMETOOLONG when attempting a path that is too long Date: Thu, 20 Feb 2025 11:04:21 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana When attempting to build a too long path we are currently returning -ENOMEM, which is very odd and misleading. So update fs_path_ensure_buf() to return -ENAMETOOLONG instead. Also, while at it, move the WARN_ON() into the if statement's expression, as it makes it clear what is being tested and also has the effect of adding 'unlikely' to the statement, which allows the compiler to generate better code as this condition is never expected to happen. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index b9de1ab94367..dcc1cf7d1dbd 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -484,10 +484,8 @@ static int fs_path_ensure_buf(struct fs_path *p, int len) if (p->buf_len >= len) return 0; - if (len > PATH_MAX) { - WARN_ON(1); - return -ENOMEM; - } + if (WARN_ON(len > PATH_MAX)) + return -ENAMETOOLONG; path_len = fs_path_len(p); old_buf_len = p->buf_len; From patchwork Thu Feb 20 11:04:22 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983758 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 593B91F30A4 for ; Thu, 20 Feb 2025 11:04:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049497; cv=none; b=qnF6mqD12hGaJoo2NYVVcAfwrzwsx1LccpWSmTIyekUYvcSqVsbohboTDNs5R9qu3CyO+LtGZV4KaAZaKYzJjqM4XO9KHaT4pcTQGfuNz/lQKV7g9wiL3jjRNB6OGV8ouJkyuXVc2wuMlzIWhZWAenBTyHEbkUEJuwztMm58/VY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049497; c=relaxed/simple; bh=ChBKnQAulfXbutwRNaXkCCJf8hYyc7teGSzKCz2J0jg=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=qbbdgb46v4aG9WFLahGpalWeEQqqlQBWzhK5jfzpvDQCQ8i34lvjl8dr3NnGXce1KhaAqBObHOgCaah5a5AB72ckB3Mg5uDmrFcFuY1wYg1wV08Z5qtHk2IQA3WZMLNaK3yHGRPP6yxohu+/B6y68kbd6kLOiuCVrB6Q6mGVf0A= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=q5fwQZF9; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="q5fwQZF9" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4AEDFC4CEE3 for ; Thu, 20 Feb 2025 11:04:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049496; bh=ChBKnQAulfXbutwRNaXkCCJf8hYyc7teGSzKCz2J0jg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=q5fwQZF9JwZIkVsDMA5KVmmU6+pzodZ2Z/ME+N40yR9mHxXueK0hDCxO//zPfobD9 y14Ag/tlEp735z+hgMEXy6VXx27zW9aQhbvPGTqeE0ei7puAuz95sdbFOpXJuLR1DK 5WpS4HXRgCu10Okftugl0DmDLGr7bXNY65Vyqu7CJ5mt7zdYwHPmiQwlCzE42L+FOW 3ecKBoTSuEvE3kScfJLoy4YLvffJDVkvo7uo8x2IieDZXPVgNC6HG4eOXPFFNXeVeC 2KGqwK0GC478KT1/70j5Omdbj9WA2GHU515tVNR/Two6coYi54/4dZwGV/m3uia/M8 6B/kRLbtTjpzw== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 09/30] btrfs: send: simplify return logic from __get_cur_name_and_parent() Date: Thu, 20 Feb 2025 11:04:22 +0000 Message-Id: <9383ea4c0470479ba972cb7422dc3698d96b9fb6.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There is no need to have an 'out' label and jump into it since there are no resource cleanups to perform (release locks, free memory, etc), so make this simpler by removing the label and goto and instead return directly. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index dcc1cf7d1dbd..393c9ca5de90 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -2309,9 +2309,8 @@ static int __get_cur_name_and_parent(struct send_ctx *sctx, *parent_gen = nce->parent_gen; ret = fs_path_add(dest, nce->name, nce->name_len); if (ret < 0) - goto out; - ret = nce->ret; - goto out; + return ret; + return nce->ret; } } @@ -2322,12 +2321,12 @@ static int __get_cur_name_and_parent(struct send_ctx *sctx, */ ret = is_inode_existent(sctx, ino, gen, NULL, NULL); if (ret < 0) - goto out; + return ret; if (!ret) { ret = gen_unique_name(sctx, ino, gen, dest); if (ret < 0) - goto out; + return ret; ret = 1; goto out_cache; } @@ -2343,7 +2342,7 @@ static int __get_cur_name_and_parent(struct send_ctx *sctx, ret = get_first_ref(sctx->parent_root, ino, parent_ino, parent_gen, dest); if (ret < 0) - goto out; + return ret; /* * Check if the ref was overwritten by an inode's ref that was processed @@ -2352,12 +2351,12 @@ static int __get_cur_name_and_parent(struct send_ctx *sctx, ret = did_overwrite_ref(sctx, *parent_ino, *parent_gen, ino, gen, dest->start, fs_path_len(dest)); if (ret < 0) - goto out; + return ret; if (ret) { fs_path_reset(dest); ret = gen_unique_name(sctx, ino, gen, dest); if (ret < 0) - goto out; + return ret; ret = 1; } @@ -2366,10 +2365,8 @@ static int __get_cur_name_and_parent(struct send_ctx *sctx, * Store the result of the lookup in the name cache. */ nce = kmalloc(sizeof(*nce) + fs_path_len(dest), GFP_KERNEL); - if (!nce) { - ret = -ENOMEM; - goto out; - } + if (!nce) + return -ENOMEM; nce->entry.key = ino; nce->entry.gen = gen; @@ -2387,10 +2384,9 @@ static int __get_cur_name_and_parent(struct send_ctx *sctx, nce_ret = btrfs_lru_cache_store(&sctx->name_cache, &nce->entry, GFP_KERNEL); if (nce_ret < 0) { kfree(nce); - ret = nce_ret; + return nce_ret; } -out: return ret; } From patchwork Thu Feb 20 11:04:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983759 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5B0681F3B8B for ; Thu, 20 Feb 2025 11:04:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049498; cv=none; b=jABMFdpF1VHTBEwa6ugcUFHe0lXS7Cvd5wkWtzOO9kHtq7x1gC+Q+7hPJ9hlaA4u3sKrYv23/A+DuWT3/NmpF7gxQizCCK5PuLc4892Vn5GSHt14YxfjMmQNKHzQjqKQ9eGKh8N36iWdAvS+zVFiHrL6ecdc4uB6/AZu6Vsam7o= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049498; c=relaxed/simple; bh=wU+8lAGav3ycWmUOUtxDG0zPsFe5lhgvAzLDXJIHe+M=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nXIyympa/IKk1D42iNCEJ4NJckUMp0H4akx7NANYZhbMfk/17K67JZWhZkpkTEet9+LcIE7HVTI4FkqhDWoLT1mNprOi4pbH0X6wFAirSoj687UO6rxWdDkEmdc08UGMeEjipZDZJBEWKTrhCMOdJKBW1Gb3gPOP2Jsmwg923AE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=oszeNFIW; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="oszeNFIW" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 52106C4CEDD for ; Thu, 20 Feb 2025 11:04:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049497; bh=wU+8lAGav3ycWmUOUtxDG0zPsFe5lhgvAzLDXJIHe+M=; h=From:To:Subject:Date:In-Reply-To:References:From; b=oszeNFIW71BEITh3ORgHq8d07csxtqAje4CyVB2B6yK9E0jYdKsinXo7AKTGGqc3O 38wrRdxkmMS81KQ2pPBU03Y3h3gAGz+k5SULz6fxnrPg3ju1Y8nTgspX+Ic5vzcA2q mVWVC968r2hU7i1MUZ2JpwaHVVKmjNnU8tNVU7wsuPNSlikq8yqcZa8WZlBtOtfonw A1YktXSUPcOHldIAe5YsglVrQV1UM3WzpocICijyis2T+xrgXN7mKQDvdm2wtg/XLf yhv6axGqx4xDvAyCs7FaQnjHBqibLMf3D0EkmlzfJtTQCxW03TXMvBuLxLTN0Bo1ep Eaxnhilc9s8zQ== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 10/30] btrfs: send: simplify return logic from is_inode_existent() Date: Thu, 20 Feb 2025 11:04:23 +0000 Message-Id: <099b202330b07fa00ede7d0ec1437b5c86a4b40e.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There is no need to have an 'out' label and jump into it since there are no resource cleanups to perform (release locks, free memory, etc), so make this simpler by removing the label and goto and instead return directly. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 393c9ca5de90..0a908e1066a6 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -1950,17 +1950,14 @@ static int is_inode_existent(struct send_ctx *sctx, u64 ino, u64 gen, ret = get_cur_inode_state(sctx, ino, gen, send_gen, parent_gen); if (ret < 0) - goto out; + return ret; if (ret == inode_state_no_change || ret == inode_state_did_create || ret == inode_state_will_delete) - ret = 1; - else - ret = 0; + return 1; -out: - return ret; + return 0; } /* From patchwork Thu Feb 20 11:04:24 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983760 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 086881F3BA3 for ; Thu, 20 Feb 2025 11:04:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049499; cv=none; b=J/fkuP7HEUU87xwzjNXF6YuV3fBK12nwrVWT1W5Jx8oiWmOao78K1/EH/RSoIHb2QSdQF2IPiWgiWfi/7c7BgrQZZCBX+LLgM0IBxey1HyBmmw/KWgxktekL8BWC9ZjEQKkDXcr6kI+0Jwu2rbP0Dt/cJiUSaf3Se3UGz7GSws8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049499; c=relaxed/simple; bh=yGG6Cy9K8ygG2fE8rIJTVP2uEfYv8gX0Yf3gDRp25FY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Rqt2thJYa6FurP8snbAYjFcSWlStiWw86SPx6yUWEC2lUVFh+eQyNtQoy5IbBn/srObnGYp7LUD7+u8cEUBtdmMdPZ1Pw9mryKYwhLjtiMSmvcH9z5jvc25XDG4gFLuWOuyQqMyLtQaNNzPgxjYlDXSX9ObQmf8AGg1SbS7dkAI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=YyMdV0HL; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="YyMdV0HL" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 586E1C4CED1 for ; Thu, 20 Feb 2025 11:04:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049498; bh=yGG6Cy9K8ygG2fE8rIJTVP2uEfYv8gX0Yf3gDRp25FY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=YyMdV0HL8gAq31Wqes/O/2pJtUCOXeIN9D/YgIo/a4KwkFCESAhjJreRJzKGMqwIY uw8zv29ljc20om0eksb4REK3wMs+0KbACeUwEbRM4p6/kHvja6sET9w1RTt73uOoyS o7PXUQl2QMB+Y3Qg0svbXwLCtFr6xnikCgZRvzlm4HxmAmfpzy//UFtM6ePN3ne2df pyelyOXQfsGTQFdCfH8/VgRpaZhI2DRF/KNsZhXer1XsS4/kiFnhHukjI+CK5u54Jg n2TNvP1yunHhxvA/HYT5hOwZWK8QybH+IMQORDyiPn5ycowYENYSbcBYRKBSk0Gebf cvtn3x2FehtNQ== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 11/30] btrfs: send: simplify return logic from get_cur_inode_state() Date: Thu, 20 Feb 2025 11:04:24 +0000 Message-Id: <03a17adfd1cbe7b435971a8c1d196cc5c2455006.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There is no need to have an 'out' label and jump into it since there are no resource cleanups to perform (release locks, free memory, etc), so make this simpler by removing the label and goto and instead return directly. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 0a908e1066a6..e0e24ac94aac 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -1880,7 +1880,7 @@ static int get_cur_inode_state(struct send_ctx *sctx, u64 ino, u64 gen, ret = get_inode_info(sctx->send_root, ino, &info); if (ret < 0 && ret != -ENOENT) - goto out; + return ret; left_ret = (info.nlink == 0) ? -ENOENT : ret; left_gen = info.gen; if (send_gen) @@ -1891,7 +1891,7 @@ static int get_cur_inode_state(struct send_ctx *sctx, u64 ino, u64 gen, } else { ret = get_inode_info(sctx->parent_root, ino, &info); if (ret < 0 && ret != -ENOENT) - goto out; + return ret; right_ret = (info.nlink == 0) ? -ENOENT : ret; right_gen = info.gen; if (parent_gen) @@ -1936,7 +1936,6 @@ static int get_cur_inode_state(struct send_ctx *sctx, u64 ino, u64 gen, ret = -ENOENT; } -out: return ret; } From patchwork Thu Feb 20 11:04:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983761 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 72A271F3D30 for ; Thu, 20 Feb 2025 11:05:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049500; cv=none; b=n/DQMTMVmEQZoKR1vN512vPGqQmCQJcig+2NmjBDrj+fYSBans4+f8VJhdRVRLFJ6zktgz5hHnWeDWSEdVte1EsNTrpf0SfWDRRF4bLecm4HZ+dxgeaoCPr86Hv/tfcJwpkv9uBCWAwXIEo9yC/ESAar3bJLwmbI4fM1X8VdVfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049500; c=relaxed/simple; bh=GSRyDQepQ8nNM+59vyTKZf4Kiuw+8c2fQg4jvtw63aI=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=a/Or0AQFXhXxID1eNBHjz4HH0ULJyRkFFhRj/toR8FpH9yOQwJtmCq/mSow6XSlTofMdKZ7aZaiIH4j2nUbq9eNmYxZRwXUZAXaA0BG4Mz4UVnlLrX/dlKsAjFZ9WGFQ/e/NoD65lf03WD3XOB4ASYtniV7W0++YDa1WxgqWPxM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ZHydnfSo; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ZHydnfSo" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5EF6EC4CED1 for ; Thu, 20 Feb 2025 11:04:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049499; bh=GSRyDQepQ8nNM+59vyTKZf4Kiuw+8c2fQg4jvtw63aI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZHydnfSoO2ciAb9yLLzDxjT/v8UAGy97r0T76upPgK158aocmyonqei+QdFjIKp62 smZDNWLhr5HLq5ldPXI7hGeMagjofX/S+jYV98BIcoMaZCnkCRr3M5sjsZC7h/xDtF vy2g2A222xgiNXwRxLEjg3jaRVMB46C9hYg3ijOR35zzDKo29kX5FDsDJtxojb+1Tv jfFg7M4ra2XPBAs1Jd8EUA1FZDFxM+IvF0JcMicHoABJLthVM+/vbdbyreHhgpZ9k+ G0UZtYT2MmmDIjedSliGYDlE79egmxfZCCLG6fMohND7TxxEJGtAztKnvzdm5YhH+S gSm2CxRnmuAlQ== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 12/30] btrfs: send: factor out common logic when sending xattrs Date: Thu, 20 Feb 2025 11:04:25 +0000 Message-Id: <59b725ede4ee186aaa067b5e467ac309e9476605.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana We always send xattrs for the current inode only and both callers of send_set_xattr() pass a path for the current inode. So move the path allocation and computation to send_set_xattr(), reducing duplicated code. This also facilitates an upcoming patch. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 41 +++++++++++++++-------------------------- 1 file changed, 15 insertions(+), 26 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index e0e24ac94aac..3aa2877f8c80 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -4844,11 +4844,19 @@ static int process_all_refs(struct send_ctx *sctx, } static int send_set_xattr(struct send_ctx *sctx, - struct fs_path *path, const char *name, int name_len, const char *data, int data_len) { - int ret = 0; + struct fs_path *path; + int ret; + + path = fs_path_alloc(); + if (!path) + return -ENOMEM; + + ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, path); + if (ret < 0) + goto out; ret = begin_cmd(sctx, BTRFS_SEND_C_SET_XATTR); if (ret < 0) @@ -4862,6 +4870,8 @@ static int send_set_xattr(struct send_ctx *sctx, tlv_put_failure: out: + fs_path_free(path); + return ret; } @@ -4889,19 +4899,13 @@ static int __process_new_xattr(int num, struct btrfs_key *di_key, const char *name, int name_len, const char *data, int data_len, void *ctx) { - int ret; struct send_ctx *sctx = ctx; - struct fs_path *p; struct posix_acl_xattr_header dummy_acl; /* Capabilities are emitted by finish_inode_if_needed */ if (!strncmp(name, XATTR_NAME_CAPS, name_len)) return 0; - p = fs_path_alloc(); - if (!p) - return -ENOMEM; - /* * This hack is needed because empty acls are stored as zero byte * data in xattrs. Problem with that is, that receiving these zero byte @@ -4918,15 +4922,7 @@ static int __process_new_xattr(int num, struct btrfs_key *di_key, } } - ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p); - if (ret < 0) - goto out; - - ret = send_set_xattr(sctx, p, name, name_len, data, data_len); - -out: - fs_path_free(p); - return ret; + return send_set_xattr(sctx, name, name_len, data, data_len); } static int __process_deleted_xattr(int num, struct btrfs_key *di_key, @@ -5803,7 +5799,6 @@ static int send_extent_data(struct send_ctx *sctx, struct btrfs_path *path, */ static int send_capabilities(struct send_ctx *sctx) { - struct fs_path *fspath = NULL; struct btrfs_path *path; struct btrfs_dir_item *di; struct extent_buffer *leaf; @@ -5829,25 +5824,19 @@ static int send_capabilities(struct send_ctx *sctx) leaf = path->nodes[0]; buf_len = btrfs_dir_data_len(leaf, di); - fspath = fs_path_alloc(); buf = kmalloc(buf_len, GFP_KERNEL); - if (!fspath || !buf) { + if (!buf) { ret = -ENOMEM; goto out; } - ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, fspath); - if (ret < 0) - goto out; - data_ptr = (unsigned long)(di + 1) + btrfs_dir_name_len(leaf, di); read_extent_buffer(leaf, buf, data_ptr, buf_len); - ret = send_set_xattr(sctx, fspath, XATTR_NAME_CAPS, + ret = send_set_xattr(sctx, XATTR_NAME_CAPS, strlen(XATTR_NAME_CAPS), buf, buf_len); out: kfree(buf); - fs_path_free(fspath); btrfs_free_path(path); return ret; } From patchwork Thu Feb 20 11:04:26 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983762 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F6771F3D54 for ; Thu, 20 Feb 2025 11:05:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049501; cv=none; b=qTX0q0PEx+QnQSNqV6X7+knS8UpWtnWr0mq4jaCfY7iB2Rla+JSJBAHERAIbLACakYI6QUH1mcPZSgPlvQrf5RnTm7aedgla9AyaJ2GoN/MFbEHnM39ZLqddj4IR7bfAen5JYdlSrKWE/xJ25pNzkS6ghAQJU9YDqJZRofio5YA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049501; c=relaxed/simple; bh=9hxk+7ErPnp6CkqDnLiQhSsA+nXDmhR3kp3A7y4ud6c=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lfNjyB8jEtHY8m470NQSFbqqp+x731LBgB8YzRuEcdpqqM/BLkA0F3qwKdeHNIsCUQquHfzfQMN/v00fZhGgjk6+lq1i2D5dR1z/PKoW/zopcaXkIuuNdMYKWrtMgAEFFqL+tNwl0u0oPgET3wLHvgZuralwZ/9z3oK+FlUd624= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=hy8y5qmR; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="hy8y5qmR" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 662A0C4CEE3 for ; Thu, 20 Feb 2025 11:05:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049501; bh=9hxk+7ErPnp6CkqDnLiQhSsA+nXDmhR3kp3A7y4ud6c=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hy8y5qmRUOK1P6c+hf0nix9aseLMS3YLBSBm9a+D82tvp8tOZ/DrKjKXHwEYpKRV4 eq0DKMpEhm5ZztkKn0PM70vd06wEC/I9MDYLsJMislbo/SQ2MwJ70XdrGS8oBVmBCu KzuGCgZ1x8mV265x4ALTgaIJfkfcNpRAXlwpfTR6ZoG9SKQuwZ5hHal0HPuvGbi3tH sacJR9JVRL4f30H8b1bpjtipSqElBjz+omkcLmVeI23JCD8MJpLWzP2jdu/YC6Il+5 ChaYgZwPcZbuOJFLX/FWFEccTKrU4oNENcJiNrVgSsgAF3fU5RmOvO4Ap+eUjwDxIR wY0lS0P9IWAcA== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 13/30] btrfs: send: only use booleans variables at process_recorded_refs() Date: Thu, 20 Feb 2025 11:04:26 +0000 Message-Id: <11df18fd97e1723b2d0135b0912f64f739dc215d.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana We have several local variables at process_recorded_refs() that are used as booleans, with some of them having a 'bool' type while two of them having an 'int' type. Change this to make them all use the 'bool' type which is more clear and to make everything more consistent. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 3aa2877f8c80..6e27a7d77b25 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -4147,9 +4147,9 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move) u64 ow_inode = 0; u64 ow_gen; u64 ow_mode; - int did_overwrite = 0; - int is_orphan = 0; u64 last_dir_ino_rm = 0; + bool did_overwrite = false; + bool is_orphan = false; bool can_rename = true; bool orphanized_dir = false; bool orphanized_ancestor = false; @@ -4191,14 +4191,14 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move) if (ret < 0) goto out; if (ret) - did_overwrite = 1; + did_overwrite = true; } if (sctx->cur_inode_new || did_overwrite) { ret = gen_unique_name(sctx, sctx->cur_ino, sctx->cur_inode_gen, valid_path); if (ret < 0) goto out; - is_orphan = 1; + is_orphan = true; } else { ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, valid_path); @@ -4421,7 +4421,7 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move) ret = send_rename(sctx, valid_path, cur->full_path); if (ret < 0) goto out; - is_orphan = 0; + is_orphan = false; ret = fs_path_copy(valid_path, cur->full_path); if (ret < 0) goto out; @@ -4482,7 +4482,7 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move) sctx->cur_inode_gen, valid_path); if (ret < 0) goto out; - is_orphan = 1; + is_orphan = true; } list_for_each_entry(cur, &sctx->deleted_refs, list) { From patchwork Thu Feb 20 11:04:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983763 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C0F81F3FD3 for ; Thu, 20 Feb 2025 11:05:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049502; cv=none; b=gFbpcxIqQ6B1pDbJm8aobj4oNHMld2kv/Dow1WVCPBblWrW7DbBvqyndIf7maDNz2JXT1IBPFpZIZ4NhUxjm6dfeq+mWFkna5jIxxyOL9CrQkpU7xE7qnIfICmlWezShnHvdYRGYxv28R00UmSKiHzXcqr+BF6u9gx+kbjYDprg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049502; c=relaxed/simple; bh=rKG84Dm+qgA2a8K8nJHKowtWopfIOurS1J8H/BWnAXQ=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=UGXgpINsyGPORMLftkwQ1vAe9TGcN3Mc+1eTk6Khi3m2fATxw8PlAQSJB9DTtnE6wGS6ELLSEYCeZn0r0C++aFCyNhHVnB8XG0nMGvxnBVZrZcuzZwNSInSAHn7/nyCIfjbJyprOiPcl+NM3S5vyWF3qWtuYwv0HXr+nnnSAAfU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=adpuROAK; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="adpuROAK" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6CB3DC4CEE4 for ; Thu, 20 Feb 2025 11:05:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049502; bh=rKG84Dm+qgA2a8K8nJHKowtWopfIOurS1J8H/BWnAXQ=; h=From:To:Subject:Date:In-Reply-To:References:From; b=adpuROAKSnCJ8WljcCtoxfH80EFLfSAUQxdkqQp3gA+VcZCBJz3nYL9VCcK2yNgRu GtWacV29vqVTLx7BKmBPZa/A0A9UPpPCBBkQPh2w3vWRu+TF3AlRYM6ev3+pRr119a l4G75rl879IoWsY1hPoshTzUt+2NrdBqCKHsoQkdezTBGTStmLwrl+DwBYNzn91enS 9Vuq+HHDygxuz3ND7Opiw7YEhlZRRYmbwBLae0DwsMvNhZt+2c5I81OnLaWyOVfJzH ZRAHSv/cqM6QKSZaQL0s4nDIj9RmqRQIf2fTaWNt9YDM/nu3kyq3afOj8rPu2EUjrL 84vinWrS7JZpQ== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 14/30] btrfs: send: add and use helper to rename current inode when processing refs Date: Thu, 20 Feb 2025 11:04:27 +0000 Message-Id: <0ad5ae9dee056f6b70b70e9175ba80cfab69c63c.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana Extract the logic to rename the current inode at process_recorded_refs() into a helper function and use it, therefore removing duplicated logic and making it easier for an upcoming patch by avoiding yet more duplicated logic. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 6e27a7d77b25..653e0b9a94ca 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -4133,6 +4133,19 @@ static int refresh_ref_path(struct send_ctx *sctx, struct recorded_ref *ref) return ret; } +static int rename_current_inode(struct send_ctx *sctx, + struct fs_path *current_path, + struct fs_path *new_path) +{ + int ret; + + ret = send_rename(sctx, current_path, new_path); + if (ret < 0) + return ret; + + return fs_path_copy(current_path, new_path); +} + /* * This does all the move/link/unlink/rmdir magic. */ @@ -4418,13 +4431,10 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move) * it depending on the inode mode. */ if (is_orphan && can_rename) { - ret = send_rename(sctx, valid_path, cur->full_path); + ret = rename_current_inode(sctx, valid_path, cur->full_path); if (ret < 0) goto out; is_orphan = false; - ret = fs_path_copy(valid_path, cur->full_path); - if (ret < 0) - goto out; } else if (can_rename) { if (S_ISDIR(sctx->cur_inode_mode)) { /* @@ -4432,10 +4442,7 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move) * dirs, we always have one new and one deleted * ref. The deleted ref is ignored later. */ - ret = send_rename(sctx, valid_path, - cur->full_path); - if (!ret) - ret = fs_path_copy(valid_path, + ret = rename_current_inode(sctx, valid_path, cur->full_path); if (ret < 0) goto out; From patchwork Thu Feb 20 11:04:28 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983764 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2ED3A1F3FED for ; Thu, 20 Feb 2025 11:05:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049503; cv=none; b=U2iypj536ynN2+8uJHV+9ZlKoAGZorTmmF4B+zKhzQd1CgG9KgvK8s4+DEIBBRQbj8Cv21W2ROA5UEWrodvqbMuedAk15ggmHU/HbkBGeHcs2hgiHb4VBQmdHQ+b7slXlKhm480KZsFx0qBZdfFPf5w1VzltW82Bm4egJVBIsDk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049503; c=relaxed/simple; bh=8ihYbfEmW/bqLw/MsLra7UmB8oJ2hM1pKiPbv9n1Dqo=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=sZ/vvAaVtETsIpLqzyMYcS2EQ1/fXKWrGNeE4aa9KWMqqWvZ9KolYkqVobEeCFSwRTNGico4hpQIyYRLvRmlmnEe/z9iosAdn0rBYn1gczCf2tEXOVfQPCMFnQKTNAz3yiD9VmYuoIeUhupTQS6hzwy2ZBg5ytZMb/c8DLPQRcE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Bw1BAAuF; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Bw1BAAuF" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 76740C4CED1 for ; Thu, 20 Feb 2025 11:05:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049503; bh=8ihYbfEmW/bqLw/MsLra7UmB8oJ2hM1pKiPbv9n1Dqo=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Bw1BAAuFzP9U1aZvJIXRqSYyaNFzdfJc1Tu/BLNRdxSfe5CmR8N+uQCpHLlWs4xmC 6mtul9m6svoC/P1x3LJezzzFnmX8/XMQzWrJg8+2BcdMwDorDFZq33Pceuz8TdkqiO HekX8Q9/KwLyvj/oBFgCaaL2mZkEIzvGlEA+oYvYwL7wpU8Boirge1buSeKks8thAD dPeJHlsjpxAQLOvHS0RVbZAswgRxQdBBK6xfnGSjkoXHg3BoWdHSsV6FsrbKhwmywt +yWYeKHBqbcOXHqPShDY7+s920fhaapdk4vRHd/faucVk8KUsJlcaCh4X0TEK1XEh2 68Wo3Dy3dI7vQ== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 15/30] btrfs: send: simplify return logic from send_remove_xattr() Date: Thu, 20 Feb 2025 11:04:28 +0000 Message-Id: <1df434f6ef3b9eb144e3d22c9c6022a14a9632bf.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There's no need for the 'out' label as there are no resources to cleanup in case of an error and we can directly return if begin_cmd() fails. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 653e0b9a94ca..5fd3deaf14d6 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -4886,11 +4886,11 @@ static int send_remove_xattr(struct send_ctx *sctx, struct fs_path *path, const char *name, int name_len) { - int ret = 0; + int ret; ret = begin_cmd(sctx, BTRFS_SEND_C_REMOVE_XATTR); if (ret < 0) - goto out; + return ret; TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, path); TLV_PUT_STRING(sctx, BTRFS_SEND_A_XATTR_NAME, name, name_len); @@ -4898,7 +4898,6 @@ static int send_remove_xattr(struct send_ctx *sctx, ret = send_cmd(sctx); tlv_put_failure: -out: return ret; } From patchwork Thu Feb 20 11:04:29 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983765 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8DE041F4189 for ; Thu, 20 Feb 2025 11:05:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049504; cv=none; b=Ba3hkrgQeMUXush35mCunLMKUBdS3lqgq5SiWPiYGHIuUrs4bQj3Kn/STGvmETWerjLWbLnYqhthF2gackJ5Qz8iacUx8TrGBPAjRcfe30/ejN2x7PIYgQCTUOUwqZJE9lPpmDsmBwNO0TEl5n/0kiOZH4xryb/fRs+Z8pazc0k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049504; c=relaxed/simple; bh=THpErzxIZlA7QdlBQjpr5bQsJcE1FHd68W0QxJlpsYI=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FpsVH5pQ7aihsBL5aE32AawolGDBQozjY+kIaOBev+JqEOz/hzOwBF2+RimgsMGYYWNXPzCVxgCdzhJP8xjLmIFpjkL1nBTF+RMhT7+atit2yAxO4aQ+4j4bzicU1azicV5ist4nVMB+3ReJr6AgVDHH5cFS+VsgbfgxiQuli5Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WermkIrG; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WermkIrG" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DABCC4CED1 for ; Thu, 20 Feb 2025 11:05:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049504; bh=THpErzxIZlA7QdlBQjpr5bQsJcE1FHd68W0QxJlpsYI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=WermkIrGvV2/HQBO6b3LmNmpNzOXv8ADvjZ8nGYkbwY+y/nweohUI7bKSvaN8X0oa 3EU+QZkPVwVD0t/rY8k2lQnutv+WZa6XeFvhNpZB2/o8uVSdUwspfME/t8VPYm3lo3 7gL5IeiY1k38iexXIJY+gvvtBmg5dWT0Xbag+kiUKLkzWPc97YEptMchW0xq612Rux D7HkNz+Nw/FkCSHb1YSjnLfZTjps4YBb9WtN4u16p8Cde1XvGm695yki0TlG5lSh9C cE032qoN9Bnsc3Zb1fwjujr1V/+3XQ2PQWgRP2xCxccikfzb2N4c2jrI2Zyq2+p6LB 76zHOEzmZIBTQ== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 16/30] btrfs: send: simplify return logic from record_new_ref_if_needed() Date: Thu, 20 Feb 2025 11:04:29 +0000 Message-Id: <9229ca2ec7c2baf45e6aeb869a764ee3ddf036e3.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There is no need to have an 'out' label and jump into it since there are no resource cleanups to perform (release locks, free memory, etc), so make this simpler by removing the label and goto and instead return directly. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 5fd3deaf14d6..96aa519e791a 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -4683,7 +4683,7 @@ static int record_ref_in_tree(struct rb_root *root, struct list_head *refs, static int record_new_ref_if_needed(u64 dir, struct fs_path *name, void *ctx) { - int ret = 0; + int ret; struct send_ctx *sctx = ctx; struct rb_node *node = NULL; struct recorded_ref data; @@ -4692,7 +4692,7 @@ static int record_new_ref_if_needed(u64 dir, struct fs_path *name, void *ctx) ret = get_inode_gen(sctx->send_root, dir, &dir_gen); if (ret < 0) - goto out; + return ret; data.dir = dir; data.dir_gen = dir_gen; @@ -4706,7 +4706,7 @@ static int record_new_ref_if_needed(u64 dir, struct fs_path *name, void *ctx) &sctx->new_refs, name, dir, dir_gen, sctx); } -out: + return ret; } From patchwork Thu Feb 20 11:04:30 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983766 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 323DA1F419E for ; Thu, 20 Feb 2025 11:05:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049505; cv=none; b=PdZSKuROJakolo5JEl4C3cBuyTJi21Ii2Kmu9p8Gy5pZp501hlEgwOwBfVwQblJjDA6kXN9gLMPRot5i/gNv+KjZmWTHILGgQNS1fV1puFNRhQlUeEjKt9AFM3/MBZ6+GQ5AR7FRtKMDrwAN78HqHDjmGUNCgmnWQgA9CZSTpzQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049505; c=relaxed/simple; bh=1JCUCDDhbrBpj9klUlZfnrC0vS8NJuYV+O9hY/74lBc=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ZZsY89OUWBLPyxsVP2o+TcvR4T/5eHHZp4vOT8LHBiaulbn9wzq2ivL8wm5EsMRWhpstRzzl75+dnA/sADn3TCu9+l1O5b6wUS1bTrWO3+iyDdJYrrH1nfHrQAsdsL4GDvBXuWCkVpChbnv2JQoRrSqQgQVJD4FhR5zI2ynMNAc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UP3lGC4j; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UP3lGC4j" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 84107C4CEE3 for ; Thu, 20 Feb 2025 11:05:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049505; bh=1JCUCDDhbrBpj9klUlZfnrC0vS8NJuYV+O9hY/74lBc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=UP3lGC4jaCwBs1NADhADp0e+bB1PcJH88z+YGGg3Bs+uBziaJ84RPF0rOyq2yJH9q CQZJh4CVKjQ58PQAMS3oVdF0WiXeNNrV0K31nL22W7W02nexM1GZGgCIFAMrSTeVF1 d0inUQ8gwz1lWhedY76RLt3LKbGXpxP7k7R4A3VIdTnfuZ9LLDZVGaBS8vcE22ZFDK mI5cddu1/11cxctrI5batMU9gO0uH1iDYxZBf9FTLvDjZmDCGcYc1JQkvfI/09o6if SSyV20OA04sF+m8GGdqe7/lV8BsiD1f1xAglq/6OATrPW3zVPcWiX7xAg93fq/v1dM 8ED/nWi5b532w== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 17/30] btrfs: send: simplify return logic from record_deleted_ref_if_needed() Date: Thu, 20 Feb 2025 11:04:30 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There is no need to have an 'out' label and jump into it since there are no resource cleanups to perform (release locks, free memory, etc), so make this simpler by removing the label and goto and instead return directly. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 96aa519e791a..b715557ec720 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -4712,7 +4712,7 @@ static int record_new_ref_if_needed(u64 dir, struct fs_path *name, void *ctx) static int record_deleted_ref_if_needed(u64 dir, struct fs_path *name, void *ctx) { - int ret = 0; + int ret; struct send_ctx *sctx = ctx; struct rb_node *node = NULL; struct recorded_ref data; @@ -4721,7 +4721,7 @@ static int record_deleted_ref_if_needed(u64 dir, struct fs_path *name, void *ctx ret = get_inode_gen(sctx->parent_root, dir, &dir_gen); if (ret < 0) - goto out; + return ret; data.dir = dir; data.dir_gen = dir_gen; @@ -4735,7 +4735,7 @@ static int record_deleted_ref_if_needed(u64 dir, struct fs_path *name, void *ctx &sctx->deleted_refs, name, dir, dir_gen, sctx); } -out: + return ret; } From patchwork Thu Feb 20 11:04:31 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983767 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 397CA1F4604 for ; Thu, 20 Feb 2025 11:05:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049506; cv=none; b=WuCNfXjv+GjZSGl4fzQb3MLFRV/wgAVxQ9SoEBDeg4W7SgSzU/8TuQChLHiqBM7p9vblvee8k80x6332F9ZJdbFnYLa2K7TSMcSbTqnjTBxWK81xZIOiFF6zR1RPxXrdqndKg9z5PtJY9SlPY+Qgvz4EiqwEaNvJ9nd3i+KuPWg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049506; c=relaxed/simple; bh=Wyd5Wd89gnJUPIDlPqkGSgkK7n/wp64eKpdAMR3Jnzs=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dBfqOkBZuqJgkeovEpTXo668rdbknBxtriDJynCXmUfgo+arp5n3nq7RIBkGKNIN2T96gYLudo9A0D/oOaXLczTi1l1E3qyxXx2ztnajXjzVpCRdyrb+G9cQK3PNUh7L/KE0/KBpKMXpT2MZ3+IjjHmzBSW7ez2Qjwx4c8oziSs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kCAMJgCA; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kCAMJgCA" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8AECEC4CEE3 for ; Thu, 20 Feb 2025 11:05:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049506; bh=Wyd5Wd89gnJUPIDlPqkGSgkK7n/wp64eKpdAMR3Jnzs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=kCAMJgCAL1OGHn/otgY1v8GuS8ZK+7wmSkWzL3yacAhQUmID8BVo1t+sJ6N85xdyV EAAFkevTge4IXYRz/b/P9IyxY7EgFqFtcmzVt3Gav7E4rjqMrJ7glVoTEqdxhgFdY7 0O15QG/L7z1Xn6Y/jDifZVZiWINFMPy94X09YAyA/b3ZCYi1BsbDP1GbrRRCecD85x v7X3STxxOP4lR+s8g/cO7QQf8jFIjEIpJSJi5cQvOL9/HHv8gRH1ex73hOaRXo+Ej7 +ln2bUryQBsIdjHPNsmD9IAjHc6W8HQyjmBXePL3Yywg3GBy9D1UPLnK+f+fDlfOa/ zhOBvUHaVG1IQ== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 18/30] btrfs: send: simplify return logic from record_new_ref() Date: Thu, 20 Feb 2025 11:04:31 +0000 Message-Id: <56ddd47f9ff5493137cc6ec668ff7b97413068b1.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There is no need to have an 'out' label and jump into it since there are no resource cleanups to perform (release locks, free memory, etc), so make this simpler by removing the label and goto and instead return directly. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index b715557ec720..181a234e3a5e 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -4746,11 +4746,9 @@ static int record_new_ref(struct send_ctx *sctx) ret = iterate_inode_ref(sctx->send_root, sctx->left_path, sctx->cmp_key, 0, record_new_ref_if_needed, sctx); if (ret < 0) - goto out; - ret = 0; + return ret; -out: - return ret; + return 0; } static int record_deleted_ref(struct send_ctx *sctx) From patchwork Thu Feb 20 11:04:32 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983768 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3D18C1F4614 for ; Thu, 20 Feb 2025 11:05:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049507; cv=none; b=ZDb6nUwp8KyGks2f27qfpPWlC0m9Op/N6ZFpwVOJ2Ir1JN8KmWxaDhyCa48CDwMy+v0X1n7mNq6zaroKJOMZv+iA51nmAPv1YLiqydKeddmxWwe8DMdoa5NDjV2XGg7ljjZiCokLLj69TOBez+0Qso6u17l+DP/F16BvYDfrx54= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049507; c=relaxed/simple; bh=bo65LBflfD+3mpw0tdqCeliFgx2TqnU6QVvpvc7mI6U=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=lvi/v5bOimWR69cYdR8lJrb1XsjBdJ57FfLicTam6wsiOUPHCOJpDJABe6mllo6h2N0j824slyW6c5YRtgZ6ePIM6YSFCWGEmo97uFZmtUicxlbCAaWcPUV2p+KaVPrOUXIGxWwre3BkpQnbM6Hf/i7DIUOmKLy8aQlzwq+f6bw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=B2/x0EcV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="B2/x0EcV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 91239C4CEDD for ; Thu, 20 Feb 2025 11:05:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049507; bh=bo65LBflfD+3mpw0tdqCeliFgx2TqnU6QVvpvc7mI6U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=B2/x0EcVSTgVR1a4ROmcXLqeAQcAX9c/D8h65Eq9j1NpGDFLse9vZtlHt9jZT3paI r0LXYpEHwgJVs5mkOnKhEYPoNUfu0cTQsRnnTioAOM9bmCYjACPrlL26vmRnnl7GJM rZEkjppWMHX1JGbM17JpAJf37n+Y/RIKPSX7njAk+hwqBytdfNHQA6HjHzPwunZZzM kfHg6B2LF6mY2SlAN6YgUHTXMMYR2PTiymH1cJpCl8ErUseiJVyhZ9/80HC4P40d7y Ed0fkud5WpGqMzndmao+PkOif3ONFJ04MmXZ1y/CFlPqYslMCER6jlAnpdZDswMLqF k00KVWaPrhaaw== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 19/30] btrfs: send: simplify return logic from record_deleted_ref() Date: Thu, 20 Feb 2025 11:04:32 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There is no need to have an 'out' label and jump into it since there are no resource cleanups to perform (release locks, free memory, etc), so make this simpler by removing the label and goto and instead return directly. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 181a234e3a5e..6e171b504415 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -4759,11 +4759,9 @@ static int record_deleted_ref(struct send_ctx *sctx) sctx->cmp_key, 0, record_deleted_ref_if_needed, sctx); if (ret < 0) - goto out; - ret = 0; + return ret; -out: - return ret; + return 0; } static int record_changed_ref(struct send_ctx *sctx) From patchwork Thu Feb 20 11:04:33 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983769 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 94DE01F4614 for ; Thu, 20 Feb 2025 11:05:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049508; cv=none; b=rgbZqv+HRjekGoXq96T3S7yRnu2tryABLrTVrGVSclKb71Rm2YudNteLQIRC4lY+++gVKGBkH4274UlfStdeBVbhCYTNDre/LX22dN7PqqLRnLT5CAFoSMRSQTcWlnVPXWXr43GKGpgd30sfEO+/9puqTdorQfvQBYV6RoCgzm8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049508; c=relaxed/simple; bh=wXsAxsgamsNQG+m9lr5ppecgeBVTHoTlfPbVpx8Orsc=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FUOaVMqs6if9lWox+iQoW6YEgWNps/CbiDjUoWj/ka5bUNAH9h0gXNDnarwThZvCTHz+tNYXA8AEIuOAWYxdYD3nitC8UM74nLnmpHZNNYGiyqtvwdyMQspZYUZNAycOJAW1m4boSoNDwlv6QmlJioSaKKPzQkBUjZ8ONF6RstE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=NexzNJ7Y; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="NexzNJ7Y" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 970CEC4CED1 for ; Thu, 20 Feb 2025 11:05:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049508; bh=wXsAxsgamsNQG+m9lr5ppecgeBVTHoTlfPbVpx8Orsc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=NexzNJ7YwjbIiiW1AqWojJC+aDEmQ96pY4RPHH/yESWbE31tuD9qmc5ED+hlzdiBH yEaAruboIntThsj9CnGquehI/NwhLIIiHL3y4Ly3pMr9pNmYXf9DfnFFXmOSA9Kk4D TShMx4VGYg6B2aLxUZZzvurBLRcjK0XwQi1FYDgzBTTXlz6mJCtELb2ESL+rXuVGR0 CjVOXsYE3+5+WggpDWaLBb0ejFrqY+9/adE8dg/Yx1l1Fo6eYxQOpZdtv93qjDGLM0 atysAdhxmIDmJ90mRtPkHpp48QxSLICzeDLdks9Y24vFxSSYJm9JZOzRQzqZM8dBrT QPAuB3aDGMyJQ== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 20/30] btrfs: send: simplify return logic from record_changed_ref() Date: Thu, 20 Feb 2025 11:04:33 +0000 Message-Id: <0d104fa4a4e8f3a58c93c1179d5c0dae0207ed75.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There is no need to have an 'out' label and jump into it since there are no resource cleanups to perform (release locks, free memory, etc), so make this simpler by removing the label and goto and instead return directly. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 6e171b504415..01b8b570d6ed 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -4766,20 +4766,18 @@ static int record_deleted_ref(struct send_ctx *sctx) static int record_changed_ref(struct send_ctx *sctx) { - int ret = 0; + int ret; ret = iterate_inode_ref(sctx->send_root, sctx->left_path, sctx->cmp_key, 0, record_new_ref_if_needed, sctx); if (ret < 0) - goto out; + return ret; ret = iterate_inode_ref(sctx->parent_root, sctx->right_path, sctx->cmp_key, 0, record_deleted_ref_if_needed, sctx); if (ret < 0) - goto out; - ret = 0; + return ret; -out: - return ret; + return 0; } /* From patchwork Thu Feb 20 11:04:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983770 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4C43B1F4639 for ; Thu, 20 Feb 2025 11:05:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049509; cv=none; b=la5qxfd8EjsKXx05L3AGHdPOXctlnj4YLNMxWgcfaUaTdDiDo4kurZ6S7jFjoV93IqV+y5ksZK1CeDUPeJcEr9i1Q2f8gkeT8847ek4KOKhA/4Cir7Xqu5oPH7waVEG8nudNprVKCW7kWNUyE2bxWTatzvadl2nBn730F8HdSiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049509; c=relaxed/simple; bh=RzCBeOeEYPp3KthUnzogTIy1HdaiyHqUReO3IYXsSj4=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=Hib4pDOBto/P+mdaJEKxriEN984tLt1IV6Ndx4f72XmG4mkniOqxPeKLb9LhEUC0aN2gwlYdvHOOd+32ekXrCjRB35yu8fese3Y6jjLs9DKlI2YPKATpWABMQomK4FwuJDdEyHf9CGt7/7c0SYRmInKU3e0CN4xVHE5uzDODXV0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=mViNmrGQ; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="mViNmrGQ" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DB00C4CEDD for ; Thu, 20 Feb 2025 11:05:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049509; bh=RzCBeOeEYPp3KthUnzogTIy1HdaiyHqUReO3IYXsSj4=; h=From:To:Subject:Date:In-Reply-To:References:From; b=mViNmrGQfUlkvtFvx1ZWO5J0gyJjTTKidt1aG1Zv8LCPaQ4vaq1+7syIy1Ud1yghU BrPwzCQYyO2nfpjSimgv3njFTT6w94a5Jdl81qF0i20f+juTJ1dFZuNJYbxhRTsM4z pMjZ6j3UOjUrkqXXLxjFf9vLFKdBfaOtI7w67wmcbIQQwt9dvQ8WF6iy5LT/+im3O5 OCmkQ24rXhhrEziy6SdiYsq9bgVb5XV5EJuoyP1F+b+5+VWRCaKGZnaoTSl0/n8BJB IkD3/mVh+J9c65x+8A/A7g4LbhllEPsxnVy/IkKYj99EqnmU4dyGbHu8hLYYU3rj3E f0LgJxJ6A7UoA== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 21/30] btrfs: send: remove unnecessary return variable from process_new_xattr() Date: Thu, 20 Feb 2025 11:04:34 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There's no need for the 'ret' variable, we can just return directly the result of the call to iterate_dir_item(). Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 01b8b570d6ed..e29b5a5ccdd6 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -4950,12 +4950,8 @@ static int __process_deleted_xattr(int num, struct btrfs_key *di_key, static int process_new_xattr(struct send_ctx *sctx) { - int ret = 0; - - ret = iterate_dir_item(sctx->send_root, sctx->left_path, - __process_new_xattr, sctx); - - return ret; + return iterate_dir_item(sctx->send_root, sctx->left_path, + __process_new_xattr, sctx); } static int process_deleted_xattr(struct send_ctx *sctx) From patchwork Thu Feb 20 11:04:35 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983771 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 51E1C1F472E for ; Thu, 20 Feb 2025 11:05:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049510; cv=none; b=nhTSmoWeSuGlrrztcrAi7p0ulza19RCNSjnCjE20FpRm/IKvZebtBQLAIDwtrVoyO1CegFs7EPwG5DiNrAiHdQpOp1ibzPbcp7aQpFNWsMOPvtdZqPc7C67cUok4twWNL/0rjkvessbuYT4/75BT2eP+aXMg1PAHOU3FOacY7/c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049510; c=relaxed/simple; bh=NJ2JgutmmQTjMHYytZ3fYMdgpi7FupvrNgUYg/RUnPg=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eEU8eOlCseeYZO7hhVP92aqLXNE6cSBs9AcMJCpwh8nykANmKC4wzUgcKPB3qwpoWsW3lFcXf+DTKeFTBR/Z4e7Z48pn/+esvg4RVF9XEF9WXmT/0pGLWhrcETy9oPwmvNko7NcAalLasFPp+UYOJOyE9kJw+dy+CeA2hwIi9I8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=dcbmybAP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="dcbmybAP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A4A6AC4CEE4 for ; Thu, 20 Feb 2025 11:05:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049510; bh=NJ2JgutmmQTjMHYytZ3fYMdgpi7FupvrNgUYg/RUnPg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=dcbmybAPm2pFoCq8R2NkSqIkTicZll0itp2zZA2hJxCYKP7nB0UMOh0M/ZcCKHFRH 24rkOEziJk9m/Li8lcxXexGMQoPwInkC/ujPQGUOtCyc4EAiloAemxG+oVxpe3Ff1X EWXv1d4N16TJTGM+vPxk/Z0GsEyFrKDiGv741SVygG0SVwreQsGWZ82pkzvuDvn4a3 VSxdamuPPcRCJa8igu2GfJJRS7DUCN/z5DBt6EA6fHexLvnSifDhLPBfaKJ3divFB3 M5CDxZgRZRM1tE3gR3cZR8O7IhSdGVb5UbTyP9ei5oaUDBEpU0Ji6R9u+gCS4BUFFX tHUe4drwNvAMQ== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 22/30] btrfs: send: simplify return logic from process_changed_xattr() Date: Thu, 20 Feb 2025 11:04:35 +0000 Message-Id: <2bfe8c0be41bc9d7443bef179b798c34a1152ee1.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There is no need to have an 'out' label and jump into it since there are no resource cleanups to perform (release locks, free memory, etc), so make this simpler by removing the label and goto and instead return directly. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index e29b5a5ccdd6..0cbc8b5b6fab 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -5067,17 +5067,15 @@ static int __process_changed_deleted_xattr(int num, struct btrfs_key *di_key, static int process_changed_xattr(struct send_ctx *sctx) { - int ret = 0; + int ret; ret = iterate_dir_item(sctx->send_root, sctx->left_path, __process_changed_new_xattr, sctx); if (ret < 0) - goto out; - ret = iterate_dir_item(sctx->parent_root, sctx->right_path, - __process_changed_deleted_xattr, sctx); + return ret; -out: - return ret; + return iterate_dir_item(sctx->parent_root, sctx->right_path, + __process_changed_deleted_xattr, sctx); } static int process_all_new_xattrs(struct send_ctx *sctx) From patchwork Thu Feb 20 11:04:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983772 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CBD9E1B0F19 for ; Thu, 20 Feb 2025 11:05:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049511; cv=none; b=hJysHtjHEqJgHdzbQSYI88u9YlYEiHejB3/kz6qY/UPK3/qMJZDri/RBdX5uRBE0ynd0EZPD6cO6jt0xEll9INbjRUBQJqNiK3bJHZb2aY4t7MhVYdedJK6uAuMUFOoGF1PlD4DDu8PBlVhzOs1MjpnvQLAZ02XlIWJ8Hluuda4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049511; c=relaxed/simple; bh=Z0gnj+j7I6tesK3fs5Y4sZ2G4+laz1ers4iiF43Kdgs=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=QTwFnit8g35GaPCxWOZrmvBnXS85EPfhOv9A3yyqVa3TFNghOwxylSYKVLlrLYA0aa8MSFbHfF7fIl6+FVtqV0rvU+4+IEJODw2dpjfGPuhrc+u557kUOLN+ecLARUJ02AZnuyfTv00HsI7hSQyFotkEZTFZ1xPyvQOOMmcu7vU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Y1y6Gy/G; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Y1y6Gy/G" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A9CC6C4CED1 for ; Thu, 20 Feb 2025 11:05:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049511; bh=Z0gnj+j7I6tesK3fs5Y4sZ2G4+laz1ers4iiF43Kdgs=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Y1y6Gy/GHtYzfMBfx65XuWkI9CGNQZI142L4ZLgv9Q/4+xcIs/u4TX0xmuXvYV4ej PZjpseyEEYKPieypt0rKcK9Yz0bo8goxGRetMwL3K0z8wTXj2n3FbGUAQDCyHRBs9/ KFr20sy4VA696UKWtk/QSPZ3wxF+jDwYdvnIezGOKhDlTNSlRkavxBjs5bFzXDEW5G ukA1S7Ae3vl0byug5f6oMu6N/SYNvBiDCZeOIC1nhHdNPF6cVF9CwRLaFdSe8M+TzE n29J0LP3GROo61HSfHPy1zOJQHuMKMbcxPYMkmmI1e9CKnbt7QZcm7TotNxJ5hv03+ k3LGWQFy6bvrw== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 23/30] btrfs: send: simplify return logic from send_verity() Date: Thu, 20 Feb 2025 11:04:36 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There's no need for the 'out' label as there are no resources to cleanup in case of an error and we can directly return if begin_cmd() fails. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 0cbc8b5b6fab..f161e6a695bd 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -5122,7 +5122,7 @@ static int send_verity(struct send_ctx *sctx, struct fs_path *path, ret = begin_cmd(sctx, BTRFS_SEND_C_ENABLE_VERITY); if (ret < 0) - goto out; + return ret; TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, path); TLV_PUT_U8(sctx, BTRFS_SEND_A_VERITY_ALGORITHM, @@ -5137,7 +5137,6 @@ static int send_verity(struct send_ctx *sctx, struct fs_path *path, ret = send_cmd(sctx); tlv_put_failure: -out: return ret; } From patchwork Thu Feb 20 11:04:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983773 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 606381F0E31 for ; Thu, 20 Feb 2025 11:05:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049512; cv=none; b=PJPCvor9yHCPWEXGTc+rtb/W5iZdtgi/1VndkgvZV2Z1DCIZy7zHvPJwf4aNFefEXoaHy/eWaVLerNgx3B3sAdwIb6TDmDC4SUAzVsjWTXzSUsanRu/9GMC2xiFpkZhO9ReB5gskfU0ncm0aGEes+w1W8Q90MlZhAc//hnkB3Fo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049512; c=relaxed/simple; bh=No1hRUoq8G5x+5o40hJzJRvS7EauTBPVtearmdchDHY=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=n7ga6+bZtn0Bi/p9L5pWwZpBG0/3acOOe3VnfrlGmK5C8YKGONR3tZcOztmKYKFvIOyRnauyj2XkO3NnIXVyO26kmZfIdx6L7RKGG0GAWcEgPWmGmNwkZ6IlO+/olV01kuqEOoxFrmOaIRG5rwPI3wVnTfTh3AO4EsyNYZMgKn4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=L/MU9iSY; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="L/MU9iSY" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B19B2C4CEE3 for ; Thu, 20 Feb 2025 11:05:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049512; bh=No1hRUoq8G5x+5o40hJzJRvS7EauTBPVtearmdchDHY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=L/MU9iSYz3G+aizRyhjO7G5bfr5XXvlgHPRdfNFdLa6lkGG6VKrpcf37nOio3G5tU sFE0yqT+CzxgzaxmAFPNhoQTt1eg+HxUeaGQL0FLRWNFQpzGRtsLqCyzcPFsHgiC8E QQmeitTcycIq6KYxhRu5TH1Hipf2ooZkwodg8FWSLsffrsx8t/HKfCFtnkE9cBUO9t bIJlmttLhqJ6kuYNdXXbB6ah1FvMD2AyCWxp9ABPW8dzwWDQBjOeWgPfyV0w6IhaoN sXZRo3zkk5pvM30SmX1ESABktkz6FyJ24ZkMIK9Tcdx4j3ZdeAbOSLp+03rC32pWFR 4L2JKQhroM9Zg== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 24/30] btrfs: send: simplify return logic from send_rename() Date: Thu, 20 Feb 2025 11:04:37 +0000 Message-Id: <406a37adace0bfb7a92fec821bafd1ba1e277536.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There is no need to have an 'out' label and jump into it since there are no resource cleanups to perform (release locks, free memory, etc), so make this simpler by removing the label and goto and instead return directly. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index f161e6a695bd..d5c151651d07 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -809,7 +809,7 @@ static int send_rename(struct send_ctx *sctx, ret = begin_cmd(sctx, BTRFS_SEND_C_RENAME); if (ret < 0) - goto out; + return ret; TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, from); TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH_TO, to); @@ -817,7 +817,6 @@ static int send_rename(struct send_ctx *sctx, ret = send_cmd(sctx); tlv_put_failure: -out: return ret; } From patchwork Thu Feb 20 11:04:38 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983774 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 675EA1F1913 for ; Thu, 20 Feb 2025 11:05:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049513; cv=none; b=djKgj1UgcPxCZsPTIsEHyKpGMmqaJIjXGl0fqDYggtGh6OwmVCpPKYshlA+fmvRhVkxTZbpe9W8HI/8W2NbwsJjTqdAS673MioAhCJVoGSQenR6ZX/n4yb08U/c7AtiP30wiVdPAVA3jGDn7nJ5KRwoLDxrh4+GbAgtlfP+bnvM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049513; c=relaxed/simple; bh=YRwbdZySKM3CEdobzlcWa7QWhdjG3B8FlMUrlCzFH6U=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=eRjWNPJnNownySbPa5nrSLKJMNdg6Xi4RGNb0mknMnZNIsZ5dXyAk5bTk9/SvUYLTBtivacqo8d72FQPu34l4Fl9j3uR/WNDsoSWkBP8qQpKpGZCKdhi/oQ0jGU21Qx9jho3zWADbTVIT+OuZQSReVKocYvmmYBAp0Jq7q95fQQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m+HWilIS; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="m+HWilIS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id B75CEC4CEE3 for ; Thu, 20 Feb 2025 11:05:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049513; bh=YRwbdZySKM3CEdobzlcWa7QWhdjG3B8FlMUrlCzFH6U=; h=From:To:Subject:Date:In-Reply-To:References:From; b=m+HWilISCi1zKKMd6goABkMRLH8LyaUnjSQyta/sQ+FRFo8JPUXndcq/+NrNk0k+y Hdzt6/uUgZ6m8uBILmGTh31i0Sprixm53lvntkytBbRNFtDK/UlsCy4GgWxoVSxsJN KrHVruFEnfGtZmbUDeq9tlRJ6L+C7aIXln+aCfi0mZ7AJWb1Dh/TfcJdwi6t0MxWI5 zfoo+iKfiyo1sr37EpqDqivIpEO+7QLKTWVUlvEHRma5jGgUqPsSDr1JqmUtJkJLaj t1IEYqeqCEjNwyLCaPU9zKRuLh/1baGkiELff4ovNqEHM4pc4iNoZ15b52VgX7MkAM tc0R32PU3sgLA== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 25/30] btrfs: send: simplify return logic from send_link() Date: Thu, 20 Feb 2025 11:04:38 +0000 Message-Id: <3f719e4e989a54bf8cf671d5227969a8e61fc0a1.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There is no need to have an 'out' label and jump into it since there are no resource cleanups to perform (release locks, free memory, etc), so make this simpler by removing the label and goto and instead return directly. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index d5c151651d07..bda229c7084b 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -833,7 +833,7 @@ static int send_link(struct send_ctx *sctx, ret = begin_cmd(sctx, BTRFS_SEND_C_LINK); if (ret < 0) - goto out; + return ret; TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, path); TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH_LINK, lnk); @@ -841,7 +841,6 @@ static int send_link(struct send_ctx *sctx, ret = send_cmd(sctx); tlv_put_failure: -out: return ret; } From patchwork Thu Feb 20 11:04:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983775 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A2351DE2D8 for ; Thu, 20 Feb 2025 11:05:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049514; cv=none; b=MoZjEmbYzPtTHjXEqoea52Vm6ZGODBzgF7rjkLkD8kVCyHkmAbL1VtAHBgqi4qhlFijdTcS2ZyKVCiFEZhXfdu2k2tXiYrJblsgSdxXkGj7U0EdFNIUCYbkgfhmXS2qq0R1spkiq/Zz7tNat6nvWXJ4nNVlhh6vH6Avipc6GeX8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049514; c=relaxed/simple; bh=TEyvVs9sSH67OdNK9N+PYvkA6S8b9X+bW4EZLLSSLHw=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=KjFtpxYy1Iu2qsxiR3e8VfE/5TnpE5o9Ubij0Di9hsnnMIajuJ6V7s2R3wVwUiy23qe4AywD4B/ZM5zSc1NuDj4Tlfre81YhDInrsO694AzTXoqkvnpF83Gtx4MtQoTDiuH4gwd79HoHAgpLthI43TT1VAtei6bsQ2Ap3euIQR8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=goh34P2m; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="goh34P2m" Received: by smtp.kernel.org (Postfix) with ESMTPSA id BD43EC4CED1 for ; Thu, 20 Feb 2025 11:05:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049514; bh=TEyvVs9sSH67OdNK9N+PYvkA6S8b9X+bW4EZLLSSLHw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=goh34P2m27MHdTtdnIVu1gEpszSp9VYL2z4VlBjPvWyvPuu7VPhsgUO+scgvQxe1f kkF5zFxRzPMQGl799tR+p5HBRWSoxyBaYLQS7ul3rc4VLh6isNvjYcByG0tUYw5Eri gdjNniMcJoM3fpjnzCAPrxxIW4sgD2LTBIp2C/a6ZH6gD6G2lEdXLXZYD0D3yNRKjj qFe8YiR6FtqOrS6j4XTCRjXhoP8AaDOn3rp14UVlv6fpevd6yPAhutVcxTO9Vo4Sq5 wd6rWuSjLYPwf8mxQgmsXsaqxopBZZ/fJ+1Y2PE5r0lehrDZLwx8/8QDzY2yF+suf8 Io/tekPn+jsyQ== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 26/30] btrfs: send: simplify return logic from send_unlink() Date: Thu, 20 Feb 2025 11:04:39 +0000 Message-Id: <08ce139f9df32e2449cccea0335687f6376875be.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There is no need to have an 'out' label and jump into it since there are no resource cleanups to perform (release locks, free memory, etc), so make this simpler by removing the label and goto and instead return directly. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index bda229c7084b..cbc9ca9db062 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -856,14 +856,13 @@ static int send_unlink(struct send_ctx *sctx, struct fs_path *path) ret = begin_cmd(sctx, BTRFS_SEND_C_UNLINK); if (ret < 0) - goto out; + return ret; TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, path); ret = send_cmd(sctx); tlv_put_failure: -out: return ret; } From patchwork Thu Feb 20 11:04:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983776 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7332A1F4E54 for ; Thu, 20 Feb 2025 11:05:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049515; cv=none; b=cjGpAf9najploo2vkN0H30v0xCWeyUYktUavWjWe/aZ31i+fBROqrTvV+6ZPmnJztRlUDeN1yCiUETqJXUCq6SQreYE99MpSZS+xaCPxg5YJGCwzeDd3zs67KL+0l0ixXdKPYDavexLvA1e9YPVWgeG7864Os07/RLfTrux39Zg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049515; c=relaxed/simple; bh=IDJlvcdhDQQUfwB4RDcgxx9hfHya+TjJhCjWxPMCujg=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=JPf4U/JJ3NgxgNiYfKxIH+XJ9fgrx5to434lIwn2cRBBxX1Xo0utegBOdysSB7bE9k/Ww0R1YyMd5f690TKzjS1kgjb1a0ivtd0Rz9WbiUEFfeyVTlG5lIsszv/3SoG4AQNsaYRheOrSmci+OkfPJEHbL4f93u6QLYWCfGa4QEI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IqSKSxHV; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IqSKSxHV" Received: by smtp.kernel.org (Postfix) with ESMTPSA id C46AEC4CED1 for ; Thu, 20 Feb 2025 11:05:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049515; bh=IDJlvcdhDQQUfwB4RDcgxx9hfHya+TjJhCjWxPMCujg=; h=From:To:Subject:Date:In-Reply-To:References:From; b=IqSKSxHVpTUgtm38Gr8mux5c2qtXQIsXEVpdpeLvXqlnkLtxuLcivqUu6nl1We1Sv 23aZv/EZl3vUf1VqdzFtiFUtRQJxayk2zMufzURj3r46zQmtPf9wqh869RqMPIpTqd v6gFQErcL04UZReA4srFvhKEtC0sNYKFNWs9kX2/9GMvaTxINNANxUg02w16Dt1rA8 1Uze8ODQb2gXASVsLRdRvDMkjUgAipyvHNDWRq4oxcQdmb3PFnH3Y33BGgM+mL4990 NeIK4rNuhhX12YP3gQFzu4L4mHtXvKW3tu6O2VW+R2VKr8DK/D4r5HAuVUfhz1Q/H2 WaDO1Cp04U99Q== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 27/30] btrfs: send: simplify return logic from send_rmdir() Date: Thu, 20 Feb 2025 11:04:40 +0000 Message-Id: <787ca60ae3a756f78ec49ff633ea250f0050d828.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There is no need to have an 'out' label and jump into it since there are no resource cleanups to perform (release locks, free memory, etc), so make this simpler by removing the label and goto and instead return directly. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index cbc9ca9db062..0c496270e10f 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -878,14 +878,13 @@ static int send_rmdir(struct send_ctx *sctx, struct fs_path *path) ret = begin_cmd(sctx, BTRFS_SEND_C_RMDIR); if (ret < 0) - goto out; + return ret; TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, path); ret = send_cmd(sctx); tlv_put_failure: -out: return ret; } From patchwork Thu Feb 20 11:04:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983777 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7884E1F239B for ; Thu, 20 Feb 2025 11:05:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049516; cv=none; b=YyUZJFrezkpN1cQNRWFwxGfQumLewHUP0Vm6yb1EIJDNzFiUZbbP0kn4YAhvuGcfEZc1Qy4jp+VTGtrx83Vm1Uszjz0TtarGp/TkQ19rn3PYyTJqNBf/fOF5U/5HDZGAfA8oIzKVVts+Q/TOKcCB7To0TzJVD1qEyxW/zLA1/kY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049516; c=relaxed/simple; bh=fP2IJ341pVtho47G7OeVJ+kISspNOnjKAdj7w1n0ZOI=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=nEBmOKIs/NrY4V7l8Rtb410EODp61PxfNEdA73Ex9GMjXVQCc9aG8nZgcBcO/7iRfFd7a+ymqgIJ1uFPGRPVWo/jXzoqAaBOKb+puqKH5M24ddpIqgazKDYTumFInPjIgkQF2NeHJSpYrFhSvPUL9UNbOsSG1Bw06nydg+uWICU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=AN8C0cVP; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="AN8C0cVP" Received: by smtp.kernel.org (Postfix) with ESMTPSA id CA3DBC4CEE4 for ; Thu, 20 Feb 2025 11:05:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049516; bh=fP2IJ341pVtho47G7OeVJ+kISspNOnjKAdj7w1n0ZOI=; h=From:To:Subject:Date:In-Reply-To:References:From; b=AN8C0cVPAHsl7DBsgASC5IKTO00S05rvU7MdggvpoUav63gR0m36Q7W71z2ppLDfq e3BDCOGP2l8gWqCAaH7whOsStQVH0EBzCaVa/YB+yP1sHnmsH6jN8EjN+8YhliMtAI pRY3h1pnVpV3MrZ3SNbRmyTTpmSY1GOfJXz97pMourb3xC7jMv1rBqUDa3uz4aV+YZ n9WCPBCRqbeekTyUqpZVml5tE514dyXC/vA2uEEiIUrSbqT1J9iFbZ8Y8e+doYx8fG izq4imf3d36tN9eP4wlG9ablaW4EVztg3p5iQvjAVzpWow3BrYhJmOcZfKkF46G9z8 JR+CmYUwyaQ5w== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 28/30] btrfs: send: keep the current inode's path cached Date: Thu, 20 Feb 2025 11:04:41 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana Whenever we need to send a command for the current inode, like sending writes, xattr updates, truncates, utimes, etc, we compute the inode's path each time, which implies doing some memory allocations and traversing the inode hierarchy to extract the name of the inode and each ancestor directory, and that implies doing lookups in the subvolume tree amongst other operations. Most of the time, by far, the current inode's path doesn't change while we are processing it (like if we need to issue 100 write commands, the path remains the same and it's pointless to compute it 100 times). To avoid this keep the current inode's path cached in the send context and invalidate it or update it whenever it's needed (after unlinks or renames). A performance test, and its results, is mentioned in the next patch in the series (subject: "btrfs: send: avoid path allocation for the current inode when issuing commands"). Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 53 ++++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 0c496270e10f..e811c9237e9e 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -177,6 +177,7 @@ struct send_ctx { u64 cur_inode_rdev; u64 cur_inode_last_extent; u64 cur_inode_next_write_offset; + struct fs_path cur_inode_path; bool cur_inode_new; bool cur_inode_new_gen; bool cur_inode_deleted; @@ -433,6 +434,14 @@ static void fs_path_reset(struct fs_path *p) *p->start = 0; } +static void init_path(struct fs_path *p) +{ + p->reversed = 0; + p->buf = p->inline_buf; + p->buf_len = FS_PATH_INLINE_SIZE; + fs_path_reset(p); +} + static struct fs_path *fs_path_alloc(void) { struct fs_path *p; @@ -440,10 +449,7 @@ static struct fs_path *fs_path_alloc(void) p = kmalloc(sizeof(*p), GFP_KERNEL); if (!p) return NULL; - p->reversed = 0; - p->buf = p->inline_buf; - p->buf_len = FS_PATH_INLINE_SIZE; - fs_path_reset(p); + init_path(p); return p; } @@ -609,6 +615,14 @@ static void fs_path_unreverse(struct fs_path *p) p->reversed = 0; } +static inline bool is_current_inode_path(const struct send_ctx *sctx, + const struct fs_path *path) +{ + const struct fs_path *cur = &sctx->cur_inode_path; + + return (strncmp(path->start, cur->start, fs_path_len(cur)) == 0); +} + static struct btrfs_path *alloc_path_for_send(void) { struct btrfs_path *path; @@ -2415,6 +2429,14 @@ static int get_cur_path(struct send_ctx *sctx, u64 ino, u64 gen, u64 parent_inode = 0; u64 parent_gen = 0; int stop = 0; + const bool is_cur_inode = (ino == sctx->cur_ino && gen == sctx->cur_inode_gen); + + if (is_cur_inode && fs_path_len(&sctx->cur_inode_path) > 0) { + if (dest != &sctx->cur_inode_path) + return fs_path_copy(dest, &sctx->cur_inode_path); + + return 0; + } name = fs_path_alloc(); if (!name) { @@ -2466,8 +2488,12 @@ static int get_cur_path(struct send_ctx *sctx, u64 ino, u64 gen, out: fs_path_free(name); - if (!ret) + if (!ret) { fs_path_unreverse(dest); + if (is_cur_inode && dest != &sctx->cur_inode_path) + ret = fs_path_copy(&sctx->cur_inode_path, dest); + } + return ret; } @@ -3077,6 +3103,11 @@ static int orphanize_inode(struct send_ctx *sctx, u64 ino, u64 gen, goto out; ret = send_rename(sctx, path, orphan); + if (ret < 0) + goto out; + + if (ino == sctx->cur_ino && gen == sctx->cur_inode_gen) + ret = fs_path_copy(&sctx->cur_inode_path, orphan); out: fs_path_free(orphan); @@ -4139,6 +4170,10 @@ static int rename_current_inode(struct send_ctx *sctx, if (ret < 0) return ret; + ret = fs_path_copy(&sctx->cur_inode_path, new_path); + if (ret < 0) + return ret; + return fs_path_copy(current_path, new_path); } @@ -4332,6 +4367,7 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move) if (ret > 0) { orphanized_ancestor = true; fs_path_reset(valid_path); + fs_path_reset(&sctx->cur_inode_path); ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, valid_path); @@ -4531,6 +4567,8 @@ static int process_recorded_refs(struct send_ctx *sctx, int *pending_move) ret = send_unlink(sctx, cur->full_path); if (ret < 0) goto out; + if (is_current_inode_path(sctx, cur->full_path)) + fs_path_reset(&sctx->cur_inode_path); } ret = dup_ref(cur, &check_dirs); if (ret < 0) @@ -6851,6 +6889,7 @@ static int changed_inode(struct send_ctx *sctx, sctx->cur_inode_last_extent = (u64)-1; sctx->cur_inode_next_write_offset = 0; sctx->ignore_cur_inode = false; + fs_path_reset(&sctx->cur_inode_path); /* * Set send_progress to current inode. This will tell all get_cur_xxx @@ -8126,6 +8165,7 @@ long btrfs_ioctl_send(struct btrfs_inode *inode, const struct btrfs_ioctl_send_a goto out; } + init_path(&sctx->cur_inode_path); INIT_LIST_HEAD(&sctx->new_refs); INIT_LIST_HEAD(&sctx->deleted_refs); @@ -8402,6 +8442,9 @@ long btrfs_ioctl_send(struct btrfs_inode *inode, const struct btrfs_ioctl_send_a btrfs_lru_cache_clear(&sctx->dir_created_cache); btrfs_lru_cache_clear(&sctx->dir_utimes_cache); + if (sctx->cur_inode_path.buf != sctx->cur_inode_path.inline_buf) + kfree(sctx->cur_inode_path.buf); + kfree(sctx); } From patchwork Thu Feb 20 11:04:42 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983778 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7E1171F5438 for ; Thu, 20 Feb 2025 11:05:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049517; cv=none; b=tsPCX0Y4kOdvAu9ylmLNWor3R2z5xYHY/F8AHBU9TcbHkdpJvb5fT3BnuCMSf11GTSLdg92E6VJZ3Q9aM0VBJ8P7dxRm1wQBAgahWQgVD7n+QzuH27x5HbboKJugax+2kU/SjeRAg9r4NKGEUUi3GZsndu4sMHwz/951oHEzN7Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049517; c=relaxed/simple; bh=UiMze5NXCd0hBLLOT5ruU/CXc4k2KLMweo+TBBh1rrc=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=ATX5BbQiHrDFUVS5u/v7Xq1KPydXqz8u4tQNQB1AkYOiFz24EgAbkTiUWDTUS3isU6xylOpnoUn8DLcEMV0nv59pNhLH29OYOQ+J6QGt7yYmh5WgVE5bZ/NJt0Pm5o6IlwTZEjhr00kCfrckOaOrGZoZPZyo244knXHvcJegWQc= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ADQ0cG++; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ADQ0cG++" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D0F6EC4CEDD for ; Thu, 20 Feb 2025 11:05:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049517; bh=UiMze5NXCd0hBLLOT5ruU/CXc4k2KLMweo+TBBh1rrc=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ADQ0cG++wHuvyaOidD82AdIyi1LsA6pFT5JUMDsC2bOvnWHny/My9MowUU14okQ8/ n0Ru5vEWbKKXH3HwqN6057QRUpU302nr9ux5zNyhiWn/z1kt5dKcYZJXKOKpBISHTO faTHzeB9V9gCja3OokNFfv45BSbQ4m57kV818lMgquBoQimHWaqfX3kfCs48pgo0rQ wAdDMVWDLqWPAH6gsRMYDMh4N63nBlgd3ZIBv1xrgFlIj6HA4B76+7FYmpc/+eoM6m 69PJjApz1JPdV8XvnT8qP4tRCYO6tfqdZY9N4gCa+yHK3kZ1cA8vbUEKdkuDxyn1BP 1piWLxfck51mg== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 29/30] btrfs: send: avoid path allocation for the current inode when issuing commands Date: Thu, 20 Feb 2025 11:04:42 +0000 Message-Id: X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana Whenever we issue a command we allocate a path and then compute it. For the current inode this is not necessary since we have one preallocated and computed in the send context structure, so we can use it instead and avoid allocating and freeing a path. For example if we have 100 extents to send (100 write commands) for a file, we are allocating and freeing paths 100 times. So improve on this by avoiding path allocation and freeing whenever a command is for the current inode by using the current inode's path stored in the send context structure. A test was run before applying this patch and the previous one in the series: "btrfs: send: keep the current inode's path cached" The test script is the following: $ cat test.sh #!/bin/bash DEV=/dev/nullb0 MNT=/mnt/nullb0 mkfs.btrfs -f $DEV > /dev/null mount $DEV $MNT DIR="$MNT/one/two/three/four" FILE="$DIR/foobar" mkdir -p $DIR # Create some empty files to get a deeper btree and therefore make # path computations slower. for ((i = 1; i <= 30000; i++)); do echo -n > "$DIR/filler_$i" done for ((i = 0; i < 10000; i += 2)); do offset=$(( i * 4096 )) xfs_io -f -c "pwrite -S 0xab $offset 4K" $FILE > /dev/null done btrfs subvolume snapshot -r $MNT $MNT/snap start=$(date +%s%N) btrfs send -f /dev/null $MNT/snap end=$(date +%s%N) echo -e "\nsend took $(( (end - start) / 1000000 )) milliseconds" umount $MNT Result before applying the 2 patches: 1121 milliseconds Result after applying the 2 patches: 815 milliseconds (-31.6%) Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 215 ++++++++++++++++++++++-------------------------- 1 file changed, 97 insertions(+), 118 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index e811c9237e9e..2c1259068b76 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -2588,6 +2588,47 @@ static int send_subvol_begin(struct send_ctx *sctx) return ret; } +static struct fs_path *get_cur_inode_path(struct send_ctx *sctx) +{ + if (fs_path_len(&sctx->cur_inode_path) == 0) { + int ret; + + ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, + &sctx->cur_inode_path); + if (ret < 0) + return ERR_PTR(ret); + } + + return &sctx->cur_inode_path; +} + +static struct fs_path *get_path_for_command(struct send_ctx *sctx, u64 ino, u64 gen) +{ + struct fs_path *path; + int ret; + + if (ino == sctx->cur_ino && gen == sctx->cur_inode_gen) + return get_cur_inode_path(sctx); + + path = fs_path_alloc(); + if (!path) + return ERR_PTR(-ENOMEM); + + ret = get_cur_path(sctx, ino, gen, path); + if (ret < 0) { + fs_path_free(path); + return ERR_PTR(ret); + } + + return path; +} + +static void free_path_for_command(const struct send_ctx *sctx, struct fs_path *path) +{ + if (path != &sctx->cur_inode_path) + fs_path_free(path); +} + static int send_truncate(struct send_ctx *sctx, u64 ino, u64 gen, u64 size) { struct btrfs_fs_info *fs_info = sctx->send_root->fs_info; @@ -2596,17 +2637,14 @@ static int send_truncate(struct send_ctx *sctx, u64 ino, u64 gen, u64 size) btrfs_debug(fs_info, "send_truncate %llu size=%llu", ino, size); - p = fs_path_alloc(); - if (!p) - return -ENOMEM; + p = get_path_for_command(sctx, ino, gen); + if (IS_ERR(p)) + return PTR_ERR(p); ret = begin_cmd(sctx, BTRFS_SEND_C_TRUNCATE); if (ret < 0) goto out; - ret = get_cur_path(sctx, ino, gen, p); - if (ret < 0) - goto out; TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, p); TLV_PUT_U64(sctx, BTRFS_SEND_A_SIZE, size); @@ -2614,7 +2652,7 @@ static int send_truncate(struct send_ctx *sctx, u64 ino, u64 gen, u64 size) tlv_put_failure: out: - fs_path_free(p); + free_path_for_command(sctx, p); return ret; } @@ -2626,17 +2664,14 @@ static int send_chmod(struct send_ctx *sctx, u64 ino, u64 gen, u64 mode) btrfs_debug(fs_info, "send_chmod %llu mode=%llu", ino, mode); - p = fs_path_alloc(); - if (!p) - return -ENOMEM; + p = get_path_for_command(sctx, ino, gen); + if (IS_ERR(p)) + return PTR_ERR(p); ret = begin_cmd(sctx, BTRFS_SEND_C_CHMOD); if (ret < 0) goto out; - ret = get_cur_path(sctx, ino, gen, p); - if (ret < 0) - goto out; TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, p); TLV_PUT_U64(sctx, BTRFS_SEND_A_MODE, mode & 07777); @@ -2644,7 +2679,7 @@ static int send_chmod(struct send_ctx *sctx, u64 ino, u64 gen, u64 mode) tlv_put_failure: out: - fs_path_free(p); + free_path_for_command(sctx, p); return ret; } @@ -2659,17 +2694,14 @@ static int send_fileattr(struct send_ctx *sctx, u64 ino, u64 gen, u64 fileattr) btrfs_debug(fs_info, "send_fileattr %llu fileattr=%llu", ino, fileattr); - p = fs_path_alloc(); - if (!p) - return -ENOMEM; + p = get_path_for_command(sctx, ino, gen); + if (IS_ERR(p)) + return PTR_ERR(p); ret = begin_cmd(sctx, BTRFS_SEND_C_FILEATTR); if (ret < 0) goto out; - ret = get_cur_path(sctx, ino, gen, p); - if (ret < 0) - goto out; TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, p); TLV_PUT_U64(sctx, BTRFS_SEND_A_FILEATTR, fileattr); @@ -2677,7 +2709,7 @@ static int send_fileattr(struct send_ctx *sctx, u64 ino, u64 gen, u64 fileattr) tlv_put_failure: out: - fs_path_free(p); + free_path_for_command(sctx, p); return ret; } @@ -2690,17 +2722,14 @@ static int send_chown(struct send_ctx *sctx, u64 ino, u64 gen, u64 uid, u64 gid) btrfs_debug(fs_info, "send_chown %llu uid=%llu, gid=%llu", ino, uid, gid); - p = fs_path_alloc(); - if (!p) - return -ENOMEM; + p = get_path_for_command(sctx, ino, gen); + if (IS_ERR(p)) + return PTR_ERR(p); ret = begin_cmd(sctx, BTRFS_SEND_C_CHOWN); if (ret < 0) goto out; - ret = get_cur_path(sctx, ino, gen, p); - if (ret < 0) - goto out; TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, p); TLV_PUT_U64(sctx, BTRFS_SEND_A_UID, uid); TLV_PUT_U64(sctx, BTRFS_SEND_A_GID, gid); @@ -2709,7 +2738,7 @@ static int send_chown(struct send_ctx *sctx, u64 ino, u64 gen, u64 uid, u64 gid) tlv_put_failure: out: - fs_path_free(p); + free_path_for_command(sctx, p); return ret; } @@ -2726,9 +2755,9 @@ static int send_utimes(struct send_ctx *sctx, u64 ino, u64 gen) btrfs_debug(fs_info, "send_utimes %llu", ino); - p = fs_path_alloc(); - if (!p) - return -ENOMEM; + p = get_path_for_command(sctx, ino, gen); + if (IS_ERR(p)) + return PTR_ERR(p); path = alloc_path_for_send(); if (!path) { @@ -2753,9 +2782,6 @@ static int send_utimes(struct send_ctx *sctx, u64 ino, u64 gen) if (ret < 0) goto out; - ret = get_cur_path(sctx, ino, gen, p); - if (ret < 0) - goto out; TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, p); TLV_PUT_BTRFS_TIMESPEC(sctx, BTRFS_SEND_A_ATIME, eb, &ii->atime); TLV_PUT_BTRFS_TIMESPEC(sctx, BTRFS_SEND_A_MTIME, eb, &ii->mtime); @@ -2767,7 +2793,7 @@ static int send_utimes(struct send_ctx *sctx, u64 ino, u64 gen) tlv_put_failure: out: - fs_path_free(p); + free_path_for_command(sctx, p); btrfs_free_path(path); return ret; } @@ -4885,13 +4911,9 @@ static int send_set_xattr(struct send_ctx *sctx, struct fs_path *path; int ret; - path = fs_path_alloc(); - if (!path) - return -ENOMEM; - - ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, path); - if (ret < 0) - goto out; + path = get_cur_inode_path(sctx); + if (IS_ERR(path)) + return PTR_ERR(path); ret = begin_cmd(sctx, BTRFS_SEND_C_SET_XATTR); if (ret < 0) @@ -4905,8 +4927,6 @@ static int send_set_xattr(struct send_ctx *sctx, tlv_put_failure: out: - fs_path_free(path); - return ret; } @@ -4963,23 +4983,14 @@ static int __process_deleted_xattr(int num, struct btrfs_key *di_key, const char *name, int name_len, const char *data, int data_len, void *ctx) { - int ret; struct send_ctx *sctx = ctx; struct fs_path *p; - p = fs_path_alloc(); - if (!p) - return -ENOMEM; - - ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p); - if (ret < 0) - goto out; - - ret = send_remove_xattr(sctx, p, name, name_len); + p = get_cur_inode_path(sctx); + if (IS_ERR(p)) + return PTR_ERR(p); -out: - fs_path_free(p); - return ret; + return send_remove_xattr(sctx, p, name, name_len); } static int process_new_xattr(struct send_ctx *sctx) @@ -5205,21 +5216,13 @@ static int process_verity(struct send_ctx *sctx) if (ret < 0) goto iput; - p = fs_path_alloc(); - if (!p) { - ret = -ENOMEM; + p = get_cur_inode_path(sctx); + if (IS_ERR(p)) { + ret = PTR_ERR(p); goto iput; } - ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p); - if (ret < 0) - goto free_path; ret = send_verity(sctx, p, sctx->verity_descriptor); - if (ret < 0) - goto free_path; - -free_path: - fs_path_free(p); iput: iput(inode); return ret; @@ -5341,31 +5344,25 @@ static int send_write(struct send_ctx *sctx, u64 offset, u32 len) int ret = 0; struct fs_path *p; - p = fs_path_alloc(); - if (!p) - return -ENOMEM; - btrfs_debug(fs_info, "send_write offset=%llu, len=%d", offset, len); - ret = begin_cmd(sctx, BTRFS_SEND_C_WRITE); - if (ret < 0) - goto out; + p = get_cur_inode_path(sctx); + if (IS_ERR(p)) + return PTR_ERR(p); - ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p); + ret = begin_cmd(sctx, BTRFS_SEND_C_WRITE); if (ret < 0) - goto out; + return ret; TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, p); TLV_PUT_U64(sctx, BTRFS_SEND_A_FILE_OFFSET, offset); ret = put_file_data(sctx, offset, len); if (ret < 0) - goto out; + return ret; ret = send_cmd(sctx); tlv_put_failure: -out: - fs_path_free(p); return ret; } @@ -5378,6 +5375,7 @@ static int send_clone(struct send_ctx *sctx, { int ret = 0; struct fs_path *p; + struct fs_path *cur_inode_path; u64 gen; btrfs_debug(sctx->send_root->fs_info, @@ -5385,6 +5383,10 @@ static int send_clone(struct send_ctx *sctx, offset, len, btrfs_root_id(clone_root->root), clone_root->ino, clone_root->offset); + cur_inode_path = get_cur_inode_path(sctx); + if (IS_ERR(cur_inode_path)) + return PTR_ERR(cur_inode_path); + p = fs_path_alloc(); if (!p) return -ENOMEM; @@ -5393,13 +5395,9 @@ static int send_clone(struct send_ctx *sctx, if (ret < 0) goto out; - ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p); - if (ret < 0) - goto out; - TLV_PUT_U64(sctx, BTRFS_SEND_A_FILE_OFFSET, offset); TLV_PUT_U64(sctx, BTRFS_SEND_A_CLONE_LEN, len); - TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, p); + TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, cur_inode_path); if (clone_root->root == sctx->send_root) { ret = get_inode_gen(sctx->send_root, clone_root->ino, &gen); @@ -5450,17 +5448,13 @@ static int send_update_extent(struct send_ctx *sctx, int ret = 0; struct fs_path *p; - p = fs_path_alloc(); - if (!p) - return -ENOMEM; + p = get_cur_inode_path(sctx); + if (IS_ERR(p)) + return PTR_ERR(p); ret = begin_cmd(sctx, BTRFS_SEND_C_UPDATE_EXTENT); if (ret < 0) - goto out; - - ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p); - if (ret < 0) - goto out; + return ret; TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, p); TLV_PUT_U64(sctx, BTRFS_SEND_A_FILE_OFFSET, offset); @@ -5469,8 +5463,6 @@ static int send_update_extent(struct send_ctx *sctx, ret = send_cmd(sctx); tlv_put_failure: -out: - fs_path_free(p); return ret; } @@ -5499,12 +5491,10 @@ static int send_hole(struct send_ctx *sctx, u64 end) if (sctx->flags & BTRFS_SEND_FLAG_NO_FILE_DATA) return send_update_extent(sctx, offset, end - offset); - p = fs_path_alloc(); - if (!p) - return -ENOMEM; - ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, p); - if (ret < 0) - goto tlv_put_failure; + p = get_cur_inode_path(sctx); + if (IS_ERR(p)) + return PTR_ERR(p); + while (offset < end) { u64 len = min(end - offset, read_size); @@ -5525,7 +5515,6 @@ static int send_hole(struct send_ctx *sctx, u64 end) } sctx->cur_inode_next_write_offset = offset; tlv_put_failure: - fs_path_free(p); return ret; } @@ -5548,9 +5537,9 @@ static int send_encoded_inline_extent(struct send_ctx *sctx, if (IS_ERR(inode)) return PTR_ERR(inode); - fspath = fs_path_alloc(); - if (!fspath) { - ret = -ENOMEM; + fspath = get_cur_inode_path(sctx); + if (IS_ERR(fspath)) { + ret = PTR_ERR(fspath); goto out; } @@ -5558,10 +5547,6 @@ static int send_encoded_inline_extent(struct send_ctx *sctx, if (ret < 0) goto out; - ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, fspath); - if (ret < 0) - goto out; - btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_file_extent_item); ram_bytes = btrfs_file_extent_ram_bytes(leaf, ei); @@ -5590,7 +5575,6 @@ static int send_encoded_inline_extent(struct send_ctx *sctx, tlv_put_failure: out: - fs_path_free(fspath); iput(inode); return ret; } @@ -5615,9 +5599,9 @@ static int send_encoded_extent(struct send_ctx *sctx, struct btrfs_path *path, if (IS_ERR(inode)) return PTR_ERR(inode); - fspath = fs_path_alloc(); - if (!fspath) { - ret = -ENOMEM; + fspath = get_cur_inode_path(sctx); + if (IS_ERR(fspath)) { + ret = PTR_ERR(fspath); goto out; } @@ -5625,10 +5609,6 @@ static int send_encoded_extent(struct send_ctx *sctx, struct btrfs_path *path, if (ret < 0) goto out; - ret = get_cur_path(sctx, sctx->cur_ino, sctx->cur_inode_gen, fspath); - if (ret < 0) - goto out; - btrfs_item_key_to_cpu(leaf, &key, path->slots[0]); ei = btrfs_item_ptr(leaf, path->slots[0], struct btrfs_file_extent_item); disk_bytenr = btrfs_file_extent_disk_bytenr(leaf, ei); @@ -5696,7 +5676,6 @@ static int send_encoded_extent(struct send_ctx *sctx, struct btrfs_path *path, tlv_put_failure: out: - fs_path_free(fspath); iput(inode); return ret; } From patchwork Thu Feb 20 11:04:43 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Filipe Manana X-Patchwork-Id: 13983779 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 844C81F55F5 for ; Thu, 20 Feb 2025 11:05:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049518; cv=none; b=jswWJI3DnefWDILzwE9+YnJrS8lutHVtTjRHQhATpTorKsmNb22HhVwU5iBs8EstHTsIwudvOFgHQxB6v3TWtF4DkJ12UvcBkQsdcNzDkqiCBJpuE2dv5BM0Bc3u2e9bt6njBO6iLHa9HRQsMnq0IDcZ7WpmFLyvCQa1meICqAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1740049518; c=relaxed/simple; bh=sND5AadJivekOGKz9y//4pBxSPGXLqgKjxggF0TcMLE=; h=From:To:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=TVnKSabfaXElEFCadMkxZjlDWzDH9XqExpygS6U3Ii0RO/O0e+9/W2buA2APwwefmX2FUZX72m/BrsonWPbStFv9d4dV8bT7qsFayjU6YJjtTTv79v7M2Y7uzi12tncCXOgbINA78GwUI+YZbDQ7gWUvMFjFl5iT8l48h9hB9T0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=Iah3g9ne; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="Iah3g9ne" Received: by smtp.kernel.org (Postfix) with ESMTPSA id D61A3C4CEDD for ; Thu, 20 Feb 2025 11:05:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1740049518; bh=sND5AadJivekOGKz9y//4pBxSPGXLqgKjxggF0TcMLE=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Iah3g9ne3osEBScFQR+tWLT355UiFHRVM3qo2s5HzQqAbYw/xtFHbrRXEi8RuFjEi cd4VC5Nlq4S8rIYkEX6jBGro4lwtgYvrO894xHrOgiBPR+Nej14bo48ZwJDWte/w+D 3CnYPyCCJTKEajUe2OC1Ho2/sy8qJu3UAo2mcAlRJn/I9cKL6ugYsfrku2NRF5RshH 4/qF81WSugGUIkTHmmNWKDoeAL3CoQMY5LorGpy8NlncyUzbzq7kkZIYPPVCUsOIwi UDqbAjSgJh9FPW5yCls3VS48iFXpP1qPJn9Ln82i2cjgT/36HufTE0jqzVILjhuxZy UrSqS+MlmAhcQ== From: fdmanana@kernel.org To: linux-btrfs@vger.kernel.org Subject: [PATCH v2 30/30] btrfs: send: simplify return logic from send_set_xattr() Date: Thu, 20 Feb 2025 11:04:43 +0000 Message-Id: <65f564543c176d884b248646b64cfaf08fb0ca0f.1740049233.git.fdmanana@suse.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: References: Precedence: bulk X-Mailing-List: linux-btrfs@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 From: Filipe Manana There's no longer any need for the 'out' label as there are no resources to cleanup anymore in case of an error and we can directly return if begin_cmd() fails. Signed-off-by: Filipe Manana --- fs/btrfs/send.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/btrfs/send.c b/fs/btrfs/send.c index 2c1259068b76..878b32331bc2 100644 --- a/fs/btrfs/send.c +++ b/fs/btrfs/send.c @@ -4917,7 +4917,7 @@ static int send_set_xattr(struct send_ctx *sctx, ret = begin_cmd(sctx, BTRFS_SEND_C_SET_XATTR); if (ret < 0) - goto out; + return ret; TLV_PUT_PATH(sctx, BTRFS_SEND_A_PATH, path); TLV_PUT_STRING(sctx, BTRFS_SEND_A_XATTR_NAME, name, name_len); @@ -4926,7 +4926,6 @@ static int send_set_xattr(struct send_ctx *sctx, ret = send_cmd(sctx); tlv_put_failure: -out: return ret; }