From: "Björn Stenberg" <bjorn@haxx.se>
To: linux-kernel@vger.kernel.org
Cc: marcelo@conectiva.com.br, torvalds@transmeta.com
Subject: [PATCH] fat cluster search speedup (2.4.20, 2.5.68)
Date: Tue, 22 Apr 2003 13:38:19 +0200 [thread overview]
Message-ID: <20030422113819.GD14737@linux3.contactor.se> (raw)
Hello.
This simple patch makes the linux fat filesystem driver use the next_cluster field in the fat_boot_fsinfo structure. This field is a hint where to start looking for free clusters.
Using this field makes a big difference for disks connected over slow links such as USB 1.1. Finding the first free cluster on a 40gig fat-formatted usb disk can today take several minutes. This patch cuts it down to a fraction of a second.
Please Cc me on any discussion about this patch, as I am not subscribed to the list.
The patch is cooked in two flavors, for 2.4.20 and 2.5.68:
For 2.4.20:
diff -Nru include/linux.orig/msdos_fs.h include/linux/msdos_fs.h
--- include/linux.orig/msdos_fs.h Tue Apr 22 10:55:09 2003
+++ include/linux/msdos_fs.h Tue Apr 22 10:58:33 2003
@@ -145,8 +145,7 @@
__u32 reserved1[120]; /* Nothing as far as I can tell */
__u32 signature2; /* 0x61417272L */
__u32 free_clusters; /* Free cluster count. -1 if unknown */
- __u32 next_cluster; /* Most recently allocated cluster.
- * Unused under Linux. */
+ __u32 next_cluster; /* Most recently allocated cluster */
__u32 reserved2[4];
};
diff -Nru fs/fat.orig/inode.c fs/fat/inode.c
--- fs/fat.orig/inode.c Sat Aug 3 02:39:45 2002
+++ fs/fat/inode.c Tue Apr 22 11:47:50 2003
@@ -637,6 +637,7 @@
sbi->cluster_bits = ffs(logical_sector_size * sbi->cluster_size) - 1;
sbi->fats = b->fats;
sbi->fat_start = CF_LE_W(b->reserved);
+ sbi->prev_free = 0;
if (!b->fat_length && b->fat32_length) {
struct fat_boot_fsinfo *fsinfo;
struct buffer_head *fsinfo_bh;
@@ -675,6 +676,7 @@
sbi->fsinfo_sector);
} else {
sbi->free_clusters = CF_LE_L(fsinfo->free_clusters);
+ sbi->prev_free = CF_LE_L(fsinfo->next_cluster);
}
if (fsinfo_block != 0)
@@ -754,7 +756,6 @@
sb->s_magic = MSDOS_SUPER_MAGIC;
/* set up enough so that it can read an inode */
init_MUTEX(&sbi->fat_lock);
- sbi->prev_free = 0;
cp = opts.codepage ? opts.codepage : 437;
sprintf(buf, "cp%d", cp);
diff -Nru fs/fat.orig/misc.c fs/fat/misc.c
--- fs/fat.orig/misc.c Fri Oct 12 22:48:42 2001
+++ fs/fat/misc.c Tue Apr 22 10:59:52 2003
@@ -108,6 +108,7 @@
return;
}
fsinfo->free_clusters = CF_LE_L(MSDOS_SB(sb)->free_clusters);
+ fsinfo->next_cluster = CF_LE_L(MSDOS_SB(sb)->prev_free);
fat_mark_buffer_dirty(sb, bh);
fat_brelse(sb, bh);
}
For 2.5.68:
--- include/linux/msdos_fs.h.orig Tue Apr 22 12:05:35 2003
+++ include/linux/msdos_fs.h Tue Apr 22 12:06:02 2003
@@ -146,8 +146,7 @@
__u32 reserved1[120]; /* Nothing as far as I can tell */
__u32 signature2; /* 0x61417272L */
__u32 free_clusters; /* Free cluster count. -1 if unknown */
- __u32 next_cluster; /* Most recently allocated cluster.
- * Unused under Linux. */
+ __u32 next_cluster; /* Most recently allocated cluster */
__u32 reserved2[4];
};
--- fs/fat/inode.c.orig Tue Apr 22 12:06:12 2003
+++ fs/fat/inode.c Tue Apr 22 12:08:12 2003
@@ -898,6 +898,7 @@
sbi->fsinfo_sector);
} else {
sbi->free_clusters = CF_LE_L(fsinfo->free_clusters);
+ sbi->prev_free = CF_LE_L(fsinfo->next_cluster);
}
brelse(fsinfo_bh);
--- fs/fat/misc.c.orig Tue Apr 22 12:06:16 2003
+++ fs/fat/misc.c Tue Apr 22 12:06:49 2003
@@ -74,6 +74,7 @@
MSDOS_SB(sb)->fsinfo_sector);
} else {
fsinfo->free_clusters = CF_LE_L(MSDOS_SB(sb)->free_clusters);
+ fsinfo->next_cluster = CF_LE_L(MSDOS_SB(sb)->prev_free);
mark_buffer_dirty(bh);
}
brelse(bh);
--
Björn
reply other threads:[~2003-04-22 11:26 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20030422113819.GD14737@linux3.contactor.se \
--to=bjorn@haxx.se \
--cc=linux-kernel@vger.kernel.org \
--cc=marcelo@conectiva.com.br \
--cc=torvalds@transmeta.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.