Re: [PATCH v5 03/10] maple_tree: Introduce interfaces __mt_dup() and mtree_dup()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





在 2023/10/16 22:10, Matthew Wilcox 写道:
On Mon, Oct 16, 2023 at 11:22:19AM +0800, Peng Zhang wrote:
+++ b/lib/maple_tree.c
@@ -4,6 +4,10 @@
   * Copyright (c) 2018-2022 Oracle Corporation
   * Authors: Liam R. Howlett <Liam.Howlett@xxxxxxxxxx>
   *	    Matthew Wilcox <willy@xxxxxxxxxxxxx>
+ *
+ * Algorithm for duplicating Maple Tree
+ * Copyright (c) 2023 ByteDance
+ * Author: Peng Zhang <zhangpeng.00@xxxxxxxxxxxxx>

You can't copyright an algorithm.  You can copyright the
_implementation_ of an algorithm.  You have a significant chunk of code
in this file, so adding your copyright is reasonable (although not
legally required, AIUI).  Just leave out this line:

+ * Algorithm for duplicating Maple Tree
Okay, I will make the correction, thank you.

+/**
+ * __mt_dup(): Duplicate an entire maple tree
+ * @mt: The source maple tree
+ * @new: The new maple tree
+ * @gfp: The GFP_FLAGS to use for allocations
+ *
+ * This function duplicates a maple tree in Depth-First Search (DFS) pre-order
+ * traversal. It uses memcopy() to copy nodes in the source tree and allocate

memcpy()?
Yes, thank you for pointing this out.

+int __mt_dup(struct maple_tree *mt, struct maple_tree *new, gfp_t gfp)
+{
+	int ret = 0;
+	MA_STATE(mas, mt, 0, 0);
+	MA_STATE(new_mas, new, 0, 0);
+
+	mas_dup_build(&mas, &new_mas, gfp);
+
+	if (unlikely(mas_is_err(&mas))) {
+		ret = xa_err(mas.node);
+		if (ret == -ENOMEM)
+			mas_dup_free(&new_mas);
+	}
+
+	return ret;
+}
+EXPORT_SYMBOL(__mt_dup);

Why does it need to be exported?
I consider __mt_dup() as a general interface for Maple Tree,
uncertain whether it will be used by certain modules in the future.






[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [NTFS 3]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [NTFS 3]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux