* [PATCH] fs/fat: remove fat12_ent_blocknr and use fat_ent_blocknr instead
@ 2015-02-18 19:13 Alexander Kuleshov
2015-02-18 19:23 ` OGAWA Hirofumi
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Kuleshov @ 2015-02-18 19:13 UTC (permalink / raw)
To: OGAWA Hirofumi; +Cc: linux-kernel, Alexander Kuleshov
There is only one difference between fat12_ent_blocknr and fat_ent_blocknr
functions in bytes calculation. Let's add bits checking to fat_ent_blocknr
instead code duplication.
Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
---
fs/fat/fatent.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/fs/fat/fatent.c b/fs/fat/fatent.c
index 260705c..314ab50 100644
--- a/fs/fat/fatent.c
+++ b/fs/fat/fatent.c
@@ -21,21 +21,16 @@ struct fatent_operations {
static DEFINE_SPINLOCK(fat12_entry_lock);
-static void fat12_ent_blocknr(struct super_block *sb, int entry,
- int *offset, sector_t *blocknr)
-{
- struct msdos_sb_info *sbi = MSDOS_SB(sb);
- int bytes = entry + (entry >> 1);
- WARN_ON(entry < FAT_START_ENT || sbi->max_cluster <= entry);
- *offset = bytes & (sb->s_blocksize - 1);
- *blocknr = sbi->fat_start + (bytes >> sb->s_blocksize_bits);
-}
-
static void fat_ent_blocknr(struct super_block *sb, int entry,
int *offset, sector_t *blocknr)
{
struct msdos_sb_info *sbi = MSDOS_SB(sb);
- int bytes = (entry << sbi->fatent_shift);
+ int bytes;
+
+ if (sbi->fat_bits == 12)
+ bytes = entry + (entry >> 1);
+ else
+ bytes = (entry << sbi->fatent_shift);
WARN_ON(entry < FAT_START_ENT || sbi->max_cluster <= entry);
*offset = bytes & (sb->s_blocksize - 1);
*blocknr = sbi->fat_start + (bytes >> sb->s_blocksize_bits);
@@ -250,7 +245,7 @@ static int fat32_ent_next(struct fat_entry *fatent)
}
static struct fatent_operations fat12_ops = {
- .ent_blocknr = fat12_ent_blocknr,
+ .ent_blocknr = fat_ent_blocknr,
.ent_set_ptr = fat12_ent_set_ptr,
.ent_bread = fat12_ent_bread,
.ent_get = fat12_ent_get,
--
2.3.0.80.g18d0fec
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] fs/fat: remove fat12_ent_blocknr and use fat_ent_blocknr instead
2015-02-18 19:13 [PATCH] fs/fat: remove fat12_ent_blocknr and use fat_ent_blocknr instead Alexander Kuleshov
@ 2015-02-18 19:23 ` OGAWA Hirofumi
2015-02-18 19:49 ` Alexander Kuleshov
0 siblings, 1 reply; 3+ messages in thread
From: OGAWA Hirofumi @ 2015-02-18 19:23 UTC (permalink / raw)
To: Alexander Kuleshov; +Cc: linux-kernel
Alexander Kuleshov <kuleshovmail@gmail.com> writes:
> There is only one difference between fat12_ent_blocknr and fat_ent_blocknr
> functions in bytes calculation. Let's add bits checking to fat_ent_blocknr
> instead code duplication.
I guess, fat12 (very small volume size) is uncommon to be used now, and
there is no way to switch fat12 <= fat16/fat32 at runtime. It is why has
special handler, i.e. avoid overhead to fat16/fat32 by fat12 code.
Thanks.
--
OGAWA Hirofumi <hirofumi@mail.parknet.co.jp>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] fs/fat: remove fat12_ent_blocknr and use fat_ent_blocknr instead
2015-02-18 19:23 ` OGAWA Hirofumi
@ 2015-02-18 19:49 ` Alexander Kuleshov
0 siblings, 0 replies; 3+ messages in thread
From: Alexander Kuleshov @ 2015-02-18 19:49 UTC (permalink / raw)
To: OGAWA Hirofumi; +Cc: linux-kernel
> I guess, fat12 (very small volume size) is uncommon to be used now, and
> there is no way to switch fat12 <= fat16/fat32 at runtime. It is why has
> special handler, i.e. avoid overhead to fat16/fat32 by fat12 code.
Understand. Thank you for explanation.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-02-18 19:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-02-18 19:13 [PATCH] fs/fat: remove fat12_ent_blocknr and use fat_ent_blocknr instead Alexander Kuleshov
2015-02-18 19:23 ` OGAWA Hirofumi
2015-02-18 19:49 ` Alexander Kuleshov
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.