mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
To: Andreas Schwab <schwab@suse.de>
Cc: 7eggert@gmx.de, Juergen Beisert <juergen127@kreuzholzen.de>,
	linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>
Subject: Re: Wrong free clusters count on FAT32
Date: Mon, 23 Apr 2007 00:13:11 +0900	[thread overview]
Message-ID: <873b2ssarc.fsf@duaron.myhome.or.jp> (raw)
In-Reply-To: <jewt04e9zn.fsf@sykes.suse.de> (Andreas Schwab's message of "Sun\, 22 Apr 2007 16\:53\:32 +0200")

Andreas Schwab <schwab@suse.de> writes:

> OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> writes:
>
>> diff -puN Documentation/filesystems/vfat.txt~fat_dont-use_free_clusters-for-fat32 Documentation/filesystems/vfat.txt
>> --- linux-2.6/Documentation/filesystems/vfat.txt~fat_dont-use_free_clusters-for-fat32	2007-04-22 23:06:21.000000000 +0900
>> +++ linux-2.6-hirofumi/Documentation/filesystems/vfat.txt	2007-04-22 23:28:19.000000000 +0900
>> @@ -34,6 +34,13 @@ iocharset=name -- Character set to use f
>>  		 NOTE: "iocharset=utf8" is not recommended. If unsure,
>>  		 you should consider the following option instead.
>
> "the following option" is no longer correct.

Whoops. Thanks for correcting it.
The patch was fixed.
-- 
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>



It seems that the recent Windows changed specification, and it's
undocumented. Windows doesn't update ->free_clusters correctly.

This patch doesn't use ->free_clusters by default. (instead, add
"usefree" for forcing to use it)

Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
---

 Documentation/filesystems/vfat.txt |    7 +++++++
 fs/fat/inode.c                     |   14 +++++++++++---
 include/linux/msdos_fs.h           |    3 ++-
 3 files changed, 20 insertions(+), 4 deletions(-)

diff -puN fs/fat/inode.c~fat_dont-use_free_clusters-for-fat32 fs/fat/inode.c
--- linux-2.6/fs/fat/inode.c~fat_dont-use_free_clusters-for-fat32	2007-04-22 13:07:05.000000000 +0900
+++ linux-2.6-hirofumi/fs/fat/inode.c	2007-04-22 13:18:07.000000000 +0900
@@ -825,6 +825,8 @@ static int fat_show_options(struct seq_f
 	}
 	if (opts->name_check != 'n')
 		seq_printf(m, ",check=%c", opts->name_check);
+	if (opts->usefree)
+		seq_puts(m, ",usefree");
 	if (opts->quiet)
 		seq_puts(m, ",quiet");
 	if (opts->showexec)
@@ -850,7 +852,7 @@ static int fat_show_options(struct seq_f
 
 enum {
 	Opt_check_n, Opt_check_r, Opt_check_s, Opt_uid, Opt_gid,
-	Opt_umask, Opt_dmask, Opt_fmask, Opt_codepage, Opt_nocase,
+	Opt_umask, Opt_dmask, Opt_fmask, Opt_codepage, Opt_usefree, Opt_nocase,
 	Opt_quiet, Opt_showexec, Opt_debug, Opt_immutable,
 	Opt_dots, Opt_nodots,
 	Opt_charset, Opt_shortname_lower, Opt_shortname_win95,
@@ -872,6 +874,7 @@ static match_table_t fat_tokens = {
 	{Opt_dmask, "dmask=%o"},
 	{Opt_fmask, "fmask=%o"},
 	{Opt_codepage, "codepage=%u"},
+	{Opt_usefree, "usefree"},
 	{Opt_nocase, "nocase"},
 	{Opt_quiet, "quiet"},
 	{Opt_showexec, "showexec"},
@@ -951,7 +954,7 @@ static int parse_options(char *options, 
 	opts->quiet = opts->showexec = opts->sys_immutable = opts->dotsOK =  0;
 	opts->utf8 = opts->unicode_xlate = 0;
 	opts->numtail = 1;
-	opts->nocase = 0;
+	opts->usefree = opts->nocase = 0;
 	*debug = 0;
 
 	if (!options)
@@ -979,6 +982,9 @@ static int parse_options(char *options, 
 		case Opt_check_n:
 			opts->name_check = 'n';
 			break;
+		case Opt_usefree:
+			opts->usefree = 1;
+			break;
 		case Opt_nocase:
 			if (!is_vfat)
 				opts->nocase = 1;
@@ -1306,7 +1312,9 @@ int fat_fill_super(struct super_block *s
 			       le32_to_cpu(fsinfo->signature2),
 			       sbi->fsinfo_sector);
 		} else {
-			sbi->free_clusters = le32_to_cpu(fsinfo->free_clusters);
+			if (sbi->options.usefree)
+				sbi->free_clusters =
+					le32_to_cpu(fsinfo->free_clusters);
 			sbi->prev_free = le32_to_cpu(fsinfo->next_cluster);
 		}
 
diff -puN include/linux/msdos_fs.h~fat_dont-use_free_clusters-for-fat32 include/linux/msdos_fs.h
--- linux-2.6/include/linux/msdos_fs.h~fat_dont-use_free_clusters-for-fat32	2007-04-22 13:07:05.000000000 +0900
+++ linux-2.6-hirofumi/include/linux/msdos_fs.h	2007-04-22 13:09:14.000000000 +0900
@@ -205,7 +205,8 @@ struct fat_mount_options {
 		 numtail:1,       /* Does first alias have a numeric '~1' type tail? */
 		 atari:1,         /* Use Atari GEMDOS variation of MS-DOS fs */
 		 flush:1,	  /* write things quickly */
-		 nocase:1;	  /* Does this need case conversion? 0=need case conversion*/
+		 nocase:1,	  /* Does this need case conversion? 0=need case conversion*/
+		 usefree:1;	  /* Use free_clusters for FAT32 */
 };
 
 #define FAT_HASH_BITS	8
diff -puN Documentation/filesystems/vfat.txt~fat_dont-use_free_clusters-for-fat32 Documentation/filesystems/vfat.txt
--- linux-2.6/Documentation/filesystems/vfat.txt~fat_dont-use_free_clusters-for-fat32	2007-04-22 23:06:21.000000000 +0900
+++ linux-2.6-hirofumi/Documentation/filesystems/vfat.txt	2007-04-23 00:09:35.000000000 +0900
@@ -57,6 +57,13 @@ nonumtail=<bool> -- When creating 8.3 al
                  currently exist in the directory, 'longfile.txt' will
                  be the short alias instead of 'longfi~1.txt'. 
                   
+usefree       -- Use the "free clusters" value stored on FSINFO. It'll
+                 be used to determine number of free clusters without
+                 scanning disk. But it's not used by default, because
+                 recent Windows don't update it correctly in some
+                 case. If you are sure the "free clusters" on FSINFO is
+                 correct, by this option you can avoid scanning disk.
+
 quiet         -- Stops printing certain warning messages.
 
 check=s|r|n   -- Case sensitivity checking setting.
_

  reply	other threads:[~2007-04-22 15:13 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <8bAF0-3Yj-29@gated-at.bofh.it>
     [not found] ` <8bDta-8rc-31@gated-at.bofh.it>
     [not found]   ` <8bFEr-3B4-1@gated-at.bofh.it>
     [not found]     ` <8cwz8-2fE-13@gated-at.bofh.it>
2007-04-22 13:28       ` Bodo Eggert
2007-04-22 14:04         ` OGAWA Hirofumi
2007-04-22 14:29           ` OGAWA Hirofumi
2007-04-22 14:53             ` Andreas Schwab
2007-04-22 15:13               ` OGAWA Hirofumi [this message]
2007-04-22 21:46           ` Bodo Eggert
2007-04-23  2:20             ` OGAWA Hirofumi
2007-04-22 20:11         ` DervishD
     [not found]       ` <8cAMl-du-3@gated-at.bofh.it>
     [not found]         ` <8cBS7-1Qa-1@gated-at.bofh.it>
     [not found]           ` <8cIqE-3qZ-9@gated-at.bofh.it>
     [not found]             ` <8cITG-40H-5@gated-at.bofh.it>
2007-04-22 17:21               ` Bodo Eggert
2007-04-22 17:44                 ` OGAWA Hirofumi
2007-04-19  8:57 DervishD
2007-04-19 10:27 ` Boaz Harrosh
2007-04-19 14:23   ` DervishD
2007-04-19 11:52 ` Juergen Beisert
2007-04-19 14:19   ` DervishD
2007-04-21 22:42     ` OGAWA Hirofumi
2007-04-22  3:18       ` Andrew Morton
2007-04-22  4:26         ` OGAWA Hirofumi
2007-04-22 11:26           ` DervishD
2007-04-22 11:55             ` OGAWA Hirofumi
2007-04-22 20:08               ` DervishD
2007-04-23  2:27                 ` OGAWA Hirofumi
2007-04-23  6:19                   ` DervishD
2007-04-22 11:17       ` DervishD
2007-04-22 11:28       ` Juergen Beisert

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=873b2ssarc.fsf@duaron.myhome.or.jp \
    --to=hirofumi@mail.parknet.co.jp \
    --cc=7eggert@gmx.de \
    --cc=akpm@linux-foundation.org \
    --cc=juergen127@kreuzholzen.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=schwab@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome