Skip to contentSkip to conversation

dedupe smb unicode files

PATCH Superseded [email protected] 6 participants 18 messages Jun 28, 2023

Subsystems (2)

v1 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

cover dedupe smb unicode files

From: "Dr. David Alan Gilbert" <[email protected]>

The smb client and server code have (mostly) duplicated code for unicode manipulation, in particular upper case handling.

Flatten this lot into shared code.

There's some code that's slightly different between the two, and I've not attempted to share that - this should be strictly a no behaviour change set.

I'd love to also boil out the same code from fs/jfs/ - but that's a thought for another time (and harder since there's no good test for it).

Lightly tested with a module and a monolithic build, and just mounting itself.

This dupe was found using PMD:
https://pmd.github.io/pmd/pmd_userdocs_cpd.html

Dave

Dr. David Alan Gilbert (3):
fs/smb: Remove unicode 'lower' tables fs/smb: Swing unicode common code from server->common fs/smb/client: Use common code in client

 fs/smb/client/cifs_unicode.c                  |   1 -
 fs/smb/client/cifs_unicode.h                  | 313 +-----------------
 fs/smb/client/cifs_uniupr.h                   | 239 -------------
 fs/smb/common/Makefile                        |   1 +
 .../uniupr.h => common/cifs_unicode_common.c} | 156 +--------
 fs/smb/common/cifs_unicode_common.h           | 279 ++++++++++++++++
 fs/smb/server/unicode.c                       |   1 -
 fs/smb/server/unicode.h                       | 301 +----------------
 8 files changed, 298 insertions(+), 993 deletions(-)
 delete mode 100644 fs/smb/client/cifs_uniupr.h
 rename fs/smb/{server/uniupr.h => common/cifs_unicode_common.c} (50%)
 create mode 100644 fs/smb/common/cifs_unicode_common.h
Signature · 1 line
2.41.0
#1 lore raw

PATCH 1/3 fs/smb: Remove unicode 'lower' tables

From: "Dr. David Alan Gilbert" <[email protected]>

The unicode glue in smb/*/..uniupr.h has a section guarded by 'ifndef UNIUPR_NOLOWER' - but that's always defined in smb/*/..unicode.h. Nuke those tables.

---
 fs/smb/client/cifs_unicode.h |  50 --------------
 fs/smb/client/cifs_uniupr.h  | 116 -------------------------------
 fs/smb/server/unicode.h      |  48 -------------
 fs/smb/server/uniupr.h       | 129 -----------------------------------
 4 files changed, 343 deletions(-)
fs/smb/client/cifs_unicode.h +0 -50
index 80b3d845419f..33b651def482 100644
@@ -22,8 +22,6 @@
 #include <linux/types.h>
 #include <linux/nls.h>
 
-#define  UNIUPR_NOLOWER		/* Example to not expand lower case tables */
-
 /*
  * Windows maps these to the user defined 16 bit Unicode range since they are
  * reserved symbols (along with \ and /), otherwise illegal to store
@@ -84,11 +82,6 @@ extern signed char CifsUniUpperTable[512];
 extern const struct UniCaseRange CifsUniUpperRange[];
 #endif				/* UNIUPR_NOUPPER */
 
-#ifndef UNIUPR_NOLOWER
-extern signed char CifsUniLowerTable[512];
-extern const struct UniCaseRange CifsUniLowerRange[];
-#endif				/* UNIUPR_NOLOWER */
-
 #ifdef __KERNEL__
 int cifs_from_utf16(char *to, const __le16 *from, int tolen, int fromlen,
 		    const struct nls_table *cp, int map_type);
@@ -358,47 +351,4 @@ UniStrupr(register __le16 *upin)
 }
 #endif				/* UNIUPR_NOUPPER */
 
-#ifndef UNIUPR_NOLOWER
-/*
- * UniTolower:  Convert a unicode character to lower case
- */
-static inline wchar_t
-UniTolower(register wchar_t uc)
-{
-	register const struct UniCaseRange *rp;
-
-	if (uc < sizeof(CifsUniLowerTable)) {
-		/* Latin characters */
-		return uc + CifsUniLowerTable[uc];	/* Use base tables */
-	} else {
-		rp = CifsUniLowerRange;	/* Use range tables */
-		while (rp->start) {
-			if (uc < rp->start)	/* Before start of range */
-				return uc;	/* Uppercase = input */
-			if (uc <= rp->end)	/* In range */
-				return uc + rp->table[uc - rp->start];
-			rp++;	/* Try next range */
-		}
-	}
-	return uc;		/* Past last range */
-}
-
-/*
- * UniStrlwr:  Lower case a unicode string
- */
-static inline wchar_t *
-UniStrlwr(register wchar_t *upin)
-{
-	register wchar_t *up;
-
-	up = upin;
-	while (*up) {		/* For all characters */
-		*up = UniTolower(*up);
-		up++;
-	}
-	return upin;		/* Return input pointer */
-}
-
-#endif
-
 #endif /* _CIFS_UNICODE_H */
fs/smb/client/cifs_uniupr.h +0 -116

119 lines not on this page · raw message

fs/smb/server/unicode.h +0 -48

64 lines not on this page · raw message

fs/smb/server/uniupr.h +0 -129

133 lines not on this page · raw message

Signature · 1 line
2.41.0
#2 lore raw

PATCH 2/3 fs/smb: Swing unicode common code from server->common

In reply to [email protected]

From: "Dr. David Alan Gilbert" <[email protected]>

Swing most of the inline functions and unicode tables into smb/common from the copy in smb/server.

UniStrcat has different types between the client and server versions so I've not moved it (although I suspect it's OK). The actual unicode.c implementations vary much more between server and client so they're unmoved.

---
 fs/smb/common/Makefile                        |   1 +
 .../uniupr.h => common/cifs_unicode_common.c} |  27 +-
 fs/smb/common/cifs_unicode_common.h           | 279 ++++++++++++++++++
 fs/smb/server/unicode.c                       |   1 -
 fs/smb/server/unicode.h                       | 253 +---------------
 5 files changed, 297 insertions(+), 264 deletions(-)
 rename fs/smb/{server/uniupr.h => common/cifs_unicode_common.c} (91%)
 create mode 100644 fs/smb/common/cifs_unicode_common.h
fs/smb/common/Makefile +1 -0
index c66dbbc1469c..5a2edc72f5d4 100644
@@ -5,3 +5,4 @@
 
 obj-$(CONFIG_SMBFS) += cifs_arc4.o
 obj-$(CONFIG_SMBFS) += cifs_md4.o
+obj-$(CONFIG_SMBFS) += cifs_unicode_common.o
fs/smb/common/cifs_unicode_common.c renamed from fs/smb/server/uniupr.h +16 -11
similarity index 91%
rename from fs/smb/server/uniupr.h
rename to fs/smb/common/cifs_unicode_common.c
index d09c585f20c9..edf09c8763be 100644
@@ -1,15 +1,21 @@
-/* SPDX-License-Identifier: GPL-2.0-or-later */
+// SPDX-License-Identifier: GPL-2.0-or-later
 /*
- *   Some of the source code in this file came from fs/cifs/uniupr.h
- *   Copyright (c) International Business Machines  Corp., 2000,2002
- *
- * uniupr.h - Unicode compressed case ranges
+ *   Some of the source code in this file came from fs/cifs/cifs_unicode.c
+ *   via fs/smb/unicode.c and fs/smb/uniupr.h and fs/cifs/uniupr.h
+ *   Copyright (c) International Business Machines  Corp., 2000,2002,2009
+ *   Modified by Steve French ([email protected])
+ *   Modified by Namjae Jeon ([email protected])
+ *   Modified by Dr. David Alan Gilbert <[email protected]>
  *
  */
-#ifndef __KSMBD_UNIUPR_H
-#define __KSMBD_UNIUPR_H
+#include <linux/fs.h>
+#include <linux/module.h>
+#include <linux/slab.h>
+#include <asm/unaligned.h>
+#include "cifs_unicode_common.h"
+
+MODULE_LICENSE("GPL");
 
-#ifndef UNIUPR_NOUPPER
 /*
  * Latin upper case
  */
@@ -51,6 +57,7 @@ signed char SmbUniUpperTable[512] = {
 	0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1, 0, -1,	/* 1e0-1ef */
 	0, 0, -1, -2, 0, -1, 0, 0, 0, -1, 0, -1, 0, -1, 0, -1,	/* 1f0-1ff */
 };
+EXPORT_SYMBOL_GPL(SmbUniUpperTable);
 
 /* Upper case range - Greek */
 static signed char UniCaseRangeU03a0[47] = {
@@ -134,6 +141,4 @@ const struct UniCaseRange SmbUniUpperRange[] = {
 	{0xff40, 0xff5a, UniCaseRangeUff40},
 	{0}
 };
-#endif
-
-#endif /* __KSMBD_UNIUPR_H */
+EXPORT_SYMBOL_GPL(SmbUniUpperRange);
fs/smb/common/cifs_unicode_common.h new file +279 -0

279 lines not on this page · raw message

fs/smb/server/unicode.c +0 -1
index 9ae676906ed3..393dd4a7432b 100644
@@ -11,7 +11,6 @@
 #include <asm/unaligned.h>
 #include "glob.h"
 #include "unicode.h"
-#include "uniupr.h"
 #include "smb_common.h"
 
 /*
fs/smb/server/unicode.h +1 -252

263 lines not on this page · raw message

Signature · 1 line
2.41.0
maintainer
#3 lore raw

Re: [PATCH 2/3] fs/smb: Swing unicode common code from server->common

2023-06-28 10:14 GMT+09:00, [email protected] <[email protected]>:

Quoted 7 lines

From: "Dr. David Alan Gilbert" <[email protected]>

Swing most of the inline functions and unicode tables into smb/common from the copy in smb/server.

UniStrcat has different types between the client and server versions so I've not moved it (although I suspect it's OK).

ksmbd doesn't use this function. You can move it to smb_unicode_common.h.

Thanks.

#4 lore raw

Re: [PATCH 2/3] fs/smb: Swing unicode common code from server->common

Quoted 9 lines · * Namjae Jeon ([email protected]) wrote:

2023-06-28 10:14 GMT+09:00, [email protected] <[email protected]>:

Quoted 7 lines

From: "Dr. David Alan Gilbert" <[email protected]>

Swing most of the inline functions and unicode tables into smb/common from the copy in smb/server.

UniStrcat has different types between the client and server versions so I've not moved it (although I suspect it's OK).

ksmbd doesn't use this function. You can move it to smb_unicode_common.h.

Ah OK, thanks.

Dave

Quoted 1 line

Thanks.

Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
#5 lore raw

PATCH 3/3 fs/smb/client: Use common code in client

In reply to [email protected]

From: "Dr. David Alan Gilbert" <[email protected]>

Now we've got the common code, use it for the client as well.

---
 fs/smb/client/cifs_unicode.c |   1 -
 fs/smb/client/cifs_unicode.h | 263 +----------------------------------
 fs/smb/client/cifs_uniupr.h  | 123 ----------------
 3 files changed, 1 insertion(+), 386 deletions(-)
 delete mode 100644 fs/smb/client/cifs_uniupr.h
fs/smb/client/cifs_unicode.c +0 -1
index e7582dd79179..79d99a913944 100644
@@ -8,7 +8,6 @@
 #include <linux/slab.h>
 #include "cifs_fs_sb.h"
 #include "cifs_unicode.h"
-#include "cifs_uniupr.h"
 #include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifs_debug.h"
fs/smb/client/cifs_unicode.h +1 -262

279 lines not on this page · raw message

fs/smb/client/cifs_uniupr.h deleted +0 -123

123 lines not on this page · raw message

Signature · 1 line
2.41.0
reviewer
#6 lore raw
In reply to [email protected]
Quoted 28 lines · On 6/27/2023 9:14 PM, [email protected] wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

The smb client and server code have (mostly) duplicated code for unicode manipulation, in particular upper case handling.

Flatten this lot into shared code.

There's some code that's slightly different between the two, and I've not attempted to share that - this should be strictly a no behaviour change set.

I'd love to also boil out the same code from fs/jfs/ - but that's a thought for another time (and harder since there's no good test for it).

Lightly tested with a module and a monolithic build, and just mounting itself.

This dupe was found using PMD:
https://pmd.github.io/pmd/pmd_userdocs_cpd.html

Dave

Dr. David Alan Gilbert (3):
fs/smb: Remove unicode 'lower' tables fs/smb: Swing unicode common code from server->common fs/smb/client: Use common code in client

Quoted 6 lines
  fs/smb/client/cifs_unicode.c                  |   1 -
  fs/smb/client/cifs_unicode.h                  | 313 +-----------------
  fs/smb/client/cifs_uniupr.h                   | 239 -------------
  fs/smb/common/Makefile                        |   1 +
  .../uniupr.h => common/cifs_unicode_common.c} | 156 +--------
  fs/smb/common/cifs_unicode_common.h           | 279 ++++++++++++++++

So far so good, but please drop the "cifs_" prefix from this new file's name, since its contents apply to later smb dialects as well.

Tom.

Quoted 7 lines
  fs/smb/server/unicode.c                       |   1 -
  fs/smb/server/unicode.h                       | 301 +----------------
  8 files changed, 298 insertions(+), 993 deletions(-)

delete mode 100644 fs/smb/client/cifs_uniupr.h
rename fs/smb/{server/uniupr.h => common/cifs_unicode_common.c} (50%) create mode 100644 fs/smb/common/cifs_unicode_common.h

#7 lore raw
Quoted 36 lines · * Tom Talpey ([email protected]) wrote:
Quoted 28 lines · On 6/27/2023 9:14 PM, [email protected] wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

The smb client and server code have (mostly) duplicated code for unicode manipulation, in particular upper case handling.

Flatten this lot into shared code.

There's some code that's slightly different between the two, and I've not attempted to share that - this should be strictly a no behaviour change set.

I'd love to also boil out the same code from fs/jfs/ - but that's a thought for another time (and harder since there's no good test for it).

Lightly tested with a module and a monolithic build, and just mounting itself.

This dupe was found using PMD:
https://pmd.github.io/pmd/pmd_userdocs_cpd.html

Dave

Dr. David Alan Gilbert (3):
fs/smb: Remove unicode 'lower' tables fs/smb: Swing unicode common code from server->common fs/smb/client: Use common code in client

Quoted 6 lines
  fs/smb/client/cifs_unicode.c                  |   1 -
  fs/smb/client/cifs_unicode.h                  | 313 +-----------------
  fs/smb/client/cifs_uniupr.h                   | 239 -------------
  fs/smb/common/Makefile                        |   1 +
  .../uniupr.h => common/cifs_unicode_common.c} | 156 +--------
  fs/smb/common/cifs_unicode_common.h           | 279 ++++++++++++++++
Quoted 2 lines

So far so good, but please drop the "cifs_" prefix from this new file's name, since its contents apply to later smb dialects as well.

Sure.

Dave

Quoted 9 lines

Tom.

Quoted 7 lines
  fs/smb/server/unicode.c                       |   1 -
  fs/smb/server/unicode.h                       | 301 +----------------
  8 files changed, 298 insertions(+), 993 deletions(-)

delete mode 100644 fs/smb/client/cifs_uniupr.h
rename fs/smb/{server/uniupr.h => common/cifs_unicode_common.c} (50%) create mode 100644 fs/smb/common/cifs_unicode_common.h

Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
#8 lore raw
Quoted 37 lines · * Dr. David Alan Gilbert ([email protected]) wrote:
Quoted 36 lines · * Tom Talpey ([email protected]) wrote:
Quoted 34 lines · On 6/27/2023 9:14 PM, [email protected] wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

The smb client and server code have (mostly) duplicated code for unicode manipulation, in particular upper case handling.

Flatten this lot into shared code.

There's some code that's slightly different between the two, and I've not attempted to share that - this should be strictly a no behaviour change set.

I'd love to also boil out the same code from fs/jfs/ - but that's a thought for another time (and harder since there's no good test for it).

Lightly tested with a module and a monolithic build, and just mounting itself.

This dupe was found using PMD:
https://pmd.github.io/pmd/pmd_userdocs_cpd.html

Dave

Dr. David Alan Gilbert (3):
fs/smb: Remove unicode 'lower' tables fs/smb: Swing unicode common code from server->common fs/smb/client: Use common code in client

  fs/smb/client/cifs_unicode.c                  |   1 -
  fs/smb/client/cifs_unicode.h                  | 313 +-----------------
  fs/smb/client/cifs_uniupr.h                   | 239 -------------
  fs/smb/common/Makefile                        |   1 +
  .../uniupr.h => common/cifs_unicode_common.c} | 156 +--------
  fs/smb/common/cifs_unicode_common.h           | 279 ++++++++++++++++
Quoted 4 lines
Quoted 2 lines

So far so good, but please drop the "cifs_" prefix from this new file's name, since its contents apply to later smb dialects as well.

Sure.

Actually, would you be ok with smb_unicode_common ? The reason is that you end up with a module named unicode_common that sounds too generic.

Dave

Quoted 16 lines

Dave

Quoted 9 lines

Tom.

Quoted 7 lines
  fs/smb/server/unicode.c                       |   1 -
  fs/smb/server/unicode.h                       | 301 +----------------
  8 files changed, 298 insertions(+), 993 deletions(-)

delete mode 100644 fs/smb/client/cifs_uniupr.h
rename fs/smb/{server/uniupr.h => common/cifs_unicode_common.c} (50%) create mode 100644 fs/smb/common/cifs_unicode_common.h

Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
#9 lore raw
Quoted 38 lines · Dr. David Alan Gilbert
Quoted 37 lines · * Dr. David Alan Gilbert ([email protected]) wrote:
Quoted 36 lines · * Tom Talpey ([email protected]) wrote:
Quoted 34 lines · On 6/27/2023 9:14 PM, [email protected] wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

The smb client and server code have (mostly) duplicated code for unicode manipulation, in particular upper case handling.

Flatten this lot into shared code.

There's some code that's slightly different between the two, and I've not attempted to share that - this should be strictly a no behaviour change set.

I'd love to also boil out the same code from fs/jfs/ - but that's a thought for another time (and harder since there's no good test for it).

Lightly tested with a module and a monolithic build, and just mounting itself.

This dupe was found using PMD:
https://pmd.github.io/pmd/pmd_userdocs_cpd.html

Dave

Dr. David Alan Gilbert (3):
fs/smb: Remove unicode 'lower' tables fs/smb: Swing unicode common code from server->common fs/smb/client: Use common code in client

   fs/smb/client/cifs_unicode.c                  |   1 -
   fs/smb/client/cifs_unicode.h                  | 313 +-----------------
   fs/smb/client/cifs_uniupr.h                   | 239 -------------
   fs/smb/common/Makefile                        |   1 +
   .../uniupr.h => common/cifs_unicode_common.c} | 156 +--------
   fs/smb/common/cifs_unicode_common.h           | 279 ++++++++++++++++
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

So far so good, but please drop the "cifs_" prefix from this new file's name, since its contents apply to later smb dialects as well.

Sure.

Actually, would you be ok with smb_unicode_common ? The reason is that you end up with a module named unicode_common that sounds too generic.

I'd suggest make it generic and move it to fs/nls/. I'd run it by the nls maintainers, but I don't think there are any.

Shaggy

Quoted 19 lines

Dave

Quoted 16 lines

Dave

Quoted 9 lines

Tom.

Quoted 7 lines
   fs/smb/server/unicode.c                       |   1 -
   fs/smb/server/unicode.h                       | 301 +----------------
   8 files changed, 298 insertions(+), 993 deletions(-)

delete mode 100644 fs/smb/client/cifs_uniupr.h
rename fs/smb/{server/uniupr.h => common/cifs_unicode_common.c} (50%) create mode 100644 fs/smb/common/cifs_unicode_common.h

Signature · 4 lines
  -----Open up your eyes, open up your mind, open up your code -------
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \
\        dave @ treblig.org |                               | In Hex /
  \ _________________________|_____ http://www.treblig.org   |_______/
reviewer
#10 lore raw
Quoted 44 lines · Dave Kleikamp
Quoted 43 lines · Dr. David Alan Gilbert
Quoted 42 lines · * Dr. David Alan Gilbert ([email protected]) wrote:
Quoted 40 lines · * Tom Talpey ([email protected]) wrote:
Quoted 28 lines · On 6/27/2023 9:14 PM, [email protected] wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

The smb client and server code have (mostly) duplicated code for unicode manipulation, in particular upper case handling.

Flatten this lot into shared code.

There's some code that's slightly different between the two, and I've not attempted to share that - this should be strictly a no behaviour change set.

I'd love to also boil out the same code from fs/jfs/ - but that's a thought for another time (and harder since there's no good test for it).

Lightly tested with a module and a monolithic build, and just mounting itself.

This dupe was found using PMD:
    https://pmd.github.io/pmd/pmd_userdocs_cpd.html

Dave

Dr. David Alan Gilbert (3):
    fs/smb: Remove unicode 'lower' tables fs/smb: Swing unicode common code from server->common fs/smb/client: Use common code in client

Quoted 8 lines

   fs/smb/client/cifs_unicode.c                  |   1 - fs/smb/client/cifs_unicode.h                  | 313

+-----------------
   fs/smb/client/cifs_uniupr.h                   | 239 -------------
   fs/smb/common/Makefile                        |   1 +
   .../uniupr.h => common/cifs_unicode_common.c} | 156 +--------
   fs/smb/common/cifs_unicode_common.h           | 279 

++++++++++++++++

So far so good, but please drop the "cifs_" prefix from this new file's name, since its contents apply to later smb dialects as well.

Quoted 6 lines
Quoted 4 lines
Quoted 1 line

Sure.

Actually, would you be ok with smb_unicode_common ?  The reason is that you end up with a module named unicode_common  that sounds too generic.

I'd suggest make it generic and move it to fs/nls/. I'd run it by the nls maintainers, but I don't think there are any.

I agree that would be best. If it stays in smb/common, with or without extra filename decoration, it will still need to move someday. But I have no strong preference on prefix apart from not constraining it to a single protocol dialect.

Tom.

Quoted 23 lines

Shaggy

Quoted 20 lines

Dave

Quoted 17 lines

Dave

Quoted 10 lines

Tom.

Quoted 8 lines

   fs/smb/server/unicode.c                       |   1 - fs/smb/server/unicode.h                       | 301
+----------------

   8 files changed, 298 insertions(+), 993 deletions(-)

   delete mode 100644 fs/smb/client/cifs_uniupr.h
   rename fs/smb/{server/uniupr.h => common/cifs_unicode_common.c} (50%) create mode 100644 fs/smb/common/cifs_unicode_common.h

Signature · 4 lines
  -----Open up your eyes, open up your mind, open up your code -------
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \
\        dave @ treblig.org |                               | In Hex /
  \ _________________________|_____ http://www.treblig.org   |_______/
#11 lore raw
In reply to Dave Kleikamp
Quoted 42 lines · * Dave Kleikamp ([email protected]) wrote:
Quoted 41 lines · Dr. David Alan Gilbert
Quoted 40 lines · * Dr. David Alan Gilbert ([email protected]) wrote:
Quoted 38 lines · * Tom Talpey ([email protected]) wrote:
Quoted 28 lines · On 6/27/2023 9:14 PM, [email protected] wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

The smb client and server code have (mostly) duplicated code for unicode manipulation, in particular upper case handling.

Flatten this lot into shared code.

There's some code that's slightly different between the two, and I've not attempted to share that - this should be strictly a no behaviour change set.

I'd love to also boil out the same code from fs/jfs/ - but that's a thought for another time (and harder since there's no good test for it).

Lightly tested with a module and a monolithic build, and just mounting itself.

This dupe was found using PMD:
https://pmd.github.io/pmd/pmd_userdocs_cpd.html

Dave

Dr. David Alan Gilbert (3):
fs/smb: Remove unicode 'lower' tables fs/smb: Swing unicode common code from server->common fs/smb/client: Use common code in client

Quoted 6 lines
   fs/smb/client/cifs_unicode.c                  |   1 -
   fs/smb/client/cifs_unicode.h                  | 313 +-----------------
   fs/smb/client/cifs_uniupr.h                   | 239 -------------
   fs/smb/common/Makefile                        |   1 +
   .../uniupr.h => common/cifs_unicode_common.c} | 156 +--------
   fs/smb/common/cifs_unicode_common.h           | 279 ++++++++++++++++

So far so good, but please drop the "cifs_" prefix from this new file's name, since its contents apply to later smb dialects as well.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

Sure.

Actually, would you be ok with smb_unicode_common ? The reason is that you end up with a module named unicode_common that sounds too generic.

I'd suggest make it generic and move it to fs/nls/. I'd run it by the nls maintainers, but I don't think there are any.

Steve & Tom - would you be OK with that?

(Copying in Gabriel Bertazi, owner of fs/unicode; although this isn't utf-8)

Dave

Quoted 21 lines

Shaggy

Quoted 19 lines

Dave

Quoted 16 lines

Dave

Quoted 9 lines

Tom.

Quoted 7 lines
   fs/smb/server/unicode.c                       |   1 -
   fs/smb/server/unicode.h                       | 301 +----------------
   8 files changed, 298 insertions(+), 993 deletions(-)

delete mode 100644 fs/smb/client/cifs_uniupr.h
rename fs/smb/{server/uniupr.h => common/cifs_unicode_common.c} (50%) create mode 100644 fs/smb/common/cifs_unicode_common.h

Signature · 4 lines
  -----Open up your eyes, open up your mind, open up your code -------
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \
\        dave @ treblig.org |                               | In Hex /
  \ _________________________|_____ http://www.treblig.org   |_______/
Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
reviewer
#12 lore raw
Quoted 45 lines · Dr. David Alan Gilbert
Quoted 44 lines · * Dave Kleikamp ([email protected]) wrote:
Quoted 43 lines · Dr. David Alan Gilbert
Quoted 41 lines · * Dr. David Alan Gilbert ([email protected]) wrote:
Quoted 36 lines · * Tom Talpey ([email protected]) wrote:
Quoted 24 lines · On 6/27/2023 9:14 PM, [email protected] wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

The smb client and server code have (mostly) duplicated code for unicode manipulation, in particular upper case handling.

Flatten this lot into shared code.

There's some code that's slightly different between the two, and I've not attempted to share that - this should be strictly a no behaviour change set.

I'd love to also boil out the same code from fs/jfs/ - but that's a thought for another time (and harder since there's no good test for it).

Lightly tested with a module and a monolithic build, and just mounting itself.

This dupe was found using PMD:
https://pmd.github.io/pmd/pmd_userdocs_cpd.html

Dave

Dr. David Alan Gilbert (3):

Quoted 10 lines
     fs/smb: Remove unicode 'lower' tables
     fs/smb: Swing unicode common code from server->common
     fs/smb/client: Use common code in client

    fs/smb/client/cifs_unicode.c                  |   1 -
    fs/smb/client/cifs_unicode.h                  | 313 +-----------------
    fs/smb/client/cifs_uniupr.h                   | 239 -------------
    fs/smb/common/Makefile                        |   1 +
    .../uniupr.h => common/cifs_unicode_common.c} | 156 +--------
    fs/smb/common/cifs_unicode_common.h           | 279 ++++++++++++++++
Quoted 2 lines

So far so good, but please drop the "cifs_" prefix from this new file's name, since its contents apply to later smb dialects as well.

Sure.

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Actually, would you be ok with smb_unicode_common ? The reason is that you end up with a module named unicode_common that sounds too generic.

I'd suggest make it generic and move it to fs/nls/. I'd run it by the nls maintainers, but I don't think there are any.

Steve & Tom - would you be OK with that?

It's fine with me but there are "CifsUni<foo>" and "SmbUni<foo>" entry points which will look odd in fs/nls. I'd be fine with removing those dialect-specific Cifs/Smb prefixes, but there might be some collisions to work out.

Tom.

Quoted 26 lines

(Copying in Gabriel Bertazi, owner of fs/unicode; although this isn't utf-8)

Dave

Quoted 21 lines

Shaggy

Quoted 19 lines

Dave

Quoted 16 lines

Dave

Quoted 9 lines

Tom.

Quoted 7 lines
    fs/smb/server/unicode.c                       |   1 -
    fs/smb/server/unicode.h                       | 301 +----------------
    8 files changed, 298 insertions(+), 993 deletions(-)

delete mode 100644 fs/smb/client/cifs_uniupr.h
rename fs/smb/{server/uniupr.h => common/cifs_unicode_common.c} (50%) create mode 100644 fs/smb/common/cifs_unicode_common.h

Signature · 4 lines
   -----Open up your eyes, open up your mind, open up your code -------
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \
\        dave @ treblig.org |                               | In Hex /
   \ _________________________|_____ http://www.treblig.org   |_______/
#13 lore raw
In reply to Dr. David Alan Gilbert
Quoted 7 lines · Dr. David Alan Gilbert
Quoted 5 lines
Quoted 2 lines

Actually, would you be ok with smb_unicode_common ? The reason is that you end up with a module named unicode_common that sounds too generic.

I'd suggest make it generic and move it to fs/nls/. I'd run it by the nls maintainers, but I don't think there are any.

Steve & Tom - would you be OK with that?

Yes - absolutely

Quoted 2 lines

(Copying in Gabriel Bertazi, owner of fs/unicode; although this isn't utf-8)

Unicode UCS-2

Signature · 3 lines
Thanks,

Steve
#14 lore raw
Quoted 11 lines · * Steve French ([email protected]) wrote:
Quoted 7 lines · Dr. David Alan Gilbert
Quoted 5 lines
Quoted 2 lines

Actually, would you be ok with smb_unicode_common ? The reason is that you end up with a module named unicode_common that sounds too generic.

I'd suggest make it generic and move it to fs/nls/. I'd run it by the nls maintainers, but I don't think there are any.

Steve & Tom - would you be OK with that?

Yes - absolutely

OK.

Quoted 4 lines
Quoted 2 lines

(Copying in Gabriel Bertazi, owner of fs/unicode; although this isn't utf-8)

Unicode UCS-2

(I'm going to regret the next question...)
So how does this compare to the stuff in include/linux/ucs2_string.h and lib/ucs2_string.c ?

Dave

Quoted 5 lines
Signature · 4 lines
-- 
Thanks,

Steve
Signature · 4 lines
 -----Open up your eyes, open up your mind, open up your code -------   
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \ 
\        dave @ treblig.org |                               | In Hex /
 \ _________________________|_____ http://www.treblig.org   |_______/
#15 lore raw
In reply to Dr. David Alan Gilbert
Quoted 39 lines · Dr. David Alan Gilbert
Quoted 37 lines · * Dr. David Alan Gilbert ([email protected]) wrote:
Quoted 36 lines · * Tom Talpey ([email protected]) wrote:
Quoted 34 lines · On 6/27/2023 9:14 PM, [email protected] wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

The smb client and server code have (mostly) duplicated code for unicode manipulation, in particular upper case handling.

Flatten this lot into shared code.

There's some code that's slightly different between the two, and I've not attempted to share that - this should be strictly a no behaviour change set.

I'd love to also boil out the same code from fs/jfs/ - but that's a thought for another time (and harder since there's no good test for it).

Lightly tested with a module and a monolithic build, and just mounting itself.

This dupe was found using PMD:
https://pmd.github.io/pmd/pmd_userdocs_cpd.html

Dave

Dr. David Alan Gilbert (3):
fs/smb: Remove unicode 'lower' tables fs/smb: Swing unicode common code from server->common fs/smb/client: Use common code in client

  fs/smb/client/cifs_unicode.c                  |   1 -
  fs/smb/client/cifs_unicode.h                  | 313 +-----------------
  fs/smb/client/cifs_uniupr.h                   | 239 -------------
  fs/smb/common/Makefile                        |   1 +
  .../uniupr.h => common/cifs_unicode_common.c} | 156 +--------
  fs/smb/common/cifs_unicode_common.h           | 279 ++++++++++++++++
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

So far so good, but please drop the "cifs_" prefix from this new file's name, since its contents apply to later smb dialects as well.

Sure.

Actually, would you be ok with smb_unicode_common ? The reason is that you end up with a module named unicode_common that sounds too generic.

Since it is already in the smb/common directory, seems easier to name them:
smb/common/unicode.c
or smb/common/smb_unicode.c

Signature · 3 lines
Thanks,

Steve
#16 lore raw
In reply to Dr. David Alan Gilbert
Quoted 38 lines · Dr. David Alan Gilbert
Quoted 37 lines · * Dr. David Alan Gilbert ([email protected]) wrote:
Quoted 36 lines · * Tom Talpey ([email protected]) wrote:
Quoted 34 lines · On 6/27/2023 9:14 PM, [email protected] wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

The smb client and server code have (mostly) duplicated code for unicode manipulation, in particular upper case handling.

Flatten this lot into shared code.

There's some code that's slightly different between the two, and I've not attempted to share that - this should be strictly a no behaviour change set.

I'd love to also boil out the same code from fs/jfs/ - but that's a thought for another time (and harder since there's no good test for it).

Lightly tested with a module and a monolithic build, and just mounting itself.

This dupe was found using PMD:
https://pmd.github.io/pmd/pmd_userdocs_cpd.html

Dave

Dr. David Alan Gilbert (3):
fs/smb: Remove unicode 'lower' tables fs/smb: Swing unicode common code from server->common fs/smb/client: Use common code in client

   fs/smb/client/cifs_unicode.c                  |   1 -
   fs/smb/client/cifs_unicode.h                  | 313 +-----------------
   fs/smb/client/cifs_uniupr.h                   | 239 -------------
   fs/smb/common/Makefile                        |   1 +
   .../uniupr.h => common/cifs_unicode_common.c} | 156 +--------
   fs/smb/common/cifs_unicode_common.h           | 279 ++++++++++++++++
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

So far so good, but please drop the "cifs_" prefix from this new file's name, since its contents apply to later smb dialects as well.

Sure.

Actually, would you be ok with smb_unicode_common ? The reason is that you end up with a module named unicode_common that sounds too generic.

A bit off topic, but a question for Steve.

Is there a need for separate modules under fs/smb/common/? Or could the makefile do something like:

obj-$(CONFIG_SMBFS) += smb_common.o

smb_common-y := cifs.arc4.o cifs_md4.o smb_unicode.o

Shaggy

Quoted 19 lines

Dave

Quoted 16 lines

Dave

Quoted 9 lines

Tom.

Quoted 7 lines
   fs/smb/server/unicode.c                       |   1 -
   fs/smb/server/unicode.h                       | 301 +----------------
   8 files changed, 298 insertions(+), 993 deletions(-)

delete mode 100644 fs/smb/client/cifs_uniupr.h
rename fs/smb/{server/uniupr.h => common/cifs_unicode_common.c} (50%) create mode 100644 fs/smb/common/cifs_unicode_common.h

Signature · 4 lines
  -----Open up your eyes, open up your mind, open up your code -------
/ Dr. David Alan Gilbert    |       Running GNU/Linux       | Happy  \
\        dave @ treblig.org |                               | In Hex /
  \ _________________________|_____ http://www.treblig.org   |_______/
#17 lore raw
Quoted 48 lines · Dave Kleikamp
Quoted 38 lines · Dr. David Alan Gilbert
Quoted 37 lines · * Dr. David Alan Gilbert ([email protected]) wrote:
Quoted 36 lines · * Tom Talpey ([email protected]) wrote:
Quoted 34 lines · On 6/27/2023 9:14 PM, [email protected] wrote:

From: "Dr. David Alan Gilbert" <[email protected]>

The smb client and server code have (mostly) duplicated code for unicode manipulation, in particular upper case handling.

Flatten this lot into shared code.

There's some code that's slightly different between the two, and I've not attempted to share that - this should be strictly a no behaviour change set.

I'd love to also boil out the same code from fs/jfs/ - but that's a thought for another time (and harder since there's no good test for it).

Lightly tested with a module and a monolithic build, and just mounting itself.

This dupe was found using PMD:
https://pmd.github.io/pmd/pmd_userdocs_cpd.html

Dave

Dr. David Alan Gilbert (3):
fs/smb: Remove unicode 'lower' tables fs/smb: Swing unicode common code from server->common fs/smb/client: Use common code in client

   fs/smb/client/cifs_unicode.c                  |   1 -
   fs/smb/client/cifs_unicode.h                  | 313 +-----------------
   fs/smb/client/cifs_uniupr.h                   | 239 -------------
   fs/smb/common/Makefile                        |   1 +
   .../uniupr.h => common/cifs_unicode_common.c} | 156 +--------
   fs/smb/common/cifs_unicode_common.h           | 279 ++++++++++++++++
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

So far so good, but please drop the "cifs_" prefix from this new file's name, since its contents apply to later smb dialects as well.

Sure.

Actually, would you be ok with smb_unicode_common ? The reason is that you end up with a module named unicode_common that sounds too generic.

Quoted 8 lines

A bit off topic, but a question for Steve.

Is there a need for separate modules under fs/smb/common/? Or could the makefile do something like:

obj-$(CONFIG_SMBFS) += smb_common.o

smb_common-y := cifs.arc4.o cifs_md4.o smb_unicode.o

Since arc4 and md4 are used more rarely used than smb_unicode (and in some environments
use of md4 could be forbidden), and also since arc4 and md4 are not really smb/cifs but crypto,
seems more logical to keep them separate. There are other things
like quic support
(which is important for smb3.1.1) that will probably be much larger (even with upcalls) that
could also be distinct modules in fs/smb/common in the future.

Signature · 3 lines
Thanks,

Steve