diff mbox series

[RFC,03/20] udf: Fix iocharset=utf8 mount option

Message ID 20210808162453.1653-4-pali@kernel.org
State New
Headers show
Series fs: Remove usage of broken nls_utf8 and drop it | expand

Commit Message

Pali Rohár Aug. 8, 2021, 4:24 p.m. UTC
Currently iocharset=utf8 mount option is broken. To use UTF-8 as iocharset,
it is required to use utf8 mount option.

Fix iocharset=utf8 mount option to use be equivalent to the utf8 mount
option.

If UTF-8 as iocharset is used then s_nls_map is set to NULL. So simplify
code around, remove UDF_FLAG_NLS_MAP and UDF_FLAG_UTF8 flags as to
distinguish between UTF-8 and non-UTF-8 it is needed just to check if
s_nls_map set to NULL or not.

Signed-off-by: Pali Rohár <pali@kernel.org>
---
 fs/udf/super.c   | 50 ++++++++++++++++++------------------------------
 fs/udf/udf_sb.h  |  2 --
 fs/udf/unicode.c |  4 ++--
 3 files changed, 21 insertions(+), 35 deletions(-)

Comments

Jan Kara Aug. 12, 2021, 2:17 p.m. UTC | #1
On Sun 08-08-21 18:24:36, Pali Rohár wrote:
> Currently iocharset=utf8 mount option is broken. To use UTF-8 as iocharset,
> it is required to use utf8 mount option.
> 
> Fix iocharset=utf8 mount option to use be equivalent to the utf8 mount
> option.
> 
> If UTF-8 as iocharset is used then s_nls_map is set to NULL. So simplify
> code around, remove UDF_FLAG_NLS_MAP and UDF_FLAG_UTF8 flags as to
> distinguish between UTF-8 and non-UTF-8 it is needed just to check if
> s_nls_map set to NULL or not.
> 
> Signed-off-by: Pali Rohár <pali@kernel.org>

Thanks for the cleanup. It looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

Or should I take this patch through my tree?

								Honza


> ---
>  fs/udf/super.c   | 50 ++++++++++++++++++------------------------------
>  fs/udf/udf_sb.h  |  2 --
>  fs/udf/unicode.c |  4 ++--
>  3 files changed, 21 insertions(+), 35 deletions(-)
> 
> diff --git a/fs/udf/super.c b/fs/udf/super.c
> index 2f83c1204e20..6e8c29107b04 100644
> --- a/fs/udf/super.c
> +++ b/fs/udf/super.c
> @@ -349,10 +349,10 @@ static int udf_show_options(struct seq_file *seq, struct dentry *root)
>  		seq_printf(seq, ",lastblock=%u", sbi->s_last_block);
>  	if (sbi->s_anchor != 0)
>  		seq_printf(seq, ",anchor=%u", sbi->s_anchor);
> -	if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8))
> -		seq_puts(seq, ",utf8");
> -	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP) && sbi->s_nls_map)
> +	if (sbi->s_nls_map)
>  		seq_printf(seq, ",iocharset=%s", sbi->s_nls_map->charset);
> +	else
> +		seq_puts(seq, ",iocharset=utf8");
>  
>  	return 0;
>  }
> @@ -558,19 +558,24 @@ static int udf_parse_options(char *options, struct udf_options *uopt,
>  			/* Ignored (never implemented properly) */
>  			break;
>  		case Opt_utf8:
> -			uopt->flags |= (1 << UDF_FLAG_UTF8);
> +			if (!remount) {
> +				unload_nls(uopt->nls_map);
> +				uopt->nls_map = NULL;
> +			}
>  			break;
>  		case Opt_iocharset:
>  			if (!remount) {
> -				if (uopt->nls_map)
> -					unload_nls(uopt->nls_map);
> -				/*
> -				 * load_nls() failure is handled later in
> -				 * udf_fill_super() after all options are
> -				 * parsed.
> -				 */
> +				unload_nls(uopt->nls_map);
> +				uopt->nls_map = NULL;
> +			}
> +			/* When nls_map is not loaded then UTF-8 is used */
> +			if (!remount && strcmp(args[0].from, "utf8") != 0) {
>  				uopt->nls_map = load_nls(args[0].from);
> -				uopt->flags |= (1 << UDF_FLAG_NLS_MAP);
> +				if (!uopt->nls_map) {
> +					pr_err("iocharset %s not found\n",
> +						args[0].from);
> +					return 0;
> +				}
>  			}
>  			break;
>  		case Opt_uforget:
> @@ -2139,21 +2144,6 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
>  	if (!udf_parse_options((char *)options, &uopt, false))
>  		goto parse_options_failure;
>  
> -	if (uopt.flags & (1 << UDF_FLAG_UTF8) &&
> -	    uopt.flags & (1 << UDF_FLAG_NLS_MAP)) {
> -		udf_err(sb, "utf8 cannot be combined with iocharset\n");
> -		goto parse_options_failure;
> -	}
> -	if ((uopt.flags & (1 << UDF_FLAG_NLS_MAP)) && !uopt.nls_map) {
> -		uopt.nls_map = load_nls_default();
> -		if (!uopt.nls_map)
> -			uopt.flags &= ~(1 << UDF_FLAG_NLS_MAP);
> -		else
> -			udf_debug("Using default NLS map\n");
> -	}
> -	if (!(uopt.flags & (1 << UDF_FLAG_NLS_MAP)))
> -		uopt.flags |= (1 << UDF_FLAG_UTF8);
> -
>  	fileset.logicalBlockNum = 0xFFFFFFFF;
>  	fileset.partitionReferenceNum = 0xFFFF;
>  
> @@ -2308,8 +2298,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
>  error_out:
>  	iput(sbi->s_vat_inode);
>  parse_options_failure:
> -	if (uopt.nls_map)
> -		unload_nls(uopt.nls_map);
> +	unload_nls(uopt.nls_map);
>  	if (lvid_open)
>  		udf_close_lvid(sb);
>  	brelse(sbi->s_lvid_bh);
> @@ -2359,8 +2348,7 @@ static void udf_put_super(struct super_block *sb)
>  	sbi = UDF_SB(sb);
>  
>  	iput(sbi->s_vat_inode);
> -	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
> -		unload_nls(sbi->s_nls_map);
> +	unload_nls(sbi->s_nls_map);
>  	if (!sb_rdonly(sb))
>  		udf_close_lvid(sb);
>  	brelse(sbi->s_lvid_bh);
> diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
> index 758efe557a19..4fa620543d30 100644
> --- a/fs/udf/udf_sb.h
> +++ b/fs/udf/udf_sb.h
> @@ -20,8 +20,6 @@
>  #define UDF_FLAG_UNDELETE		6
>  #define UDF_FLAG_UNHIDE			7
>  #define UDF_FLAG_VARCONV		8
> -#define UDF_FLAG_NLS_MAP		9
> -#define UDF_FLAG_UTF8			10
>  #define UDF_FLAG_UID_FORGET     11    /* save -1 for uid to disk */
>  #define UDF_FLAG_GID_FORGET     12
>  #define UDF_FLAG_UID_SET	13
> diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
> index 5fcfa96463eb..622569007b53 100644
> --- a/fs/udf/unicode.c
> +++ b/fs/udf/unicode.c
> @@ -177,7 +177,7 @@ static int udf_name_from_CS0(struct super_block *sb,
>  		return 0;
>  	}
>  
> -	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
> +	if (UDF_SB(sb)->s_nls_map)
>  		conv_f = UDF_SB(sb)->s_nls_map->uni2char;
>  	else
>  		conv_f = NULL;
> @@ -285,7 +285,7 @@ static int udf_name_to_CS0(struct super_block *sb,
>  	if (ocu_max_len <= 0)
>  		return 0;
>  
> -	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
> +	if (UDF_SB(sb)->s_nls_map)
>  		conv_f = UDF_SB(sb)->s_nls_map->char2uni;
>  	else
>  		conv_f = NULL;
> -- 
> 2.20.1
>
Pali Rohár Aug. 12, 2021, 3:51 p.m. UTC | #2
On Thursday 12 August 2021 16:17:36 Jan Kara wrote:
> On Sun 08-08-21 18:24:36, Pali Rohár wrote:
> > Currently iocharset=utf8 mount option is broken. To use UTF-8 as iocharset,
> > it is required to use utf8 mount option.
> > 
> > Fix iocharset=utf8 mount option to use be equivalent to the utf8 mount
> > option.
> > 
> > If UTF-8 as iocharset is used then s_nls_map is set to NULL. So simplify
> > code around, remove UDF_FLAG_NLS_MAP and UDF_FLAG_UTF8 flags as to
> > distinguish between UTF-8 and non-UTF-8 it is needed just to check if
> > s_nls_map set to NULL or not.
> > 
> > Signed-off-by: Pali Rohár <pali@kernel.org>
> 
> Thanks for the cleanup. It looks good. Feel free to add:
> 
> Reviewed-by: Jan Kara <jack@suse.cz>
> 
> Or should I take this patch through my tree?

Hello! Patches are just RFC, mostly untested and not ready for merging.
I will wait for feedback and then I do more testing nad prepare new
patch series.

> 
> 								Honza
> 
> 
> > ---
> >  fs/udf/super.c   | 50 ++++++++++++++++++------------------------------
> >  fs/udf/udf_sb.h  |  2 --
> >  fs/udf/unicode.c |  4 ++--
> >  3 files changed, 21 insertions(+), 35 deletions(-)
> > 
> > diff --git a/fs/udf/super.c b/fs/udf/super.c
> > index 2f83c1204e20..6e8c29107b04 100644
> > --- a/fs/udf/super.c
> > +++ b/fs/udf/super.c
> > @@ -349,10 +349,10 @@ static int udf_show_options(struct seq_file *seq, struct dentry *root)
> >  		seq_printf(seq, ",lastblock=%u", sbi->s_last_block);
> >  	if (sbi->s_anchor != 0)
> >  		seq_printf(seq, ",anchor=%u", sbi->s_anchor);
> > -	if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8))
> > -		seq_puts(seq, ",utf8");
> > -	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP) && sbi->s_nls_map)
> > +	if (sbi->s_nls_map)
> >  		seq_printf(seq, ",iocharset=%s", sbi->s_nls_map->charset);
> > +	else
> > +		seq_puts(seq, ",iocharset=utf8");
> >  
> >  	return 0;
> >  }
> > @@ -558,19 +558,24 @@ static int udf_parse_options(char *options, struct udf_options *uopt,
> >  			/* Ignored (never implemented properly) */
> >  			break;
> >  		case Opt_utf8:
> > -			uopt->flags |= (1 << UDF_FLAG_UTF8);
> > +			if (!remount) {
> > +				unload_nls(uopt->nls_map);
> > +				uopt->nls_map = NULL;
> > +			}
> >  			break;
> >  		case Opt_iocharset:
> >  			if (!remount) {
> > -				if (uopt->nls_map)
> > -					unload_nls(uopt->nls_map);
> > -				/*
> > -				 * load_nls() failure is handled later in
> > -				 * udf_fill_super() after all options are
> > -				 * parsed.
> > -				 */
> > +				unload_nls(uopt->nls_map);
> > +				uopt->nls_map = NULL;
> > +			}
> > +			/* When nls_map is not loaded then UTF-8 is used */
> > +			if (!remount && strcmp(args[0].from, "utf8") != 0) {
> >  				uopt->nls_map = load_nls(args[0].from);
> > -				uopt->flags |= (1 << UDF_FLAG_NLS_MAP);
> > +				if (!uopt->nls_map) {
> > +					pr_err("iocharset %s not found\n",
> > +						args[0].from);
> > +					return 0;
> > +				}
> >  			}
> >  			break;
> >  		case Opt_uforget:
> > @@ -2139,21 +2144,6 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
> >  	if (!udf_parse_options((char *)options, &uopt, false))
> >  		goto parse_options_failure;
> >  
> > -	if (uopt.flags & (1 << UDF_FLAG_UTF8) &&
> > -	    uopt.flags & (1 << UDF_FLAG_NLS_MAP)) {
> > -		udf_err(sb, "utf8 cannot be combined with iocharset\n");
> > -		goto parse_options_failure;
> > -	}
> > -	if ((uopt.flags & (1 << UDF_FLAG_NLS_MAP)) && !uopt.nls_map) {
> > -		uopt.nls_map = load_nls_default();
> > -		if (!uopt.nls_map)
> > -			uopt.flags &= ~(1 << UDF_FLAG_NLS_MAP);
> > -		else
> > -			udf_debug("Using default NLS map\n");
> > -	}
> > -	if (!(uopt.flags & (1 << UDF_FLAG_NLS_MAP)))
> > -		uopt.flags |= (1 << UDF_FLAG_UTF8);
> > -
> >  	fileset.logicalBlockNum = 0xFFFFFFFF;
> >  	fileset.partitionReferenceNum = 0xFFFF;
> >  
> > @@ -2308,8 +2298,7 @@ static int udf_fill_super(struct super_block *sb, void *options, int silent)
> >  error_out:
> >  	iput(sbi->s_vat_inode);
> >  parse_options_failure:
> > -	if (uopt.nls_map)
> > -		unload_nls(uopt.nls_map);
> > +	unload_nls(uopt.nls_map);
> >  	if (lvid_open)
> >  		udf_close_lvid(sb);
> >  	brelse(sbi->s_lvid_bh);
> > @@ -2359,8 +2348,7 @@ static void udf_put_super(struct super_block *sb)
> >  	sbi = UDF_SB(sb);
> >  
> >  	iput(sbi->s_vat_inode);
> > -	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
> > -		unload_nls(sbi->s_nls_map);
> > +	unload_nls(sbi->s_nls_map);
> >  	if (!sb_rdonly(sb))
> >  		udf_close_lvid(sb);
> >  	brelse(sbi->s_lvid_bh);
> > diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
> > index 758efe557a19..4fa620543d30 100644
> > --- a/fs/udf/udf_sb.h
> > +++ b/fs/udf/udf_sb.h
> > @@ -20,8 +20,6 @@
> >  #define UDF_FLAG_UNDELETE		6
> >  #define UDF_FLAG_UNHIDE			7
> >  #define UDF_FLAG_VARCONV		8
> > -#define UDF_FLAG_NLS_MAP		9
> > -#define UDF_FLAG_UTF8			10
> >  #define UDF_FLAG_UID_FORGET     11    /* save -1 for uid to disk */
> >  #define UDF_FLAG_GID_FORGET     12
> >  #define UDF_FLAG_UID_SET	13
> > diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
> > index 5fcfa96463eb..622569007b53 100644
> > --- a/fs/udf/unicode.c
> > +++ b/fs/udf/unicode.c
> > @@ -177,7 +177,7 @@ static int udf_name_from_CS0(struct super_block *sb,
> >  		return 0;
> >  	}
> >  
> > -	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
> > +	if (UDF_SB(sb)->s_nls_map)
> >  		conv_f = UDF_SB(sb)->s_nls_map->uni2char;
> >  	else
> >  		conv_f = NULL;
> > @@ -285,7 +285,7 @@ static int udf_name_to_CS0(struct super_block *sb,
> >  	if (ocu_max_len <= 0)
> >  		return 0;
> >  
> > -	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
> > +	if (UDF_SB(sb)->s_nls_map)
> >  		conv_f = UDF_SB(sb)->s_nls_map->char2uni;
> >  	else
> >  		conv_f = NULL;
> > -- 
> > 2.20.1
> > 
> -- 
> Jan Kara <jack@suse.com>
> SUSE Labs, CR
Jan Kara Aug. 13, 2021, 1:48 p.m. UTC | #3
On Thu 12-08-21 17:51:34, Pali Rohár wrote:
> On Thursday 12 August 2021 16:17:36 Jan Kara wrote:
> > On Sun 08-08-21 18:24:36, Pali Rohár wrote:
> > > Currently iocharset=utf8 mount option is broken. To use UTF-8 as iocharset,
> > > it is required to use utf8 mount option.
> > > 
> > > Fix iocharset=utf8 mount option to use be equivalent to the utf8 mount
> > > option.
> > > 
> > > If UTF-8 as iocharset is used then s_nls_map is set to NULL. So simplify
> > > code around, remove UDF_FLAG_NLS_MAP and UDF_FLAG_UTF8 flags as to
> > > distinguish between UTF-8 and non-UTF-8 it is needed just to check if
> > > s_nls_map set to NULL or not.
> > > 
> > > Signed-off-by: Pali Rohár <pali@kernel.org>
> > 
> > Thanks for the cleanup. It looks good. Feel free to add:
> > 
> > Reviewed-by: Jan Kara <jack@suse.cz>
> > 
> > Or should I take this patch through my tree?
> 
> Hello! Patches are just RFC, mostly untested and not ready for merging.
> I will wait for feedback and then I do more testing nad prepare new
> patch series.

OK, FWIW I've also tested the UDF and isofs patches.

								Honza
Pali Rohár Aug. 19, 2021, 8:34 a.m. UTC | #4
On Friday 13 August 2021 15:48:22 Jan Kara wrote:
> On Thu 12-08-21 17:51:34, Pali Rohár wrote:
> > On Thursday 12 August 2021 16:17:36 Jan Kara wrote:
> > > On Sun 08-08-21 18:24:36, Pali Rohár wrote:
> > > > Currently iocharset=utf8 mount option is broken. To use UTF-8 as iocharset,
> > > > it is required to use utf8 mount option.
> > > > 
> > > > Fix iocharset=utf8 mount option to use be equivalent to the utf8 mount
> > > > option.
> > > > 
> > > > If UTF-8 as iocharset is used then s_nls_map is set to NULL. So simplify
> > > > code around, remove UDF_FLAG_NLS_MAP and UDF_FLAG_UTF8 flags as to
> > > > distinguish between UTF-8 and non-UTF-8 it is needed just to check if
> > > > s_nls_map set to NULL or not.
> > > > 
> > > > Signed-off-by: Pali Rohár <pali@kernel.org>
> > > 
> > > Thanks for the cleanup. It looks good. Feel free to add:
> > > 
> > > Reviewed-by: Jan Kara <jack@suse.cz>
> > > 
> > > Or should I take this patch through my tree?
> > 
> > Hello! Patches are just RFC, mostly untested and not ready for merging.
> > I will wait for feedback and then I do more testing nad prepare new
> > patch series.
> 
> OK, FWIW I've also tested the UDF and isofs patches.

Well, if you have already done tests, patches are correct and these fs
driver are working fine then fell free to take it through your tree.

I just wanted to warn people that patches in this RFC are mostly
untested to prevent some issues. But if somebody else was faster than
me, did testing + reviewing and there was no issue, I do not see any
problem with including them. Just I cannot put my own Tested-by (yet) :-)

> 								Honza
> 
> -- 
> Jan Kara <jack@suse.com>
> SUSE Labs, CR
Jan Kara Aug. 19, 2021, 10:41 a.m. UTC | #5
On Thu 19-08-21 10:34:32, Pali Rohár wrote:
> On Friday 13 August 2021 15:48:22 Jan Kara wrote:
> > On Thu 12-08-21 17:51:34, Pali Rohár wrote:
> > > On Thursday 12 August 2021 16:17:36 Jan Kara wrote:
> > > > On Sun 08-08-21 18:24:36, Pali Rohár wrote:
> > > > > Currently iocharset=utf8 mount option is broken. To use UTF-8 as iocharset,
> > > > > it is required to use utf8 mount option.
> > > > > 
> > > > > Fix iocharset=utf8 mount option to use be equivalent to the utf8 mount
> > > > > option.
> > > > > 
> > > > > If UTF-8 as iocharset is used then s_nls_map is set to NULL. So simplify
> > > > > code around, remove UDF_FLAG_NLS_MAP and UDF_FLAG_UTF8 flags as to
> > > > > distinguish between UTF-8 and non-UTF-8 it is needed just to check if
> > > > > s_nls_map set to NULL or not.
> > > > > 
> > > > > Signed-off-by: Pali Rohár <pali@kernel.org>
> > > > 
> > > > Thanks for the cleanup. It looks good. Feel free to add:
> > > > 
> > > > Reviewed-by: Jan Kara <jack@suse.cz>
> > > > 
> > > > Or should I take this patch through my tree?
> > > 
> > > Hello! Patches are just RFC, mostly untested and not ready for merging.
> > > I will wait for feedback and then I do more testing nad prepare new
> > > patch series.
> > 
> > OK, FWIW I've also tested the UDF and isofs patches.
> 
> Well, if you have already done tests, patches are correct and these fs
> driver are working fine then fell free to take it through your tree.
> 
> I just wanted to warn people that patches in this RFC are mostly
> untested to prevent some issues. But if somebody else was faster than
> me, did testing + reviewing and there was no issue, I do not see any
> problem with including them. Just I cannot put my own Tested-by (yet) :-)

OK, I've pulled the udf and isofs fixes to my tree.

								Honza
diff mbox series

Patch

diff --git a/fs/udf/super.c b/fs/udf/super.c
index 2f83c1204e20..6e8c29107b04 100644
--- a/fs/udf/super.c
+++ b/fs/udf/super.c
@@ -349,10 +349,10 @@  static int udf_show_options(struct seq_file *seq, struct dentry *root)
 		seq_printf(seq, ",lastblock=%u", sbi->s_last_block);
 	if (sbi->s_anchor != 0)
 		seq_printf(seq, ",anchor=%u", sbi->s_anchor);
-	if (UDF_QUERY_FLAG(sb, UDF_FLAG_UTF8))
-		seq_puts(seq, ",utf8");
-	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP) && sbi->s_nls_map)
+	if (sbi->s_nls_map)
 		seq_printf(seq, ",iocharset=%s", sbi->s_nls_map->charset);
+	else
+		seq_puts(seq, ",iocharset=utf8");
 
 	return 0;
 }
@@ -558,19 +558,24 @@  static int udf_parse_options(char *options, struct udf_options *uopt,
 			/* Ignored (never implemented properly) */
 			break;
 		case Opt_utf8:
-			uopt->flags |= (1 << UDF_FLAG_UTF8);
+			if (!remount) {
+				unload_nls(uopt->nls_map);
+				uopt->nls_map = NULL;
+			}
 			break;
 		case Opt_iocharset:
 			if (!remount) {
-				if (uopt->nls_map)
-					unload_nls(uopt->nls_map);
-				/*
-				 * load_nls() failure is handled later in
-				 * udf_fill_super() after all options are
-				 * parsed.
-				 */
+				unload_nls(uopt->nls_map);
+				uopt->nls_map = NULL;
+			}
+			/* When nls_map is not loaded then UTF-8 is used */
+			if (!remount && strcmp(args[0].from, "utf8") != 0) {
 				uopt->nls_map = load_nls(args[0].from);
-				uopt->flags |= (1 << UDF_FLAG_NLS_MAP);
+				if (!uopt->nls_map) {
+					pr_err("iocharset %s not found\n",
+						args[0].from);
+					return 0;
+				}
 			}
 			break;
 		case Opt_uforget:
@@ -2139,21 +2144,6 @@  static int udf_fill_super(struct super_block *sb, void *options, int silent)
 	if (!udf_parse_options((char *)options, &uopt, false))
 		goto parse_options_failure;
 
-	if (uopt.flags & (1 << UDF_FLAG_UTF8) &&
-	    uopt.flags & (1 << UDF_FLAG_NLS_MAP)) {
-		udf_err(sb, "utf8 cannot be combined with iocharset\n");
-		goto parse_options_failure;
-	}
-	if ((uopt.flags & (1 << UDF_FLAG_NLS_MAP)) && !uopt.nls_map) {
-		uopt.nls_map = load_nls_default();
-		if (!uopt.nls_map)
-			uopt.flags &= ~(1 << UDF_FLAG_NLS_MAP);
-		else
-			udf_debug("Using default NLS map\n");
-	}
-	if (!(uopt.flags & (1 << UDF_FLAG_NLS_MAP)))
-		uopt.flags |= (1 << UDF_FLAG_UTF8);
-
 	fileset.logicalBlockNum = 0xFFFFFFFF;
 	fileset.partitionReferenceNum = 0xFFFF;
 
@@ -2308,8 +2298,7 @@  static int udf_fill_super(struct super_block *sb, void *options, int silent)
 error_out:
 	iput(sbi->s_vat_inode);
 parse_options_failure:
-	if (uopt.nls_map)
-		unload_nls(uopt.nls_map);
+	unload_nls(uopt.nls_map);
 	if (lvid_open)
 		udf_close_lvid(sb);
 	brelse(sbi->s_lvid_bh);
@@ -2359,8 +2348,7 @@  static void udf_put_super(struct super_block *sb)
 	sbi = UDF_SB(sb);
 
 	iput(sbi->s_vat_inode);
-	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
-		unload_nls(sbi->s_nls_map);
+	unload_nls(sbi->s_nls_map);
 	if (!sb_rdonly(sb))
 		udf_close_lvid(sb);
 	brelse(sbi->s_lvid_bh);
diff --git a/fs/udf/udf_sb.h b/fs/udf/udf_sb.h
index 758efe557a19..4fa620543d30 100644
--- a/fs/udf/udf_sb.h
+++ b/fs/udf/udf_sb.h
@@ -20,8 +20,6 @@ 
 #define UDF_FLAG_UNDELETE		6
 #define UDF_FLAG_UNHIDE			7
 #define UDF_FLAG_VARCONV		8
-#define UDF_FLAG_NLS_MAP		9
-#define UDF_FLAG_UTF8			10
 #define UDF_FLAG_UID_FORGET     11    /* save -1 for uid to disk */
 #define UDF_FLAG_GID_FORGET     12
 #define UDF_FLAG_UID_SET	13
diff --git a/fs/udf/unicode.c b/fs/udf/unicode.c
index 5fcfa96463eb..622569007b53 100644
--- a/fs/udf/unicode.c
+++ b/fs/udf/unicode.c
@@ -177,7 +177,7 @@  static int udf_name_from_CS0(struct super_block *sb,
 		return 0;
 	}
 
-	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
+	if (UDF_SB(sb)->s_nls_map)
 		conv_f = UDF_SB(sb)->s_nls_map->uni2char;
 	else
 		conv_f = NULL;
@@ -285,7 +285,7 @@  static int udf_name_to_CS0(struct super_block *sb,
 	if (ocu_max_len <= 0)
 		return 0;
 
-	if (UDF_QUERY_FLAG(sb, UDF_FLAG_NLS_MAP))
+	if (UDF_SB(sb)->s_nls_map)
 		conv_f = UDF_SB(sb)->s_nls_map->char2uni;
 	else
 		conv_f = NULL;