* [PATCHSET 2/5] xfsprogs: new libxfs code from kernel 6.14
[not found] <20250206222122.GA21808@frogsfrogsfrogs>
@ 2025-02-06 22:29 ` Darrick J. Wong
2025-02-06 22:49 ` [PATCH 56/56] xfs/libxfs: replace kmalloc() and memcpy() with kmemdup() Darrick J. Wong
0 siblings, 1 reply; 2+ messages in thread
From: Darrick J. Wong @ 2025-02-06 22:29 UTC (permalink / raw)
To: djwong, aalbersh
Cc: david, alexjlzheng, chandanbabu, mtodorovac69, cem, dchinner,
linux-kernel, cmaiolino, linux-xfs, hch, hch, linux-xfs
Hi all,
Port kernel libxfs code to userspace.
If you're going to start using this code, I strongly recommend pulling
from my git trees, which are linked below.
This has been running on the djcloud for months with no problems. Enjoy!
Comments and questions are, as always, welcome.
--D
xfsprogs git tree:
https://git.kernel.org/cgit/linux/kernel/git/djwong/xfsprogs-dev.git/log/?h=libxfs-sync-6.14
---
Commits in this patchset:
* xfs: tidy up xfs_iroot_realloc
* xfs: refactor the inode fork memory allocation functions
* xfs: make xfs_iroot_realloc take the new numrecs instead of deltas
* xfs: make xfs_iroot_realloc a bmap btree function
* xfs: tidy up xfs_bmap_broot_realloc a bit
* xfs: hoist the node iroot update code out of xfs_btree_new_iroot
* xfs: hoist the node iroot update code out of xfs_btree_kill_iroot
* xfs: add some rtgroup inode helpers
* xfs: prepare to reuse the dquot pointer space in struct xfs_inode
* xfs: simplify the xfs_rmap_{alloc,free}_extent calling conventions
* xfs: support storing records in the inode core root
* xfs: allow inode-based btrees to reserve space in the data device
* xfs: introduce realtime rmap btree ondisk definitions
* xfs: realtime rmap btree transaction reservations
* xfs: add realtime rmap btree operations
* xfs: prepare rmap functions to deal with rtrmapbt
* xfs: add a realtime flag to the rmap update log redo items
* xfs: pretty print metadata file types in error messages
* xfs: support file data forks containing metadata btrees
* xfs: add realtime reverse map inode to metadata directory
* xfs: add metadata reservations for realtime rmap btrees
* xfs: wire up a new metafile type for the realtime rmap
* xfs: wire up rmap map and unmap to the realtime rmapbt
* xfs: create routine to allocate and initialize a realtime rmap btree inode
* xfs: report realtime rmap btree corruption errors to the health system
* xfs: scrub the realtime rmapbt
* xfs: scrub the metadir path of rt rmap btree files
* xfs: online repair of realtime bitmaps for a realtime group
* xfs: online repair of the realtime rmap btree
* xfs: create a shadow rmap btree during realtime rmap repair
* xfs: namespace the maximum length/refcount symbols
* xfs: introduce realtime refcount btree ondisk definitions
* xfs: realtime refcount btree transaction reservations
* xfs: add realtime refcount btree operations
* xfs: prepare refcount functions to deal with rtrefcountbt
* xfs: add a realtime flag to the refcount update log redo items
* xfs: add realtime refcount btree inode to metadata directory
* xfs: add metadata reservations for realtime refcount btree
* xfs: wire up a new metafile type for the realtime refcount
* xfs: wire up realtime refcount btree cursors
* xfs: create routine to allocate and initialize a realtime refcount btree inode
* xfs: update rmap to allow cow staging extents in the rt rmap
* xfs: compute rtrmap btree max levels when reflink enabled
* xfs: allow inodes to have the realtime and reflink flags
* xfs: recover CoW leftovers in the realtime volume
* xfs: fix xfs_get_extsz_hint behavior with realtime alwayscow files
* xfs: apply rt extent alignment constraints to CoW extsize hint
* xfs: enable extent size hints for CoW operations
* xfs: report realtime refcount btree corruption errors to the health system
* xfs: scrub the realtime refcount btree
* xfs: scrub the metadir path of rt refcount btree files
* xfs: fix the entry condition of exact EOF block allocation optimization
* xfs: mark xfs_dir_isempty static
* xfs: remove XFS_ILOG_NONCORE
* xfs: constify feature checks
* xfs/libxfs: replace kmalloc() and memcpy() with kmemdup()
---
include/kmem.h | 9
include/libxfs.h | 2
include/xfs_inode.h | 5
include/xfs_mount.h | 27 +
include/xfs_trace.h | 7
io/inject.c | 1
libxfs/Makefile | 4
libxfs/libxfs_priv.h | 11
libxfs/xfs_ag_resv.c | 3
libxfs/xfs_attr.c | 4
libxfs/xfs_bmap.c | 47 +-
libxfs/xfs_bmap_btree.c | 111 ++++
libxfs/xfs_bmap_btree.h | 3
libxfs/xfs_btree.c | 410 +++++++++++++---
libxfs/xfs_btree.h | 28 +
libxfs/xfs_btree_mem.c | 1
libxfs/xfs_btree_staging.c | 10
libxfs/xfs_defer.h | 2
libxfs/xfs_dir2.c | 9
libxfs/xfs_dir2.h | 1
libxfs/xfs_errortag.h | 4
libxfs/xfs_exchmaps.c | 4
libxfs/xfs_format.h | 51 ++
libxfs/xfs_fs.h | 10
libxfs/xfs_health.h | 6
libxfs/xfs_inode_buf.c | 65 ++-
libxfs/xfs_inode_fork.c | 201 +++-----
libxfs/xfs_inode_fork.h | 6
libxfs/xfs_log_format.h | 16 -
libxfs/xfs_metadir.c | 3
libxfs/xfs_metafile.c | 221 +++++++++
libxfs/xfs_metafile.h | 13 +
libxfs/xfs_ondisk.h | 4
libxfs/xfs_refcount.c | 277 +++++++++--
libxfs/xfs_refcount.h | 23 +
libxfs/xfs_rmap.c | 178 ++++++-
libxfs/xfs_rmap.h | 12
libxfs/xfs_rtbitmap.c | 2
libxfs/xfs_rtbitmap.h | 9
libxfs/xfs_rtgroup.c | 74 ++-
libxfs/xfs_rtgroup.h | 58 ++
libxfs/xfs_rtrefcount_btree.c | 755 ++++++++++++++++++++++++++++++
libxfs/xfs_rtrefcount_btree.h | 189 +++++++
libxfs/xfs_rtrmap_btree.c | 1034 +++++++++++++++++++++++++++++++++++++++++
libxfs/xfs_rtrmap_btree.h | 210 ++++++++
libxfs/xfs_sb.c | 14 +
libxfs/xfs_shared.h | 21 +
libxfs/xfs_trans_resv.c | 37 +
libxfs/xfs_trans_space.h | 13 +
libxfs/xfs_types.h | 7
repair/rmap.c | 2
repair/scan.c | 2
52 files changed, 3822 insertions(+), 394 deletions(-)
create mode 100644 libxfs/xfs_rtrefcount_btree.c
create mode 100644 libxfs/xfs_rtrefcount_btree.h
create mode 100644 libxfs/xfs_rtrmap_btree.c
create mode 100644 libxfs/xfs_rtrmap_btree.h
^ permalink raw reply [flat|nested] 2+ messages in thread
* [PATCH 56/56] xfs/libxfs: replace kmalloc() and memcpy() with kmemdup()
2025-02-06 22:29 ` [PATCHSET 2/5] xfsprogs: new libxfs code from kernel 6.14 Darrick J. Wong
@ 2025-02-06 22:49 ` Darrick J. Wong
0 siblings, 0 replies; 2+ messages in thread
From: Darrick J. Wong @ 2025-02-06 22:49 UTC (permalink / raw)
To: djwong, aalbersh
Cc: cem, chandanbabu, dchinner, linux-xfs, linux-kernel,
mtodorovac69, cem, hch, linux-xfs
From: Mirsad Todorovac <mtodorovac69@gmail.com>
Source kernel commit: 9d9b72472631262b35157f1a650f066c0e11c2bb
The source static analysis tool gave the following advice:
./fs/xfs/libxfs/xfs_dir2.c:382:15-22: WARNING opportunity for kmemdup
→ 382 args->value = kmalloc(len,
383 GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_RETRY_MAYFAIL);
384 if (!args->value)
385 return -ENOMEM;
386
→ 387 memcpy(args->value, name, len);
388 args->valuelen = len;
389 return -EEXIST;
Replacing kmalloc() + memcpy() with kmemdump() doesn't change semantics.
Original code works without fault, so this is not a bug fix but proposed improvement.
Link: https://lwn.net/Articles/198928/
Fixes: 94a69db2367ef ("xfs: use __GFP_NOLOCKDEP instead of GFP_NOFS")
Fixes: 384f3ced07efd ("[XFS] Return case-insensitive match for dentry cache")
Fixes: 2451337dd0439 ("xfs: global error sign conversion")
Cc: Carlos Maiolino <cem@kernel.org>
Cc: Darrick J. Wong <djwong@kernel.org>
Cc: Chandan Babu R <chandanbabu@kernel.org>
Cc: Dave Chinner <dchinner@redhat.com>
Cc: linux-xfs@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
Signed-off-by: Mirsad Todorovac <mtodorovac69@gmail.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
---
include/kmem.h | 9 +++++++++
libxfs/xfs_dir2.c | 3 +--
2 files changed, 10 insertions(+), 2 deletions(-)
diff --git a/include/kmem.h b/include/kmem.h
index 16a7957f1acee3..66f8b1fbea8fdf 100644
--- a/include/kmem.h
+++ b/include/kmem.h
@@ -79,4 +79,13 @@ static inline void kfree_rcu_mightsleep(const void *ptr)
__attribute__((format(printf,2,3)))
char *kasprintf(gfp_t gfp, const char *fmt, ...);
+static inline void *kmemdup(const void *src, size_t len, gfp_t gfp)
+{
+ void *p = kmalloc(len, gfp);
+
+ if (p)
+ memcpy(p, src, len);
+ return p;
+}
+
#endif
diff --git a/libxfs/xfs_dir2.c b/libxfs/xfs_dir2.c
index 29e64603d4ae82..1285019b674423 100644
--- a/libxfs/xfs_dir2.c
+++ b/libxfs/xfs_dir2.c
@@ -378,12 +378,11 @@ xfs_dir_cilookup_result(
!(args->op_flags & XFS_DA_OP_CILOOKUP))
return -EEXIST;
- args->value = kmalloc(len,
+ args->value = kmemdup(name, len,
GFP_KERNEL | __GFP_NOLOCKDEP | __GFP_RETRY_MAYFAIL);
if (!args->value)
return -ENOMEM;
- memcpy(args->value, name, len);
args->valuelen = len;
return -EEXIST;
}
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-02-06 22:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20250206222122.GA21808@frogsfrogsfrogs>
2025-02-06 22:29 ` [PATCHSET 2/5] xfsprogs: new libxfs code from kernel 6.14 Darrick J. Wong
2025-02-06 22:49 ` [PATCH 56/56] xfs/libxfs: replace kmalloc() and memcpy() with kmemdup() Darrick J. Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®